Commit 9ff6505e authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Clean up tabstrip observer method names/args.

* Removed initial TabStrip* arg, no one was using it.
* Changed names from e.g. TabStripAddedTabAt() to OnTabAdded() to shorten and
  make consistent with other observer OnXXX() names.
* Changed TabStripMaxXChanged() to OnTabsMaxXChanged() in keeping with the
  meaning change in https://chromium-review.googlesource.com/c/chromium/src/+/1038789 .
* Changed override order in GlassBrowserFrameView to match base class.

BUG=none
TEST=none

Change-Id: Ibf29362d818d8f63e34c168d428173bca6e2a257
Reviewed-on: https://chromium-review.googlesource.com/1038796
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555514}
parent d8bbc95a
...@@ -179,7 +179,7 @@ void TabScrubber::Observe(int type, ...@@ -179,7 +179,7 @@ void TabScrubber::Observe(int type,
} }
} }
void TabScrubber::TabStripAddedTabAt(TabStrip* tab_strip, int index) { void TabScrubber::OnTabAdded(int index) {
if (highlighted_tab_ == -1) if (highlighted_tab_ == -1)
return; return;
...@@ -187,9 +187,7 @@ void TabScrubber::TabStripAddedTabAt(TabStrip* tab_strip, int index) { ...@@ -187,9 +187,7 @@ void TabScrubber::TabStripAddedTabAt(TabStrip* tab_strip, int index) {
++highlighted_tab_; ++highlighted_tab_;
} }
void TabScrubber::TabStripMovedTab(TabStrip* tab_strip, void TabScrubber::OnTabMoved(int from_index, int to_index) {
int from_index,
int to_index) {
if (highlighted_tab_ == -1) if (highlighted_tab_ == -1)
return; return;
...@@ -201,7 +199,7 @@ void TabScrubber::TabStripMovedTab(TabStrip* tab_strip, ...@@ -201,7 +199,7 @@ void TabScrubber::TabStripMovedTab(TabStrip* tab_strip,
++highlighted_tab_; ++highlighted_tab_;
} }
void TabScrubber::TabStripRemovedTabAt(TabStrip* tab_strip, int index) { void TabScrubber::OnTabRemoved(int index) {
if (highlighted_tab_ == -1) if (highlighted_tab_ == -1)
return; return;
if (index == highlighted_tab_) { if (index == highlighted_tab_) {
......
...@@ -60,11 +60,9 @@ class TabScrubber : public ui::EventHandler, ...@@ -60,11 +60,9 @@ class TabScrubber : public ui::EventHandler,
const content::NotificationDetails& details) override; const content::NotificationDetails& details) override;
// TabStripObserver overrides. // TabStripObserver overrides.
void TabStripAddedTabAt(TabStrip* tab_strip, int index) override; void OnTabAdded(int index) override;
void TabStripMovedTab(TabStrip* tab_strip, void OnTabMoved(int from_index, int to_index) override;
int from_index, void OnTabRemoved(int index) override;
int to_index) override;
void TabStripRemovedTabAt(TabStrip* tab_strip, int index) override;
Browser* GetActiveBrowser(); Browser* GetActiveBrowser();
......
...@@ -382,7 +382,7 @@ AvatarButtonStyle BrowserNonClientFrameViewMus::GetAvatarButtonStyle() const { ...@@ -382,7 +382,7 @@ AvatarButtonStyle BrowserNonClientFrameViewMus::GetAvatarButtonStyle() const {
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// BrowserNonClientFrameViewMus, private: // BrowserNonClientFrameViewMus, private:
void BrowserNonClientFrameViewMus::TabStripMaxXChanged(TabStrip* tab_strip) { void BrowserNonClientFrameViewMus::OnTabsMaxXChanged() {
UpdateClientArea(); UpdateClientArea();
} }
......
...@@ -68,7 +68,7 @@ class BrowserNonClientFrameViewMus : public BrowserNonClientFrameView, ...@@ -68,7 +68,7 @@ class BrowserNonClientFrameViewMus : public BrowserNonClientFrameView,
private: private:
// TabStripObserver: // TabStripObserver:
void TabStripMaxXChanged(TabStrip* tab_strip) override; void OnTabsMaxXChanged() override;
// Distance between the right edge of the NonClientFrameView and the tab // Distance between the right edge of the NonClientFrameView and the tab
// strip. // strip.
......
...@@ -375,18 +375,17 @@ gfx::ImageSkia GlassBrowserFrameView::GetFaviconForTabIconView() { ...@@ -375,18 +375,17 @@ gfx::ImageSkia GlassBrowserFrameView::GetFaviconForTabIconView() {
return frame()->widget_delegate()->GetWindowIcon(); return frame()->widget_delegate()->GetWindowIcon();
} }
void GlassBrowserFrameView::TabStripMaxXChanged(TabStrip* tab_strip) { void GlassBrowserFrameView::OnTabRemoved(int index) {
// The profile switcher button's height depends on the position of the new // The profile switcher button may need to change height here, too.
// tab button. // TabStripMaxXChanged is not enough when a tab other than the last tab is
// closed.
if (browser_view()->IsRegularOrGuestSession()) if (browser_view()->IsRegularOrGuestSession())
LayoutProfileSwitcher(); LayoutProfileSwitcher();
} }
void GlassBrowserFrameView::TabStripRemovedTabAt(TabStrip* tab_strip, void GlassBrowserFrameView::OnTabsMaxXChanged() {
int index) { // The profile switcher button's height depends on the position of the new
// The profile switcher button may need to change height here, too. // tab button, which may have changed if the tabs max X changed.
// TabStripMaxXChanged is not enough when a tab other than the last tab is
// closed.
if (browser_view()->IsRegularOrGuestSession()) if (browser_view()->IsRegularOrGuestSession())
LayoutProfileSwitcher(); LayoutProfileSwitcher();
} }
......
...@@ -63,8 +63,8 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView, ...@@ -63,8 +63,8 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
gfx::ImageSkia GetFaviconForTabIconView() override; gfx::ImageSkia GetFaviconForTabIconView() override;
// TabStripObserver: // TabStripObserver:
void TabStripMaxXChanged(TabStrip* tab_strip) override; void OnTabRemoved(int index) override;
void TabStripRemovedTabAt(TabStrip* tab_strip, int index) override; void OnTabsMaxXChanged() override;
bool IsMaximized() const; bool IsMaximized() const;
......
...@@ -456,7 +456,7 @@ void TabStrip::AddTabAt(int model_index, TabRendererData data, bool is_active) { ...@@ -456,7 +456,7 @@ void TabStrip::AddTabAt(int model_index, TabRendererData data, bool is_active) {
SwapLayoutIfNecessary(); SwapLayoutIfNecessary();
for (TabStripObserver& observer : observers_) for (TabStripObserver& observer : observers_)
observer.TabStripAddedTabAt(this, model_index); observer.OnTabAdded(model_index);
// Stop dragging when a new tab is added and dragging a window. Doing // Stop dragging when a new tab is added and dragging a window. Doing
// otherwise results in a confusing state if the user attempts to reattach. We // otherwise results in a confusing state if the user attempts to reattach. We
...@@ -498,7 +498,7 @@ void TabStrip::MoveTab(int from_model_index, ...@@ -498,7 +498,7 @@ void TabStrip::MoveTab(int from_model_index,
SwapLayoutIfNecessary(); SwapLayoutIfNecessary();
for (TabStripObserver& observer : observers_) for (TabStripObserver& observer : observers_)
observer.TabStripMovedTab(this, from_model_index, to_model_index); observer.OnTabMoved(from_model_index, to_model_index);
} }
void TabStrip::RemoveTabAt(content::WebContents* contents, int model_index) { void TabStrip::RemoveTabAt(content::WebContents* contents, int model_index) {
...@@ -520,7 +520,7 @@ void TabStrip::RemoveTabAt(content::WebContents* contents, int model_index) { ...@@ -520,7 +520,7 @@ void TabStrip::RemoveTabAt(content::WebContents* contents, int model_index) {
SwapLayoutIfNecessary(); SwapLayoutIfNecessary();
for (TabStripObserver& observer : observers_) for (TabStripObserver& observer : observers_)
observer.TabStripRemovedTabAt(this, model_index); observer.OnTabRemoved(model_index);
// Stop dragging when a new tab is removed and dragging a window. Doing // Stop dragging when a new tab is removed and dragging a window. Doing
// otherwise results in a confusing state if the user attempts to reattach. We // otherwise results in a confusing state if the user attempts to reattach. We
...@@ -2162,7 +2162,7 @@ void TabStrip::GenerateIdealBounds() { ...@@ -2162,7 +2162,7 @@ void TabStrip::GenerateIdealBounds() {
if (GetTabsMaxX() != old_max_x) { if (GetTabsMaxX() != old_max_x) {
for (TabStripObserver& observer : observers_) for (TabStripObserver& observer : observers_)
observer.TabStripMaxXChanged(this); observer.OnTabsMaxXChanged();
} }
} }
......
...@@ -4,15 +4,10 @@ ...@@ -4,15 +4,10 @@
#include "chrome/browser/ui/views/tabs/tab_strip_observer.h" #include "chrome/browser/ui/views/tabs/tab_strip_observer.h"
void TabStripObserver::TabStripAddedTabAt(TabStrip* tab_strip, int index) { void TabStripObserver::OnTabAdded(int index) {}
}
void TabStripObserver::TabStripMovedTab(TabStrip* tab_strip, void TabStripObserver::OnTabMoved(int from_index, int to_index) {}
int from_index,
int to_index) {
}
void TabStripObserver::TabStripRemovedTabAt(TabStrip* tab_strip, int index) { void TabStripObserver::OnTabRemoved(int index) {}
}
void TabStripObserver::TabStripMaxXChanged(TabStrip* tab_strip) {} void TabStripObserver::OnTabsMaxXChanged() {}
...@@ -22,19 +22,17 @@ class TabStrip; ...@@ -22,19 +22,17 @@ class TabStrip;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
class CHROME_VIEWS_EXPORT TabStripObserver { class CHROME_VIEWS_EXPORT TabStripObserver {
public: public:
// A new tab was added to |tab_strip| at |index|. // Sent when a new tab has been added at |index|.
virtual void TabStripAddedTabAt(TabStrip* tab_strip, int index); virtual void OnTabAdded(int index);
// The tab at |from_index| was moved to |to_index| in |tab_strip|. // Sent when the tab at |from_index| has been moved to |to_index|.
virtual void TabStripMovedTab(TabStrip* tab_strip, virtual void OnTabMoved(int from_index, int to_index);
int from_index,
int to_index);
// The tab at |index| was removed from |tab_strip|. // Sent when the tab at |index| has been removed.
virtual void TabStripRemovedTabAt(TabStrip* tab_strip, int index); virtual void OnTabRemoved(int index);
// tab_strip->max_x() has changed. // Sent when the trailing edge of the last tab has changed.
virtual void TabStripMaxXChanged(TabStrip* tab_strip); virtual void OnTabsMaxXChanged();
protected: protected:
virtual ~TabStripObserver() {} virtual ~TabStripObserver() {}
......
...@@ -62,20 +62,14 @@ class TestTabStripObserver : public TabStripObserver { ...@@ -62,20 +62,14 @@ class TestTabStripObserver : public TabStripObserver {
private: private:
// TabStripObserver overrides. // TabStripObserver overrides.
void TabStripAddedTabAt(TabStrip* tab_strip, int index) override { void OnTabAdded(int index) override { last_tab_added_ = index; }
last_tab_added_ = index;
}
void TabStripMovedTab(TabStrip* tab_strip, void OnTabMoved(int from_index, int to_index) override {
int from_index,
int to_index) override {
last_tab_moved_from_ = from_index; last_tab_moved_from_ = from_index;
last_tab_moved_to_ = to_index; last_tab_moved_to_ = to_index;
} }
void TabStripRemovedTabAt(TabStrip* tab_strip, int index) override { void OnTabRemoved(int index) override { last_tab_removed_ = index; }
last_tab_removed_ = index;
}
TabStrip* tab_strip_; TabStrip* tab_strip_;
int last_tab_added_ = -1; int last_tab_added_ = -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment