Commit 2707eafb authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Remove tabstrip deletion observer method.

This method was used in the following places:
(1) TabScrubber, where the code did nothing.
(2) BrowserNonClientFrameViewMus, to handle the tabstrip being deleted before
    the frame.
(3) GlassBrowserFrameView, to NOTREACHED() because the tabstrip should never be
    deleted before the frame.
(4) A test that the call was fired.

Because of (3), I assume (2) is actually dead code.  Since that's the only
functional use, it seems like this whole method can disappear.

BUG=none
TEST=none

Change-Id: I5945ccd019741eff09df286bf5ae1bfa82337761
Reviewed-on: https://chromium-review.googlesource.com/1039004
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555480}
parent e61d6110
......@@ -212,11 +212,6 @@ void TabScrubber::TabStripRemovedTabAt(TabStrip* tab_strip, int index) {
--highlighted_tab_;
}
void TabScrubber::TabStripDeleted(TabStrip* tab_strip) {
if (highlighted_tab_ == -1)
return;
}
Browser* TabScrubber::GetActiveBrowser() {
Browser* browser = chrome::FindLastActive();
if (!browser || browser->type() != Browser::TYPE_TABBED ||
......
......@@ -65,7 +65,6 @@ class TabScrubber : public ui::EventHandler,
int from_index,
int to_index) override;
void TabStripRemovedTabAt(TabStrip* tab_strip, int index) override;
void TabStripDeleted(TabStrip* tab_strip) override;
Browser* GetActiveBrowser();
......
......@@ -386,11 +386,6 @@ void BrowserNonClientFrameViewMus::TabStripMaxXChanged(TabStrip* tab_strip) {
UpdateClientArea();
}
void BrowserNonClientFrameViewMus::TabStripDeleted(TabStrip* tab_strip) {
tab_strip_->RemoveObserver(this);
tab_strip_ = nullptr;
}
int BrowserNonClientFrameViewMus::GetTabStripRightInset() const {
int right_inset = frame_values().normal_insets.right() +
frame_values().max_title_bar_button_width;
......
......@@ -69,7 +69,6 @@ class BrowserNonClientFrameViewMus : public BrowserNonClientFrameView,
private:
// TabStripObserver:
void TabStripMaxXChanged(TabStrip* tab_strip) override;
void TabStripDeleted(TabStrip* tab_strip) override;
// Distance between the right edge of the NonClientFrameView and the tab
// strip.
......
......@@ -391,12 +391,6 @@ void GlassBrowserFrameView::TabStripRemovedTabAt(TabStrip* tab_strip,
LayoutProfileSwitcher();
}
void GlassBrowserFrameView::TabStripDeleted(TabStrip* tab_strip) {
// The tab strip is currently never deleted before the frame. If that changes
// tab_strip_observer_.Remove(tab_strip) may be needed here.
NOTREACHED();
}
bool GlassBrowserFrameView::IsMaximized() const {
return frame()->IsMaximized();
}
......
......@@ -64,7 +64,6 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
// TabStripObserver:
void TabStripMaxXChanged(TabStrip* tab_strip) override;
void TabStripDeleted(TabStrip* tab_strip) override;
void TabStripRemovedTabAt(TabStrip* tab_strip, int index) override;
bool IsMaximized() const;
......
......@@ -289,9 +289,6 @@ TabStrip::TabStrip(std::unique_ptr<TabStripController> controller)
}
TabStrip::~TabStrip() {
for (TabStripObserver& observer : observers_)
observer.TabStripDeleted(this);
// The animations may reference the tabs. Shut down the animation before we
// delete the tabs.
StopAnimating(false);
......
......@@ -15,7 +15,4 @@ void TabStripObserver::TabStripMovedTab(TabStrip* tab_strip,
void TabStripObserver::TabStripRemovedTabAt(TabStrip* tab_strip, int index) {
}
void TabStripObserver::TabStripDeleted(TabStrip* tab_strip) {
}
void TabStripObserver::TabStripMaxXChanged(TabStrip* tab_strip) {}
......@@ -33,10 +33,6 @@ class CHROME_VIEWS_EXPORT TabStripObserver {
// The tab at |index| was removed from |tab_strip|.
virtual void TabStripRemovedTabAt(TabStrip* tab_strip, int index);
// Sent when the |tabstrip| is about to be deleted and any reference held must
// be dropped.
virtual void TabStripDeleted(TabStrip* tab_strip);
// tab_strip->max_x() has changed.
virtual void TabStripMaxXChanged(TabStrip* tab_strip);
......
......@@ -53,16 +53,12 @@ class TestTabStripObserver : public TabStripObserver {
tab_strip_->AddObserver(this);
}
~TestTabStripObserver() override {
if (tab_strip_)
tab_strip_->RemoveObserver(this);
}
~TestTabStripObserver() override { tab_strip_->RemoveObserver(this); }
int last_tab_added() const { return last_tab_added_; }
int last_tab_removed() const { return last_tab_removed_; }
int last_tab_moved_from() const { return last_tab_moved_from_; }
int last_tab_moved_to() const { return last_tab_moved_to_; }
bool tabstrip_deleted() const { return tabstrip_deleted_; }
private:
// TabStripObserver overrides.
......@@ -81,17 +77,11 @@ class TestTabStripObserver : public TabStripObserver {
last_tab_removed_ = index;
}
void TabStripDeleted(TabStrip* tab_strip) override {
tabstrip_deleted_ = true;
tab_strip_ = nullptr;
}
TabStrip* tab_strip_;
int last_tab_added_ = -1;
int last_tab_removed_ = -1;
int last_tab_moved_from_ = -1;
int last_tab_moved_to_ = -1;
bool tabstrip_deleted_ = false;
DISALLOW_COPY_AND_ASSIGN(TestTabStripObserver);
};
......@@ -195,17 +185,6 @@ TEST_P(TabStripTest, AddTabAt) {
EXPECT_FALSE(tab == NULL);
}
// Confirms that TabStripObserver::TabStripDeleted() is sent.
TEST_P(TabStripTest, TabStripDeleted) {
FakeBaseTabStripController* controller = new FakeBaseTabStripController;
std::unique_ptr<TabStrip> tab_strip(
new TabStrip(std::unique_ptr<TabStripController>(controller)));
controller->set_tab_strip(tab_strip.get());
TestTabStripObserver observer(tab_strip.get());
tab_strip.reset();
EXPECT_TRUE(observer.tabstrip_deleted());
}
TEST_P(TabStripTest, MoveTab) {
TestTabStripObserver observer(tab_strip_);
tab_strip_->AddTabAt(0, TabRendererData(), false);
......
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