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

Side by Side Diff: chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc

Issue 441803004: Introduce new WebApp header style for hosted apps and fizzy apps on ash. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More feedback Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h" 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/frame/caption_buttons/frame_caption_button.h"
10 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" 11 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
11 #include "ash/frame/default_header_painter.h" 12 #include "ash/frame/default_header_painter.h"
12 #include "ash/frame/frame_border_hit_test_controller.h" 13 #include "ash/frame/frame_border_hit_test_controller.h"
13 #include "ash/frame/header_painter_util.h" 14 #include "ash/frame/header_painter_util.h"
14 #include "ash/shell.h" 15 #include "ash/shell.h"
15 #include "base/command_line.h" 16 #include "base/command_line.h"
17 #include "chrome/app/chrome_command_ids.h"
16 #include "chrome/browser/themes/theme_properties.h" 18 #include "chrome/browser/themes/theme_properties.h"
17 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_commands.h"
18 #include "chrome/browser/ui/views/frame/browser_frame.h" 21 #include "chrome/browser/ui/views/frame/browser_frame.h"
19 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h" 22 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h"
20 #include "chrome/browser/ui/views/frame/browser_view.h" 23 #include "chrome/browser/ui/views/frame/browser_view.h"
21 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 24 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
22 #include "chrome/browser/ui/views/profiles/avatar_label.h" 25 #include "chrome/browser/ui/views/profiles/avatar_label.h"
23 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" 26 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
24 #include "chrome/browser/ui/views/tab_icon_view.h" 27 #include "chrome/browser/ui/views/tab_icon_view.h"
25 #include "chrome/browser/ui/views/tabs/tab_strip.h" 28 #include "chrome/browser/ui/views/tabs/tab_strip.h"
26 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
27 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // for restored windows, apps, etc. 65 // for restored windows, apps, etc.
63 const int kTabstripTopSpacingTall = 7; 66 const int kTabstripTopSpacingTall = 7;
64 // Space between top of window and top of tabstrip for short headers, such as 67 // Space between top of window and top of tabstrip for short headers, such as
65 // for maximized windows, pop-ups, etc. 68 // for maximized windows, pop-ups, etc.
66 const int kTabstripTopSpacingShort = 0; 69 const int kTabstripTopSpacingShort = 0;
67 // Height of the shadow in the tab image, used to ensure clicks in the shadow 70 // Height of the shadow in the tab image, used to ensure clicks in the shadow
68 // area still drag restored windows. This keeps the clickable area large enough 71 // area still drag restored windows. This keeps the clickable area large enough
69 // to hit easily. 72 // to hit easily.
70 const int kTabShadowHeight = 4; 73 const int kTabShadowHeight = 4;
71 74
75 // Combines View::ConvertPointToTarget() and View::HitTest() for a given
76 // |point|.
77 // Converts |point| from |src| to |dst| and hit tests it against |dst|.
James Cook 2014/08/15 00:00:47 wrap comment together
benwells 2014/08/18 05:59:13 Done.
78 bool ConvertedHitTest(views::View* src,
79 views::View* dst,
80 const gfx::Point& point) {
81 if (!dst)
82 return false;
83
84 DCHECK(src);
85 gfx::Point converted_point(point);
86 views::View::ConvertPointToTarget(src, dst, &converted_point);
87 return dst->HitTestPoint(converted_point);
88 }
89
72 } // namespace 90 } // namespace
73 91
74 /////////////////////////////////////////////////////////////////////////////// 92 ///////////////////////////////////////////////////////////////////////////////
75 // BrowserNonClientFrameViewAsh, public: 93 // BrowserNonClientFrameViewAsh, public:
76 94
77 // static 95 // static
78 const char BrowserNonClientFrameViewAsh::kViewClassName[] = 96 const char BrowserNonClientFrameViewAsh::kViewClassName[] =
79 "BrowserNonClientFrameViewAsh"; 97 "BrowserNonClientFrameViewAsh";
80 98
81 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh( 99 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh(
82 BrowserFrame* frame, BrowserView* browser_view) 100 BrowserFrame* frame,
101 BrowserView* browser_view)
83 : BrowserNonClientFrameView(frame, browser_view), 102 : BrowserNonClientFrameView(frame, browser_view),
84 caption_button_container_(NULL), 103 caption_button_container_(NULL),
104 web_app_back_button_(NULL),
85 window_icon_(NULL), 105 window_icon_(NULL),
86 frame_border_hit_test_controller_( 106 frame_border_hit_test_controller_(
87 new ash::FrameBorderHitTestController(frame)) { 107 new ash::FrameBorderHitTestController(frame)) {
88 ash::Shell::GetInstance()->AddShellObserver(this); 108 ash::Shell::GetInstance()->AddShellObserver(this);
89 } 109 }
90 110
91 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() { 111 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() {
92 ash::Shell::GetInstance()->RemoveShellObserver(this); 112 ash::Shell::GetInstance()->RemoveShellObserver(this);
113 chrome::RemoveCommandObserver(browser_view()->browser(), IDC_BACK, this);
James Cook 2014/08/15 00:00:47 You might comment here on the memory ownership (wh
benwells 2014/08/18 05:59:13 Done.
93 } 114 }
94 115
95 void BrowserNonClientFrameViewAsh::Init() { 116 void BrowserNonClientFrameViewAsh::Init() {
96 caption_button_container_ = new ash::FrameCaptionButtonContainerView(frame(), 117 caption_button_container_ = new ash::FrameCaptionButtonContainerView(frame(),
97 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); 118 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED);
98 caption_button_container_->UpdateSizeButtonVisibility(); 119 caption_button_container_->UpdateSizeButtonVisibility();
99 AddChildView(caption_button_container_); 120 AddChildView(caption_button_container_);
100 121
101 // Initializing the TabIconView is expensive, so only do it if we need to. 122 // Initializing the TabIconView is expensive, so only do it if we need to.
102 if (browser_view()->ShouldShowWindowIcon()) { 123 if (browser_view()->ShouldShowWindowIcon()) {
103 window_icon_ = new TabIconView(this, NULL); 124 window_icon_ = new TabIconView(this, NULL);
104 window_icon_->set_is_light(true); 125 window_icon_->set_is_light(true);
105 AddChildView(window_icon_); 126 AddChildView(window_icon_);
106 window_icon_->Update(); 127 window_icon_->Update();
107 } 128 }
108 129
109 // Create incognito icon if necessary. 130 // Create incognito icon if necessary.
110 UpdateAvatarInfo(); 131 UpdateAvatarInfo();
111 132
112 // HeaderPainter handles layout. 133 // HeaderPainter handles layout.
113 if (UsePackagedAppHeaderStyle()) { 134 if (UsePackagedAppHeaderStyle()) {
114 ash::DefaultHeaderPainter* header_painter = new ash::DefaultHeaderPainter; 135 ash::DefaultHeaderPainter* header_painter = new ash::DefaultHeaderPainter;
115 header_painter_.reset(header_painter); 136 header_painter_.reset(header_painter);
116 header_painter->Init(frame(), this, window_icon_, 137 header_painter->Init(frame(), this, caption_button_container_);
117 caption_button_container_); 138 if (window_icon_) {
139 header_painter->UpdateLeftHeaderView(window_icon_);
140 }
141 } else if (UseWebAppHeaderStyle()) {
142 web_app_back_button_ =
143 new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_BACK);
144 web_app_back_button_->SetImages(ash::CAPTION_BUTTON_ICON_BACK,
145 ash::FrameCaptionButton::ANIMATE_NO,
146 IDR_AURA_WINDOW_CONTROL_ICON_BACK,
147 IDR_AURA_WINDOW_CONTROL_ICON_BACK_I,
148 IDR_AURA_WINDOW_CONTROL_BACKGROUND_H,
149 IDR_AURA_WINDOW_CONTROL_BACKGROUND_P);
150
151 UpdateBackButtonState(true);
152 chrome::AddCommandObserver(browser_view()->browser(), IDC_BACK, this);
153 AddChildView(web_app_back_button_);
154
155 ash::DefaultHeaderPainter* header_painter = new ash::DefaultHeaderPainter;
156 header_painter_.reset(header_painter);
James Cook 2014/08/15 00:00:47 Collapse this with the line above and use header_p
benwells 2014/08/18 05:59:13 Init and UpdateLeftHeaderView are not on the Heade
157 header_painter->Init(frame(), this, caption_button_container_);
158 header_painter->UpdateLeftHeaderView(web_app_back_button_);
118 } else { 159 } else {
119 BrowserHeaderPainterAsh* header_painter = new BrowserHeaderPainterAsh; 160 BrowserHeaderPainterAsh* header_painter = new BrowserHeaderPainterAsh;
120 header_painter_.reset(header_painter); 161 header_painter_.reset(header_painter);
121 header_painter->Init(frame(), browser_view(), this, window_icon_, 162 header_painter->Init(frame(), browser_view(), this, window_icon_,
122 caption_button_container_); 163 caption_button_container_);
123 } 164 }
124 } 165 }
125 166
126 /////////////////////////////////////////////////////////////////////////////// 167 ///////////////////////////////////////////////////////////////////////////////
127 // BrowserNonClientFrameView: 168 // BrowserNonClientFrameView:
(...skipping 20 matching lines...) Expand all
148 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) 189 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle())
149 return 0; 190 return 0;
150 191
151 if (browser_view()->IsTabStripVisible()) { 192 if (browser_view()->IsTabStripVisible()) {
152 if (frame()->IsMaximized() || frame()->IsFullscreen()) 193 if (frame()->IsMaximized() || frame()->IsFullscreen())
153 return kTabstripTopSpacingShort; 194 return kTabstripTopSpacingShort;
154 else 195 else
155 return kTabstripTopSpacingTall; 196 return kTabstripTopSpacingTall;
156 } 197 }
157 198
158 if (UsePackagedAppHeaderStyle()) 199 if (UsePackagedAppHeaderStyle() || UseWebAppHeaderStyle())
159 return header_painter_->GetHeaderHeightForPainting(); 200 return header_painter_->GetHeaderHeightForPainting();
160 201
161 int caption_buttons_bottom = caption_button_container_->bounds().bottom(); 202 int caption_buttons_bottom = caption_button_container_->bounds().bottom();
162 203
163 // The toolbar partially overlaps the caption buttons. 204 // The toolbar partially overlaps the caption buttons.
164 if (browser_view()->IsToolbarVisible()) 205 if (browser_view()->IsToolbarVisible())
165 return caption_buttons_bottom - kContentShadowHeight; 206 return caption_buttons_bottom - kContentShadowHeight;
166 207
167 return caption_buttons_bottom + kClientEdgeThickness; 208 return caption_buttons_bottom + kClientEdgeThickness;
168 } 209 }
(...skipping 23 matching lines...) Expand all
192 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds( 233 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds(
193 const gfx::Rect& client_bounds) const { 234 const gfx::Rect& client_bounds) const {
194 return client_bounds; 235 return client_bounds;
195 } 236 }
196 237
197 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { 238 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) {
198 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, 239 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this,
199 caption_button_container_, point); 240 caption_button_container_, point);
200 241
201 // See if the point is actually within the avatar menu button or within 242 // See if the point is actually within the avatar menu button or within
202 // the avatar label. 243 // the web app back button.
203 if (hit_test == HTCAPTION && ((avatar_button() && 244 if (hit_test == HTCAPTION &&
204 avatar_button()->GetMirroredBounds().Contains(point)) || 245 (ConvertedHitTest(this, avatar_button(), point) ||
205 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)))) 246 ConvertedHitTest(this, web_app_back_button_, point))) {
James Cook 2014/08/15 00:00:47 I would prefer to see this unrolled as two hit tes
benwells 2014/08/18 05:59:13 Done.
206 return HTCLIENT; 247 return HTCLIENT;
248 }
207 249
208 // When the window is restored we want a large click target above the tabs 250 // When the window is restored we want a large click target above the tabs
209 // to drag the window, so redirect clicks in the tab's shadow to caption. 251 // to drag the window, so redirect clicks in the tab's shadow to caption.
210 if (hit_test == HTCLIENT && 252 if (hit_test == HTCLIENT &&
211 !(frame()->IsMaximized() || frame()->IsFullscreen())) { 253 !(frame()->IsMaximized() || frame()->IsFullscreen())) {
212 // Convert point to client coordinates. 254 // Convert point to client coordinates.
213 gfx::Point client_point(point); 255 gfx::Point client_point(point);
214 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); 256 View::ConvertPointToTarget(this, frame()->client_view(), &client_point);
215 // Report hits in shadow at top of tabstrip as caption. 257 // Report hits in shadow at top of tabstrip as caption.
216 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); 258 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { 293 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) {
252 if (!ShouldPaint()) 294 if (!ShouldPaint())
253 return; 295 return;
254 296
255 if (UseImmersiveLightbarHeaderStyle()) { 297 if (UseImmersiveLightbarHeaderStyle()) {
256 PaintImmersiveLightbarStyleHeader(canvas); 298 PaintImmersiveLightbarStyleHeader(canvas);
257 return; 299 return;
258 } 300 }
259 301
260 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); 302 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive());
303 if (web_app_back_button_) {
304 // TODO(benwells): Check that the disabled and inactive states should be
305 // drawn in the same way.
306 web_app_back_button_->set_paint_as_active(
307 ShouldPaintAsActive() &&
308 chrome::IsCommandEnabled(browser_view()->browser(), IDC_BACK));
309 }
261 310
262 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? 311 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ?
263 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; 312 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE;
264 header_painter_->PaintHeader(canvas, header_mode); 313 header_painter_->PaintHeader(canvas, header_mode);
265 if (browser_view()->IsToolbarVisible()) 314 if (browser_view()->IsToolbarVisible())
266 PaintToolbarBackground(canvas); 315 PaintToolbarBackground(canvas);
267 else if (!UsePackagedAppHeaderStyle()) 316 else if (!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle())
268 PaintContentEdge(canvas); 317 PaintContentEdge(canvas);
269 } 318 }
270 319
271 void BrowserNonClientFrameViewAsh::Layout() { 320 void BrowserNonClientFrameViewAsh::Layout() {
272 // The header must be laid out before computing |painted_height| because the 321 // The header must be laid out before computing |painted_height| because the
273 // computation of |painted_height| for app and popup windows depends on the 322 // computation of |painted_height| for app and popup windows depends on the
274 // position of the window controls. 323 // position of the window controls.
275 header_painter_->LayoutHeader(); 324 header_painter_->LayoutHeader();
276 325
277 int painted_height = 0; 326 int painted_height = 0;
278 if (browser_view()->IsTabStripVisible()) { 327 if (browser_view()->IsTabStripVisible()) {
279 painted_height = GetTopInset() + 328 painted_height = GetTopInset() +
280 browser_view()->tabstrip()->GetPreferredSize().height(); 329 browser_view()->tabstrip()->GetPreferredSize().height();
281 } else if (browser_view()->IsToolbarVisible()) { 330 } else if (browser_view()->IsToolbarVisible()) {
282 // Paint the header so that it overlaps with the top few pixels of the 331 // Paint the header so that it overlaps with the top few pixels of the
283 // toolbar because the top few pixels of the toolbar are not opaque. 332 // toolbar because the top few pixels of the toolbar are not opaque.
284 painted_height = GetTopInset() + kFrameShadowThickness * 2; 333 painted_height = GetTopInset() + kFrameShadowThickness * 2;
285 } else { 334 } else {
286 painted_height = GetTopInset(); 335 painted_height = GetTopInset();
287 } 336 }
288 header_painter_->SetHeaderHeightForPainting(painted_height); 337 header_painter_->SetHeaderHeightForPainting(painted_height);
289 if (avatar_button()) 338 if (avatar_button()) {
290 LayoutAvatar(); 339 LayoutAvatar();
340 header_painter_->UpdateLeftViewXInset(avatar_button()->bounds().right());
341 } else {
342 header_painter_->UpdateLeftViewXInset(
343 ash::HeaderPainterUtil::GetDefaultLeftViewXInset());
344 }
291 BrowserNonClientFrameView::Layout(); 345 BrowserNonClientFrameView::Layout();
292 } 346 }
293 347
294 const char* BrowserNonClientFrameViewAsh::GetClassName() const { 348 const char* BrowserNonClientFrameViewAsh::GetClassName() const {
295 return kViewClassName; 349 return kViewClassName;
296 } 350 }
297 351
298 void BrowserNonClientFrameViewAsh::GetAccessibleState( 352 void BrowserNonClientFrameViewAsh::GetAccessibleState(
299 ui::AXViewState* state) { 353 ui::AXViewState* state) {
300 state->role = ui::AX_ROLE_TITLE_BAR; 354 state->role = ui::AX_ROLE_TITLE_BAR;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 } 409 }
356 410
357 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { 411 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() {
358 views::WidgetDelegate* delegate = frame()->widget_delegate(); 412 views::WidgetDelegate* delegate = frame()->widget_delegate();
359 if (!delegate) 413 if (!delegate)
360 return gfx::ImageSkia(); 414 return gfx::ImageSkia();
361 return delegate->GetWindowIcon(); 415 return delegate->GetWindowIcon();
362 } 416 }
363 417
364 /////////////////////////////////////////////////////////////////////////////// 418 ///////////////////////////////////////////////////////////////////////////////
419 // CommandObserver:
420
421 void BrowserNonClientFrameViewAsh::EnabledStateChangedForCommand(int id,
422 bool enabled) {
423 DCHECK_EQ(IDC_BACK, id);
424 UpdateBackButtonState(enabled);
425 }
426
427 ///////////////////////////////////////////////////////////////////////////////
428 // views::ButtonListener:
429
430 void BrowserNonClientFrameViewAsh::ButtonPressed(views::Button* sender,
431 const ui::Event& event) {
432 DCHECK_EQ(sender, web_app_back_button_);
433 chrome::ExecuteCommand(browser_view()->browser(), IDC_BACK);
434 }
435
436 ///////////////////////////////////////////////////////////////////////////////
365 // BrowserNonClientFrameViewAsh, private: 437 // BrowserNonClientFrameViewAsh, private:
366 438
367 // views::NonClientFrameView: 439 // views::NonClientFrameView:
368 bool BrowserNonClientFrameViewAsh::DoesIntersectRect( 440 bool BrowserNonClientFrameViewAsh::DoesIntersectRect(
369 const views::View* target, 441 const views::View* target,
370 const gfx::Rect& rect) const { 442 const gfx::Rect& rect) const {
371 CHECK_EQ(target, this); 443 CHECK_EQ(target, this);
372 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { 444 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) {
373 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. 445 // |rect| is outside BrowserNonClientFrameViewAsh's bounds.
374 return false; 446 return false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 479
408 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const { 480 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const {
409 ImmersiveModeController* immersive_controller = 481 ImmersiveModeController* immersive_controller =
410 browser_view()->immersive_mode_controller(); 482 browser_view()->immersive_mode_controller();
411 return immersive_controller->IsEnabled() && 483 return immersive_controller->IsEnabled() &&
412 !immersive_controller->IsRevealed() && 484 !immersive_controller->IsRevealed() &&
413 browser_view()->IsTabStripVisible(); 485 browser_view()->IsTabStripVisible();
414 } 486 }
415 487
416 bool BrowserNonClientFrameViewAsh::UsePackagedAppHeaderStyle() const { 488 bool BrowserNonClientFrameViewAsh::UsePackagedAppHeaderStyle() const {
417 // Non streamlined hosted apps do not have a toolbar or tabstrip. Their header 489 // Use the packaged app style for apps that aren't using the newer WebApp
418 // should look the same as the header for packaged apps. Streamlined hosted 490 // style.
419 // apps have a toolbar so should use the browser header style. 491 return browser_view()->browser()->is_app() && !UseWebAppHeaderStyle();
492 }
493
494 bool BrowserNonClientFrameViewAsh::UseWebAppHeaderStyle() const {
495 // Use of the experimental WebApp header style is guarded with the
496 // streamlined hosted app style.
420 return browser_view()->browser()->is_app() && 497 return browser_view()->browser()->is_app() &&
421 !CommandLine::ForCurrentProcess()->HasSwitch( 498 CommandLine::ForCurrentProcess()->HasSwitch(
422 switches::kEnableStreamlinedHostedApps); 499 switches::kEnableStreamlinedHostedApps);
423 } 500 }
424 501
425 void BrowserNonClientFrameViewAsh::LayoutAvatar() { 502 void BrowserNonClientFrameViewAsh::LayoutAvatar() {
426 DCHECK(avatar_button()); 503 DCHECK(avatar_button());
427 #if !defined(OS_CHROMEOS) 504 #if !defined(OS_CHROMEOS)
428 // ChromeOS shows avatar on V1 app. 505 // ChromeOS shows avatar on V1 app.
429 DCHECK(browser_view()->IsTabStripVisible()); 506 DCHECK(browser_view()->IsTabStripVisible());
430 #endif 507 #endif
431 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); 508 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon();
432 509
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 canvas->FillRect( 619 canvas->FillRect(
543 gfx::Rect(x + kClientEdgeThickness, 620 gfx::Rect(x + kClientEdgeThickness,
544 toolbar_bounds.bottom() - kClientEdgeThickness, 621 toolbar_bounds.bottom() - kClientEdgeThickness,
545 w - (2 * kClientEdgeThickness), 622 w - (2 * kClientEdgeThickness),
546 kClientEdgeThickness), 623 kClientEdgeThickness),
547 ThemeProperties::GetDefaultColor( 624 ThemeProperties::GetDefaultColor(
548 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); 625 ThemeProperties::COLOR_TOOLBAR_SEPARATOR));
549 } 626 }
550 627
551 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { 628 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) {
552 DCHECK(!UsePackagedAppHeaderStyle()); 629 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle());
553 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), 630 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(),
554 width(), kClientEdgeThickness), 631 width(), kClientEdgeThickness),
555 ThemeProperties::GetDefaultColor( 632 ThemeProperties::GetDefaultColor(
556 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); 633 ThemeProperties::COLOR_TOOLBAR_SEPARATOR));
557 } 634 }
635
636 void BrowserNonClientFrameViewAsh::UpdateBackButtonState(bool enabled) {
637 web_app_back_button_->SetState(enabled ? views::Button::STATE_NORMAL
638 : views::Button::STATE_DISABLED);
639 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698