Chromium Code Reviews| Index: chrome/browser/chromeos/webui/login/browser/dom_browser_view_layout.cc |
| diff --git a/chrome/browser/chromeos/webui/login/browser/dom_browser_view_layout.cc b/chrome/browser/chromeos/webui/login/browser/dom_browser_view_layout.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e035012d79a056a5a9649847501efa12976ae3a8 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/webui/login/browser/dom_browser_view_layout.cc |
| @@ -0,0 +1,163 @@ |
| +// Copyright (c) 2011 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/chromeos/webui/login/browser/dom_browser_view_layout.h" |
| + |
| +#include <algorithm> |
| + |
| +#include "chrome/browser/chromeos/status/status_area_view.h" |
| +#include "chrome/browser/chromeos/view_ids.h" |
| +#include "chrome/browser/ui/views/toolbar_view.h" |
| +#include "views/window/hit_test.h" |
| + |
| +namespace { |
| + |
| +// Amount to offset the toolbar by when vertical tabs are enabled. |
| +const int kVerticalTabStripToolbarOffset = 2; |
| + |
| +} // namespace |
| + |
| + |
| +namespace chromeos { |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// DOMBrowserViewLayout public: |
|
oshima
2011/03/14 20:09:22
could you please add brief description of how comp
rharrison
2011/03/15 22:01:21
Done.
|
| + |
| + |
|
oshima
2011/03/14 20:09:22
remove extra new line
rharrison
2011/03/15 22:01:21
Done.
|
| +////////////////////////////////////////////////////////////////////////////// |
| +// DOMBrowserViewLayout, ::DOMBrowserViewLayout overrides: |
| + |
| +void DOMBrowserViewLayout::Installed(views::View* host) { |
| + status_area_ = NULL; |
| + ::BrowserViewLayout::Installed(host); |
| +} |
| + |
| +void DOMBrowserViewLayout::ViewAdded(views::View* host, |
| + views::View* view) { |
|
oshima
2011/03/14 20:09:22
indent
rharrison
2011/03/15 22:01:21
Done.
|
| + ::BrowserViewLayout::ViewAdded(host, view); |
| + switch (view->GetID()) { |
| + case VIEW_ID_STATUS_AREA: |
| + status_area_ = static_cast<chromeos::StatusAreaView*>(view); |
| + break; |
| + } |
| +} |
| + |
| +// In the normal and the compact navigation bar mode, ChromeOS |
|
oshima
2011/03/14 20:09:22
Compact nav bar is gone long time ago. I guess it'
rharrison
2011/03/15 22:01:21
Done.
|
| +// layouts compact navigation buttons and status views in the title |
| +// area. See Layout |
| +int DOMBrowserViewLayout::LayoutTabStrip() { |
| + status_area_->SetVisible(true); |
| + gfx::Size status_size = status_area_->GetPreferredSize(); |
| + status_area_->SetBounds(vertical_layout_rect_.width() - status_size.width(), |
| + 0, |
| + vertical_layout_rect_.width(), |
| + status_size.height()); |
| + |
| + return status_size.height(); |
| +} |
| + |
| +int DOMBrowserViewLayout::LayoutToolbar(int top) { |
| + return top; |
| +} |
| +int DOMBrowserViewLayout::LayoutBookmarkAndInfoBars(int top) { |
| + return top; |
| +} |
| + |
| +bool DOMBrowserViewLayout::IsPositionInWindowCaption(const gfx::Point& point) { |
| + return false; |
| +} |
| + |
| +int DOMBrowserViewLayout::NonClientHitTest(const gfx::Point& point) { |
| + views::View* parent = browser_view_->parent(); |
| + gfx::Point point_in_browser_view_coords(point); |
| + views::View::ConvertPointToView( |
| + parent, browser_view_, &point_in_browser_view_coords); |
| + gfx::Rect bv_bounds = browser_view_->bounds(); |
| + bv_bounds.set_height(bv_bounds.height()); |
|
oshima
2011/03/14 20:09:22
looks like no-op?
rharrison
2011/03/15 22:01:21
Done.
|
| + if (bv_bounds.Contains(point)) |
| + return HTCLIENT; |
| + bv_bounds = browser_view_->bounds(); |
| + bv_bounds.set_height(0); |
| + if (bv_bounds.Contains(point)) |
| + return HTNOWHERE; |
|
oshima
2011/03/14 20:09:22
what is this condition for?
rharrison
2011/03/15 22:01:21
Not really sure, I think it was an artifact from b
|
| + // If the point is somewhere else, delegate to the default implementation. |
| + return browser_view_->views::ClientView::NonClientHitTest(point); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// DOMBrowserViewLayout private: |
| + |
| +// Tests if the point is on one of views that are within the |
| +// considered title bar area of client view. |
| +bool DOMBrowserViewLayout::IsPointInViewsInTitleArea(const gfx::Point& point) |
| + const { |
| + gfx::Point point_in_status_area_coords(point); |
| + views::View::ConvertPointToView(browser_view_, status_area_, |
| + &point_in_status_area_coords); |
| + if (status_area_->HitTest(point_in_status_area_coords)) |
| + return true; |
| + |
| + return false; |
| +} |
| + |
| +// Positions the titlebar, toolbar and tabstrip. This is |
| +// used when side tabs are enabled. |
| +int DOMBrowserViewLayout::LayoutTitlebarComponentsWithVerticalTabs( |
| + const gfx::Rect& bounds) { |
| + if (bounds.IsEmpty()) |
|
oshima
2011/03/14 20:09:22
Do we want to support virtual tabs in touch? You c
rharrison
2011/03/15 22:01:21
We are not supporting vertical tabs, I should have
|
| + return 0; |
| + |
| + tabstrip_->SetVisible(true); |
| + status_area_->SetVisible(true); |
| + |
| + gfx::Size status_size = status_area_->GetPreferredSize(); |
| + int status_height = status_size.height(); |
| + |
| + int status_x = bounds.x(); |
| + // Layout the status area. |
| + status_area_->SetBounds(status_x, bounds.bottom() - status_height, |
| + status_size.width(), status_height); |
| + |
| + // The tabstrip's width is the bigger of it's preferred width and the width |
| + // the status area. |
| + int tabstrip_w = std::max(status_x + status_size.width(), |
| + tabstrip_->GetPreferredSize().width()); |
| + tabstrip_->SetBounds(bounds.x(), bounds.y(), tabstrip_w, |
| + bounds.height() - status_height); |
| + |
| + // The toolbar is promoted to the title for vertical tabs. |
| + bool toolbar_visible = browser_view_->IsToolbarVisible(); |
| + toolbar_->SetVisible(toolbar_visible); |
| + int toolbar_height = 0; |
| + if (toolbar_visible) |
| + toolbar_height = toolbar_->GetPreferredSize().height(); |
| + int tabstrip_max_x = tabstrip_->bounds().right(); |
| + toolbar_->SetBounds(tabstrip_max_x, |
| + bounds.y() - kVerticalTabStripToolbarOffset, |
| + browser_view_->width() - tabstrip_max_x, |
| + toolbar_height); |
| + |
| + // Adjust the available bounds for other components. |
| + gfx::Rect available_bounds = vertical_layout_rect(); |
| + available_bounds.Inset(tabstrip_w, 0, 0, 0); |
| + set_vertical_layout_rect(available_bounds); |
| + |
| + return bounds.y() + toolbar_height; |
| +} |
| + |
| +// Lays out tabstrip and status area in the title bar area (given by |
| +// |bounds|). |
| +int DOMBrowserViewLayout::LayoutTitlebarComponents(const gfx::Rect& bounds) { |
| + status_area_->SetVisible(true); |
| + gfx::Size status_size = status_area_->GetPreferredSize(); |
| + status_area_->SetBounds(bounds.right() - status_size.width(), bounds.y(), |
| + status_size.width(), status_size.height()); |
| + return status_size.height(); |
| +} |
| + |
| +DOMBrowserView* DOMBrowserViewLayout::dom_browser_view() { |
| + return static_cast<DOMBrowserView*>(browser_view_); |
| +} |
| + |
| +} // namespace chromeos |