diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 19:12:32 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-09 19:12:32 +0000 |
commit | 509be00ee63e097821dae26585c0e65b9dc70682 (patch) | |
tree | c10d62fb2a02b8049f0f64d983c7f4fd57ddeb62 /chrome/browser/views | |
parent | 4ca385d42637bfa550c08ae43b13dd950f913fa4 (diff) | |
download | chromium_src-509be00ee63e097821dae26585c0e65b9dc70682.zip chromium_src-509be00ee63e097821dae26585c0e65b9dc70682.tar.gz chromium_src-509be00ee63e097821dae26585c0e65b9dc70682.tar.bz2 |
BrowserTabStrip should not be a TabStrip2 subclass, instead, it should just use it.
Note that this results in the BrowserTabStrip being leaked. I will solve this problem later.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/379002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31455 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/frame/browser_frame_win.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/tabs/browser_tab_strip.cc | 29 | ||||
-rw-r--r-- | chrome/browser/views/tabs/browser_tab_strip.h | 13 |
3 files changed, 27 insertions, 21 deletions
diff --git a/chrome/browser/views/frame/browser_frame_win.cc b/chrome/browser/views/frame/browser_frame_win.cc index a72bc3a..e514d22 100644 --- a/chrome/browser/views/frame/browser_frame_win.cc +++ b/chrome/browser/views/frame/browser_frame_win.cc @@ -137,13 +137,13 @@ void BrowserFrameWin::OnEndSession(BOOL ending, UINT logoff) { void BrowserFrameWin::OnEnterSizeMove() { if (TabStrip2::Enabled()) - browser_view_->tabstrip()->AsBrowserTabStrip()->DetachDragStarted(); + browser_view_->tabstrip()->AsBrowserTabStrip()->view()->DetachDragStarted(); browser_view_->WindowMoveOrResizeStarted(); } void BrowserFrameWin::OnExitSizeMove() { if (TabStrip2::Enabled()) - browser_view_->tabstrip()->AsBrowserTabStrip()->DetachDragEnded(); + browser_view_->tabstrip()->AsBrowserTabStrip()->view()->DetachDragEnded(); WidgetWin::OnExitSizeMove(); } @@ -188,7 +188,7 @@ LRESULT BrowserFrameWin::OnNCHitTest(const CPoint& pt) { void BrowserFrameWin::OnWindowPosChanged(WINDOWPOS* window_pos) { if (TabStrip2::Enabled()) - browser_view_->tabstrip()->AsBrowserTabStrip()->DetachDragMoved(); + browser_view_->tabstrip()->AsBrowserTabStrip()->view()->DetachDragMoved(); // Windows lies to us about the position of the minimize button before a // window is visible. We use the position of the minimize button to place the diff --git a/chrome/browser/views/tabs/browser_tab_strip.cc b/chrome/browser/views/tabs/browser_tab_strip.cc index 7f1bad6..0735ff0 100644 --- a/chrome/browser/views/tabs/browser_tab_strip.cc +++ b/chrome/browser/views/tabs/browser_tab_strip.cc @@ -74,12 +74,15 @@ class RemovingTabModel : public Tab2Model { // BrowserTabStrip, public: BrowserTabStrip::BrowserTabStrip(TabStripModel* model) - : ALLOW_THIS_IN_INITIALIZER_LIST(TabStrip2(this)), - model_(model) { + : model_(model), + ALLOW_THIS_IN_INITIALIZER_LIST(view_(new TabStrip2(this))) { model_->AddObserver(this); } BrowserTabStrip::~BrowserTabStrip() { + // TODO(beng): This object is never actually freed since it's no longer a + // view. The solution is probably to refer to it in a scoped_ptr + // in BrowserView after the transition. model_->RemoveObserver(this); } @@ -95,15 +98,15 @@ void BrowserTabStrip::AttachTab(TabContents* contents, gfx::Point tabstrip_point(screen_point); gfx::Point screen_origin; - View::ConvertPointToScreen(this, &screen_origin); + views::View::ConvertPointToScreen(view_, &screen_origin); tabstrip_point.Offset(-screen_origin.x(), -screen_origin.y()); - int index = GetInsertionIndexForPoint(tabstrip_point); + int index = view_->GetInsertionIndexForPoint(tabstrip_point); model_->InsertTabContentsAt(index, contents, true, false); gfx::Point origin(tab_screen_bounds.origin()); - View::ConvertPointToView(NULL, this, &origin); - ResumeDraggingTab(index, gfx::Rect(origin, tab_screen_bounds.size())); + views::View::ConvertPointToView(NULL, view_, &origin); + view_->ResumeDraggingTab(index, gfx::Rect(origin, tab_screen_bounds.size())); // TODO(beng): post task to continue dragging now. } @@ -113,25 +116,25 @@ void BrowserTabStrip::AttachTab(TabContents* contents, void BrowserTabStrip::TabInsertedAt(TabContents* contents, int index, bool foreground) { - AddTabAt(index); + view_->AddTabAt(index); } void BrowserTabStrip::TabDetachedAt(TabContents* contents, int index) { - RemoveTabAt(index, new RemovingTabModel(contents)); + view_->RemoveTabAt(index, new RemovingTabModel(contents)); } void BrowserTabStrip::TabSelectedAt(TabContents* old_contents, TabContents* contents, int index, bool user_gesture) { - TabStrip2::SelectTabAt(index); + view_->SelectTabAt(index); } void BrowserTabStrip::TabMoved(TabContents* contents, int from_index, int to_index, bool pinned_state_changed) { - TabStrip2::MoveTabAt(from_index, to_index); + view_->MoveTabAt(from_index, to_index); } void BrowserTabStrip::TabChangedAt(TabContents* contents, int index) { @@ -192,7 +195,7 @@ void BrowserTabStrip::DetachTabAt(int index, const gfx::Rect& window_bounds, // BrowserTabStrip, TabStripWrapper implementation: int BrowserTabStrip::GetPreferredHeight() { - return GetPreferredSize().height(); + return view_->GetPreferredSize().height(); } bool BrowserTabStrip::IsAnimating() const { @@ -216,14 +219,14 @@ bool BrowserTabStrip::IsCompatibleWith(TabStripWrapper* other) const { void BrowserTabStrip::SetDraggedTabBounds(int tab_index, const gfx::Rect& tab_bounds) { - TabStrip2::SetDraggedTabBounds(tab_index, tab_bounds); + view_->SetDraggedTabBounds(tab_index, tab_bounds); } void BrowserTabStrip::UpdateLoadingAnimations() { } views::View* BrowserTabStrip::GetView() { - return this; + return view_; } BrowserTabStrip* BrowserTabStrip::AsBrowserTabStrip() { diff --git a/chrome/browser/views/tabs/browser_tab_strip.h b/chrome/browser/views/tabs/browser_tab_strip.h index 9057a13..5ed7353 100644 --- a/chrome/browser/views/tabs/browser_tab_strip.h +++ b/chrome/browser/views/tabs/browser_tab_strip.h @@ -8,12 +8,11 @@ #include "chrome/browser/views/tabs/tab_strip_2.h" #include "chrome/browser/tabs/tab_strip_model.h" -// A specialization fo TabStrip2 for the browser window. +// An object that translates model change notifications into manipulations to +// be applied to the TabStrip2 view, and feed data from Browser/TabContents +// specific types to the TabStrip2. // -// TODO(beng): This shouldn't be a subclass of TabStrip2, rather it should own -// one. -class BrowserTabStrip : public TabStrip2, - public TabStrip2Model, +class BrowserTabStrip : public TabStrip2Model, public TabStripModelObserver, public TabStripWrapper { public: @@ -28,6 +27,8 @@ class BrowserTabStrip : public TabStrip2, void AttachTab(TabContents* contents, const gfx::Point& screen_point, const gfx::Rect& tab_screen_bounds); + TabStrip2* view() const { return view_; } + // Overridden from TabStripModelObserver: virtual void TabInsertedAt(TabContents* contents, int index, @@ -73,6 +74,8 @@ class BrowserTabStrip : public TabStrip2, private: TabStripModel* model_; + TabStrip2* view_; + DISALLOW_COPY_AND_ASSIGN(BrowserTabStrip); }; |