summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-18 02:39:20 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-18 02:39:20 +0000
commit787f0187ad19e4bf401faf39eef4ca19ae896a28 (patch)
treee710a7ea04fc5945e5b9a666a9d43c4dc1175258 /chrome
parentf38443efabeec09c6c2e178f3c23c4ea1bb5e7cb (diff)
downloadchromium_src-787f0187ad19e4bf401faf39eef4ca19ae896a28.zip
chromium_src-787f0187ad19e4bf401faf39eef4ca19ae896a28.tar.gz
chromium_src-787f0187ad19e4bf401faf39eef4ca19ae896a28.tar.bz2
Refactoring to reduce chromeos dependency in chrome.
* renamed BrowserLayoutManager to more explicit, BrowserViewLayoutManager. * Added factory method to create chromeos specific tab/tabstrip and layoutmanagers. * Introduced ChromeosBrowserView and chromeos specific tab/tabstrip and layoutmanager, and moved chromeos specifi code into them. BUG=none TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=36452 Review URL: http://codereview.chromium.org/543095 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36485 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/chromeos_browser_view.cc144
-rw-r--r--chrome/browser/views/frame/browser_layout_manager.cc403
-rw-r--r--chrome/browser/views/frame/browser_view.cc31
-rw-r--r--chrome/browser/views/frame/browser_view.h17
-rw-r--r--chrome/browser/views/frame/browser_view_layout_manager.h (renamed from chrome/browser/views/frame/browser_layout_manager.h)13
-rw-r--r--chrome/browser/views/frame/chrome_browser_view_layout_manager.cc368
-rw-r--r--chrome/browser/views/frame/chrome_browser_view_layout_manager.h78
-rw-r--r--chrome/browser/views/tabs/tab.cc31
-rw-r--r--chrome/browser/views/tabs/tab.h7
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc6
-rw-r--r--chrome/browser/views/tabs/tab_strip.h6
-rwxr-xr-xchrome/chrome_browser.gypi11
12 files changed, 642 insertions, 473 deletions
diff --git a/chrome/browser/chromeos/chromeos_browser_view.cc b/chrome/browser/chromeos/chromeos_browser_view.cc
new file mode 100644
index 0000000..57455a6
--- /dev/null
+++ b/chrome/browser/chromeos/chromeos_browser_view.cc
@@ -0,0 +1,144 @@
+// 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.
+
+#include "chrome/browser/views/frame/browser_extender.h"
+#include "chrome/browser/views/frame/browser_view.h"
+#include "chrome/browser/views/frame/chrome_browser_view_layout_manager.h"
+#include "chrome/browser/views/tabs/tab.h"
+#include "chrome/browser/views/tabs/tab_strip.h"
+
+namespace {
+
+// A chromeos implementation of Tab that shows the compact location bar.
+class ChromeosTab : public Tab {
+ public:
+ ChromeosTab(TabStrip* tab_strip, const BrowserView* browser_view)
+ : Tab(tab_strip),
+ browser_view_(browser_view) {
+ }
+ virtual ~ChromeosTab() {}
+
+ // Overridden from views::View.
+ virtual void OnMouseEntered(const views::MouseEvent& event) {
+ TabRenderer::OnMouseEntered(event);
+ browser_view_->browser_extender()->OnMouseEnteredToTab(this);
+ }
+
+ virtual void OnMouseMoved(const views::MouseEvent& event) {
+ browser_view_->browser_extender()->OnMouseMovedOnTab(this);
+ }
+
+ virtual void OnMouseExited(const views::MouseEvent& event) {
+ TabRenderer::OnMouseExited(event);
+ browser_view_->browser_extender()->OnMouseExitedFromTab(this);
+ }
+
+ private:
+ const BrowserView* browser_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeosTab);
+};
+
+// A Tabstrip that uses ChromeosTab as a Tab implementation.
+class ChromeosTabStrip : public TabStrip {
+ public:
+ ChromeosTabStrip(TabStripModel* model, const BrowserView* browser_view)
+ : TabStrip(model), browser_view_(browser_view) {
+ }
+ virtual ~ChromeosTabStrip() {}
+
+ protected:
+ // Overridden from TabStrip.
+ virtual Tab* CreateTab() {
+ return new ChromeosTab(this, browser_view_);
+ }
+
+ private:
+ const BrowserView* browser_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeosTabStrip);
+};
+
+// LayoutManager for ChromeosBrowserView, which layouts extra components such as
+// main menu, stataus are via BrowserExtender.
+class ChromeosBrowserViewLayoutManager : public ChromeBrowserViewLayoutManager {
+ public:
+ ChromeosBrowserViewLayoutManager() : ChromeBrowserViewLayoutManager() {}
+ virtual ~ChromeosBrowserViewLayoutManager() {}
+
+ // Overriden from ChromeBrowserViewLayoutManager.
+ virtual int LayoutTabStrip() {
+ gfx::Rect layout_bounds =
+ browser_view_->frame()->GetBoundsForTabStrip(tabstrip_);
+ gfx::Rect toolbar_bounds = browser_view_->GetToolbarBounds();
+ tabstrip_->SetBackgroundOffset(
+ gfx::Point(layout_bounds.x() - toolbar_bounds.x(), layout_bounds.y()));
+
+ gfx::Point tabstrip_origin = layout_bounds.origin();
+ views::View::ConvertPointToView(browser_view_->GetParent(), browser_view_,
+ &tabstrip_origin);
+ layout_bounds.set_origin(tabstrip_origin);
+
+ // Layout extra components.
+ int bottom = 0;
+ gfx::Rect tabstrip_bounds;
+ browser_view_->browser_extender()->Layout(
+ layout_bounds, &tabstrip_bounds, &bottom);
+ tabstrip_->SetVisible(browser_view_->IsTabStripVisible());
+ tabstrip_->SetBounds(tabstrip_bounds);
+ return bottom;
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ChromeosBrowserViewLayoutManager);
+};
+
+// ChromeosBrowserView implements Chromeos specific behavior of
+// BrowserView.
+class ChromeosBrowserView : public BrowserView {
+ public:
+ explicit ChromeosBrowserView(Browser* browser)
+ : BrowserView(browser) {
+ }
+ virtual ~ChromeosBrowserView() {}
+
+ // Overriden from BrowserView.
+ virtual bool IsToolbarVisible() const {
+ if (browser_extender()->ShouldForceHideToolbar())
+ return false;
+ return BrowserView::IsToolbarVisible();
+ }
+
+ virtual void SetFocusToLocationBar() {
+ if (!browser_extender()->SetFocusToCompactNavigationBar()) {
+ BrowserView::SetFocusToLocationBar();
+ }
+ }
+
+ virtual void UpdateTitleBar() {
+ BrowserView::UpdateTitleBar();
+ browser_extender()->UpdateTitleBar();
+ }
+
+ virtual BrowserViewLayoutManager* CreateLayoutManager() const {
+ return new ChromeosBrowserViewLayoutManager();
+ }
+
+ virtual TabStrip* CreateTabStrip(TabStripModel* tab_strip_model) const {
+ return new ChromeosTabStrip(tab_strip_model, this);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ChromeosBrowserView);
+};
+
+} // namespace
+
+// static
+BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
+ // Create a browser view for chromeos.
+ BrowserView* view = new ChromeosBrowserView(browser);
+ BrowserFrame::Create(view, browser->profile());
+ return view;
+}
diff --git a/chrome/browser/views/frame/browser_layout_manager.cc b/chrome/browser/views/frame/browser_layout_manager.cc
deleted file mode 100644
index cdc7ca3..0000000
--- a/chrome/browser/views/frame/browser_layout_manager.cc
+++ /dev/null
@@ -1,403 +0,0 @@
-// 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.
-
-#include "chrome/browser/views/frame/browser_layout_manager.h"
-
-#include "app/gfx/scrollbar_size.h"
-#include "chrome/browser/find_bar.h"
-#include "chrome/browser/find_bar_controller.h"
-#include "chrome/browser/view_ids.h"
-#include "chrome/browser/views/bookmark_bar_view.h"
-#include "chrome/browser/views/download_shelf_view.h"
-#include "chrome/browser/views/extensions/extension_shelf.h"
-#include "chrome/browser/views/frame/browser_extender.h"
-#include "chrome/browser/views/frame/browser_frame.h"
-#include "chrome/browser/views/frame/browser_view.h"
-#include "chrome/browser/views/tabs/tab_strip.h"
-#include "chrome/browser/views/toolbar_view.h"
-
-namespace {
-
-// The vertical overlap between the TabStrip and the Toolbar.
-static const int kToolbarTabStripVerticalOverlap = 3;
-// An offset distance between certain toolbars and the toolbar that preceded
-// them in layout.
-static const int kSeparationLineHeight = 1;
-
-// The layout manager used in chrome browser.
-class ChromeLayoutManager : public BrowserLayoutManager {
- public:
- ChromeLayoutManager()
- : tabstrip_(NULL),
- toolbar_(NULL),
- contents_split_(NULL),
- contents_container_(NULL),
- infobar_container_(NULL),
- download_shelf_(NULL),
- extension_shelf_(NULL),
- active_bookmark_bar_(NULL),
- browser_view_(NULL),
- find_bar_y_(0) {
- }
-
- //////////////////////////////////////////////////////////////////////////////
- // Overridden from LayoutManager.
-
- virtual void 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);
- }
-
- virtual void Uninstalled(views::View* host) {}
-
- virtual void 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;
- }
- }
-
- virtual void ViewRemoved(views::View* host, views::View* view) {
- switch (view->GetID()) {
- case VIEW_ID_BOOKMARK_BAR:
- active_bookmark_bar_ = NULL;
- break;
- }
- }
-
- // Lay out the children of |host| according to implementation-specific
- // heuristics. The graphics used during painting is provided to allow for
- // string sizing.
- virtual void 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.
- virtual gfx::Size GetPreferredSize(views::View* host) {
- return gfx::Size();
- }
-
- //////////////////////////////////////////////////////////////////////////////
- // Overridden from BrowserLayoutManager.
-
- virtual gfx::Size GetMinimumSize() {
- // TODO(noname): In theory the tabstrip width should probably be
- // (OTR + tabstrip + caption buttons) width.
- gfx::Size tabstrip_size(
- browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ?
- tabstrip_->GetMinimumSize() : gfx::Size());
- gfx::Size toolbar_size(
- (browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
- browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ?
- toolbar_->GetMinimumSize() : gfx::Size());
- if (tabstrip_size.height() && toolbar_size.height())
- toolbar_size.Enlarge(0, -kToolbarTabStripVerticalOverlap);
- gfx::Size bookmark_bar_size;
- if (active_bookmark_bar_ &&
- browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) {
- bookmark_bar_size = active_bookmark_bar_->GetMinimumSize();
- bookmark_bar_size.Enlarge(
- 0,
- -kSeparationLineHeight -
- active_bookmark_bar_->GetToolbarOverlap(true));
- }
- gfx::Size contents_size(contents_split_->GetMinimumSize());
-
- int min_height = tabstrip_size.height() + toolbar_size.height() +
- bookmark_bar_size.height() + contents_size.height();
- int widths[] = { tabstrip_size.width(), toolbar_size.width(),
- bookmark_bar_size.width(), contents_size.width() };
- int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]);
- return gfx::Size(min_width, min_height);
- }
-
- virtual gfx::Rect 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
- // scrollbar. This is not quite so straightforward as positioning
- // based on the TabContentsContainer since the BookmarkBarView may
- // be visible but not persistent (in the New Tab case) and we
- // position the Find Bar over the top of it in that case since the
- // BookmarkBarView is not _visually_ connected to the Toolbar.
-
- // First determine the bounding box of the content area in Widget
- // coordinates.
- gfx::Rect bounding_box(contents_container_->bounds());
-
- gfx::Point topleft;
- views::View::ConvertPointToWidget(contents_container_, &topleft);
- bounding_box.set_origin(topleft);
-
- // Adjust the position and size of the bounding box by the find bar offset
- // calculated during the last Layout.
- int height_delta = find_bar_y_ - bounding_box.y();
- bounding_box.set_y(find_bar_y_);
- bounding_box.set_height(std::max(0, bounding_box.height() + height_delta));
-
- // Finally decrease the width of the bounding box by the width of
- // the vertical scroll bar.
- int scrollbar_width = gfx::scrollbar_size();
- bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width));
- if (browser_view_->UILayoutIsRightToLeft())
- bounding_box.set_x(bounding_box.x() + scrollbar_width);
-
- return bounding_box;
- }
-
- private:
- Browser* browser() {
- return browser_view_->browser();
- }
-
- // Layout the TabStrip, returns the coordinate of the bottom of the TabStrip,
- // for laying out subsequent controls.
- int LayoutTabStrip() {
- gfx::Rect layout_bounds =
- browser_view_->frame()->GetBoundsForTabStrip(tabstrip_);
- gfx::Rect toolbar_bounds = browser_view_->GetToolbarBounds();
- tabstrip_->SetBackgroundOffset(
- gfx::Point(layout_bounds.x() - toolbar_bounds.x(), layout_bounds.y()));
-
- gfx::Point tabstrip_origin = layout_bounds.origin();
- views::View::ConvertPointToView(browser_view_->GetParent(), browser_view_,
- &tabstrip_origin);
- layout_bounds.set_origin(tabstrip_origin);
-
- // Layout extra components.
- int bottom = 0;
- gfx::Rect tabstrip_bounds;
- browser_view_->browser_extender()->Layout(
- layout_bounds, &tabstrip_bounds, &bottom);
- tabstrip_->SetVisible(browser_view_->IsTabStripVisible());
- tabstrip_->SetBounds(tabstrip_bounds);
- return bottom;
- }
-
- // Layout the following controls, starting at |top|, returns the coordinate
- // of the bottom of the control, for laying out the next control.
- int LayoutToolbar(int top) {
- int browser_view_width = browser_view_->width();
- bool visible = browser_view_->IsToolbarVisible();
- toolbar_->location_bar()->SetFocusable(visible);
- int y = top -
- ((visible && browser_view_->IsTabStripVisible())
- ? kToolbarTabStripVerticalOverlap : 0);
- int height = visible ? toolbar_->GetPreferredSize().height() : 0;
- toolbar_->SetVisible(visible);
- toolbar_->SetBounds(0, y, browser_view_width, height);
- return y + height;
- }
-
- int 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
- // need to show any Info bar _above_ the Bookmark bar, since the
- // Bookmark bar is styled to look like it's part of the page.
- if (active_bookmark_bar_->IsDetached())
- return LayoutTopBar(LayoutInfoBar(top));
- // Otherwise, Bookmark bar first, Info bar second.
- top = LayoutTopBar(top);
- }
- find_bar_y_ = top + browser_view_->y() - 1;
- return LayoutInfoBar(top);
- }
-
- int 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
- // bookmark items and extension toolstrips to fit in the single
- // bar, some compromises are made as follows: 1. The bookmark bar
- // is shrunk till it reaches the minimum width. 2. After reaching
- // the minimum width, the bookmark bar width is kept fixed - the
- // extension shelf bar width is reduced.
- DCHECK(active_bookmark_bar_);
- int y = top, x = 0;
- if (!browser_view_->IsBookmarkBarVisible()) {
- active_bookmark_bar_->SetVisible(false);
- active_bookmark_bar_->SetBounds(0, y, browser_view_->width(), 0);
- if (extension_shelf_->IsOnTop())
- extension_shelf_->SetVisible(false);
- return y;
- }
-
- int bookmark_bar_height = active_bookmark_bar_->GetPreferredSize().height();
- y -= kSeparationLineHeight + (
- active_bookmark_bar_->IsDetached() ?
- 0 : active_bookmark_bar_->GetToolbarOverlap(false));
-
- if (extension_shelf_->IsOnTop()) {
- if (!active_bookmark_bar_->IsDetached()) {
- int extension_shelf_width =
- extension_shelf_->GetPreferredSize().width();
- int bookmark_bar_given_width =
- browser_view_->width() - extension_shelf_width;
- int minimum_allowed_bookmark_bar_width =
- active_bookmark_bar_->GetMinimumSize().width();
- if (bookmark_bar_given_width < minimum_allowed_bookmark_bar_width) {
- // The bookmark bar cannot compromise on its width any more. The
- // extension shelf needs to shrink now.
- extension_shelf_width =
- browser_view_->width() - minimum_allowed_bookmark_bar_width;
- }
- extension_shelf_->SetVisible(true);
- extension_shelf_->SetBounds(x, y, extension_shelf_width,
- bookmark_bar_height);
- x += extension_shelf_width;
- } else {
- // TODO(sidchat): For detached style bookmark bar, set the extensions
- // shelf in a better position. Issue = 20741.
- extension_shelf_->SetVisible(false);
- }
- }
-
- active_bookmark_bar_->SetVisible(true);
- active_bookmark_bar_->SetBounds(x, y,
- browser_view_->width() - x,
- bookmark_bar_height);
- return y + bookmark_bar_height;
- }
-
- int LayoutInfoBar(int top) {
- bool visible = browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR);
- int height = visible ? infobar_container_->GetPreferredSize().height() : 0;
- infobar_container_->SetVisible(visible);
- infobar_container_->SetBounds(0, top, browser_view_->width(), height);
- return top + height;
- }
-
- // Layout the TabContents container, between the coordinates |top| and
- // |bottom|.
- void LayoutTabContents(int top, int bottom) {
- contents_split_->SetBounds(0, top, browser_view_->width(), bottom - top);
- }
-
- int 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.
- //
- // TODO(Oshima): confirm this comment.
- int bottom = browser_view_->height();
- if (extension_shelf_) {
- if (extension_shelf_->IsDetached()) {
- bottom = LayoutDownloadShelf(bottom);
- return LayoutExtensionShelf(bottom);
- }
- // Otherwise, Extension shelf first, Download shelf second.
- bottom = LayoutExtensionShelf(bottom);
- }
- return LayoutDownloadShelf(bottom);
- }
-
- // Layout the Download Shelf, returns the coordinate of the top of the
- // control, for laying out the previous control.
- int 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() ||
- (download_shelf_ && download_shelf_->IsClosing())) {
- bool visible = browser()->SupportsWindowFeature(
- Browser::FEATURE_DOWNLOADSHELF);
- DCHECK(download_shelf_);
- int height = visible ? download_shelf_->GetPreferredSize().height() : 0;
- download_shelf_->SetVisible(visible);
- download_shelf_->SetBounds(0, bottom - height,
- browser_view_->width(), height);
- download_shelf_->Layout();
- bottom -= height;
- }
- return bottom;
- }
-
- // Layout the Extension Shelf, returns the coordinate of the top of the
- // control, for laying out the previous control.
- int LayoutExtensionShelf(int bottom) {
- if (!extension_shelf_ || extension_shelf_->IsOnTop())
- return bottom;
-
- if (extension_shelf_) {
- bool visible = browser()->SupportsWindowFeature(
- Browser::FEATURE_EXTENSIONSHELF);
- int height =
- visible ? extension_shelf_->GetPreferredSize().height() : 0;
- extension_shelf_->SetVisible(visible);
- extension_shelf_->SetBounds(0, bottom - height,
- browser_view_->width(), height);
- extension_shelf_->Layout();
- bottom -= height;
- }
- return bottom;
- }
-
- // Child views that the layout manager manages.
- TabStrip* tabstrip_;
- ToolbarView* toolbar_;
- views::View* contents_split_;
- views::View* contents_container_;
- views::View* infobar_container_;
- DownloadShelfView* download_shelf_;
- ExtensionShelf* extension_shelf_;
- BookmarkBarView* active_bookmark_bar_;
-
- BrowserView* browser_view_;
-
- // The distance the FindBar is from the top of the window, in pixels.
- int find_bar_y_;
-
- DISALLOW_COPY_AND_ASSIGN(ChromeLayoutManager);
-};
-
-} // namespace
-
-// static
-BrowserLayoutManager* BrowserLayoutManager::CreateBrowserLayoutManager() {
- return new ChromeLayoutManager();
-}
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index be8a488..4110fd0b 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -37,9 +37,9 @@
#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/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/frame/browser_layout_manager.h"
#include "chrome/browser/views/fullscreen_exit_bubble.h"
#include "chrome/browser/views/infobars/infobar_container.h"
#include "chrome/browser/views/status_bubble_views.h"
@@ -526,7 +526,7 @@ bool BrowserView::ShouldFindBarBlendWithBookmarksBar() const {
}
gfx::Rect BrowserView::GetFindBarBoundingBox() const {
- return GetBrowserLayoutManager()->GetFindBarBoundingBox();
+ return GetBrowserViewLayoutManager()->GetFindBarBoundingBox();
}
int BrowserView::GetTabStripHeight() const {
@@ -780,7 +780,6 @@ void BrowserView::UpdateTitleBar() {
frame_->GetWindow()->UpdateWindowTitle();
if (ShouldShowWindowIcon() && !loading_animation_timer_.IsRunning())
frame_->GetWindow()->UpdateWindowIcon();
- browser_extender_->UpdateTitleBar();
}
void BrowserView::ShelfVisibilityChanged() {
@@ -857,9 +856,7 @@ LocationBar* BrowserView::GetLocationBar() const {
void BrowserView::SetFocusToLocationBar() {
LocationBarView* location_bar = toolbar_->location_bar();
- if (browser_extender_->SetFocusToCompactNavigationBar()) {
- // Compact navigation bar got focus.
- } else if (location_bar->IsFocusable()) {
+ if (location_bar->IsFocusable()) {
// Location bar got focus.
location_bar->FocusLocation();
} else {
@@ -910,8 +907,6 @@ bool BrowserView::IsBookmarkBarVisible() const {
}
bool BrowserView::IsToolbarVisible() const {
- if (browser_extender_->ShouldForceHideToolbar())
- return false;
return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR);
}
@@ -1589,7 +1584,7 @@ int BrowserView::NonClientHitTest(const gfx::Point& point) {
}
gfx::Size BrowserView::GetMinimumSize() {
- return GetBrowserLayoutManager()->GetMinimumSize();
+ return GetBrowserViewLayoutManager()->GetMinimumSize();
}
///////////////////////////////////////////////////////////////////////////////
@@ -1642,11 +1637,19 @@ void BrowserView::SetAccessibleName(const std::wstring& name) {
accessible_name_ = name;
}
+views::LayoutManager* BrowserView::CreateLayoutManager() const {
+ return new ChromeBrowserViewLayoutManager();
+}
+
+TabStrip* BrowserView::CreateTabStrip(TabStripModel* model) const {
+ return new TabStrip(model);
+}
+
///////////////////////////////////////////////////////////////////////////////
// BrowserView, private:
void BrowserView::Init() {
- SetLayoutManager(BrowserLayoutManager::CreateBrowserLayoutManager());
+ SetLayoutManager(CreateLayoutManager());
// Stow a pointer to this object onto the window handle so that we can get
// at it later when all we have is a native view.
#if defined(OS_WIN)
@@ -1666,7 +1669,7 @@ void BrowserView::Init() {
LoadAccelerators();
SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME));
- tabstrip_ = new TabStrip(browser_->tabstrip_model());
+ tabstrip_ = CreateTabStrip(browser_->tabstrip_model());
tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP));
AddChildView(tabstrip_);
frame_->TabStripCreated(tabstrip_);
@@ -1738,8 +1741,8 @@ void BrowserView::InitSystemMenu() {
}
#endif
-BrowserLayoutManager* BrowserView::GetBrowserLayoutManager() const {
- return static_cast<BrowserLayoutManager*>(GetLayoutManager());
+BrowserViewLayoutManager* BrowserView::GetBrowserViewLayoutManager() const {
+ return static_cast<BrowserViewLayoutManager*>(GetLayoutManager());
}
void BrowserView::LayoutStatusBubble(int top) {
@@ -2132,6 +2135,7 @@ void BrowserView::InitClass() {
}
}
+#if !defined(OS_CHROMEOS)
// static
BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
// Create the view and the frame. The frame will attach itself via the view
@@ -2140,6 +2144,7 @@ BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
BrowserFrame::Create(view, browser->profile());
return view;
}
+#endif
// static
FindBar* BrowserWindow::CreateFindBar(Browser* browser) {
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index c6dc2ce..e786228 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 BrowserLayoutManager;
+class BrowserViewLayoutManager;
class DownloadShelfView;
class EncodingMenuModel;
class ExtensionShelf;
@@ -367,16 +367,25 @@ class BrowserView : public BrowserWindow,
views::View* child);
virtual void ChildPreferredSizeChanged(View* child);
+ // Factory Methods.
+ // Returns a new LayoutManager for this browser view. A subclass may
+ // override to implemnet different layout pocily.
+ virtual views::LayoutManager* CreateLayoutManager() const;
+
+ // 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) const;
+
private:
// Browser window related initializations.
- void Init();
+ virtual void Init();
#if defined(OS_WIN)
// Creates the system menu.
void InitSystemMenu();
#endif
- // Returns the BrowserLayoutManager.
- BrowserLayoutManager* GetBrowserLayoutManager() 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_layout_manager.h b/chrome/browser/views/frame/browser_view_layout_manager.h
index ea73f57..65ecfc6 100644
--- a/chrome/browser/views/frame/browser_layout_manager.h
+++ b/chrome/browser/views/frame/browser_view_layout_manager.h
@@ -2,26 +2,21 @@
// 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_LAYOUT_MANAGER_H_
-#define CHROME_BROWSER_VIEWS_FRAME_BROWSER_LAYOUT_MANAGER_H_
+#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"
-class BrowserView;
-
// An extended LayoutManager to layout components in
// BrowserView.
-class BrowserLayoutManager : public views::LayoutManager {
+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;
-
- static BrowserLayoutManager* CreateBrowserLayoutManager();
};
-#endif // CHROME_BROWSER_VIEWS_FRAME_BROWSER_LAYOUT_MANAGER_H_
-
+#endif // CHROME_BROWSER_VIEWS_FRAME_BROWSER_VIEW_LAYOUT_MANAGER_H_
diff --git a/chrome/browser/views/frame/chrome_browser_view_layout_manager.cc b/chrome/browser/views/frame/chrome_browser_view_layout_manager.cc
new file mode 100644
index 0000000..3c217f5
--- /dev/null
+++ b/chrome/browser/views/frame/chrome_browser_view_layout_manager.cc
@@ -0,0 +1,368 @@
+// 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.
+
+#include "chrome/browser/views/frame/chrome_browser_view_layout_manager.h"
+
+#include "app/gfx/scrollbar_size.h"
+#include "chrome/browser/find_bar.h"
+#include "chrome/browser/find_bar_controller.h"
+#include "chrome/browser/view_ids.h"
+#include "chrome/browser/views/bookmark_bar_view.h"
+#include "chrome/browser/views/download_shelf_view.h"
+#include "chrome/browser/views/extensions/extension_shelf.h"
+#include "chrome/browser/views/frame/browser_extender.h"
+#include "chrome/browser/views/frame/browser_frame.h"
+#include "chrome/browser/views/frame/browser_view.h"
+#include "chrome/browser/views/tabs/tab_strip.h"
+#include "chrome/browser/views/toolbar_view.h"
+
+// The vertical overlap between the TabStrip and the Toolbar.
+static const int kToolbarTabStripVerticalOverlap = 3;
+// An offset distance between certain toolbars and the toolbar that preceded
+// them in layout.
+static const int kSeparationLineHeight = 1;
+
+ChromeBrowserViewLayoutManager::ChromeBrowserViewLayoutManager()
+ : tabstrip_(NULL),
+ toolbar_(NULL),
+ contents_split_(NULL),
+ contents_container_(NULL),
+ infobar_container_(NULL),
+ download_shelf_(NULL),
+ extension_shelf_(NULL),
+ active_bookmark_bar_(NULL),
+ browser_view_(NULL),
+ find_bar_y_(0) {
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// 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(
+ browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ?
+ tabstrip_->GetMinimumSize() : gfx::Size());
+ gfx::Size toolbar_size(
+ (browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
+ browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ?
+ toolbar_->GetMinimumSize() : gfx::Size());
+ if (tabstrip_size.height() && toolbar_size.height())
+ toolbar_size.Enlarge(0, -kToolbarTabStripVerticalOverlap);
+ gfx::Size bookmark_bar_size;
+ if (active_bookmark_bar_ &&
+ browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) {
+ bookmark_bar_size = active_bookmark_bar_->GetMinimumSize();
+ bookmark_bar_size.Enlarge(
+ 0,
+ -kSeparationLineHeight -
+ active_bookmark_bar_->GetToolbarOverlap(true));
+ }
+ gfx::Size contents_size(contents_split_->GetMinimumSize());
+
+ int min_height = tabstrip_size.height() + toolbar_size.height() +
+ bookmark_bar_size.height() + contents_size.height();
+ int widths[] = { tabstrip_size.width(), toolbar_size.width(),
+ bookmark_bar_size.width(), contents_size.width() };
+ int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]);
+ return gfx::Size(min_width, min_height);
+}
+
+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
+ // scrollbar. This is not quite so straightforward as positioning
+ // based on the TabContentsContainer since the BookmarkBarView may
+ // be visible but not persistent (in the New Tab case) and we
+ // position the Find Bar over the top of it in that case since the
+ // BookmarkBarView is not _visually_ connected to the Toolbar.
+
+ // First determine the bounding box of the content area in Widget
+ // coordinates.
+ gfx::Rect bounding_box(contents_container_->bounds());
+
+ gfx::Point topleft;
+ views::View::ConvertPointToWidget(contents_container_, &topleft);
+ bounding_box.set_origin(topleft);
+
+ // Adjust the position and size of the bounding box by the find bar offset
+ // calculated during the last Layout.
+ int height_delta = find_bar_y_ - bounding_box.y();
+ bounding_box.set_y(find_bar_y_);
+ bounding_box.set_height(std::max(0, bounding_box.height() + height_delta));
+
+ // Finally decrease the width of the bounding box by the width of
+ // the vertical scroll bar.
+ int scrollbar_width = gfx::scrollbar_size();
+ bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width));
+ if (browser_view_->UILayoutIsRightToLeft())
+ bounding_box.set_x(bounding_box.x() + scrollbar_width);
+
+ return bounding_box;
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// Overridden from ChromeBrowserViewLayoutManager, private:
+
+int ChromeBrowserViewLayoutManager::LayoutTabStrip() {
+ if (!browser_view_->IsTabStripVisible()) {
+ tabstrip_->SetVisible(false);
+ tabstrip_->SetBounds(0, 0, 0, 0);
+ return 0;
+ } else {
+ gfx::Rect layout_bounds =
+ browser_view_->frame()->GetBoundsForTabStrip(tabstrip_);
+ gfx::Rect toolbar_bounds = browser_view_->GetToolbarBounds();
+ tabstrip_->SetBackgroundOffset(
+ gfx::Point(layout_bounds.x() - toolbar_bounds.x(), layout_bounds.y()));
+
+ gfx::Point tabstrip_origin = layout_bounds.origin();
+ views::View::ConvertPointToView(browser_view_->GetParent(), browser_view_,
+ &tabstrip_origin);
+ layout_bounds.set_origin(tabstrip_origin);
+ tabstrip_->SetVisible(true);
+ tabstrip_->SetBounds(layout_bounds);
+ return layout_bounds.bottom();
+ }
+}
+
+// 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);
+ int y = top -
+ ((visible && browser_view_->IsTabStripVisible())
+ ? kToolbarTabStripVerticalOverlap : 0);
+ int height = visible ? toolbar_->GetPreferredSize().height() : 0;
+ toolbar_->SetVisible(visible);
+ toolbar_->SetBounds(0, y, browser_view_width, height);
+ return y + height;
+}
+
+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
+ // need to show any Info bar _above_ the Bookmark bar, since the
+ // Bookmark bar is styled to look like it's part of the page.
+ if (active_bookmark_bar_->IsDetached())
+ return LayoutTopBar(LayoutInfoBar(top));
+ // Otherwise, Bookmark bar first, Info bar second.
+ top = LayoutTopBar(top);
+ }
+ find_bar_y_ = top + browser_view_->y() - 1;
+ return LayoutInfoBar(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
+ // bookmark items and extension toolstrips to fit in the single
+ // bar, some compromises are made as follows: 1. The bookmark bar
+ // is shrunk till it reaches the minimum width. 2. After reaching
+ // the minimum width, the bookmark bar width is kept fixed - the
+ // extension shelf bar width is reduced.
+ DCHECK(active_bookmark_bar_);
+ int y = top, x = 0;
+ if (!browser_view_->IsBookmarkBarVisible()) {
+ active_bookmark_bar_->SetVisible(false);
+ active_bookmark_bar_->SetBounds(0, y, browser_view_->width(), 0);
+ if (extension_shelf_->IsOnTop())
+ extension_shelf_->SetVisible(false);
+ return y;
+ }
+
+ int bookmark_bar_height = active_bookmark_bar_->GetPreferredSize().height();
+ y -= kSeparationLineHeight + (
+ active_bookmark_bar_->IsDetached() ?
+ 0 : active_bookmark_bar_->GetToolbarOverlap(false));
+
+ if (extension_shelf_->IsOnTop()) {
+ if (!active_bookmark_bar_->IsDetached()) {
+ int extension_shelf_width =
+ extension_shelf_->GetPreferredSize().width();
+ int bookmark_bar_given_width =
+ browser_view_->width() - extension_shelf_width;
+ int minimum_allowed_bookmark_bar_width =
+ active_bookmark_bar_->GetMinimumSize().width();
+ if (bookmark_bar_given_width < minimum_allowed_bookmark_bar_width) {
+ // The bookmark bar cannot compromise on its width any more. The
+ // extension shelf needs to shrink now.
+ extension_shelf_width =
+ browser_view_->width() - minimum_allowed_bookmark_bar_width;
+ }
+ extension_shelf_->SetVisible(true);
+ extension_shelf_->SetBounds(x, y, extension_shelf_width,
+ bookmark_bar_height);
+ x += extension_shelf_width;
+ } else {
+ // TODO(sidchat): For detached style bookmark bar, set the extensions
+ // shelf in a better position. Issue = 20741.
+ extension_shelf_->SetVisible(false);
+ }
+ }
+
+ active_bookmark_bar_->SetVisible(true);
+ active_bookmark_bar_->SetBounds(x, y,
+ browser_view_->width() - x,
+ bookmark_bar_height);
+ return y + bookmark_bar_height;
+}
+
+int ChromeBrowserViewLayoutManager::LayoutInfoBar(int top) {
+ bool visible = browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR);
+ int height = visible ? infobar_container_->GetPreferredSize().height() : 0;
+ infobar_container_->SetVisible(visible);
+ infobar_container_->SetBounds(0, top, browser_view_->width(), height);
+ return top + height;
+}
+
+// Layout the TabContents container, between the coordinates |top| and
+// |bottom|.
+void ChromeBrowserViewLayoutManager::LayoutTabContents(int top, int bottom) {
+ contents_split_->SetBounds(0, top, browser_view_->width(), bottom - top);
+}
+
+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.
+ //
+ // TODO(Oshima): confirm this comment.
+ int bottom = browser_view_->height();
+ if (extension_shelf_) {
+ if (extension_shelf_->IsDetached()) {
+ bottom = LayoutDownloadShelf(bottom);
+ return LayoutExtensionShelf(bottom);
+ }
+ // Otherwise, Extension shelf first, Download shelf second.
+ bottom = LayoutExtensionShelf(bottom);
+ }
+ return LayoutDownloadShelf(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() ||
+ (download_shelf_ && download_shelf_->IsClosing())) {
+ bool visible = browser()->SupportsWindowFeature(
+ Browser::FEATURE_DOWNLOADSHELF);
+ DCHECK(download_shelf_);
+ int height = visible ? download_shelf_->GetPreferredSize().height() : 0;
+ download_shelf_->SetVisible(visible);
+ download_shelf_->SetBounds(0, bottom - height,
+ browser_view_->width(), height);
+ download_shelf_->Layout();
+ bottom -= height;
+ }
+ return 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;
+
+ if (extension_shelf_) {
+ bool visible = browser()->SupportsWindowFeature(
+ Browser::FEATURE_EXTENSIONSHELF);
+ int height =
+ visible ? extension_shelf_->GetPreferredSize().height() : 0;
+ extension_shelf_->SetVisible(visible);
+ extension_shelf_->SetBounds(0, bottom - height,
+ browser_view_->width(), height);
+ extension_shelf_->Layout();
+ bottom -= height;
+ }
+ return bottom;
+}
diff --git a/chrome/browser/views/frame/chrome_browser_view_layout_manager.h b/chrome/browser/views/frame/chrome_browser_view_layout_manager.h
new file mode 100644
index 0000000..9f43b6a
--- /dev/null
+++ b/chrome/browser/views/frame/chrome_browser_view_layout_manager.h
@@ -0,0 +1,78 @@
+// 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_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"
+
+// The layout manager used in chrome browser.
+class ChromeBrowserViewLayoutManager : public BrowserViewLayoutManager {
+ public:
+ ChromeBrowserViewLayoutManager();
+ virtual ~ChromeBrowserViewLayoutManager() {}
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Overridden from LayoutManager.
+ virtual void Installed(views::View* host);
+ virtual void Uninstalled(views::View* host);
+ virtual void ViewAdded(views::View* host, views::View* view);
+ virtual void ViewRemoved(views::View* host, views::View* view);
+ 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;
+
+ protected:
+ Browser* browser() {
+ return browser_view_->browser();
+ }
+
+ // Layout the TabStrip, returns the coordinate of the bottom of the TabStrip,
+ // for laying out subsequent controls.
+ virtual int LayoutTabStrip();
+
+ // Layout the following controls, starting at |top|, returns the coordinate
+ // of the bottom of the control, for laying out the next control.
+ int LayoutToolbar(int top);
+ int LayoutBookmarkAndInfoBars(int top);
+ int LayoutTopBar(int top);
+ int LayoutInfoBar(int top);
+
+ // Layout the TabContents container, between the coordinates |top| and
+ // |bottom|.
+ void LayoutTabContents(int top, int bottom);
+ int LayoutExtensionAndDownloadShelves();
+
+ // Layout the Download Shelf, returns the coordinate of the top of the
+ // control, for laying out the previous control.
+ int LayoutDownloadShelf(int bottom);
+
+ // Layout the Extension Shelf, returns the coordinate of the top of the
+ // control, for laying out the previous control.
+ int LayoutExtensionShelf(int bottom);
+
+ // Child views that the layout manager manages.
+ TabStrip* tabstrip_;
+ ToolbarView* toolbar_;
+ views::View* contents_split_;
+ views::View* contents_container_;
+ views::View* infobar_container_;
+ DownloadShelfView* download_shelf_;
+ ExtensionShelf* extension_shelf_;
+ BookmarkBarView* active_bookmark_bar_;
+
+ BrowserView* browser_view_;
+
+ // The distance the FindBar is from the top of the window, in pixels.
+ int find_bar_y_;
+
+ DISALLOW_COPY_AND_ASSIGN(ChromeBrowserViewLayoutManager);
+};
+
+#endif // CHROME_BROWSER_VIEWS_FRAME_CHROME_BROWSER_VIEW_LAYOUT_MANAGER_H_
diff --git a/chrome/browser/views/tabs/tab.cc b/chrome/browser/views/tabs/tab.cc
index a775734..efebda1 100644
--- a/chrome/browser/views/tabs/tab.cc
+++ b/chrome/browser/views/tabs/tab.cc
@@ -13,7 +13,6 @@
#include "base/compiler_specific.h"
#include "base/gfx/size.h"
#include "chrome/browser/tab_menu_model.h"
-#include "chrome/browser/views/frame/browser_extender.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/tabs/tab_strip.h"
#include "grit/generated_resources.h"
@@ -142,11 +141,6 @@ bool Tab::OnMousePressed(const views::MouseEvent& event) {
bool just_selected = !IsSelected();
if (just_selected) {
delegate_->SelectTab(this);
- // This is a hack to update the compact location bar when the tab
- // is selected. This is just an experiement and will be modified later.
- // TODO(oshima): Improve the BrowserExtender interface if we
- // decided to keep this UI, or remove this otherwise.
- GetBrowserExtender()->OnMouseEnteredToTab(this);
}
delegate_->MaybeStartDrag(this, event);
}
@@ -174,20 +168,6 @@ void Tab::OnMouseReleased(const views::MouseEvent& event, bool canceled) {
delegate_->CloseTab(this);
}
-void Tab::OnMouseEntered(const views::MouseEvent& event) {
- TabRenderer::OnMouseEntered(event);
- GetBrowserExtender()->OnMouseEnteredToTab(this);
-}
-
-void Tab::OnMouseMoved(const views::MouseEvent& event) {
- GetBrowserExtender()->OnMouseMovedOnTab(this);
-}
-
-void Tab::OnMouseExited(const views::MouseEvent& event) {
- TabRenderer::OnMouseExited(event);
- GetBrowserExtender()->OnMouseExitedFromTab(this);
-}
-
bool Tab::GetTooltipText(int x, int y, std::wstring* tooltip) {
std::wstring title = GetTitle();
if (!title.empty()) {
@@ -241,17 +221,6 @@ void Tab::ButtonPressed(views::Button* sender, const views::Event& event) {
///////////////////////////////////////////////////////////////////////////////
// Tab, private:
-BrowserExtender* Tab::GetBrowserExtender() {
- // This is a hack to BrowserExtender from a Tab.
- // TODO(oshima): Fix when the decision on compact location bar is made.
- // Potential candidates are:
- // * Use View ID with a cached reference to BrowserView.
- // * Pass the BrowserView reference to Tabs.
- // * Add GetBrowserView method to Delegate.
- TabStrip* tab_strip = static_cast<TabStrip*>(delegate_);
- return static_cast<BrowserView*>(tab_strip->GetParent())->browser_extender();
-}
-
void Tab::MakePathForTab(gfx::Path* path) const {
DCHECK(path);
diff --git a/chrome/browser/views/tabs/tab.h b/chrome/browser/views/tabs/tab.h
index e543ea3..303a80a 100644
--- a/chrome/browser/views/tabs/tab.h
+++ b/chrome/browser/views/tabs/tab.h
@@ -12,7 +12,6 @@ namespace gfx {
class Path;
class Point;
}
-class BrowserExtender;
///////////////////////////////////////////////////////////////////////////////
//
@@ -95,9 +94,6 @@ class Tab : public TabRenderer,
virtual bool OnMouseDragged(const views::MouseEvent& event);
virtual void OnMouseReleased(const views::MouseEvent& event,
bool canceled);
- virtual void OnMouseEntered(const views::MouseEvent& event);
- virtual void OnMouseMoved(const views::MouseEvent& event);
- virtual void OnMouseExited(const views::MouseEvent& event);
virtual bool GetTooltipText(int x, int y, std::wstring* tooltip);
virtual bool GetTooltipTextOrigin(int x, int y, gfx::Point* origin);
virtual std::string GetClassName() const { return kTabClassName; }
@@ -113,9 +109,6 @@ class Tab : public TabRenderer,
// views::ButtonListener overrides:
virtual void ButtonPressed(views::Button* sender, const views::Event& event);
- // Returns the BrowserExtender of the window that this tab belongs to.
- BrowserExtender* GetBrowserExtender();
-
// Creates a path that contains the clickable region of the tab's visual
// representation. Used by GetViewForPoint for hit-testing.
void MakePathForTab(gfx::Path* path) const;
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 248506a..27bbb68 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -1052,6 +1052,10 @@ void TabStrip::ThemeChanged() {
LoadNewTabButtonImage();
}
+Tab* TabStrip::CreateTab() {
+ return new Tab(this);
+}
+
void TabStrip::ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) {
@@ -1101,7 +1105,7 @@ void TabStrip::TabInsertedAt(TabContents* contents,
// Otherwise we need to make a new Tab.
if (!tab)
- tab = new Tab(this);
+ tab = CreateTab();
// Only insert if we're not already in the list.
if (!contains_tab) {
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index 9ecece6..27f6a97 100644
--- a/chrome/browser/views/tabs/tab_strip.h
+++ b/chrome/browser/views/tabs/tab_strip.h
@@ -12,7 +12,6 @@
#include "views/controls/button/image_button.h"
#include "views/view.h"
-class BrowserExtender;
class DraggedTabController;
class ScopedMouseCloseWidthCalculator;
class TabStripModel;
@@ -117,7 +116,12 @@ class TabStrip : public views::View,
virtual void SetAccessibleName(const std::wstring& name);
virtual views::View* GetViewForPoint(const gfx::Point& point);
virtual void ThemeChanged();
+
protected:
+ // Creates a new tab.
+ virtual Tab* CreateTab();
+
+ // views::View implementation:
virtual void ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 23c2cda..2cb2692 100755
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -248,6 +248,7 @@
'browser/chrome_thread.cc',
'browser/chrome_thread.h',
'browser/chromeos/browser_extenders.cc',
+ 'browser/chromeos/chromeos_browser_view.cc',
'browser/chromeos/clock_menu_button.cc',
'browser/chromeos/clock_menu_button.h',
'browser/chromeos/compact_location_bar_host.cc',
@@ -1719,6 +1720,8 @@
'browser/views/first_run_view.h',
'browser/views/first_run_view_base.cc',
'browser/views/first_run_view_base.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',
@@ -1726,8 +1729,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_layout_manager.cc',
- 'browser/views/frame/browser_layout_manager.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',
@@ -2258,10 +2260,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/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_layout_manager.cc'],
- ['include', '^browser/views/frame/browser_layout_manager.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'],