| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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|. Converts |point| from |src| to |dst| and hit tests it against |dst|. |
| 77 bool ConvertedHitTest(views::View* src, |
| 78 views::View* dst, |
| 79 const gfx::Point& point) { |
| 80 DCHECK(src); |
| 81 DCHECK(dst); |
| 82 gfx::Point converted_point(point); |
| 83 views::View::ConvertPointToTarget(src, dst, &converted_point); |
| 84 return dst->HitTestPoint(converted_point); |
| 85 } |
| 86 |
| 72 } // namespace | 87 } // namespace |
| 73 | 88 |
| 74 /////////////////////////////////////////////////////////////////////////////// | 89 /////////////////////////////////////////////////////////////////////////////// |
| 75 // BrowserNonClientFrameViewAsh, public: | 90 // BrowserNonClientFrameViewAsh, public: |
| 76 | 91 |
| 77 // static | 92 // static |
| 78 const char BrowserNonClientFrameViewAsh::kViewClassName[] = | 93 const char BrowserNonClientFrameViewAsh::kViewClassName[] = |
| 79 "BrowserNonClientFrameViewAsh"; | 94 "BrowserNonClientFrameViewAsh"; |
| 80 | 95 |
| 81 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh( | 96 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh( |
| 82 BrowserFrame* frame, BrowserView* browser_view) | 97 BrowserFrame* frame, |
| 98 BrowserView* browser_view) |
| 83 : BrowserNonClientFrameView(frame, browser_view), | 99 : BrowserNonClientFrameView(frame, browser_view), |
| 84 caption_button_container_(NULL), | 100 caption_button_container_(NULL), |
| 101 web_app_back_button_(NULL), |
| 85 window_icon_(NULL), | 102 window_icon_(NULL), |
| 86 frame_border_hit_test_controller_( | 103 frame_border_hit_test_controller_( |
| 87 new ash::FrameBorderHitTestController(frame)) { | 104 new ash::FrameBorderHitTestController(frame)) { |
| 88 ash::Shell::GetInstance()->AddShellObserver(this); | 105 ash::Shell::GetInstance()->AddShellObserver(this); |
| 89 } | 106 } |
| 90 | 107 |
| 91 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() { | 108 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() { |
| 92 ash::Shell::GetInstance()->RemoveShellObserver(this); | 109 ash::Shell::GetInstance()->RemoveShellObserver(this); |
| 110 // browser_view() outlives the frame, as destruction of sibling views happens |
| 111 // in the same order as creation - see BrowserView::CreateBrowserWindow. |
| 112 chrome::RemoveCommandObserver(browser_view()->browser(), IDC_BACK, this); |
| 93 } | 113 } |
| 94 | 114 |
| 95 void BrowserNonClientFrameViewAsh::Init() { | 115 void BrowserNonClientFrameViewAsh::Init() { |
| 96 caption_button_container_ = new ash::FrameCaptionButtonContainerView(frame(), | 116 caption_button_container_ = new ash::FrameCaptionButtonContainerView(frame(), |
| 97 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); | 117 ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); |
| 98 caption_button_container_->UpdateSizeButtonVisibility(); | 118 caption_button_container_->UpdateSizeButtonVisibility(); |
| 99 AddChildView(caption_button_container_); | 119 AddChildView(caption_button_container_); |
| 100 | 120 |
| 101 // Initializing the TabIconView is expensive, so only do it if we need to. | 121 // Initializing the TabIconView is expensive, so only do it if we need to. |
| 102 if (browser_view()->ShouldShowWindowIcon()) { | 122 if (browser_view()->ShouldShowWindowIcon()) { |
| 103 window_icon_ = new TabIconView(this, NULL); | 123 window_icon_ = new TabIconView(this, NULL); |
| 104 window_icon_->set_is_light(true); | 124 window_icon_->set_is_light(true); |
| 105 AddChildView(window_icon_); | 125 AddChildView(window_icon_); |
| 106 window_icon_->Update(); | 126 window_icon_->Update(); |
| 107 } | 127 } |
| 108 | 128 |
| 109 // Create incognito icon if necessary. | 129 // Create incognito icon if necessary. |
| 110 UpdateAvatarInfo(); | 130 UpdateAvatarInfo(); |
| 111 | 131 |
| 112 // HeaderPainter handles layout. | 132 // HeaderPainter handles layout. |
| 113 if (UsePackagedAppHeaderStyle()) { | 133 if (UsePackagedAppHeaderStyle()) { |
| 114 ash::DefaultHeaderPainter* header_painter = new ash::DefaultHeaderPainter; | 134 ash::DefaultHeaderPainter* header_painter = new ash::DefaultHeaderPainter; |
| 115 header_painter_.reset(header_painter); | 135 header_painter_.reset(header_painter); |
| 116 header_painter->Init(frame(), this, window_icon_, | 136 header_painter->Init(frame(), this, caption_button_container_); |
| 117 caption_button_container_); | 137 if (window_icon_) { |
| 138 header_painter->UpdateLeftHeaderView(window_icon_); |
| 139 } |
| 140 } else if (UseWebAppHeaderStyle()) { |
| 141 web_app_back_button_ = |
| 142 new ash::FrameCaptionButton(this, ash::CAPTION_BUTTON_ICON_BACK); |
| 143 web_app_back_button_->SetImages(ash::CAPTION_BUTTON_ICON_BACK, |
| 144 ash::FrameCaptionButton::ANIMATE_NO, |
| 145 IDR_AURA_WINDOW_CONTROL_ICON_BACK, |
| 146 IDR_AURA_WINDOW_CONTROL_ICON_BACK_I, |
| 147 IDR_AURA_WINDOW_CONTROL_BACKGROUND_H, |
| 148 IDR_AURA_WINDOW_CONTROL_BACKGROUND_P); |
| 149 |
| 150 UpdateBackButtonState(true); |
| 151 chrome::AddCommandObserver(browser_view()->browser(), IDC_BACK, this); |
| 152 AddChildView(web_app_back_button_); |
| 153 |
| 154 ash::DefaultHeaderPainter* header_painter = new ash::DefaultHeaderPainter; |
| 155 header_painter_.reset(header_painter); |
| 156 header_painter->Init(frame(), this, caption_button_container_); |
| 157 header_painter->UpdateLeftHeaderView(web_app_back_button_); |
| 118 } else { | 158 } else { |
| 119 BrowserHeaderPainterAsh* header_painter = new BrowserHeaderPainterAsh; | 159 BrowserHeaderPainterAsh* header_painter = new BrowserHeaderPainterAsh; |
| 120 header_painter_.reset(header_painter); | 160 header_painter_.reset(header_painter); |
| 121 header_painter->Init(frame(), browser_view(), this, window_icon_, | 161 header_painter->Init(frame(), browser_view(), this, window_icon_, |
| 122 caption_button_container_); | 162 caption_button_container_); |
| 123 } | 163 } |
| 124 } | 164 } |
| 125 | 165 |
| 126 /////////////////////////////////////////////////////////////////////////////// | 166 /////////////////////////////////////////////////////////////////////////////// |
| 127 // BrowserNonClientFrameView: | 167 // BrowserNonClientFrameView: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 148 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) | 188 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) |
| 149 return 0; | 189 return 0; |
| 150 | 190 |
| 151 if (browser_view()->IsTabStripVisible()) { | 191 if (browser_view()->IsTabStripVisible()) { |
| 152 if (frame()->IsMaximized() || frame()->IsFullscreen()) | 192 if (frame()->IsMaximized() || frame()->IsFullscreen()) |
| 153 return kTabstripTopSpacingShort; | 193 return kTabstripTopSpacingShort; |
| 154 else | 194 else |
| 155 return kTabstripTopSpacingTall; | 195 return kTabstripTopSpacingTall; |
| 156 } | 196 } |
| 157 | 197 |
| 158 if (UsePackagedAppHeaderStyle()) | 198 if (UsePackagedAppHeaderStyle() || UseWebAppHeaderStyle()) |
| 159 return header_painter_->GetHeaderHeightForPainting(); | 199 return header_painter_->GetHeaderHeightForPainting(); |
| 160 | 200 |
| 161 int caption_buttons_bottom = caption_button_container_->bounds().bottom(); | 201 int caption_buttons_bottom = caption_button_container_->bounds().bottom(); |
| 162 | 202 |
| 163 // The toolbar partially overlaps the caption buttons. | 203 // The toolbar partially overlaps the caption buttons. |
| 164 if (browser_view()->IsToolbarVisible()) | 204 if (browser_view()->IsToolbarVisible()) |
| 165 return caption_buttons_bottom - kContentShadowHeight; | 205 return caption_buttons_bottom - kContentShadowHeight; |
| 166 | 206 |
| 167 return caption_buttons_bottom + kClientEdgeThickness; | 207 return caption_buttons_bottom + kClientEdgeThickness; |
| 168 } | 208 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 191 | 231 |
| 192 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds( | 232 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds( |
| 193 const gfx::Rect& client_bounds) const { | 233 const gfx::Rect& client_bounds) const { |
| 194 return client_bounds; | 234 return client_bounds; |
| 195 } | 235 } |
| 196 | 236 |
| 197 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { | 237 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { |
| 198 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, | 238 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, |
| 199 caption_button_container_, point); | 239 caption_button_container_, point); |
| 200 | 240 |
| 201 // See if the point is actually within the avatar menu button or within | 241 // See if the point is actually within the avatar menu button. |
| 202 // the avatar label. | 242 if (hit_test == HTCAPTION && avatar_button() && |
| 203 if (hit_test == HTCAPTION && ((avatar_button() && | 243 ConvertedHitTest(this, avatar_button(), point)) { |
| 204 avatar_button()->GetMirroredBounds().Contains(point)) || | 244 return HTCLIENT; |
| 205 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)))) | 245 } |
| 206 return HTCLIENT; | 246 |
| 247 // See if the point is actually within the web app back button. |
| 248 if (hit_test == HTCAPTION && web_app_back_button_ && |
| 249 ConvertedHitTest(this, web_app_back_button_, point)) { |
| 250 return HTCLIENT; |
| 251 } |
| 207 | 252 |
| 208 // When the window is restored we want a large click target above the tabs | 253 // 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. | 254 // to drag the window, so redirect clicks in the tab's shadow to caption. |
| 210 if (hit_test == HTCLIENT && | 255 if (hit_test == HTCLIENT && |
| 211 !(frame()->IsMaximized() || frame()->IsFullscreen())) { | 256 !(frame()->IsMaximized() || frame()->IsFullscreen())) { |
| 212 // Convert point to client coordinates. | 257 // Convert point to client coordinates. |
| 213 gfx::Point client_point(point); | 258 gfx::Point client_point(point); |
| 214 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); | 259 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); |
| 215 // Report hits in shadow at top of tabstrip as caption. | 260 // Report hits in shadow at top of tabstrip as caption. |
| 216 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); | 261 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { | 296 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { |
| 252 if (!ShouldPaint()) | 297 if (!ShouldPaint()) |
| 253 return; | 298 return; |
| 254 | 299 |
| 255 if (UseImmersiveLightbarHeaderStyle()) { | 300 if (UseImmersiveLightbarHeaderStyle()) { |
| 256 PaintImmersiveLightbarStyleHeader(canvas); | 301 PaintImmersiveLightbarStyleHeader(canvas); |
| 257 return; | 302 return; |
| 258 } | 303 } |
| 259 | 304 |
| 260 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); | 305 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); |
| 306 if (web_app_back_button_) { |
| 307 // TODO(benwells): Check that the disabled and inactive states should be |
| 308 // drawn in the same way. |
| 309 web_app_back_button_->set_paint_as_active( |
| 310 ShouldPaintAsActive() && |
| 311 chrome::IsCommandEnabled(browser_view()->browser(), IDC_BACK)); |
| 312 } |
| 261 | 313 |
| 262 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? | 314 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? |
| 263 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; | 315 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; |
| 264 header_painter_->PaintHeader(canvas, header_mode); | 316 header_painter_->PaintHeader(canvas, header_mode); |
| 265 if (browser_view()->IsToolbarVisible()) | 317 if (browser_view()->IsToolbarVisible()) |
| 266 PaintToolbarBackground(canvas); | 318 PaintToolbarBackground(canvas); |
| 267 else if (!UsePackagedAppHeaderStyle()) | 319 else if (!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()) |
| 268 PaintContentEdge(canvas); | 320 PaintContentEdge(canvas); |
| 269 } | 321 } |
| 270 | 322 |
| 271 void BrowserNonClientFrameViewAsh::Layout() { | 323 void BrowserNonClientFrameViewAsh::Layout() { |
| 272 // The header must be laid out before computing |painted_height| because the | 324 // 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 | 325 // computation of |painted_height| for app and popup windows depends on the |
| 274 // position of the window controls. | 326 // position of the window controls. |
| 275 header_painter_->LayoutHeader(); | 327 header_painter_->LayoutHeader(); |
| 276 | 328 |
| 277 int painted_height = 0; | 329 int painted_height = 0; |
| 278 if (browser_view()->IsTabStripVisible()) { | 330 if (browser_view()->IsTabStripVisible()) { |
| 279 painted_height = GetTopInset() + | 331 painted_height = GetTopInset() + |
| 280 browser_view()->tabstrip()->GetPreferredSize().height(); | 332 browser_view()->tabstrip()->GetPreferredSize().height(); |
| 281 } else if (browser_view()->IsToolbarVisible()) { | 333 } else if (browser_view()->IsToolbarVisible()) { |
| 282 // Paint the header so that it overlaps with the top few pixels of the | 334 // 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. | 335 // toolbar because the top few pixels of the toolbar are not opaque. |
| 284 painted_height = GetTopInset() + kFrameShadowThickness * 2; | 336 painted_height = GetTopInset() + kFrameShadowThickness * 2; |
| 285 } else { | 337 } else { |
| 286 painted_height = GetTopInset(); | 338 painted_height = GetTopInset(); |
| 287 } | 339 } |
| 288 header_painter_->SetHeaderHeightForPainting(painted_height); | 340 header_painter_->SetHeaderHeightForPainting(painted_height); |
| 289 if (avatar_button()) | 341 if (avatar_button()) { |
| 290 LayoutAvatar(); | 342 LayoutAvatar(); |
| 343 header_painter_->UpdateLeftViewXInset(avatar_button()->bounds().right()); |
| 344 } else { |
| 345 header_painter_->UpdateLeftViewXInset( |
| 346 ash::HeaderPainterUtil::GetDefaultLeftViewXInset()); |
| 347 } |
| 291 BrowserNonClientFrameView::Layout(); | 348 BrowserNonClientFrameView::Layout(); |
| 292 } | 349 } |
| 293 | 350 |
| 294 const char* BrowserNonClientFrameViewAsh::GetClassName() const { | 351 const char* BrowserNonClientFrameViewAsh::GetClassName() const { |
| 295 return kViewClassName; | 352 return kViewClassName; |
| 296 } | 353 } |
| 297 | 354 |
| 298 void BrowserNonClientFrameViewAsh::GetAccessibleState( | 355 void BrowserNonClientFrameViewAsh::GetAccessibleState( |
| 299 ui::AXViewState* state) { | 356 ui::AXViewState* state) { |
| 300 state->role = ui::AX_ROLE_TITLE_BAR; | 357 state->role = ui::AX_ROLE_TITLE_BAR; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 } | 412 } |
| 356 | 413 |
| 357 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { | 414 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { |
| 358 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 415 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
| 359 if (!delegate) | 416 if (!delegate) |
| 360 return gfx::ImageSkia(); | 417 return gfx::ImageSkia(); |
| 361 return delegate->GetWindowIcon(); | 418 return delegate->GetWindowIcon(); |
| 362 } | 419 } |
| 363 | 420 |
| 364 /////////////////////////////////////////////////////////////////////////////// | 421 /////////////////////////////////////////////////////////////////////////////// |
| 422 // CommandObserver: |
| 423 |
| 424 void BrowserNonClientFrameViewAsh::EnabledStateChangedForCommand(int id, |
| 425 bool enabled) { |
| 426 DCHECK_EQ(IDC_BACK, id); |
| 427 UpdateBackButtonState(enabled); |
| 428 } |
| 429 |
| 430 /////////////////////////////////////////////////////////////////////////////// |
| 431 // views::ButtonListener: |
| 432 |
| 433 void BrowserNonClientFrameViewAsh::ButtonPressed(views::Button* sender, |
| 434 const ui::Event& event) { |
| 435 DCHECK_EQ(sender, web_app_back_button_); |
| 436 chrome::ExecuteCommand(browser_view()->browser(), IDC_BACK); |
| 437 } |
| 438 |
| 439 /////////////////////////////////////////////////////////////////////////////// |
| 365 // BrowserNonClientFrameViewAsh, private: | 440 // BrowserNonClientFrameViewAsh, private: |
| 366 | 441 |
| 367 // views::NonClientFrameView: | 442 // views::NonClientFrameView: |
| 368 bool BrowserNonClientFrameViewAsh::DoesIntersectRect( | 443 bool BrowserNonClientFrameViewAsh::DoesIntersectRect( |
| 369 const views::View* target, | 444 const views::View* target, |
| 370 const gfx::Rect& rect) const { | 445 const gfx::Rect& rect) const { |
| 371 CHECK_EQ(target, this); | 446 CHECK_EQ(target, this); |
| 372 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { | 447 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { |
| 373 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. | 448 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. |
| 374 return false; | 449 return false; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 | 482 |
| 408 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const { | 483 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const { |
| 409 ImmersiveModeController* immersive_controller = | 484 ImmersiveModeController* immersive_controller = |
| 410 browser_view()->immersive_mode_controller(); | 485 browser_view()->immersive_mode_controller(); |
| 411 return immersive_controller->IsEnabled() && | 486 return immersive_controller->IsEnabled() && |
| 412 !immersive_controller->IsRevealed() && | 487 !immersive_controller->IsRevealed() && |
| 413 browser_view()->IsTabStripVisible(); | 488 browser_view()->IsTabStripVisible(); |
| 414 } | 489 } |
| 415 | 490 |
| 416 bool BrowserNonClientFrameViewAsh::UsePackagedAppHeaderStyle() const { | 491 bool BrowserNonClientFrameViewAsh::UsePackagedAppHeaderStyle() const { |
| 417 // Non streamlined hosted apps do not have a toolbar or tabstrip. Their header | 492 // 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 | 493 // style. |
| 419 // apps have a toolbar so should use the browser header style. | 494 return browser_view()->browser()->is_app() && !UseWebAppHeaderStyle(); |
| 495 } |
| 496 |
| 497 bool BrowserNonClientFrameViewAsh::UseWebAppHeaderStyle() const { |
| 498 // Use of the experimental WebApp header style is guarded with the |
| 499 // streamlined hosted app style. |
| 420 return browser_view()->browser()->is_app() && | 500 return browser_view()->browser()->is_app() && |
| 421 !CommandLine::ForCurrentProcess()->HasSwitch( | 501 CommandLine::ForCurrentProcess()->HasSwitch( |
| 422 switches::kEnableStreamlinedHostedApps); | 502 switches::kEnableStreamlinedHostedApps); |
| 423 } | 503 } |
| 424 | 504 |
| 425 void BrowserNonClientFrameViewAsh::LayoutAvatar() { | 505 void BrowserNonClientFrameViewAsh::LayoutAvatar() { |
| 426 DCHECK(avatar_button()); | 506 DCHECK(avatar_button()); |
| 427 #if !defined(OS_CHROMEOS) | 507 #if !defined(OS_CHROMEOS) |
| 428 // ChromeOS shows avatar on V1 app. | 508 // ChromeOS shows avatar on V1 app. |
| 429 DCHECK(browser_view()->IsTabStripVisible()); | 509 DCHECK(browser_view()->IsTabStripVisible()); |
| 430 #endif | 510 #endif |
| 431 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); | 511 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); |
| 432 | 512 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 canvas->FillRect( | 622 canvas->FillRect( |
| 543 gfx::Rect(x + kClientEdgeThickness, | 623 gfx::Rect(x + kClientEdgeThickness, |
| 544 toolbar_bounds.bottom() - kClientEdgeThickness, | 624 toolbar_bounds.bottom() - kClientEdgeThickness, |
| 545 w - (2 * kClientEdgeThickness), | 625 w - (2 * kClientEdgeThickness), |
| 546 kClientEdgeThickness), | 626 kClientEdgeThickness), |
| 547 ThemeProperties::GetDefaultColor( | 627 ThemeProperties::GetDefaultColor( |
| 548 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 628 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 549 } | 629 } |
| 550 | 630 |
| 551 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { | 631 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { |
| 552 DCHECK(!UsePackagedAppHeaderStyle()); | 632 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); |
| 553 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), | 633 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), |
| 554 width(), kClientEdgeThickness), | 634 width(), kClientEdgeThickness), |
| 555 ThemeProperties::GetDefaultColor( | 635 ThemeProperties::GetDefaultColor( |
| 556 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 636 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 557 } | 637 } |
| 638 |
| 639 void BrowserNonClientFrameViewAsh::UpdateBackButtonState(bool enabled) { |
| 640 web_app_back_button_->SetState(enabled ? views::Button::STATE_NORMAL |
| 641 : views::Button::STATE_DISABLED); |
| 642 } |
| OLD | NEW |