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" |
| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 // Space between top of window and top of tabstrip for tall headers, such as | 64 // Space between top of window and top of tabstrip for tall headers, such as |
| 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 |
|
pkotwicz
2014/08/13 01:19:47
I was thinking of something similar to ConvertedHi
benwells
2014/08/13 08:09:28
Done.
| |
| 75 bool PointIsWithinView(const views::View* view, const gfx::Point& point) { | |
| 76 return view && view->GetMirroredBounds().Contains(point); | |
| 77 } | |
| 78 | |
| 72 } // namespace | 79 } // namespace |
| 73 | 80 |
| 74 /////////////////////////////////////////////////////////////////////////////// | 81 /////////////////////////////////////////////////////////////////////////////// |
| 75 // BrowserNonClientFrameViewAsh, public: | 82 // BrowserNonClientFrameViewAsh, public: |
| 76 | 83 |
| 77 // static | 84 // static |
| 78 const char BrowserNonClientFrameViewAsh::kViewClassName[] = | 85 const char BrowserNonClientFrameViewAsh::kViewClassName[] = |
| 79 "BrowserNonClientFrameViewAsh"; | 86 "BrowserNonClientFrameViewAsh"; |
| 80 | 87 |
| 81 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh( | 88 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh( |
| 82 BrowserFrame* frame, BrowserView* browser_view) | 89 BrowserFrame* frame, |
| 90 BrowserView* browser_view) | |
| 83 : BrowserNonClientFrameView(frame, browser_view), | 91 : BrowserNonClientFrameView(frame, browser_view), |
| 84 caption_button_container_(NULL), | 92 caption_button_container_(NULL), |
| 93 web_app_back_button_(NULL), | |
| 85 window_icon_(NULL), | 94 window_icon_(NULL), |
| 86 frame_border_hit_test_controller_( | 95 frame_border_hit_test_controller_( |
| 87 new ash::FrameBorderHitTestController(frame)) { | 96 new ash::FrameBorderHitTestController(frame)) { |
| 88 ash::Shell::GetInstance()->AddShellObserver(this); | 97 ash::Shell::GetInstance()->AddShellObserver(this); |
| 89 } | 98 } |
| 90 | 99 |
| 91 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() { | 100 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() { |
| 92 ash::Shell::GetInstance()->RemoveShellObserver(this); | 101 ash::Shell::GetInstance()->RemoveShellObserver(this); |
| 102 chrome::RemoveCommandObserver(browser_view()->browser(), IDC_BACK, this); | |
| 93 } | 103 } |
| 94 | 104 |
| 95 void BrowserNonClientFrameViewAsh::Init() { | 105 void BrowserNonClientFrameViewAsh::Init() { |
| 96 caption_button_container_ = new ash::FrameCaptionButtonContainerView(frame(), | 106 caption_button_container_ = new ash::FrameCaptionButtonContainerView(frame(), |
| 97 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); | 107 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); |
| 98 caption_button_container_->UpdateSizeButtonVisibility(); | 108 caption_button_container_->UpdateSizeButtonVisibility(); |
| 99 AddChildView(caption_button_container_); | 109 AddChildView(caption_button_container_); |
| 100 | 110 |
| 101 // Initializing the TabIconView is expensive, so only do it if we need to. | 111 // Initializing the TabIconView is expensive, so only do it if we need to. |
| 102 if (browser_view()->ShouldShowWindowIcon()) { | 112 if (browser_view()->ShouldShowWindowIcon()) { |
| 103 window_icon_ = new TabIconView(this, NULL); | 113 window_icon_ = new TabIconView(this, NULL); |
| 104 window_icon_->set_is_light(true); | 114 window_icon_->set_is_light(true); |
| 105 AddChildView(window_icon_); | 115 AddChildView(window_icon_); |
| 106 window_icon_->Update(); | 116 window_icon_->Update(); |
| 107 } | 117 } |
| 108 | 118 |
| 109 // Create incognito icon if necessary. | 119 // Create incognito icon if necessary. |
| 110 UpdateAvatarInfo(); | 120 UpdateAvatarInfo(); |
| 111 | 121 |
| 112 // HeaderPainter handles layout. | 122 // HeaderPainter handles layout. |
| 113 if (UsePackagedAppHeaderStyle()) { | 123 if (UsePackagedAppHeaderStyle()) { |
| 114 ash::DefaultHeaderPainter* header_painter = new ash::DefaultHeaderPainter; | 124 ash::DefaultHeaderPainter* header_painter = new ash::DefaultHeaderPainter; |
| 115 header_painter_.reset(header_painter); | 125 header_painter_.reset(header_painter); |
| 116 header_painter->Init(frame(), this, window_icon_, | 126 header_painter->Init(frame(), this, caption_button_container_); |
| 117 caption_button_container_); | 127 if (window_icon_) { |
| 128 header_painter->UpdateLeftHeaderView( | |
| 129 window_icon_, ash::HeaderPainterUtil::GetDefaultIconSize()); | |
| 130 } | |
| 131 } else if (UseWebAppHeaderStyle()) { | |
| 132 web_app_back_button_ = | |
| 133 new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_BACK); | |
| 134 web_app_back_button_->SetImages(ash::CAPTION_BUTTON_ICON_BACK, | |
| 135 ash::FrameCaptionButton::ANIMATE_NO, | |
| 136 IDR_AURA_WINDOW_CONTROL_ICON_BACK, | |
| 137 IDR_AURA_WINDOW_CONTROL_ICON_BACK_I, | |
| 138 IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, | |
| 139 IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); | |
| 140 | |
| 141 UpdateBackButtonState(true); | |
| 142 chrome::AddCommandObserver(browser_view()->browser(), IDC_BACK, this); | |
| 143 AddChildView(web_app_back_button_); | |
| 144 | |
| 145 ash::DefaultHeaderPainter* header_painter = new ash::DefaultHeaderPainter; | |
| 146 header_painter_.reset(header_painter); | |
| 147 header_painter->Init(frame(), this, caption_button_container_); | |
| 148 header_painter->UpdateLeftHeaderView( | |
| 149 web_app_back_button_, | |
| 150 caption_button_container_->GetPreferredSize().height()); | |
| 118 } else { | 151 } else { |
| 119 BrowserHeaderPainterAsh* header_painter = new BrowserHeaderPainterAsh; | 152 BrowserHeaderPainterAsh* header_painter = new BrowserHeaderPainterAsh; |
| 120 header_painter_.reset(header_painter); | 153 header_painter_.reset(header_painter); |
| 121 header_painter->Init(frame(), browser_view(), this, window_icon_, | 154 header_painter->Init(frame(), browser_view(), this, window_icon_, |
| 122 caption_button_container_); | 155 caption_button_container_); |
| 123 } | 156 } |
| 124 } | 157 } |
| 125 | 158 |
| 126 /////////////////////////////////////////////////////////////////////////////// | 159 /////////////////////////////////////////////////////////////////////////////// |
| 127 // BrowserNonClientFrameView: | 160 // BrowserNonClientFrameView: |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 148 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) | 181 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) |
| 149 return 0; | 182 return 0; |
| 150 | 183 |
| 151 if (browser_view()->IsTabStripVisible()) { | 184 if (browser_view()->IsTabStripVisible()) { |
| 152 if (frame()->IsMaximized() || frame()->IsFullscreen()) | 185 if (frame()->IsMaximized() || frame()->IsFullscreen()) |
| 153 return kTabstripTopSpacingShort; | 186 return kTabstripTopSpacingShort; |
| 154 else | 187 else |
| 155 return kTabstripTopSpacingTall; | 188 return kTabstripTopSpacingTall; |
| 156 } | 189 } |
| 157 | 190 |
| 158 if (UsePackagedAppHeaderStyle()) | 191 if (UsePackagedAppHeaderStyle() || UseWebAppHeaderStyle()) |
| 159 return header_painter_->GetHeaderHeightForPainting(); | 192 return header_painter_->GetHeaderHeightForPainting(); |
| 160 | 193 |
| 161 int caption_buttons_bottom = caption_button_container_->bounds().bottom(); | 194 int caption_buttons_bottom = caption_button_container_->bounds().bottom(); |
| 162 | 195 |
| 163 // The toolbar partially overlaps the caption buttons. | 196 // The toolbar partially overlaps the caption buttons. |
| 164 if (browser_view()->IsToolbarVisible()) | 197 if (browser_view()->IsToolbarVisible()) |
| 165 return caption_buttons_bottom - kContentShadowHeight; | 198 return caption_buttons_bottom - kContentShadowHeight; |
| 166 | 199 |
| 167 return caption_buttons_bottom + kClientEdgeThickness; | 200 return caption_buttons_bottom + kClientEdgeThickness; |
| 168 } | 201 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 192 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds( | 225 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds( |
| 193 const gfx::Rect& client_bounds) const { | 226 const gfx::Rect& client_bounds) const { |
| 194 return client_bounds; | 227 return client_bounds; |
| 195 } | 228 } |
| 196 | 229 |
| 197 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { | 230 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { |
| 198 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, | 231 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, |
| 199 caption_button_container_, point); | 232 caption_button_container_, point); |
| 200 | 233 |
| 201 // See if the point is actually within the avatar menu button or within | 234 // See if the point is actually within the avatar menu button or within |
| 202 // the avatar label. | 235 // the web app back button. |
| 203 if (hit_test == HTCAPTION && ((avatar_button() && | 236 if (hit_test == HTCAPTION && (PointIsWithinView(avatar_button(), point) || |
| 204 avatar_button()->GetMirroredBounds().Contains(point)) || | 237 PointIsWithinView(web_app_back_button_, point))) |
| 205 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)))) | |
| 206 return HTCLIENT; | 238 return HTCLIENT; |
| 207 | 239 |
| 208 // When the window is restored we want a large click target above the tabs | 240 // 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. | 241 // to drag the window, so redirect clicks in the tab's shadow to caption. |
| 210 if (hit_test == HTCLIENT && | 242 if (hit_test == HTCLIENT && |
| 211 !(frame()->IsMaximized() || frame()->IsFullscreen())) { | 243 !(frame()->IsMaximized() || frame()->IsFullscreen())) { |
| 212 // Convert point to client coordinates. | 244 // Convert point to client coordinates. |
| 213 gfx::Point client_point(point); | 245 gfx::Point client_point(point); |
| 214 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); | 246 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); |
| 215 // Report hits in shadow at top of tabstrip as caption. | 247 // Report hits in shadow at top of tabstrip as caption. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { | 283 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { |
| 252 if (!ShouldPaint()) | 284 if (!ShouldPaint()) |
| 253 return; | 285 return; |
| 254 | 286 |
| 255 if (UseImmersiveLightbarHeaderStyle()) { | 287 if (UseImmersiveLightbarHeaderStyle()) { |
| 256 PaintImmersiveLightbarStyleHeader(canvas); | 288 PaintImmersiveLightbarStyleHeader(canvas); |
| 257 return; | 289 return; |
| 258 } | 290 } |
| 259 | 291 |
| 260 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); | 292 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); |
| 293 if (web_app_back_button_) { | |
| 294 web_app_back_button_->set_paint_as_active( | |
| 295 ShouldPaintAsActive() && | |
| 296 chrome::IsCommandEnabled(browser_view()->browser(), IDC_BACK)); | |
| 297 } | |
| 261 | 298 |
| 262 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? | 299 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? |
| 263 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; | 300 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; |
| 264 header_painter_->PaintHeader(canvas, header_mode); | 301 header_painter_->PaintHeader(canvas, header_mode); |
| 265 if (browser_view()->IsToolbarVisible()) | 302 if (browser_view()->IsToolbarVisible()) |
| 266 PaintToolbarBackground(canvas); | 303 PaintToolbarBackground(canvas); |
| 267 else if (!UsePackagedAppHeaderStyle()) | 304 else if (!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()) |
| 268 PaintContentEdge(canvas); | 305 PaintContentEdge(canvas); |
| 269 } | 306 } |
| 270 | 307 |
| 271 void BrowserNonClientFrameViewAsh::Layout() { | 308 void BrowserNonClientFrameViewAsh::Layout() { |
| 272 // The header must be laid out before computing |painted_height| because the | 309 // 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 | 310 // computation of |painted_height| for app and popup windows depends on the |
| 274 // position of the window controls. | 311 // position of the window controls. |
| 275 header_painter_->LayoutHeader(); | 312 header_painter_->LayoutHeader(); |
| 276 | 313 |
| 277 int painted_height = 0; | 314 int painted_height = 0; |
| 278 if (browser_view()->IsTabStripVisible()) { | 315 if (browser_view()->IsTabStripVisible()) { |
| 279 painted_height = GetTopInset() + | 316 painted_height = GetTopInset() + |
| 280 browser_view()->tabstrip()->GetPreferredSize().height(); | 317 browser_view()->tabstrip()->GetPreferredSize().height(); |
| 281 } else if (browser_view()->IsToolbarVisible()) { | 318 } else if (browser_view()->IsToolbarVisible()) { |
| 282 // Paint the header so that it overlaps with the top few pixels of the | 319 // 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. | 320 // toolbar because the top few pixels of the toolbar are not opaque. |
| 284 painted_height = GetTopInset() + kFrameShadowThickness * 2; | 321 painted_height = GetTopInset() + kFrameShadowThickness * 2; |
| 285 } else { | 322 } else { |
| 286 painted_height = GetTopInset(); | 323 painted_height = GetTopInset(); |
| 287 } | 324 } |
| 288 header_painter_->SetHeaderHeightForPainting(painted_height); | 325 header_painter_->SetHeaderHeightForPainting(painted_height); |
| 289 if (avatar_button()) | 326 if (avatar_button()) { |
| 290 LayoutAvatar(); | 327 LayoutAvatar(); |
| 328 header_painter_->UpdateHeaderOffset(avatar_button()->bounds().x() + | |
| 329 avatar_button()->bounds().width()); | |
| 330 } else { | |
| 331 header_painter_->UpdateHeaderOffset(0); | |
| 332 } | |
| 291 BrowserNonClientFrameView::Layout(); | 333 BrowserNonClientFrameView::Layout(); |
| 292 } | 334 } |
| 293 | 335 |
| 294 const char* BrowserNonClientFrameViewAsh::GetClassName() const { | 336 const char* BrowserNonClientFrameViewAsh::GetClassName() const { |
| 295 return kViewClassName; | 337 return kViewClassName; |
| 296 } | 338 } |
| 297 | 339 |
| 298 void BrowserNonClientFrameViewAsh::GetAccessibleState( | 340 void BrowserNonClientFrameViewAsh::GetAccessibleState( |
| 299 ui::AXViewState* state) { | 341 ui::AXViewState* state) { |
| 300 state->role = ui::AX_ROLE_TITLE_BAR; | 342 state->role = ui::AX_ROLE_TITLE_BAR; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 } | 397 } |
| 356 | 398 |
| 357 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { | 399 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { |
| 358 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 400 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
| 359 if (!delegate) | 401 if (!delegate) |
| 360 return gfx::ImageSkia(); | 402 return gfx::ImageSkia(); |
| 361 return delegate->GetWindowIcon(); | 403 return delegate->GetWindowIcon(); |
| 362 } | 404 } |
| 363 | 405 |
| 364 /////////////////////////////////////////////////////////////////////////////// | 406 /////////////////////////////////////////////////////////////////////////////// |
| 407 // CommandObserver: | |
| 408 | |
| 409 void BrowserNonClientFrameViewAsh::EnabledStateChangedForCommand(int id, | |
| 410 bool enabled) { | |
| 411 DCHECK_EQ(IDC_BACK, id); | |
| 412 UpdateBackButtonState(enabled); | |
| 413 } | |
| 414 | |
| 415 /////////////////////////////////////////////////////////////////////////////// | |
| 416 // views::ButtonListener: | |
| 417 | |
| 418 void BrowserNonClientFrameViewAsh::ButtonPressed(views::Button* sender, | |
| 419 const ui::Event& event) { | |
| 420 DCHECK_EQ(sender, web_app_back_button_); | |
| 421 chrome::ExecuteCommand(browser_view()->browser(), IDC_BACK); | |
| 422 } | |
| 423 | |
| 424 /////////////////////////////////////////////////////////////////////////////// | |
| 365 // BrowserNonClientFrameViewAsh, private: | 425 // BrowserNonClientFrameViewAsh, private: |
| 366 | 426 |
| 367 // views::NonClientFrameView: | 427 // views::NonClientFrameView: |
| 368 bool BrowserNonClientFrameViewAsh::DoesIntersectRect( | 428 bool BrowserNonClientFrameViewAsh::DoesIntersectRect( |
| 369 const views::View* target, | 429 const views::View* target, |
| 370 const gfx::Rect& rect) const { | 430 const gfx::Rect& rect) const { |
| 371 CHECK_EQ(target, this); | 431 CHECK_EQ(target, this); |
| 372 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { | 432 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { |
| 373 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. | 433 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. |
| 374 return false; | 434 return false; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 | 467 |
| 408 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const { | 468 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const { |
| 409 ImmersiveModeController* immersive_controller = | 469 ImmersiveModeController* immersive_controller = |
| 410 browser_view()->immersive_mode_controller(); | 470 browser_view()->immersive_mode_controller(); |
| 411 return immersive_controller->IsEnabled() && | 471 return immersive_controller->IsEnabled() && |
| 412 !immersive_controller->IsRevealed() && | 472 !immersive_controller->IsRevealed() && |
| 413 browser_view()->IsTabStripVisible(); | 473 browser_view()->IsTabStripVisible(); |
| 414 } | 474 } |
| 415 | 475 |
| 416 bool BrowserNonClientFrameViewAsh::UsePackagedAppHeaderStyle() const { | 476 bool BrowserNonClientFrameViewAsh::UsePackagedAppHeaderStyle() const { |
| 417 // Non streamlined hosted apps do not have a toolbar or tabstrip. Their header | 477 // 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 | 478 // style. |
| 419 // apps have a toolbar so should use the browser header style. | 479 return browser_view()->browser()->is_app() && !UseWebAppHeaderStyle(); |
| 480 } | |
| 481 | |
| 482 bool BrowserNonClientFrameViewAsh::UseWebAppHeaderStyle() const { | |
| 483 // Use of the experimental WebApp header style is guarded with the | |
| 484 // streamlined hosted app style. | |
| 420 return browser_view()->browser()->is_app() && | 485 return browser_view()->browser()->is_app() && |
| 421 !CommandLine::ForCurrentProcess()->HasSwitch( | 486 CommandLine::ForCurrentProcess()->HasSwitch( |
| 422 switches::kEnableStreamlinedHostedApps); | 487 switches::kEnableStreamlinedHostedApps); |
| 423 } | 488 } |
| 424 | 489 |
| 425 void BrowserNonClientFrameViewAsh::LayoutAvatar() { | 490 void BrowserNonClientFrameViewAsh::LayoutAvatar() { |
| 426 DCHECK(avatar_button()); | 491 DCHECK(avatar_button()); |
| 427 #if !defined(OS_CHROMEOS) | 492 #if !defined(OS_CHROMEOS) |
| 428 // ChromeOS shows avatar on V1 app. | 493 // ChromeOS shows avatar on V1 app. |
| 429 DCHECK(browser_view()->IsTabStripVisible()); | 494 DCHECK(browser_view()->IsTabStripVisible()); |
| 430 #endif | 495 #endif |
| 431 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); | 496 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); |
| 432 | 497 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 canvas->FillRect( | 607 canvas->FillRect( |
| 543 gfx::Rect(x + kClientEdgeThickness, | 608 gfx::Rect(x + kClientEdgeThickness, |
| 544 toolbar_bounds.bottom() - kClientEdgeThickness, | 609 toolbar_bounds.bottom() - kClientEdgeThickness, |
| 545 w - (2 * kClientEdgeThickness), | 610 w - (2 * kClientEdgeThickness), |
| 546 kClientEdgeThickness), | 611 kClientEdgeThickness), |
| 547 ThemeProperties::GetDefaultColor( | 612 ThemeProperties::GetDefaultColor( |
| 548 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 613 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 549 } | 614 } |
| 550 | 615 |
| 551 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { | 616 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { |
| 552 DCHECK(!UsePackagedAppHeaderStyle()); | 617 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); |
| 553 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), | 618 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), |
| 554 width(), kClientEdgeThickness), | 619 width(), kClientEdgeThickness), |
| 555 ThemeProperties::GetDefaultColor( | 620 ThemeProperties::GetDefaultColor( |
| 556 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 621 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 557 } | 622 } |
| 623 | |
| 624 void BrowserNonClientFrameViewAsh::UpdateBackButtonState(bool enabled) { | |
| 625 web_app_back_button_->SetState(enabled ? views::Button::STATE_NORMAL | |
| 626 : views::Button::STATE_DISABLED); | |
| 627 web_app_back_button_->set_paint_as_active(enabled); | |
| 628 } | |
| OLD | NEW |