1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
// 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/frame/dom_browser_view_layout.h"
#include <algorithm>
#include "chrome/browser/chromeos/status/status_area_view.h"
#include "chrome/browser/chromeos/view_ids.h"
#include "views/window/hit_test.h"
namespace chromeos {
// DOMBrowserViewLayout public: ------------------------------------------------
DOMBrowserViewLayout::DOMBrowserViewLayout() : ::BrowserViewLayout() {}
DOMBrowserViewLayout::~DOMBrowserViewLayout() {}
// 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;
}
}
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();
if (bv_bounds.Contains(point))
return HTCLIENT;
// If the point is somewhere else, delegate to the default implementation.
return browser_view_->views::ClientView::NonClientHitTest(point);
}
// DOMBrowserViewLayout private: -----------------------------------------------
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);
return status_area_->HitTest(point_in_status_area_coords);
}
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();
}
const DOMBrowserView* DOMBrowserViewLayout::GetDOMBrowserView() {
return static_cast<DOMBrowserView*>(browser_view_);
}
} // namespace chromeos
|