Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1144)

Unified Diff: chrome/browser/chromeos/webui/login/browser/dom_browser_view_layout.cc

Issue 6577003: Entire DOMBrowser stack (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..052bee6de1fbe90d99c1fad8b3f7d6e1df3d6701
--- /dev/null
+++ b/chrome/browser/chromeos/webui/login/browser/dom_browser_view_layout.cc
@@ -0,0 +1,167 @@
+// 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:
+
+
+//////////////////////////////////////////////////////////////////////////////
+// DOMBrowserViewLayout, ::DOMBrowserViewLayout overrides:
+
+void DOMBrowserViewLayout::Installed(views::View* host) {
+ status_area_ = NULL;
+ ::BrowserViewLayout::Installed(host);
+}
+
+void DOMBrowserViewLayout::ViewAdded(views::View* host,
+ views::View* view) {
+ ::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
+// 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());
+ if (bv_bounds.Contains(point))
+ return HTCLIENT;
+
+ bv_bounds = browser_view_->bounds();
+ bv_bounds.set_height(0);
+ if (bv_bounds.Contains(point))
+ return HTNOWHERE;
+
+ // 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())
+ 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

Powered by Google App Engine
This is Rietveld 408576698