Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 25 #include "chrome/browser/ui/views/frame/webapp_header_painter_ash.h" | |
| 22 #include "chrome/browser/ui/views/profiles/avatar_label.h" | 26 #include "chrome/browser/ui/views/profiles/avatar_label.h" |
| 23 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 27 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 24 #include "chrome/browser/ui/views/tab_icon_view.h" | 28 #include "chrome/browser/ui/views/tab_icon_view.h" |
| 25 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 29 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 26 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 27 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 28 #include "grit/ash_resources.h" | 32 #include "grit/ash_resources.h" |
| 29 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
| 30 #include "ui/accessibility/ax_view_state.h" | 34 #include "ui/accessibility/ax_view_state.h" |
| 31 #include "ui/aura/client/aura_constants.h" | 35 #include "ui/aura/client/aura_constants.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 // BrowserNonClientFrameViewAsh, public: | 80 // BrowserNonClientFrameViewAsh, public: |
| 77 | 81 |
| 78 // static | 82 // static |
| 79 const char BrowserNonClientFrameViewAsh::kViewClassName[] = | 83 const char BrowserNonClientFrameViewAsh::kViewClassName[] = |
| 80 "BrowserNonClientFrameViewAsh"; | 84 "BrowserNonClientFrameViewAsh"; |
| 81 | 85 |
| 82 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh( | 86 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh( |
| 83 BrowserFrame* frame, BrowserView* browser_view) | 87 BrowserFrame* frame, BrowserView* browser_view) |
| 84 : BrowserNonClientFrameView(frame, browser_view), | 88 : BrowserNonClientFrameView(frame, browser_view), |
| 85 caption_button_container_(NULL), | 89 caption_button_container_(NULL), |
| 90 webapp_back_button_(NULL), | |
|
pkotwicz
2014/08/06 21:36:49
Nit: Rename to web_app_back_button_
benwells
2014/08/13 00:53:45
Done.
| |
| 86 window_icon_(NULL), | 91 window_icon_(NULL), |
| 87 frame_border_hit_test_controller_( | 92 frame_border_hit_test_controller_( |
| 88 new ash::FrameBorderHitTestController(frame)) { | 93 new ash::FrameBorderHitTestController(frame)) { |
| 89 ash::Shell::GetInstance()->AddShellObserver(this); | 94 ash::Shell::GetInstance()->AddShellObserver(this); |
| 90 } | 95 } |
| 91 | 96 |
| 92 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() { | 97 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() { |
| 93 ash::Shell::GetInstance()->RemoveShellObserver(this); | 98 ash::Shell::GetInstance()->RemoveShellObserver(this); |
| 99 chrome::RemoveCommandObserver(browser_view()->browser(), IDC_BACK, this); | |
| 94 } | 100 } |
| 95 | 101 |
| 96 void BrowserNonClientFrameViewAsh::Init() { | 102 void BrowserNonClientFrameViewAsh::Init() { |
| 97 caption_button_container_ = new ash::FrameCaptionButtonContainerView(frame(), | 103 caption_button_container_ = new ash::FrameCaptionButtonContainerView(frame(), |
| 98 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); | 104 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); |
| 99 caption_button_container_->UpdateSizeButtonVisibility(); | 105 caption_button_container_->UpdateSizeButtonVisibility(); |
| 100 AddChildView(caption_button_container_); | 106 AddChildView(caption_button_container_); |
| 101 | 107 |
| 102 // Initializing the TabIconView is expensive, so only do it if we need to. | 108 // Initializing the TabIconView is expensive, so only do it if we need to. |
| 103 if (browser_view()->ShouldShowWindowIcon()) { | 109 if (browser_view()->ShouldShowWindowIcon()) { |
| 104 window_icon_ = new TabIconView(this, NULL); | 110 window_icon_ = new TabIconView(this, NULL); |
| 105 window_icon_->set_is_light(true); | 111 window_icon_->set_is_light(true); |
| 106 AddChildView(window_icon_); | 112 AddChildView(window_icon_); |
| 107 window_icon_->Update(); | 113 window_icon_->Update(); |
| 108 } | 114 } |
| 109 | 115 |
| 110 // Create incognito icon if necessary. | 116 // Create incognito icon if necessary. |
| 111 UpdateAvatarInfo(); | 117 UpdateAvatarInfo(); |
| 112 | 118 |
| 113 // HeaderPainter handles layout. | 119 // HeaderPainter handles layout. |
| 114 if (UsePackagedAppHeaderStyle()) { | 120 if (UsePackagedAppHeaderStyle()) { |
| 115 ash::DefaultHeaderPainter* header_painter = new ash::DefaultHeaderPainter; | 121 ash::DefaultHeaderPainter* header_painter = new ash::DefaultHeaderPainter; |
| 116 header_painter_.reset(header_painter); | 122 header_painter_.reset(header_painter); |
| 117 header_painter->Init(frame(), this, window_icon_, | 123 header_painter->Init(frame(), this, window_icon_, |
| 118 caption_button_container_); | 124 caption_button_container_); |
| 125 } else if (UseWebAppHeaderStyle()) { | |
| 126 webapp_back_button_ = | |
| 127 new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_BACK); | |
| 128 UpdateBackButtonState(false); | |
|
pkotwicz
2014/08/06 21:36:48
The back button should be enabled by default. Othe
benwells
2014/08/13 00:53:45
Done.
| |
| 129 chrome::AddCommandObserver(browser_view()->browser(), IDC_BACK, this); | |
| 130 AddChildView(webapp_back_button_); | |
| 131 | |
| 132 WebAppHeaderPainterAsh* header_painter = new WebAppHeaderPainterAsh; | |
|
pkotwicz
2014/08/06 21:36:48
I would rather use DefaultHeaderPainter (as oppose
benwells
2014/08/11 07:06:15
Yeah there is currently little special logic. I'll
benwells
2014/08/13 00:53:45
Done.
| |
| 133 header_painter_.reset(header_painter); | |
| 134 header_painter->InitForWebApp(frame(), this, webapp_back_button_, | |
| 135 caption_button_container_); | |
| 119 } else { | 136 } else { |
| 120 BrowserHeaderPainterAsh* header_painter = new BrowserHeaderPainterAsh; | 137 BrowserHeaderPainterAsh* header_painter = new BrowserHeaderPainterAsh; |
| 121 header_painter_.reset(header_painter); | 138 header_painter_.reset(header_painter); |
| 122 header_painter->Init(frame(), browser_view(), this, window_icon_, | 139 header_painter->Init(frame(), browser_view(), this, window_icon_, |
| 123 caption_button_container_); | 140 caption_button_container_); |
| 124 } | 141 } |
| 125 } | 142 } |
| 126 | 143 |
| 127 /////////////////////////////////////////////////////////////////////////////// | 144 /////////////////////////////////////////////////////////////////////////////// |
| 128 // BrowserNonClientFrameView: | 145 // BrowserNonClientFrameView: |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 149 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) | 166 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) |
| 150 return 0; | 167 return 0; |
| 151 | 168 |
| 152 if (browser_view()->IsTabStripVisible()) { | 169 if (browser_view()->IsTabStripVisible()) { |
| 153 if (frame()->IsMaximized() || frame()->IsFullscreen()) | 170 if (frame()->IsMaximized() || frame()->IsFullscreen()) |
| 154 return kTabstripTopSpacingShort; | 171 return kTabstripTopSpacingShort; |
| 155 else | 172 else |
| 156 return kTabstripTopSpacingTall; | 173 return kTabstripTopSpacingTall; |
| 157 } | 174 } |
| 158 | 175 |
| 159 if (UsePackagedAppHeaderStyle()) | 176 if (UsePackagedAppHeaderStyle() || UseWebAppHeaderStyle()) |
| 160 return header_painter_->GetHeaderHeightForPainting(); | 177 return header_painter_->GetHeaderHeightForPainting(); |
| 161 | 178 |
| 162 int caption_buttons_bottom = caption_button_container_->bounds().bottom(); | 179 int caption_buttons_bottom = caption_button_container_->bounds().bottom(); |
| 163 | 180 |
| 164 // The toolbar partially overlaps the caption buttons. | 181 // The toolbar partially overlaps the caption buttons. |
| 165 if (browser_view()->IsToolbarVisible()) | 182 if (browser_view()->IsToolbarVisible()) |
| 166 return caption_buttons_bottom - kContentShadowHeight; | 183 return caption_buttons_bottom - kContentShadowHeight; |
| 167 | 184 |
| 168 return caption_buttons_bottom + kClientEdgeThickness; | 185 return caption_buttons_bottom + kClientEdgeThickness; |
| 169 } | 186 } |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 194 const gfx::Rect& client_bounds) const { | 211 const gfx::Rect& client_bounds) const { |
| 195 return client_bounds; | 212 return client_bounds; |
| 196 } | 213 } |
| 197 | 214 |
| 198 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { | 215 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { |
| 199 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, | 216 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, |
| 200 caption_button_container_, point); | 217 caption_button_container_, point); |
| 201 | 218 |
| 202 // See if the point is actually within the avatar menu button or within | 219 // See if the point is actually within the avatar menu button or within |
| 203 // the avatar label. | 220 // the avatar label. |
| 204 if (hit_test == HTCAPTION && ((avatar_button() && | 221 if (hit_test == HTCAPTION && ((avatar_button() && |
|
pkotwicz
2014/08/06 21:36:49
Nit: Something like this might be more readable.
benwells
2014/08/13 00:53:45
Done.
| |
| 205 avatar_button()->GetMirroredBounds().Contains(point)) || | 222 avatar_button()->GetMirroredBounds().Contains(point)) || |
| 206 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)))) | 223 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)))) |
| 207 return HTCLIENT; | 224 return HTCLIENT; |
| 208 | 225 |
| 226 if (hit_test == HTCAPTION && webapp_back_button_ && | |
| 227 webapp_back_button_->GetMirroredBounds().Contains(point)) | |
| 228 return HTCLIENT; | |
| 229 | |
| 209 // When the window is restored we want a large click target above the tabs | 230 // When the window is restored we want a large click target above the tabs |
| 210 // to drag the window, so redirect clicks in the tab's shadow to caption. | 231 // to drag the window, so redirect clicks in the tab's shadow to caption. |
| 211 if (hit_test == HTCLIENT && | 232 if (hit_test == HTCLIENT && |
| 212 !(frame()->IsMaximized() || frame()->IsFullscreen())) { | 233 !(frame()->IsMaximized() || frame()->IsFullscreen())) { |
| 213 // Convert point to client coordinates. | 234 // Convert point to client coordinates. |
| 214 gfx::Point client_point(point); | 235 gfx::Point client_point(point); |
| 215 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); | 236 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); |
| 216 // Report hits in shadow at top of tabstrip as caption. | 237 // Report hits in shadow at top of tabstrip as caption. |
| 217 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); | 238 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); |
| 218 if (client_point.y() < tabstrip_bounds.y() + kTabShadowHeight) | 239 if (client_point.y() < tabstrip_bounds.y() + kTabShadowHeight) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 | 272 |
| 252 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { | 273 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { |
| 253 if (!ShouldPaint()) | 274 if (!ShouldPaint()) |
| 254 return; | 275 return; |
| 255 | 276 |
| 256 if (UseImmersiveLightbarHeaderStyle()) { | 277 if (UseImmersiveLightbarHeaderStyle()) { |
| 257 PaintImmersiveLightbarStyleHeader(canvas); | 278 PaintImmersiveLightbarStyleHeader(canvas); |
| 258 return; | 279 return; |
| 259 } | 280 } |
| 260 | 281 |
| 261 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); | 282 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); |
|
pkotwicz
2014/08/06 21:36:48
To be consistent, you also need to change the |web
benwells
2014/08/13 00:53:45
Done.
| |
| 262 | 283 |
| 263 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? | 284 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? |
| 264 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; | 285 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; |
| 265 header_painter_->PaintHeader(canvas, header_mode); | 286 header_painter_->PaintHeader(canvas, header_mode); |
| 266 if (browser_view()->IsToolbarVisible()) | 287 if (browser_view()->IsToolbarVisible()) |
| 267 PaintToolbarBackground(canvas); | 288 PaintToolbarBackground(canvas); |
| 268 else if (!UsePackagedAppHeaderStyle()) | 289 else if (!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()) |
| 269 PaintContentEdge(canvas); | 290 PaintContentEdge(canvas); |
| 270 } | 291 } |
| 271 | 292 |
| 272 void BrowserNonClientFrameViewAsh::Layout() { | 293 void BrowserNonClientFrameViewAsh::Layout() { |
| 273 // The header must be laid out before computing |painted_height| because the | 294 // The header must be laid out before computing |painted_height| because the |
| 274 // computation of |painted_height| for app and popup windows depends on the | 295 // computation of |painted_height| for app and popup windows depends on the |
| 275 // position of the window controls. | 296 // position of the window controls. |
| 276 header_painter_->LayoutHeader(); | 297 header_painter_->LayoutHeader(); |
| 277 | 298 |
| 278 int painted_height = 0; | 299 int painted_height = 0; |
| 279 if (browser_view()->IsTabStripVisible()) { | 300 if (browser_view()->IsTabStripVisible()) { |
| 280 painted_height = GetTopInset() + | 301 painted_height = GetTopInset() + |
| 281 browser_view()->tabstrip()->GetPreferredSize().height(); | 302 browser_view()->tabstrip()->GetPreferredSize().height(); |
| 282 } else if (browser_view()->IsToolbarVisible()) { | 303 } else if (browser_view()->IsToolbarVisible()) { |
| 283 // Paint the header so that it overlaps with the top few pixels of the | 304 // Paint the header so that it overlaps with the top few pixels of the |
| 284 // toolbar because the top few pixels of the toolbar are not opaque. | 305 // toolbar because the top few pixels of the toolbar are not opaque. |
| 285 painted_height = GetTopInset() + kFrameShadowThickness * 2; | 306 painted_height = GetTopInset() + kFrameShadowThickness * 2; |
| 286 } else { | 307 } else { |
| 287 painted_height = GetTopInset(); | 308 painted_height = GetTopInset(); |
| 288 } | 309 } |
| 289 header_painter_->SetHeaderHeightForPainting(painted_height); | 310 header_painter_->SetHeaderHeightForPainting(painted_height); |
|
pkotwicz
2014/08/06 21:36:48
When both the multi-profile avatar and the back bu
benwells
2014/08/13 00:53:45
OK, I'm now taking this into account. It feels a b
| |
| 290 if (avatar_button()) | 311 if (avatar_button()) |
| 291 LayoutAvatar(); | 312 LayoutAvatar(); |
| 292 BrowserNonClientFrameView::Layout(); | 313 BrowserNonClientFrameView::Layout(); |
| 293 } | 314 } |
| 294 | 315 |
| 295 const char* BrowserNonClientFrameViewAsh::GetClassName() const { | 316 const char* BrowserNonClientFrameViewAsh::GetClassName() const { |
| 296 return kViewClassName; | 317 return kViewClassName; |
| 297 } | 318 } |
| 298 | 319 |
| 299 void BrowserNonClientFrameViewAsh::GetAccessibleState( | 320 void BrowserNonClientFrameViewAsh::GetAccessibleState( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 } | 377 } |
| 357 | 378 |
| 358 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { | 379 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { |
| 359 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 380 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
| 360 if (!delegate) | 381 if (!delegate) |
| 361 return gfx::ImageSkia(); | 382 return gfx::ImageSkia(); |
| 362 return delegate->GetWindowIcon(); | 383 return delegate->GetWindowIcon(); |
| 363 } | 384 } |
| 364 | 385 |
| 365 /////////////////////////////////////////////////////////////////////////////// | 386 /////////////////////////////////////////////////////////////////////////////// |
| 387 // CommandObserver: | |
| 388 | |
| 389 void BrowserNonClientFrameViewAsh::EnabledStateChangedForCommand(int id, | |
| 390 bool enabled) { | |
| 391 DCHECK_EQ(IDC_BACK, id); | |
| 392 UpdateBackButtonState(enabled); | |
| 393 } | |
| 394 | |
| 395 /////////////////////////////////////////////////////////////////////////////// | |
| 396 // views::ButtonListener: | |
| 397 | |
| 398 void BrowserNonClientFrameViewAsh::ButtonPressed(views::Button* sender, | |
| 399 const ui::Event& event) { | |
| 400 DCHECK_EQ(sender, webapp_back_button_); | |
| 401 chrome::ExecuteCommand(browser_view()->browser(), IDC_BACK); | |
| 402 } | |
| 403 | |
| 404 /////////////////////////////////////////////////////////////////////////////// | |
| 366 // BrowserNonClientFrameViewAsh, private: | 405 // BrowserNonClientFrameViewAsh, private: |
| 367 | 406 |
| 368 // views::NonClientFrameView: | 407 // views::NonClientFrameView: |
| 369 bool BrowserNonClientFrameViewAsh::DoesIntersectRect( | 408 bool BrowserNonClientFrameViewAsh::DoesIntersectRect( |
| 370 const views::View* target, | 409 const views::View* target, |
| 371 const gfx::Rect& rect) const { | 410 const gfx::Rect& rect) const { |
| 372 CHECK_EQ(target, this); | 411 CHECK_EQ(target, this); |
| 373 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { | 412 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { |
| 374 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. | 413 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. |
| 375 return false; | 414 return false; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 410 ImmersiveModeController* immersive_controller = | 449 ImmersiveModeController* immersive_controller = |
| 411 browser_view()->immersive_mode_controller(); | 450 browser_view()->immersive_mode_controller(); |
| 412 return immersive_controller->IsEnabled() && | 451 return immersive_controller->IsEnabled() && |
| 413 !immersive_controller->IsRevealed() && | 452 !immersive_controller->IsRevealed() && |
| 414 browser_view()->IsTabStripVisible(); | 453 browser_view()->IsTabStripVisible(); |
| 415 } | 454 } |
| 416 | 455 |
| 417 bool BrowserNonClientFrameViewAsh::UsePackagedAppHeaderStyle() const { | 456 bool BrowserNonClientFrameViewAsh::UsePackagedAppHeaderStyle() const { |
| 418 // Non streamlined hosted apps do not have a toolbar or tabstrip. Their header | 457 // Non streamlined hosted apps do not have a toolbar or tabstrip. Their header |
| 419 // should look the same as the header for packaged apps. Streamlined hosted | 458 // should look the same as the header for packaged apps. Streamlined hosted |
| 420 // apps have a toolbar so should use the browser header style. | 459 // apps have the experimental WebApp header style. |
|
pkotwicz
2014/08/06 21:36:48
Nit: Maybe change the return value to:
return brow
benwells
2014/08/13 00:53:45
Done.
| |
| 421 return browser_view()->browser()->is_app() && | 460 return browser_view()->browser()->is_app() && |
| 422 !CommandLine::ForCurrentProcess()->HasSwitch( | 461 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 423 switches::kEnableStreamlinedHostedApps); | 462 switches::kEnableStreamlinedHostedApps); |
| 424 } | 463 } |
| 425 | 464 |
| 465 bool BrowserNonClientFrameViewAsh::UseWebAppHeaderStyle() const { | |
| 466 // Use of the experimental WebApp header style is guarded with the | |
| 467 // streamlined hosted app style. | |
| 468 return browser_view()->browser()->is_app() && | |
| 469 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 470 switches::kEnableStreamlinedHostedApps); | |
| 471 } | |
| 472 | |
| 426 void BrowserNonClientFrameViewAsh::LayoutAvatar() { | 473 void BrowserNonClientFrameViewAsh::LayoutAvatar() { |
| 427 DCHECK(avatar_button()); | 474 DCHECK(avatar_button()); |
| 428 #if !defined(OS_CHROMEOS) | 475 #if !defined(OS_CHROMEOS) |
| 429 // ChromeOS shows avatar on V1 app. | 476 // ChromeOS shows avatar on V1 app. |
| 430 DCHECK(browser_view()->IsTabStripVisible()); | 477 DCHECK(browser_view()->IsTabStripVisible()); |
| 431 #endif | 478 #endif |
| 432 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); | 479 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); |
| 433 | 480 |
| 434 int avatar_bottom = GetTopInset() + | 481 int avatar_bottom = GetTopInset() + |
| 435 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; | 482 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing; |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 canvas->FillRect( | 590 canvas->FillRect( |
| 544 gfx::Rect(x + kClientEdgeThickness, | 591 gfx::Rect(x + kClientEdgeThickness, |
| 545 toolbar_bounds.bottom() - kClientEdgeThickness, | 592 toolbar_bounds.bottom() - kClientEdgeThickness, |
| 546 w - (2 * kClientEdgeThickness), | 593 w - (2 * kClientEdgeThickness), |
| 547 kClientEdgeThickness), | 594 kClientEdgeThickness), |
| 548 ThemeProperties::GetDefaultColor( | 595 ThemeProperties::GetDefaultColor( |
| 549 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 596 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 550 } | 597 } |
| 551 | 598 |
| 552 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { | 599 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { |
| 553 DCHECK(!UsePackagedAppHeaderStyle()); | 600 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); |
| 554 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), | 601 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), |
| 555 width(), kClientEdgeThickness), | 602 width(), kClientEdgeThickness), |
| 556 ThemeProperties::GetDefaultColor( | 603 ThemeProperties::GetDefaultColor( |
| 557 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 604 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 558 } | 605 } |
| 606 | |
| 607 void BrowserNonClientFrameViewAsh::UpdateBackButtonState(bool enabled) { | |
| 608 webapp_back_button_->SetState(enabled ? views::Button::STATE_NORMAL | |
| 609 : views::Button::STATE_DISABLED); | |
| 610 webapp_back_button_->set_paint_as_active(enabled); | |
| 611 } | |
| OLD | NEW |