diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 01:45:08 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 01:45:08 +0000 |
commit | fdb0d147252e3034dff2bfa8e83e93ca4c471147 (patch) | |
tree | 58eb49fd4b0aab20a746bc0ff63af9a44c06ca5d | |
parent | 7a32bd0f44d3a85e7dea0a4b1b42d3afa7cab2ad (diff) | |
download | chromium_src-fdb0d147252e3034dff2bfa8e83e93ca4c471147.zip chromium_src-fdb0d147252e3034dff2bfa8e83e93ca4c471147.tar.gz chromium_src-fdb0d147252e3034dff2bfa8e83e93ca4c471147.tar.bz2 |
Revert 37914 - Move ChromeBrowserView* > BrowserView* and ChromeosBrowserView* > chromeos::BrowserView*
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/569019
TBR=ben@chromium.org
Review URL: http://codereview.chromium.org/562030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37928 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/chromeos_browser_view.cc (renamed from chrome/browser/chromeos/browser_view.cc) | 95 | ||||
-rw-r--r-- | chrome/browser/chromeos/chromeos_browser_view.h (renamed from chrome/browser/chromeos/browser_view.h) | 27 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 16 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 7 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view_layout_manager.h | 32 | ||||
-rw-r--r-- | chrome/browser/views/frame/chrome_browser_view_layout_manager.cc (renamed from chrome/browser/views/frame/browser_view_layout.cc) | 212 | ||||
-rw-r--r-- | chrome/browser/views/frame/chrome_browser_view_layout_manager.h (renamed from chrome/browser/views/frame/browser_view_layout.h) | 43 | ||||
-rwxr-xr-x | chrome/chrome_browser.gypi | 14 |
8 files changed, 238 insertions, 208 deletions
diff --git a/chrome/browser/chromeos/browser_view.cc b/chrome/browser/chromeos/chromeos_browser_view.cc index 0e84b3c..861c393 100644 --- a/chrome/browser/chromeos/browser_view.cc +++ b/chrome/browser/chromeos/chromeos_browser_view.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/browser_view.h" +#include "chrome/browser/chromeos/chromeos_browser_view.h" #include <algorithm> #include <string> @@ -60,7 +60,7 @@ class Spacer : public views::View { // A chromeos implementation of Tab that shows the compact location bar. class ChromeosTab : public Tab { public: - ChromeosTab(TabStrip* tab_strip, chromeos::BrowserView* browser_view) + ChromeosTab(TabStrip* tab_strip, chromeos::ChromeosBrowserView* browser_view) : Tab(tab_strip), browser_view_(browser_view) { } @@ -73,7 +73,7 @@ class ChromeosTab : public Tab { } private: - chromeos::BrowserView* browser_view_; + chromeos::ChromeosBrowserView* browser_view_; DISALLOW_COPY_AND_ASSIGN(ChromeosTab); }; @@ -81,7 +81,8 @@ class ChromeosTab : public Tab { // A Tabstrip that uses ChromeosTab as a Tab implementation. class ChromeosTabStrip : public TabStrip { public: - ChromeosTabStrip(TabStripModel* model, chromeos::BrowserView* browser_view) + ChromeosTabStrip(TabStripModel* model, + chromeos::ChromeosBrowserView* browser_view) : TabStrip(model), browser_view_(browser_view) { } virtual ~ChromeosTabStrip() {} @@ -93,7 +94,7 @@ class ChromeosTabStrip : public TabStrip { } private: - chromeos::BrowserView* browser_view_; + chromeos::ChromeosBrowserView* browser_view_; DISALLOW_COPY_AND_ASSIGN(ChromeosTabStrip); }; @@ -108,31 +109,27 @@ enum ChromeOSViewIds { VIEW_ID_SPACER, }; -} // namespace - -namespace chromeos { - -// LayoutManager for BrowserView, which layouts extra components such as +// LayoutManager for ChromeosBrowserView, which layouts extra components such as // main menu, stataus views. -class BrowserViewLayout : public ::BrowserViewLayout { +class ChromeosBrowserViewLayoutManager : public ChromeBrowserViewLayoutManager { public: - BrowserViewLayout() : BrowserViewLayout() {} - virtual ~BrowserViewLayout() {} + ChromeosBrowserViewLayoutManager() : ChromeBrowserViewLayoutManager() {} + virtual ~ChromeosBrowserViewLayoutManager() {} ////////////////////////////////////////////////////////////////////////////// - // BrowserViewLayout overrides: + // ChromeBrowserViewLayoutManager overrides: void Installed(views::View* host) { main_menu_ = NULL; compact_navigation_bar_ = NULL; status_area_ = NULL; spacer_ = NULL; - BrowserViewLayout::Installed(host); + ChromeBrowserViewLayoutManager::Installed(host); } void ViewAdded(views::View* host, views::View* view) { - BrowserViewLayout::ViewAdded(host, view); + ChromeBrowserViewLayoutManager::ViewAdded(host, view); switch (view->GetID()) { case VIEW_ID_SPACER: spacer_ = view; @@ -179,7 +176,7 @@ class BrowserViewLayout : public ::BrowserViewLayout { } virtual bool IsPositionInWindowCaption(const gfx::Point& point) { - return BrowserViewLayout::IsPositionInWindowCaption(point) + return ChromeBrowserViewLayoutManager::IsPositionInWindowCaption(point) && !IsPointInViewsInTitleArea(point); } @@ -191,12 +188,12 @@ class BrowserViewLayout : public ::BrowserViewLayout { if (IsPointInViewsInTitleArea(point_in_browser_view_coords)) { return HTCLIENT; } - return BrowserViewLayout::NonClientHitTest(point); + return ChromeBrowserViewLayoutManager::NonClientHitTest(point); } private: - chromeos::BrowserView* chromeos_browser_view() { - return static_cast<chromeos::BrowserView*>(browser_view_); + chromeos::ChromeosBrowserView* chromeos_browser_view() { + return static_cast<chromeos::ChromeosBrowserView*>(browser_view_); } // Test if the point is on one of views that are within the @@ -313,10 +310,14 @@ class BrowserViewLayout : public ::BrowserViewLayout { views::View* compact_navigation_bar_; views::View* spacer_; - DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout); + DISALLOW_COPY_AND_ASSIGN(ChromeosBrowserViewLayoutManager); }; -BrowserView::BrowserView(Browser* browser) +} // namespace + +namespace chromeos { + +ChromeosBrowserView::ChromeosBrowserView(Browser* browser) : BrowserView(browser), main_menu_(NULL), status_area_(NULL), @@ -327,13 +328,13 @@ BrowserView::BrowserView(Browser* browser) force_maximized_window_(false) { } -BrowserView::~BrowserView() { +ChromeosBrowserView::~ChromeosBrowserView() { } //////////////////////////////////////////////////////////////////////////////// -// BrowserView, ::BrowserView overrides: +// ChromeosBrowserView, ChromeBrowserView overrides: -void BrowserView::Init() { +void ChromeosBrowserView::Init() { BrowserView::Init(); main_menu_ = new views::ImageButton(this); main_menu_->SetID(VIEW_ID_MAIN_MENU); @@ -387,7 +388,7 @@ void BrowserView::Init() { } } -void BrowserView::Show() { +void ChromeosBrowserView::Show() { bool was_visible = frame()->GetWindow()->IsVisible(); BrowserView::Show(); if (!was_visible) { @@ -398,13 +399,13 @@ void BrowserView::Show() { } } -bool BrowserView::IsToolbarVisible() const { +bool ChromeosBrowserView::IsToolbarVisible() const { if (is_compact_style()) return false; return BrowserView::IsToolbarVisible(); } -void BrowserView::SetFocusToLocationBar() { +void ChromeosBrowserView::SetFocusToLocationBar() { if (compact_navigation_bar_->IsFocusable()) { compact_navigation_bar_->FocusLocation(); } else { @@ -412,71 +413,73 @@ void BrowserView::SetFocusToLocationBar() { } } -void BrowserView::ToggleCompactNavigationBar() { +void ChromeosBrowserView::ToggleCompactNavigationBar() { ui_style_ = static_cast<UIStyle>((ui_style_ + 1) % 2); compact_navigation_bar_->SetFocusable(is_compact_style()); compact_location_bar_host_->SetEnabled(is_compact_style()); Layout(); } -views::LayoutManager* BrowserView::CreateLayoutManager() const { - return new BrowserViewLayout(); +views::LayoutManager* ChromeosBrowserView::CreateLayoutManager() const { + return new ChromeosBrowserViewLayoutManager(); } -TabStrip* BrowserView::CreateTabStrip( +TabStrip* ChromeosBrowserView::CreateTabStrip( TabStripModel* tab_strip_model) { return new ChromeosTabStrip(tab_strip_model, this); } // views::ButtonListener overrides. -void BrowserView::ButtonPressed(views::Button* sender, - const views::Event& event) { +void ChromeosBrowserView::ButtonPressed(views::Button* sender, + const views::Event& event) { chromeos::MainMenu::Show(browser()); } // views::ContextMenuController overrides. -void BrowserView::ShowContextMenu(views::View* source, int x, int y, - bool is_mouse_gesture) { +void ChromeosBrowserView::ShowContextMenu(views::View* source, + int x, + int y, + bool is_mouse_gesture) { system_menu_menu_->RunMenuAt(gfx::Point(x, y), views::Menu2::ALIGN_TOPLEFT); } // StatusAreaHost overrides. -gfx::NativeWindow BrowserView::GetNativeWindow() const { +gfx::NativeWindow ChromeosBrowserView::GetNativeWindow() const { return GetWindow()->GetNativeWindow(); } -void BrowserView::OpenSystemOptionsDialog() const { +void ChromeosBrowserView::OpenSystemOptionsDialog() const { browser()->OpenSystemOptionsDialog(); } -bool BrowserView::IsButtonVisible(views::View* button_view) const { +bool ChromeosBrowserView::IsButtonVisible(views::View* button_view) const { if (button_view == status_area_->menu_view()) return !IsToolbarVisible(); return true; } //////////////////////////////////////////////////////////////////////////////// -// BrowserView public: +// ChromeosBrowserView public: -void BrowserView::ShowCompactLocationBarUnderSelectedTab() { +void ChromeosBrowserView::ShowCompactLocationBarUnderSelectedTab() { if (!is_compact_style()) return; int index = browser()->selected_index(); compact_location_bar_host_->Update(index, true); } -bool BrowserView::ShouldForceMaximizedWindow() const { +bool ChromeosBrowserView::ShouldForceMaximizedWindow() const { return force_maximized_window_; } -int BrowserView::GetMainMenuWidth() const { +int ChromeosBrowserView::GetMainMenuWidth() const { return main_menu_->GetPreferredSize().width(); } //////////////////////////////////////////////////////////////////////////////// -// BrowserView private: +// ChromeosBrowserView private: -void BrowserView::InitSystemMenu() { +void ChromeosBrowserView::InitSystemMenu() { system_menu_contents_.reset(new menus::SimpleMenuModel(this)); system_menu_contents_->AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); @@ -496,7 +499,7 @@ BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { if (browser->type() & Browser::TYPE_POPUP) view = new chromeos::PanelBrowserView(browser); else - view = new chromeos::BrowserView(browser); + view = new chromeos::ChromeosBrowserView(browser); BrowserFrame::Create(view, browser->profile()); return view; } diff --git a/chrome/browser/chromeos/browser_view.h b/chrome/browser/chromeos/chromeos_browser_view.h index 9d7b67b..2000674 100644 --- a/chrome/browser/chromeos/browser_view.h +++ b/chrome/browser/chromeos/chromeos_browser_view.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_CHROMEOS_BROWSER_VIEW_H_ -#define CHROME_BROWSER_CHROMEOS_BROWSER_VIEW_H_ +#ifndef CHROME_BROWSER_CHROMEOS_CHROMEOS_BROWSER_VIEW_H_ +#define CHROME_BROWSER_CHROMEOS_CHROMEOS_BROWSER_VIEW_H_ #include "chrome/browser/chromeos/status_area_host.h" #include "chrome/browser/views/frame/browser_view.h" @@ -27,17 +27,17 @@ class CompactLocationBarHost; class CompactNavigationBar; class StatusAreaButton; -// chromeos::BrowserView adds ChromeOS specific controls and menus to a -// BrowserView created with Browser::TYPE_NORMAL. This extender adds controls -// to the title bar as follows: +// ChromeosBrowserView adds ChromeOS specific controls and menus to a +// BrowserView created with Browser::TYPE_NORMAL. This extender adds +// controls to the title bar as follows: // ____ __ __ // [MainMenu] / \ \ \ [StatusArea] // // and adds the system context menu to the remaining arae of the titlebar. -class BrowserView : public BrowserView, - public views::ButtonListener, - public views::ContextMenuController, - public StatusAreaHost { +class ChromeosBrowserView : public BrowserView, + public views::ButtonListener, + public views::ContextMenuController, + public StatusAreaHost { public: // There are 3 ui styles, standard, compact and sidebar. // Standard uses the same layout as chromium/chrome browser. @@ -51,8 +51,8 @@ class BrowserView : public BrowserView, SidebarStyle, }; - explicit BrowserView(Browser* browser); - virtual ~BrowserView(); + explicit ChromeosBrowserView(Browser* browser); + virtual ~ChromeosBrowserView(); // BrowserView overrides. virtual void Init(); @@ -122,10 +122,9 @@ class BrowserView : public BrowserView, // Menu button shown in status area when browser is in compact mode. StatusAreaButton* menu_view_; - DISALLOW_COPY_AND_ASSIGN(BrowserView); + DISALLOW_COPY_AND_ASSIGN(ChromeosBrowserView); }; } // namespace chromeos -#endif // CHROME_BROWSER_CHROMEOS_BROWSER_VIEW_H_ - +#endif // CHROME_BROWSER_CHROMEOS_CHROMEOS_BROWSER_VIEW_H_ diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 5eb03d3..e02d3d5 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -38,7 +38,7 @@ #include "chrome/browser/views/chrome_views_delegate.h" #include "chrome/browser/views/download_shelf_view.h" #include "chrome/browser/views/extensions/extension_shelf.h" -#include "chrome/browser/views/frame/browser_view_layout.h" +#include "chrome/browser/views/frame/chrome_browser_view_layout_manager.h" #include "chrome/browser/views/frame/browser_extender.h" #include "chrome/browser/views/frame/browser_frame.h" #include "chrome/browser/views/fullscreen_exit_bubble.h" @@ -524,7 +524,7 @@ bool BrowserView::ShouldFindBarBlendWithBookmarksBar() const { } gfx::Rect BrowserView::GetFindBarBoundingBox() const { - return GetBrowserViewLayout()->GetFindBarBoundingBox(); + return GetBrowserViewLayoutManager()->GetFindBarBoundingBox(); } int BrowserView::GetTabStripHeight() const { @@ -658,7 +658,7 @@ void BrowserView::DetachBrowserBubble(BrowserBubble* bubble) { } bool BrowserView::IsPositionInWindowCaption(const gfx::Point& point) { - return GetBrowserViewLayout()->IsPositionInWindowCaption(point); + return GetBrowserViewLayoutManager()->IsPositionInWindowCaption(point); } /////////////////////////////////////////////////////////////////////////////// @@ -1532,11 +1532,11 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) { } #endif - return GetBrowserViewLayout()->NonClientHitTest(point); + return GetBrowserViewLayoutManager()->NonClientHitTest(point); } gfx::Size BrowserView::GetMinimumSize() { - return GetBrowserViewLayout()->GetMinimumSize(); + return GetBrowserViewLayoutManager()->GetMinimumSize(); } /////////////////////////////////////////////////////////////////////////////// @@ -1590,7 +1590,7 @@ void BrowserView::SetAccessibleName(const std::wstring& name) { } views::LayoutManager* BrowserView::CreateLayoutManager() const { - return new BrowserViewLayout; + return new ChromeBrowserViewLayoutManager(); } TabStrip* BrowserView::CreateTabStrip(TabStripModel* model) { @@ -1692,8 +1692,8 @@ void BrowserView::InitSystemMenu() { } #endif -BrowserViewLayout* BrowserView::GetBrowserViewLayout() const { - return static_cast<BrowserViewLayout*>(GetLayoutManager()); +BrowserViewLayoutManager* BrowserView::GetBrowserViewLayoutManager() const { + return static_cast<BrowserViewLayoutManager*>(GetLayoutManager()); } void BrowserView::LayoutStatusBubble(int top) { diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 32b4491..516e9bf 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -36,7 +36,7 @@ class BookmarkBarView; class Browser; class BrowserBubble; class BrowserExtender; -class BrowserViewLayout; +class BrowserViewLayoutManager; class DownloadShelfView; class EncodingMenuModel; class ExtensionShelf; @@ -388,9 +388,8 @@ class BrowserView : public BrowserWindow, // Creates the system menu. void InitSystemMenu(); #endif - - // Returns the BrowserViewLayout. - BrowserViewLayout* GetBrowserViewLayout() const; + // Returns the BrowserViewLayoutManager. + BrowserViewLayoutManager* GetBrowserViewLayoutManager() const; // Prepare to show the Bookmark Bar for the specified TabContents. Returns // true if the Bookmark Bar can be shown (i.e. it's supported for this diff --git a/chrome/browser/views/frame/browser_view_layout_manager.h b/chrome/browser/views/frame/browser_view_layout_manager.h new file mode 100644 index 0000000..f39b877 --- /dev/null +++ b/chrome/browser/views/frame/browser_view_layout_manager.h @@ -0,0 +1,32 @@ +// 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_FRAME_BROWSER_VIEW_LAYOUT_MANAGER_H_ +#define CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_MANAGER_H_ + +#include "base/gfx/size.h" +#include "views/layout_manager.h" + +// An extended LayoutManager to layout components in +// BrowserView. +class BrowserViewLayoutManager : public views::LayoutManager { + public: + // Returns the minimum size of the browser view. + virtual gfx::Size GetMinimumSize() = 0; + + // Returns the bounding box for the find bar. + virtual gfx::Rect GetFindBarBoundingBox() const = 0; + + // Returns true if the specified point(BrowserView coordinates) is in + // in the window caption area of the browser window. + virtual bool IsPositionInWindowCaption(const gfx::Point& point) = 0; + + // Tests to see if the specified |point| (in nonclient view's coordinates) + // is within the views managed by the laymanager. Returns one of + // HitTestCompat enum defined in views/window/hit_test.h. + // See also ClientView::NonClientHitTest. + virtual int NonClientHitTest(const gfx::Point& point) = 0; +}; + +#endif // CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_MANAGER_H_ diff --git a/chrome/browser/views/frame/browser_view_layout.cc b/chrome/browser/views/frame/chrome_browser_view_layout_manager.cc index e2c5ae1..8994f75 100644 --- a/chrome/browser/views/frame/browser_view_layout.cc +++ b/chrome/browser/views/frame/chrome_browser_view_layout_manager.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/views/frame/browser_view_layout.h" +#include "chrome/browser/views/frame/chrome_browser_view_layout_manager.h" #include "app/gfx/scrollbar_size.h" #include "chrome/browser/find_bar.h" @@ -22,23 +22,16 @@ #include "views/window/hit_test.h" #endif -namespace { - // The visible height of the shadow above the tabs. Clicks in this area are // treated as clicks to the frame, rather than clicks to the tab. -const int kTabShadowSize = 2; +static const int kTabShadowSize = 2; // The vertical overlap between the TabStrip and the Toolbar. -const int kToolbarTabStripVerticalOverlap = 3; +static const int kToolbarTabStripVerticalOverlap = 3; // An offset distance between certain toolbars and the toolbar that preceded // them in layout. -const int kSeparationLineHeight = 1; - -} // namespace - -//////////////////////////////////////////////////////////////////////////////// -// BrowserViewLayout, public: +static const int kSeparationLineHeight = 1; -BrowserViewLayout::BrowserViewLayout() +ChromeBrowserViewLayoutManager::ChromeBrowserViewLayoutManager() : tabstrip_(NULL), toolbar_(NULL), contents_split_(NULL), @@ -51,7 +44,90 @@ BrowserViewLayout::BrowserViewLayout() find_bar_y_(0) { } -gfx::Size BrowserViewLayout::GetMinimumSize() { +////////////////////////////////////////////////////////////////////////////// +// Overridden from LayoutManager. + +void ChromeBrowserViewLayoutManager::Installed(views::View* host) { + toolbar_ = NULL; + contents_split_ = NULL; + contents_container_ = NULL; + infobar_container_ = NULL; + download_shelf_ = NULL; + extension_shelf_ = NULL; + active_bookmark_bar_ = NULL; + tabstrip_ = NULL; + browser_view_ = static_cast<BrowserView*>(host); +} + +void ChromeBrowserViewLayoutManager::Uninstalled(views::View* host) {} + +void ChromeBrowserViewLayoutManager::ViewAdded(views::View* host, + views::View* view) { + switch (view->GetID()) { + case VIEW_ID_CONTENTS_SPLIT: + contents_split_ = view; + contents_container_ = contents_split_->GetChildViewAt(0); + break; + case VIEW_ID_INFO_BAR_CONTAINER: + infobar_container_ = view; + break; + case VIEW_ID_DOWNLOAD_SHELF: + download_shelf_ = static_cast<DownloadShelfView*>(view); + break; + case VIEW_ID_DEV_EXTENSION_SHELF: + extension_shelf_ = static_cast<ExtensionShelf*>(view); + break; + case VIEW_ID_BOOKMARK_BAR: + active_bookmark_bar_ = static_cast<BookmarkBarView*>(view); + break; + case VIEW_ID_TOOLBAR: + toolbar_ = static_cast<ToolbarView*>(view); + break; + case VIEW_ID_TAB_STRIP: + tabstrip_ = static_cast<TabStrip*>(view); + break; + } +} + +void ChromeBrowserViewLayoutManager::ViewRemoved(views::View* host, + views::View* view) { + switch (view->GetID()) { + case VIEW_ID_BOOKMARK_BAR: + active_bookmark_bar_ = NULL; + break; + } +} + +void ChromeBrowserViewLayoutManager::Layout(views::View* host) { + int top = LayoutTabStrip(); + top = LayoutToolbar(top); + top = LayoutBookmarkAndInfoBars(top); + int bottom = LayoutExtensionAndDownloadShelves(); + LayoutTabContents(top, bottom); + // This must be done _after_ we lay out the TabContents since this + // code calls back into us to find the bounding box the find bar + // must be laid out within, and that code depends on the + // TabContentsContainer's bounds being up to date. + if (browser()->HasFindBarController()) { + browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary( + gfx::Rect(), true); + } + // Align status bubble with the bottom of the contents_container. + browser_view_->LayoutStatusBubble( + top + contents_container_->bounds().height()); + browser_view_->SchedulePaint(); +} + +// Return the preferred size which is the size required to give each +// children their respective preferred size. +gfx::Size ChromeBrowserViewLayoutManager::GetPreferredSize(views::View* host) { + return gfx::Size(); +} + +////////////////////////////////////////////////////////////////////////////// +// Overridden from BrowserViewLayoutManager. + +gfx::Size ChromeBrowserViewLayoutManager::GetMinimumSize() { // TODO(noname): In theory the tabstrip width should probably be // (OTR + tabstrip + caption buttons) width. gfx::Size tabstrip_size( @@ -82,7 +158,7 @@ gfx::Size BrowserViewLayout::GetMinimumSize() { return gfx::Size(min_width, min_height); } -gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const { +gfx::Rect ChromeBrowserViewLayoutManager::GetFindBarBoundingBox() const { // This function returns the area the Find Bar can be laid out // within. This basically implies the "user-perceived content // area" of the browser window excluding the vertical @@ -116,14 +192,14 @@ gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const { return bounding_box; } -bool BrowserViewLayout::IsPositionInWindowCaption( +bool ChromeBrowserViewLayoutManager::IsPositionInWindowCaption( const gfx::Point& point) { gfx::Point tabstrip_point(point); views::View::ConvertPointToView(browser_view_, tabstrip_, &tabstrip_point); return tabstrip_->IsPositionInWindowCaption(tabstrip_point); } -int BrowserViewLayout::NonClientHitTest( +int ChromeBrowserViewLayoutManager::NonClientHitTest( const gfx::Point& point) { // Since the TabStrip only renders in some parts of the top of the window, // the un-obscured area is considered to be part of the non-client caption @@ -192,87 +268,9 @@ int BrowserViewLayout::NonClientHitTest( } ////////////////////////////////////////////////////////////////////////////// -// BrowserViewLayout, views::LayoutManager implementation: - -void BrowserViewLayout::Installed(views::View* host) { - toolbar_ = NULL; - contents_split_ = NULL; - contents_container_ = NULL; - infobar_container_ = NULL; - download_shelf_ = NULL; - extension_shelf_ = NULL; - active_bookmark_bar_ = NULL; - tabstrip_ = NULL; - browser_view_ = static_cast<BrowserView*>(host); -} - -void BrowserViewLayout::Uninstalled(views::View* host) {} - -void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) { - switch (view->GetID()) { - case VIEW_ID_CONTENTS_SPLIT: - contents_split_ = view; - contents_container_ = contents_split_->GetChildViewAt(0); - break; - case VIEW_ID_INFO_BAR_CONTAINER: - infobar_container_ = view; - break; - case VIEW_ID_DOWNLOAD_SHELF: - download_shelf_ = static_cast<DownloadShelfView*>(view); - break; - case VIEW_ID_DEV_EXTENSION_SHELF: - extension_shelf_ = static_cast<ExtensionShelf*>(view); - break; - case VIEW_ID_BOOKMARK_BAR: - active_bookmark_bar_ = static_cast<BookmarkBarView*>(view); - break; - case VIEW_ID_TOOLBAR: - toolbar_ = static_cast<ToolbarView*>(view); - break; - case VIEW_ID_TAB_STRIP: - tabstrip_ = static_cast<TabStrip*>(view); - break; - } -} - -void BrowserViewLayout::ViewRemoved(views::View* host, views::View* view) { - switch (view->GetID()) { - case VIEW_ID_BOOKMARK_BAR: - active_bookmark_bar_ = NULL; - break; - } -} - -void BrowserViewLayout::Layout(views::View* host) { - int top = LayoutTabStrip(); - top = LayoutToolbar(top); - top = LayoutBookmarkAndInfoBars(top); - int bottom = LayoutExtensionAndDownloadShelves(); - LayoutTabContents(top, bottom); - // This must be done _after_ we lay out the TabContents since this - // code calls back into us to find the bounding box the find bar - // must be laid out within, and that code depends on the - // TabContentsContainer's bounds being up to date. - if (browser()->HasFindBarController()) { - browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary( - gfx::Rect(), true); - } - // Align status bubble with the bottom of the contents_container. - browser_view_->LayoutStatusBubble( - top + contents_container_->bounds().height()); - browser_view_->SchedulePaint(); -} - -// Return the preferred size which is the size required to give each -// children their respective preferred size. -gfx::Size BrowserViewLayout::GetPreferredSize(views::View* host) { - return gfx::Size(); -} - -////////////////////////////////////////////////////////////////////////////// -// BrowserViewLayout, private: +// Overridden from ChromeBrowserViewLayoutManager, private: -int BrowserViewLayout::LayoutTabStrip() { +int ChromeBrowserViewLayoutManager::LayoutTabStrip() { if (!browser_view_->IsTabStripVisible()) { tabstrip_->SetVisible(false); tabstrip_->SetBounds(0, 0, 0, 0); @@ -294,7 +292,9 @@ int BrowserViewLayout::LayoutTabStrip() { } } -int BrowserViewLayout::LayoutToolbar(int top) { +// Layout the following controls, starting at |top|, returns the coordinate +// of the bottom of the control, for laying out the next control. +int ChromeBrowserViewLayoutManager::LayoutToolbar(int top) { int browser_view_width = browser_view_->width(); bool visible = browser_view_->IsToolbarVisible(); toolbar_->location_bar()->SetFocusable(visible); @@ -307,7 +307,7 @@ int BrowserViewLayout::LayoutToolbar(int top) { return y + height; } -int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top) { +int ChromeBrowserViewLayoutManager::LayoutBookmarkAndInfoBars(int top) { find_bar_y_ = top + browser_view_->y() - 1; if (active_bookmark_bar_) { // If we're showing the Bookmark bar in detached style, then we @@ -322,7 +322,7 @@ int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top) { return LayoutInfoBar(top); } -int BrowserViewLayout::LayoutTopBar(int top) { +int ChromeBrowserViewLayoutManager::LayoutTopBar(int top) { // This method lays out the the bookmark bar, and, if required, // the extension shelf by its side. The bookmark bar appears on // the right of the extension shelf. If there are too many @@ -378,7 +378,7 @@ int BrowserViewLayout::LayoutTopBar(int top) { return y + bookmark_bar_height; } -int BrowserViewLayout::LayoutInfoBar(int top) { +int ChromeBrowserViewLayoutManager::LayoutInfoBar(int top) { bool visible = browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR); int height = visible ? infobar_container_->GetPreferredSize().height() : 0; infobar_container_->SetVisible(visible); @@ -388,11 +388,11 @@ int BrowserViewLayout::LayoutInfoBar(int top) { // Layout the TabContents container, between the coordinates |top| and // |bottom|. -void BrowserViewLayout::LayoutTabContents(int top, int bottom) { +void ChromeBrowserViewLayoutManager::LayoutTabContents(int top, int bottom) { contents_split_->SetBounds(0, top, browser_view_->width(), bottom - top); } -int BrowserViewLayout::LayoutExtensionAndDownloadShelves() { +int ChromeBrowserViewLayoutManager::LayoutExtensionAndDownloadShelves() { // If we're showing the Extension bar in detached style, then we // need to show Download shelf _above_ the Extension bar, since // the Extension bar is styled to look like it's part of the page. @@ -410,7 +410,9 @@ int BrowserViewLayout::LayoutExtensionAndDownloadShelves() { return LayoutDownloadShelf(bottom); } -int BrowserViewLayout::LayoutDownloadShelf(int bottom) { +// Layout the Download Shelf, returns the coordinate of the top of the +// control, for laying out the previous control. +int ChromeBrowserViewLayoutManager::LayoutDownloadShelf(int bottom) { // Re-layout the shelf either if it is visible or if it's close animation // is currently running. if (browser_view_->IsDownloadShelfVisible() || @@ -428,7 +430,9 @@ int BrowserViewLayout::LayoutDownloadShelf(int bottom) { return bottom; } -int BrowserViewLayout::LayoutExtensionShelf(int bottom) { +// Layout the Extension Shelf, returns the coordinate of the top of the +// control, for laying out the previous control. +int ChromeBrowserViewLayoutManager::LayoutExtensionShelf(int bottom) { if (!extension_shelf_ || extension_shelf_->IsOnTop()) return bottom; diff --git a/chrome/browser/views/frame/browser_view_layout.h b/chrome/browser/views/frame/chrome_browser_view_layout_manager.h index 33333fa..19334a4 100644 --- a/chrome/browser/views/frame/browser_view_layout.h +++ b/chrome/browser/views/frame/chrome_browser_view_layout_manager.h @@ -2,35 +2,20 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ -#define CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ +#ifndef CHROME_BROWSER_VIEWS_FRAME_CHROME_BROWSER_VIEW_LAYOUT_MANAGER_H_ +#define CHROME_BROWSER_VIEWS_FRAME_CHROME_BROWSER_VIEW_LAYOUT_MANAGER_H_ +#include "chrome/browser/views/frame/browser_view_layout_manager.h" #include "chrome/browser/views/frame/browser_view.h" -#include "views/layout_manager.h" // The layout manager used in chrome browser. -class BrowserViewLayout : public views::LayoutManager { +class ChromeBrowserViewLayoutManager : public BrowserViewLayoutManager { public: - BrowserViewLayout(); - virtual ~BrowserViewLayout() {} + ChromeBrowserViewLayoutManager(); + virtual ~ChromeBrowserViewLayoutManager() {} - // Returns the minimum size of the browser view. - virtual gfx::Size GetMinimumSize(); - - // Returns the bounding box for the find bar. - virtual gfx::Rect GetFindBarBoundingBox() const; - - // Returns true if the specified point(BrowserView coordinates) is in - // in the window caption area of the browser window. - virtual bool IsPositionInWindowCaption(const gfx::Point& point); - - // Tests to see if the specified |point| (in nonclient view's coordinates) - // is within the views managed by the laymanager. Returns one of - // HitTestCompat enum defined in views/window/hit_test.h. - // See also ClientView::NonClientHitTest. - virtual int NonClientHitTest(const gfx::Point& point); - - // views::LayoutManager overrides: + ////////////////////////////////////////////////////////////////////////////// + // Overridden from LayoutManager. virtual void Installed(views::View* host); virtual void Uninstalled(views::View* host); virtual void ViewAdded(views::View* host, views::View* view); @@ -38,6 +23,13 @@ class BrowserViewLayout : public views::LayoutManager { virtual void Layout(views::View* host); virtual gfx::Size GetPreferredSize(views::View* host); + ////////////////////////////////////////////////////////////////////////////// + // Overridden from BrowserLayoutManager. + virtual gfx::Size GetMinimumSize(); + virtual gfx::Rect GetFindBarBoundingBox() const; + virtual bool IsPositionInWindowCaption(const gfx::Point& point); + virtual int NonClientHitTest(const gfx::Point& point); + protected: Browser* browser() { return browser_view_->browser(); @@ -82,8 +74,7 @@ class BrowserViewLayout : public views::LayoutManager { // The distance the FindBar is from the top of the window, in pixels. int find_bar_y_; - DISALLOW_COPY_AND_ASSIGN(BrowserViewLayout); + DISALLOW_COPY_AND_ASSIGN(ChromeBrowserViewLayoutManager); }; -#endif // CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_H_ - +#endif // CHROME_BROWSER_VIEWS_FRAME_CHROME_BROWSER_VIEW_LAYOUT_MANAGER_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index d6146c8..a85e57d 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -259,8 +259,8 @@ 'browser/chromeos/browser_extenders.cc', 'browser/chromeos/browser_status_area_view.cc', 'browser/chromeos/browser_status_area_view.h', - 'browser/chromeos/browser_view.cc', - 'browser/chromeos/browser_view.h', + 'browser/chromeos/chromeos_browser_view.cc', + 'browser/chromeos/chromeos_browser_view.h', 'browser/chromeos/clock_menu_button.cc', 'browser/chromeos/clock_menu_button.h', 'browser/chromeos/compact_location_bar_host.cc', @@ -1817,8 +1817,8 @@ 'browser/views/first_run_view.h', 'browser/views/first_run_view_base.cc', 'browser/views/first_run_view_base.h', - 'browser/views/frame/browser_view_layout.cc', - 'browser/views/frame/browser_view_layout.h', + 'browser/views/frame/chrome_browser_view_layout_manager.cc', + 'browser/views/frame/chrome_browser_view_layout_manager.h', 'browser/views/frame/browser_extender.cc', 'browser/views/frame/browser_extender.h', 'browser/views/frame/browser_frame.h', @@ -1826,6 +1826,7 @@ 'browser/views/frame/browser_frame_gtk.h', 'browser/views/frame/browser_frame_win.cc', 'browser/views/frame/browser_frame_win.h', + 'browser/views/frame/browser_view_layout_manager.h', 'browser/views/frame/browser_non_client_frame_view.h', 'browser/views/frame/browser_root_view.cc', 'browser/views/frame/browser_root_view.h', @@ -2392,10 +2393,11 @@ ['include', '^browser/views/theme_install_bubble_view.h'], ['include', '^browser/views/toolbar_star_toggle.h'], ['include', '^browser/views/toolbar_star_toggle.cc'], - ['include', '^browser/views/frame/browser_view_layout.cc'], - ['include', '^browser/views/frame/browser_view_layout.h'], + ['include', '^browser/views/frame/chrome_browser_view_layout_manager.cc'], + ['include', '^browser/views/frame/chrome_browser_view_layout_manager.h'], ['include', '^browser/views/frame/browser_extender.cc'], ['include', '^browser/views/frame/browser_extender.h'], + ['include', '^browser/views/frame/browser_view_layout_manager.h'], ['include', '^browser/views/frame/browser_view.cc'], ['include', '^browser/views/frame/browser_view.h'], ['include', '^browser/views/frame/browser_frame_gtk.cc'], |