diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-04 17:23:18 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-04 17:23:18 +0000 |
commit | 0969d172f87f4692c7fdc94bc5aa12173b89b34e (patch) | |
tree | cef402ffd03618699f10061489c91840b3dc3d68 /chrome | |
parent | c98f6a50d4a181a812f94988450f4d3bcb630893 (diff) | |
download | chromium_src-0969d172f87f4692c7fdc94bc5aa12173b89b34e.zip chromium_src-0969d172f87f4692c7fdc94bc5aa12173b89b34e.tar.gz chromium_src-0969d172f87f4692c7fdc94bc5aa12173b89b34e.tar.bz2 |
Create a new base class BaseTabStrip that is the intermediary between BrowserView/etc and the specific active TabStrip implementation in use.
This simplifies things a lot. I don't need separate view IDs etc.
http://crbug.com/34509
TEST=none
Review URL: http://codereview.chromium.org/571002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
28 files changed, 174 insertions, 90 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 193b6ad..6e39abf 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1398,7 +1398,7 @@ void Browser::RegisterUserPrefs(PrefService* prefs) { prefs->RegisterBooleanPref(prefs::kWebAppCreateOnDesktop, true); prefs->RegisterBooleanPref(prefs::kWebAppCreateInAppsMenu, true); prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true); - prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, true); + prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, false); } // static diff --git a/chrome/browser/chromeos/browser_view.cc b/chrome/browser/chromeos/browser_view.cc index 656196e..8baaf49 100644 --- a/chrome/browser/chromeos/browser_view.cc +++ b/chrome/browser/chromeos/browser_view.cc @@ -423,7 +423,7 @@ views::LayoutManager* BrowserView::CreateLayoutManager() const { return new BrowserViewLayout(); } -TabStrip* BrowserView::CreateTabStrip( +BaseTabStrip* BrowserView::CreateTabStrip( TabStripModel* tab_strip_model) { return new ChromeosTabStrip(tab_strip_model, this); } diff --git a/chrome/browser/chromeos/browser_view.h b/chrome/browser/chromeos/browser_view.h index 76dd08d..6b81982 100644 --- a/chrome/browser/chromeos/browser_view.h +++ b/chrome/browser/chromeos/browser_view.h @@ -7,6 +7,7 @@ #include "chrome/browser/chromeos/status_area_host.h" #include "chrome/browser/views/frame/browser_view.h" +#include "views/controls/button/button.h" class TabStripModel; @@ -61,7 +62,7 @@ class BrowserView : public ::BrowserView, virtual void SetFocusToLocationBar(); virtual void ToggleCompactNavigationBar(); virtual views::LayoutManager* CreateLayoutManager() const; - virtual TabStrip* CreateTabStrip(TabStripModel* tab_strip_model); + virtual BaseTabStrip* CreateTabStrip(TabStripModel* tab_strip_model); // views::ButtonListener overrides. virtual void ButtonPressed(views::Button* sender, const views::Event& event); diff --git a/chrome/browser/chromeos/compact_location_bar_host.cc b/chrome/browser/chromeos/compact_location_bar_host.cc index 8449b65..aafb5fd 100644 --- a/chrome/browser/chromeos/compact_location_bar_host.cc +++ b/chrome/browser/chromeos/compact_location_bar_host.cc @@ -207,7 +207,7 @@ gfx::Rect CompactLocationBarHost::GetBoundsUnderTab(int index) const { // Get the position of the left-bottom corner of the tab on the // widget. The widget of the tab is same as the widget of the // BrowserView which is the parent of the host. - TabStrip* tabstrip = browser_view()->tabstrip(); + TabStrip* tabstrip = browser_view()->tabstrip()->AsTabStrip(); gfx::Rect bounds = tabstrip->GetIdealBounds(index); gfx::Point tab_left_bottom(bounds.x(), bounds.height()); views::View::ConvertPointToWidget(tabstrip, &tab_left_bottom); diff --git a/chrome/browser/view_ids.h b/chrome/browser/view_ids.h index 5755551..0109546 100644 --- a/chrome/browser/view_ids.h +++ b/chrome/browser/view_ids.h @@ -28,7 +28,6 @@ enum ViewID { VIEW_ID_TAB_LAST, VIEW_ID_TAB_STRIP, - VIEW_ID_SIDE_TABSTRIP, // Toolbar & toolbar elements. VIEW_ID_TOOLBAR = 1000, diff --git a/chrome/browser/views/frame/browser_frame.h b/chrome/browser/views/frame/browser_frame.h index 6cbd8a1..5bacf21 100644 --- a/chrome/browser/views/frame/browser_frame.h +++ b/chrome/browser/views/frame/browser_frame.h @@ -8,9 +8,9 @@ #include "build/build_config.h" #include "views/window/non_client_view.h" +class BaseTabStrip; class BrowserView; class Profile; -class TabStrip; class ThemeProvider; namespace gfx { @@ -43,7 +43,7 @@ class BrowserFrame { // Notification that the tab strip has been created. This should let the // BrowserRootView know about it so it can enable drag and drop. - virtual void TabStripCreated(TabStrip* tabstrip) = 0; + virtual void TabStripCreated(BaseTabStrip* tabstrip) = 0; // Determine the distance of the left edge of the minimize button from the // left edge of the window. Used in our Non-Client View's Layout. @@ -51,7 +51,7 @@ class BrowserFrame { // Retrieves the bounds, in non-client view coordinates for the specified // TabStrip. - virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const = 0; + virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const = 0; // Tells the frame to update the throbber. virtual void UpdateThrobber(bool running) = 0; diff --git a/chrome/browser/views/frame/browser_frame_gtk.cc b/chrome/browser/views/frame/browser_frame_gtk.cc index d18a177..2964566 100644 --- a/chrome/browser/views/frame/browser_frame_gtk.cc +++ b/chrome/browser/views/frame/browser_frame_gtk.cc @@ -51,7 +51,7 @@ class PopupNonClientFrameView : public BrowserNonClientFrameView { virtual void ResetWindowControls() {} // BrowserNonClientFrameView: - virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const { + virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const { return gfx::Rect(0, 0, width(), tabstrip->GetPreferredHeight()); } virtual void UpdateThrobber(bool running) {} @@ -102,7 +102,7 @@ views::Window* BrowserFrameGtk::GetWindow() { return this; } -void BrowserFrameGtk::TabStripCreated(TabStrip* tabstrip) { +void BrowserFrameGtk::TabStripCreated(BaseTabStrip* tabstrip) { } int BrowserFrameGtk::GetMinimizeButtonOffset() const { @@ -110,7 +110,7 @@ int BrowserFrameGtk::GetMinimizeButtonOffset() const { return 0; } -gfx::Rect BrowserFrameGtk::GetBoundsForTabStrip(TabStrip* tabstrip) const { +gfx::Rect BrowserFrameGtk::GetBoundsForTabStrip(BaseTabStrip* tabstrip) const { return browser_frame_view_->GetBoundsForTabStrip(tabstrip); } diff --git a/chrome/browser/views/frame/browser_frame_gtk.h b/chrome/browser/views/frame/browser_frame_gtk.h index c045b3d..bbf3b29 100644 --- a/chrome/browser/views/frame/browser_frame_gtk.h +++ b/chrome/browser/views/frame/browser_frame_gtk.h @@ -26,9 +26,9 @@ class BrowserFrameGtk : public BrowserFrame, // Overridden from BrowserFrame: virtual views::Window* GetWindow(); - virtual void TabStripCreated(TabStrip* tabstrip); + virtual void TabStripCreated(BaseTabStrip* tabstrip); virtual int GetMinimizeButtonOffset() const; - virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const; + virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const; virtual void UpdateThrobber(bool running); virtual void ContinueDraggingDetachedTab(); virtual ThemeProvider* GetThemeProviderForFrame() const; diff --git a/chrome/browser/views/frame/browser_frame_win.cc b/chrome/browser/views/frame/browser_frame_win.cc index 75b3126d3..c79c415 100644 --- a/chrome/browser/views/frame/browser_frame_win.cc +++ b/chrome/browser/views/frame/browser_frame_win.cc @@ -69,7 +69,7 @@ views::Window* BrowserFrameWin::GetWindow() { return this; } -void BrowserFrameWin::TabStripCreated(TabStrip* tabstrip) { +void BrowserFrameWin::TabStripCreated(BaseTabStrip* tabstrip) { } int BrowserFrameWin::GetMinimizeButtonOffset() const { @@ -84,7 +84,7 @@ int BrowserFrameWin::GetMinimizeButtonOffset() const { return minimize_button_corner.x; } -gfx::Rect BrowserFrameWin::GetBoundsForTabStrip(TabStrip* tabstrip) const { +gfx::Rect BrowserFrameWin::GetBoundsForTabStrip(BaseTabStrip* tabstrip) const { return browser_frame_view_->GetBoundsForTabStrip(tabstrip); } diff --git a/chrome/browser/views/frame/browser_frame_win.h b/chrome/browser/views/frame/browser_frame_win.h index 3482df9..daf0f2b 100644 --- a/chrome/browser/views/frame/browser_frame_win.h +++ b/chrome/browser/views/frame/browser_frame_win.h @@ -37,9 +37,9 @@ class BrowserFrameWin : public BrowserFrame, public views::WindowWin { // BrowserFrame implementation. virtual views::Window* GetWindow(); - virtual void TabStripCreated(TabStrip* tabstrip); + virtual void TabStripCreated(BaseTabStrip* tabstrip); virtual int GetMinimizeButtonOffset() const; - virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const; + virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const; virtual void UpdateThrobber(bool running); virtual void ContinueDraggingDetachedTab(); virtual ThemeProvider* GetThemeProviderForFrame() const; diff --git a/chrome/browser/views/frame/browser_non_client_frame_view.h b/chrome/browser/views/frame/browser_non_client_frame_view.h index 5d8931c..e891f0b 100644 --- a/chrome/browser/views/frame/browser_non_client_frame_view.h +++ b/chrome/browser/views/frame/browser_non_client_frame_view.h @@ -7,7 +7,7 @@ #include "views/window/non_client_view.h" -class TabStrip; +class BaseTabStrip; // A specialization of the NonClientFrameView object that provides additional // Browser-specific methods. @@ -17,7 +17,7 @@ class BrowserNonClientFrameView : public views::NonClientFrameView { virtual ~BrowserNonClientFrameView() {} // Returns the bounds within which the TabStrip should be laid out. - virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const = 0; + virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const = 0; // Updates the throbber. virtual void UpdateThrobber(bool running) = 0; diff --git a/chrome/browser/views/frame/browser_root_view.cc b/chrome/browser/views/frame/browser_root_view.cc index 98b449e..7d8e2a1 100644 --- a/chrome/browser/views/frame/browser_root_view.cc +++ b/chrome/browser/views/frame/browser_root_view.cc @@ -126,7 +126,7 @@ views::DropTargetEvent* BrowserRootView::MapEventToTabStrip( event.GetSourceOperations()); } -TabStrip* BrowserRootView::tabstrip() const { +BaseTabStrip* BrowserRootView::tabstrip() const { return browser_view_->tabstrip(); } diff --git a/chrome/browser/views/frame/browser_root_view.h b/chrome/browser/views/frame/browser_root_view.h index bfc0fd4..cafbefd 100644 --- a/chrome/browser/views/frame/browser_root_view.h +++ b/chrome/browser/views/frame/browser_root_view.h @@ -9,7 +9,7 @@ class BrowserView; class OSExchangeData; -class TabStrip; +class BaseTabStrip; // RootView implementation used by BrowserFrame. This forwards drop events to // the TabStrip. Visually the tabstrip extends to the top of the frame, but in @@ -41,7 +41,7 @@ class BrowserRootView : public views::RootView { const views::DropTargetEvent& event, const OSExchangeData& data); - inline TabStrip* tabstrip() const; + inline BaseTabStrip* tabstrip() const; // Returns true if |data| has string contents and the user can "paste and go". // If |url| is non-NULL and the user can "paste and go", |url| is set to the diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index d36d059..d27990d 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -403,7 +403,6 @@ BrowserView::BrowserView(Browser* browser) browser_(browser), active_bookmark_bar_(NULL), tabstrip_(NULL), - side_tabstrip_(NULL), toolbar_(NULL), infobar_container_(NULL), contents_container_(NULL), @@ -1595,8 +1594,13 @@ views::LayoutManager* BrowserView::CreateLayoutManager() const { return new BrowserViewLayout; } -TabStrip* BrowserView::CreateTabStrip(TabStripModel* model) { - return new TabStrip(model); +BaseTabStrip* BrowserView::CreateTabStrip(TabStripModel* model) { + BaseTabStrip* tabstrip = NULL; + if (SideTabStrip::Visible(browser_->profile())) + tabstrip = new SideTabStrip; + else + tabstrip = new TabStrip(model); + return tabstrip; } /////////////////////////////////////////////////////////////////////////////// @@ -1628,10 +1632,6 @@ void BrowserView::Init() { AddChildView(tabstrip_); frame_->TabStripCreated(tabstrip_); - side_tabstrip_ = new SideTabStrip; - side_tabstrip_->SetID(VIEW_ID_SIDE_TABSTRIP); - AddChildView(side_tabstrip_); - toolbar_ = new ToolbarView(browser_.get()); AddChildView(toolbar_); toolbar_->Init(browser_->profile()); diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 422cbe9..cbd4701 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -18,7 +18,7 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/views/frame/browser_frame.h" -#include "chrome/browser/views/tabs/tab_strip.h" +#include "chrome/browser/views/tabs/base_tab_strip.h" #include "chrome/browser/views/unhandled_keyboard_event_handler.h" #include "views/window/client_view.h" #include "views/window/window_delegate.h" @@ -136,7 +136,7 @@ class BrowserView : public BrowserWindow, gfx::Rect GetTabStripBounds() const; // Accessor for the TabStrip. - TabStrip* tabstrip() const { return tabstrip_; } + BaseTabStrip* tabstrip() const { return tabstrip_; } // Accessor for the ExtensionShelf. ExtensionShelf* extension_shelf() const { return extension_shelf_; } @@ -382,7 +382,7 @@ class BrowserView : public BrowserWindow, // Returns a new TabStrip for the browser view. A subclass may // override to return a different TabStrip implementation. - virtual TabStrip* CreateTabStrip(TabStripModel* tab_strip_model); + virtual BaseTabStrip* CreateTabStrip(TabStripModel* tab_strip_model); // Browser window related initializations. virtual void Init(); @@ -466,8 +466,7 @@ class BrowserView : public BrowserWindow, views::View* active_bookmark_bar_; // The TabStrip. - TabStrip* tabstrip_; - SideTabStrip* side_tabstrip_; + BaseTabStrip* tabstrip_; // The Toolbar containing the navigation buttons, menus and the address bar. ToolbarView* toolbar_; diff --git a/chrome/browser/views/frame/browser_view_layout.cc b/chrome/browser/views/frame/browser_view_layout.cc index fcaa7ed..67fdbd2 100644 --- a/chrome/browser/views/frame/browser_view_layout.cc +++ b/chrome/browser/views/frame/browser_view_layout.cc @@ -231,10 +231,7 @@ void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) { toolbar_ = static_cast<ToolbarView*>(view); break; case VIEW_ID_TAB_STRIP: - tabstrip_ = static_cast<TabStrip*>(view); - break; - case VIEW_ID_SIDE_TABSTRIP: - side_tabstrip_ = static_cast<SideTabStrip*>(view); + tabstrip_ = static_cast<BaseTabStrip*>(view); break; } } @@ -280,9 +277,9 @@ gfx::Size BrowserViewLayout::GetPreferredSize(views::View* host) { void BrowserViewLayout::LayoutSideTabs() { vertical_layout_rect_ = browser_view_->GetLocalBounds(true); if (SideTabStrip::Visible(browser()->profile())) { - gfx::Size ps = side_tabstrip_->GetPreferredSize(); + gfx::Size ps = tabstrip_->GetPreferredSize(); vertical_layout_rect_.Inset(ps.width(), 0, 0, 0); - side_tabstrip_->SetBounds(0, 0, ps.width(), browser_view_->height()); + tabstrip_->SetBounds(0, 0, ps.width(), browser_view_->height()); } } diff --git a/chrome/browser/views/frame/browser_view_layout.h b/chrome/browser/views/frame/browser_view_layout.h index 1ab4cb23..941af52 100644 --- a/chrome/browser/views/frame/browser_view_layout.h +++ b/chrome/browser/views/frame/browser_view_layout.h @@ -73,8 +73,7 @@ class BrowserViewLayout : public views::LayoutManager { int LayoutExtensionShelf(int bottom); // Child views that the layout manager manages. - TabStrip* tabstrip_; - SideTabStrip* side_tabstrip_; + BaseTabStrip* tabstrip_; ToolbarView* toolbar_; views::View* contents_split_; views::View* contents_container_; diff --git a/chrome/browser/views/frame/glass_browser_frame_view.cc b/chrome/browser/views/frame/glass_browser_frame_view.cc index cafef77a..8510ba8 100644 --- a/chrome/browser/views/frame/glass_browser_frame_view.cc +++ b/chrome/browser/views/frame/glass_browser_frame_view.cc @@ -80,7 +80,7 @@ GlassBrowserFrameView::~GlassBrowserFrameView() { // GlassBrowserFrameView, BrowserNonClientFrameView implementation: gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( - TabStrip* tabstrip) const { + BaseTabStrip* tabstrip) const { int minimize_button_offset = frame_->GetMinimizeButtonOffset(); int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_avatar_bounds_.right() + kOTRSideSpacing) : diff --git a/chrome/browser/views/frame/glass_browser_frame_view.h b/chrome/browser/views/frame/glass_browser_frame_view.h index 7933943..ec0708f 100644 --- a/chrome/browser/views/frame/glass_browser_frame_view.h +++ b/chrome/browser/views/frame/glass_browser_frame_view.h @@ -20,7 +20,7 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView { virtual ~GlassBrowserFrameView(); // Overridden from BrowserNonClientFrameView: - virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const; + virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const; virtual void UpdateThrobber(bool running); // Overridden from views::NonClientFrameView: diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc index 5e36451..321a8b9 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc @@ -220,7 +220,7 @@ OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { // OpaqueBrowserFrameView, BrowserNonClientFrameView implementation: gfx::Rect OpaqueBrowserFrameView::GetBoundsForTabStrip( - TabStrip* tabstrip) const { + BaseTabStrip* tabstrip) const { int x_offset = browser_view_->browser_extender()->GetMainMenuWidth(); int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_avatar_icon_->bounds().right() + kOTRSideSpacing) : diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.h b/chrome/browser/views/frame/opaque_browser_frame_view.h index 7726e8b..647d8ac 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.h +++ b/chrome/browser/views/frame/opaque_browser_frame_view.h @@ -11,12 +11,12 @@ #include "views/controls/button/button.h" #include "views/window/non_client_view.h" +class BaseTabStrip; class BrowserView; namespace gfx { class Font; } class TabContents; -class TabStrip; namespace views { class ImageButton; class ImageView; @@ -33,7 +33,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView, virtual ~OpaqueBrowserFrameView(); // Overridden from BrowserNonClientFrameView: - virtual gfx::Rect GetBoundsForTabStrip(TabStrip* tabstrip) const; + virtual gfx::Rect GetBoundsForTabStrip(BaseTabStrip* tabstrip) const; virtual void UpdateThrobber(bool running); virtual gfx::Size GetMinimumSize(); diff --git a/chrome/browser/views/tabs/base_tab_strip.h b/chrome/browser/views/tabs/base_tab_strip.h new file mode 100644 index 0000000..fbb7612 --- /dev/null +++ b/chrome/browser/views/tabs/base_tab_strip.h @@ -0,0 +1,48 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_VIEWS_TABS_BASE_TAB_STRIP_H_ +#define CHROME_BROWSER_VIEWS_TABS_BASE_TAB_STRIP_H_ + +#include "views/view.h" + +class TabStrip; + +// A class that represents the common interface to the tabstrip used by classes +// such as BrowserView etc. +class BaseTabStrip : public views::View { + public: + // Returns the preferred height of this TabStrip. This is based on the + // typical height of its constituent tabs. + virtual int GetPreferredHeight() = 0; + + // Set the background offset used by inactive tabs to match the frame image. + virtual void SetBackgroundOffset(const gfx::Point& offset) = 0; + + // Returns true if the specified point(TabStrip coordinates) is + // in the window caption area of the browser window. + virtual bool IsPositionInWindowCaption(const gfx::Point& point) = 0; + + // Sets the bounds of the tab at the specified |tab_index|. |tab_bounds| are + // in TabStrip coordinates. + virtual void SetDraggedTabBounds(int tab_index, + const gfx::Rect& tab_bounds) = 0; + + // Returns true if a drag session is currently active. + virtual bool IsDragSessionActive() const = 0; + + // Updates the loading animations displayed by tabs in the tabstrip to the + // next frame. + virtual void UpdateLoadingAnimations() = 0; + + // Returns true if Tabs in this TabStrip are currently changing size or + // position. + virtual bool IsAnimating() const = 0; + + // Returns this object as a TabStrip if it is one. + virtual TabStrip* AsTabStrip() = 0; +}; + +#endif // CHROME_BROWSER_VIEWS_TABS_BASE_TAB_STRIP_H_ + diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index 04c0a1b..61d3d6a 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -822,7 +822,7 @@ TabStrip* DraggedTabController::GetTabStripForPoint( if (!browser || !browser->IsBrowserTypeNormal()) return NULL; - TabStrip* other_tabstrip = browser->tabstrip(); + TabStrip* other_tabstrip = browser->tabstrip()->AsTabStrip(); if (!other_tabstrip->IsCompatibleWith(source_tabstrip_)) return NULL; return GetTabStripIfItContains(other_tabstrip, screen_point); diff --git a/chrome/browser/views/tabs/side_tab_strip.cc b/chrome/browser/views/tabs/side_tab_strip.cc index a6b906c..8de9448 100644 --- a/chrome/browser/views/tabs/side_tab_strip.cc +++ b/chrome/browser/views/tabs/side_tab_strip.cc @@ -7,18 +7,21 @@ #include "app/gfx/canvas.h" #include "base/command_line.h" #include "chrome/browser/profile.h" +#include "chrome/browser/view_ids.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" namespace { const int kVerticalTabSpacing = 2; +const int kTabStripWidth = 127; } //////////////////////////////////////////////////////////////////////////////// // SideTabStrip, public: SideTabStrip::SideTabStrip() { + SetID(VIEW_ID_TAB_STRIP); } SideTabStrip::~SideTabStrip() { @@ -37,6 +40,39 @@ bool SideTabStrip::Visible(Profile* profile) { } //////////////////////////////////////////////////////////////////////////////// +// SideTabStrip, BaseTabStrip implementation: + +int SideTabStrip::GetPreferredHeight() { + return 0; +} + +void SideTabStrip::SetBackgroundOffset(const gfx::Point& offset) { +} + +bool SideTabStrip::IsPositionInWindowCaption(const gfx::Point& point) { + return false; +} + +void SideTabStrip::SetDraggedTabBounds(int tab_index, + const gfx::Rect& tab_bounds) { +} + +bool SideTabStrip::IsDragSessionActive() const { + return false; +} + +void SideTabStrip::UpdateLoadingAnimations() { +} + +bool SideTabStrip::IsAnimating() const { + return false; +} + +TabStrip* SideTabStrip::AsTabStrip() { + return NULL; +} + +//////////////////////////////////////////////////////////////////////////////// // SideTabStrip, views::View overrides: void SideTabStrip::Layout() { @@ -53,7 +89,7 @@ void SideTabStrip::Paint(gfx::Canvas* canvas) { } gfx::Size SideTabStrip::GetPreferredSize() { - return gfx::Size(127, 0); + return gfx::Size(kTabStripWidth, 0); } //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/views/tabs/side_tab_strip.h b/chrome/browser/views/tabs/side_tab_strip.h index 06b160f..2538333 100644 --- a/chrome/browser/views/tabs/side_tab_strip.h +++ b/chrome/browser/views/tabs/side_tab_strip.h @@ -5,11 +5,11 @@ #ifndef CHROME_BROWSER_VIEWS_TABS_SIDE_TAB_STRIP_H_ #define CHROME_BROWSER_VIEWS_TABS_SIDE_TAB_STRIP_H_ -#include "views/view.h" +#include "chrome/browser/views/tabs/base_tab_strip.h" class Profile; -class SideTabStrip : public views::View { +class SideTabStrip : public BaseTabStrip { public: SideTabStrip(); virtual ~SideTabStrip(); @@ -22,6 +22,17 @@ class SideTabStrip : public views::View { // returns true. static bool Visible(Profile* profile); + // BaseTabStrip implementation: + virtual int GetPreferredHeight(); + virtual void SetBackgroundOffset(const gfx::Point& offset); + virtual bool IsPositionInWindowCaption(const gfx::Point& point); + virtual void SetDraggedTabBounds(int tab_index, + const gfx::Rect& tab_bounds); + virtual bool IsDragSessionActive() const; + virtual void UpdateLoadingAnimations(); + virtual bool IsAnimating() const; + virtual TabStrip* AsTabStrip(); + // views::View overrides: virtual void Layout(); virtual void Paint(gfx::Canvas* canvas); diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index 69af0895..c3e79b8 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -645,15 +645,18 @@ void TabStrip::InitTabStripButtons() { AddChildView(newtab_button_); } -int TabStrip::GetPreferredHeight() { - return GetPreferredSize().height(); +bool TabStrip::IsCompatibleWith(TabStrip* other) const { + return model_->profile() == other->model()->profile(); } -bool TabStrip::IsAnimating() const { - return active_animation_.get() != NULL; +//////////////////////////////////////////////////////////////////////////////// +// TabStrip, BaseTabStrip implementation: + +int TabStrip::GetPreferredHeight() { + return GetPreferredSize().height(); } -void TabStrip::SetBackgroundOffset(gfx::Point offset) { +void TabStrip::SetBackgroundOffset(const gfx::Point& offset) { int tab_count = GetTabCount(); for (int i = 0; i < tab_count; ++i) GetTabAt(i)->SetBackgroundOffset(offset); @@ -683,15 +686,11 @@ bool TabStrip::IsPositionInWindowCaption(const gfx::Point& point) { return false; } -bool TabStrip::IsDragSessionActive() const { - return drag_controller_.get() != NULL; -} - -bool TabStrip::IsCompatibleWith(TabStrip* other) const { - return model_->profile() == other->model()->profile(); +void TabStrip::SetDraggedTabBounds(int tab_index, const gfx::Rect& tab_bounds) { } -void TabStrip::SetDraggedTabBounds(int tab_index, const gfx::Rect& tab_bounds) { +bool TabStrip::IsDragSessionActive() const { + return drag_controller_.get() != NULL; } void TabStrip::UpdateLoadingAnimations() { @@ -712,6 +711,14 @@ void TabStrip::UpdateLoadingAnimations() { } } +bool TabStrip::IsAnimating() const { + return active_animation_.get() != NULL; +} + +TabStrip* TabStrip::AsTabStrip() { + return this; +} + /////////////////////////////////////////////////////////////////////////////// // TabStrip, views::View overrides: diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index e24cc43..c942ab7 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -8,9 +8,9 @@ #include "base/gfx/point.h" #include "base/message_loop.h" #include "chrome/browser/tabs/tab_strip_model.h" +#include "chrome/browser/views/tabs/base_tab_strip.h" #include "chrome/browser/views/tabs/tab.h" #include "views/controls/button/image_button.h" -#include "views/view.h" class DraggedTabController; class ScopedMouseCloseWidthCalculator; @@ -38,7 +38,7 @@ class WidgetWin; // in response to dragged tabs. // /////////////////////////////////////////////////////////////////////////////// -class TabStrip : public views::View, +class TabStrip : public BaseTabStrip, public TabStripModelObserver, public Tab::TabDelegate, public views::ButtonListener, @@ -70,35 +70,20 @@ class TabStrip : public views::View, // Create the new tab button. void InitTabStripButtons(); - // Returns the preferred height of this TabStrip. This is based on the - // typical height of its constituent tabs. - int GetPreferredHeight(); - - // Returns true if Tabs in this TabStrip are currently changing size or - // position. - bool IsAnimating() const; - - // Set the background offset used by inactive tabs to match the frame image. - void SetBackgroundOffset(gfx::Point offset); - - // Returns true if the specified point(TabStrip coordinates) is - // in the window caption area of the browser window. - bool IsPositionInWindowCaption(const gfx::Point& point); - - // Returns true if a drag session is currently active. - bool IsDragSessionActive() const; - // Return true if this tab strip is compatible with the provided tab strip. // Compatible tab strips can transfer tabs during drag and drop. bool IsCompatibleWith(TabStrip* other) const; - // Sets the bounds of the tab at the specified |tab_index|. |tab_bounds| are - // in TabStrip coordinates. - void SetDraggedTabBounds(int tab_index, const gfx::Rect& tab_bounds); - - // Updates the loading animations displayed by tabs in the tabstrip to the - // next frame. - void UpdateLoadingAnimations(); + // BaseTabStrip implementation: + virtual int GetPreferredHeight(); + virtual void SetBackgroundOffset(const gfx::Point& offset); + virtual bool IsPositionInWindowCaption(const gfx::Point& point); + virtual void SetDraggedTabBounds(int tab_index, + const gfx::Rect& tab_bounds); + virtual bool IsDragSessionActive() const; + virtual void UpdateLoadingAnimations(); + virtual bool IsAnimating() const; + virtual TabStrip* AsTabStrip(); // views::View overrides: virtual void PaintChildren(gfx::Canvas* canvas); diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index ef3a7a9..65f300e 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1967,6 +1967,7 @@ 'browser/views/tabs/native_view_photobooth_gtk.h', 'browser/views/tabs/native_view_photobooth_win.cc', 'browser/views/tabs/native_view_photobooth_win.h', + 'browser/views/tabs/base_tab_strip.h', 'browser/views/tabs/side_tab.cc', 'browser/views/tabs/side_tab.h', 'browser/views/tabs/side_tab_strip.cc', @@ -2458,6 +2459,7 @@ ['include', '^browser/views/tabs/native_view_photobooth.h'], ['include', '^browser/views/tabs/native_view_photobooth_gtk.cc'], ['include', '^browser/views/tabs/native_view_photobooth_gtk.h'], + ['include', '^browser/views/tabs/base_tab_strip.h'], ['include', '^browser/views/tabs/side_tab.cc'], ['include', '^browser/views/tabs/side_tab.h'], ['include', '^browser/views/tabs/side_tab_strip.cc'], |