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 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 |point|. | |
|
pkotwicz
2014/08/14 01:59:44
Nit: "View::ConvertPointToTarget() and View::HitTe
benwells
2014/08/14 04:42:50
Done.
| |
| 76 // 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 if (!dst) | |
| 81 return false; | |
| 82 | |
| 83 DCHECK(src); | |
| 84 gfx::Point converted_point(point); | |
| 85 views::View::ConvertPointToTarget(src, dst, &converted_point); | |
| 86 return dst->HitTestPoint(converted_point); | |
| 87 } | |
| 88 | |
| 72 } // namespace | 89 } // namespace |
| 73 | 90 |
| 74 /////////////////////////////////////////////////////////////////////////////// | 91 /////////////////////////////////////////////////////////////////////////////// |
| 75 // BrowserNonClientFrameViewAsh, public: | 92 // BrowserNonClientFrameViewAsh, public: |
| 76 | 93 |
| 77 // static | 94 // static |
| 78 const char BrowserNonClientFrameViewAsh::kViewClassName[] = | 95 const char BrowserNonClientFrameViewAsh::kViewClassName[] = |
| 79 "BrowserNonClientFrameViewAsh"; | 96 "BrowserNonClientFrameViewAsh"; |
| 80 | 97 |
| 81 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh( | 98 BrowserNonClientFrameViewAsh::BrowserNonClientFrameViewAsh( |
| 82 BrowserFrame* frame, BrowserView* browser_view) | 99 BrowserFrame* frame, |
| 100 BrowserView* browser_view) | |
| 83 : BrowserNonClientFrameView(frame, browser_view), | 101 : BrowserNonClientFrameView(frame, browser_view), |
| 84 caption_button_container_(NULL), | 102 caption_button_container_(NULL), |
| 103 web_app_back_button_(NULL), | |
| 85 window_icon_(NULL), | 104 window_icon_(NULL), |
| 86 frame_border_hit_test_controller_( | 105 frame_border_hit_test_controller_( |
| 87 new ash::FrameBorderHitTestController(frame)) { | 106 new ash::FrameBorderHitTestController(frame)) { |
| 88 ash::Shell::GetInstance()->AddShellObserver(this); | 107 ash::Shell::GetInstance()->AddShellObserver(this); |
| 89 } | 108 } |
| 90 | 109 |
| 91 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() { | 110 BrowserNonClientFrameViewAsh::~BrowserNonClientFrameViewAsh() { |
| 92 ash::Shell::GetInstance()->RemoveShellObserver(this); | 111 ash::Shell::GetInstance()->RemoveShellObserver(this); |
| 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 23 matching lines...) Expand all Loading... | |
| 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 or within |
| 202 // the avatar label. | 242 // the web app back button. |
| 203 if (hit_test == HTCAPTION && ((avatar_button() && | 243 if (hit_test == HTCAPTION && |
| 204 avatar_button()->GetMirroredBounds().Contains(point)) || | 244 (ConvertedHitTest(this, avatar_button(), point) || |
| 205 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)))) | 245 ConvertedHitTest(this, web_app_back_button_, point))) |
|
pkotwicz
2014/08/14 01:59:44
Nit: I like braces with multi-line if statements
benwells
2014/08/14 04:42:50
Done.
| |
| 206 return HTCLIENT; | 246 return HTCLIENT; |
| 207 | 247 |
| 208 // When the window is restored we want a large click target above the tabs | 248 // 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. | 249 // to drag the window, so redirect clicks in the tab's shadow to caption. |
| 210 if (hit_test == HTCLIENT && | 250 if (hit_test == HTCLIENT && |
| 211 !(frame()->IsMaximized() || frame()->IsFullscreen())) { | 251 !(frame()->IsMaximized() || frame()->IsFullscreen())) { |
| 212 // Convert point to client coordinates. | 252 // Convert point to client coordinates. |
| 213 gfx::Point client_point(point); | 253 gfx::Point client_point(point); |
| 214 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); | 254 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); |
| 215 // Report hits in shadow at top of tabstrip as caption. | 255 // 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) { | 291 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { |
| 252 if (!ShouldPaint()) | 292 if (!ShouldPaint()) |
| 253 return; | 293 return; |
| 254 | 294 |
| 255 if (UseImmersiveLightbarHeaderStyle()) { | 295 if (UseImmersiveLightbarHeaderStyle()) { |
| 256 PaintImmersiveLightbarStyleHeader(canvas); | 296 PaintImmersiveLightbarStyleHeader(canvas); |
| 257 return; | 297 return; |
| 258 } | 298 } |
| 259 | 299 |
| 260 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); | 300 caption_button_container_->SetPaintAsActive(ShouldPaintAsActive()); |
| 301 if (web_app_back_button_) { | |
| 302 // TODO(benwells): Check that the disabled and inactive states should be | |
| 303 // drawn in the same way. | |
| 304 web_app_back_button_->set_paint_as_active( | |
| 305 ShouldPaintAsActive() && | |
| 306 chrome::IsCommandEnabled(browser_view()->browser(), IDC_BACK)); | |
| 307 } | |
| 261 | 308 |
| 262 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? | 309 ash::HeaderPainter::Mode header_mode = ShouldPaintAsActive() ? |
| 263 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; | 310 ash::HeaderPainter::MODE_ACTIVE : ash::HeaderPainter::MODE_INACTIVE; |
| 264 header_painter_->PaintHeader(canvas, header_mode); | 311 header_painter_->PaintHeader(canvas, header_mode); |
| 265 if (browser_view()->IsToolbarVisible()) | 312 if (browser_view()->IsToolbarVisible()) |
| 266 PaintToolbarBackground(canvas); | 313 PaintToolbarBackground(canvas); |
| 267 else if (!UsePackagedAppHeaderStyle()) | 314 else if (!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()) |
| 268 PaintContentEdge(canvas); | 315 PaintContentEdge(canvas); |
| 269 } | 316 } |
| 270 | 317 |
| 271 void BrowserNonClientFrameViewAsh::Layout() { | 318 void BrowserNonClientFrameViewAsh::Layout() { |
| 272 // The header must be laid out before computing |painted_height| because the | 319 // 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 | 320 // computation of |painted_height| for app and popup windows depends on the |
| 274 // position of the window controls. | 321 // position of the window controls. |
| 275 header_painter_->LayoutHeader(); | 322 header_painter_->LayoutHeader(); |
| 276 | 323 |
| 277 int painted_height = 0; | 324 int painted_height = 0; |
| 278 if (browser_view()->IsTabStripVisible()) { | 325 if (browser_view()->IsTabStripVisible()) { |
| 279 painted_height = GetTopInset() + | 326 painted_height = GetTopInset() + |
| 280 browser_view()->tabstrip()->GetPreferredSize().height(); | 327 browser_view()->tabstrip()->GetPreferredSize().height(); |
| 281 } else if (browser_view()->IsToolbarVisible()) { | 328 } else if (browser_view()->IsToolbarVisible()) { |
| 282 // Paint the header so that it overlaps with the top few pixels of the | 329 // 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. | 330 // toolbar because the top few pixels of the toolbar are not opaque. |
| 284 painted_height = GetTopInset() + kFrameShadowThickness * 2; | 331 painted_height = GetTopInset() + kFrameShadowThickness * 2; |
| 285 } else { | 332 } else { |
| 286 painted_height = GetTopInset(); | 333 painted_height = GetTopInset(); |
| 287 } | 334 } |
| 288 header_painter_->SetHeaderHeightForPainting(painted_height); | 335 header_painter_->SetHeaderHeightForPainting(painted_height); |
| 289 if (avatar_button()) | 336 if (avatar_button()) { |
| 290 LayoutAvatar(); | 337 LayoutAvatar(); |
| 338 header_painter_->UpdateLeftViewXInset(avatar_button()->bounds().x() + | |
| 339 avatar_button()->bounds().width()); | |
|
pkotwicz
2014/08/14 01:59:44
Nit: bounds().right()
benwells
2014/08/14 04:42:50
Done.
| |
| 340 } else { | |
| 341 header_painter_->UpdateLeftViewXInset(0); | |
|
pkotwicz
2014/08/14 01:59:44
I think it would be more readable if we passed in
benwells
2014/08/14 04:42:50
Done.
| |
| 342 } | |
| 291 BrowserNonClientFrameView::Layout(); | 343 BrowserNonClientFrameView::Layout(); |
| 292 } | 344 } |
| 293 | 345 |
| 294 const char* BrowserNonClientFrameViewAsh::GetClassName() const { | 346 const char* BrowserNonClientFrameViewAsh::GetClassName() const { |
| 295 return kViewClassName; | 347 return kViewClassName; |
| 296 } | 348 } |
| 297 | 349 |
| 298 void BrowserNonClientFrameViewAsh::GetAccessibleState( | 350 void BrowserNonClientFrameViewAsh::GetAccessibleState( |
| 299 ui::AXViewState* state) { | 351 ui::AXViewState* state) { |
| 300 state->role = ui::AX_ROLE_TITLE_BAR; | 352 state->role = ui::AX_ROLE_TITLE_BAR; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 } | 407 } |
| 356 | 408 |
| 357 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { | 409 gfx::ImageSkia BrowserNonClientFrameViewAsh::GetFaviconForTabIconView() { |
| 358 views::WidgetDelegate* delegate = frame()->widget_delegate(); | 410 views::WidgetDelegate* delegate = frame()->widget_delegate(); |
| 359 if (!delegate) | 411 if (!delegate) |
| 360 return gfx::ImageSkia(); | 412 return gfx::ImageSkia(); |
| 361 return delegate->GetWindowIcon(); | 413 return delegate->GetWindowIcon(); |
| 362 } | 414 } |
| 363 | 415 |
| 364 /////////////////////////////////////////////////////////////////////////////// | 416 /////////////////////////////////////////////////////////////////////////////// |
| 417 // CommandObserver: | |
| 418 | |
| 419 void BrowserNonClientFrameViewAsh::EnabledStateChangedForCommand(int id, | |
| 420 bool enabled) { | |
| 421 DCHECK_EQ(IDC_BACK, id); | |
| 422 UpdateBackButtonState(enabled); | |
| 423 } | |
| 424 | |
| 425 /////////////////////////////////////////////////////////////////////////////// | |
| 426 // views::ButtonListener: | |
| 427 | |
| 428 void BrowserNonClientFrameViewAsh::ButtonPressed(views::Button* sender, | |
| 429 const ui::Event& event) { | |
| 430 DCHECK_EQ(sender, web_app_back_button_); | |
| 431 chrome::ExecuteCommand(browser_view()->browser(), IDC_BACK); | |
| 432 } | |
| 433 | |
| 434 /////////////////////////////////////////////////////////////////////////////// | |
| 365 // BrowserNonClientFrameViewAsh, private: | 435 // BrowserNonClientFrameViewAsh, private: |
| 366 | 436 |
| 367 // views::NonClientFrameView: | 437 // views::NonClientFrameView: |
| 368 bool BrowserNonClientFrameViewAsh::DoesIntersectRect( | 438 bool BrowserNonClientFrameViewAsh::DoesIntersectRect( |
| 369 const views::View* target, | 439 const views::View* target, |
| 370 const gfx::Rect& rect) const { | 440 const gfx::Rect& rect) const { |
| 371 CHECK_EQ(target, this); | 441 CHECK_EQ(target, this); |
| 372 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { | 442 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { |
| 373 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. | 443 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. |
| 374 return false; | 444 return false; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 | 477 |
| 408 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const { | 478 bool BrowserNonClientFrameViewAsh::UseImmersiveLightbarHeaderStyle() const { |
| 409 ImmersiveModeController* immersive_controller = | 479 ImmersiveModeController* immersive_controller = |
| 410 browser_view()->immersive_mode_controller(); | 480 browser_view()->immersive_mode_controller(); |
| 411 return immersive_controller->IsEnabled() && | 481 return immersive_controller->IsEnabled() && |
| 412 !immersive_controller->IsRevealed() && | 482 !immersive_controller->IsRevealed() && |
| 413 browser_view()->IsTabStripVisible(); | 483 browser_view()->IsTabStripVisible(); |
| 414 } | 484 } |
| 415 | 485 |
| 416 bool BrowserNonClientFrameViewAsh::UsePackagedAppHeaderStyle() const { | 486 bool BrowserNonClientFrameViewAsh::UsePackagedAppHeaderStyle() const { |
| 417 // Non streamlined hosted apps do not have a toolbar or tabstrip. Their header | 487 // 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 | 488 // style. |
| 419 // apps have a toolbar so should use the browser header style. | 489 return browser_view()->browser()->is_app() && !UseWebAppHeaderStyle(); |
| 490 } | |
| 491 | |
| 492 bool BrowserNonClientFrameViewAsh::UseWebAppHeaderStyle() const { | |
| 493 // Use of the experimental WebApp header style is guarded with the | |
| 494 // streamlined hosted app style. | |
| 420 return browser_view()->browser()->is_app() && | 495 return browser_view()->browser()->is_app() && |
| 421 !CommandLine::ForCurrentProcess()->HasSwitch( | 496 CommandLine::ForCurrentProcess()->HasSwitch( |
| 422 switches::kEnableStreamlinedHostedApps); | 497 switches::kEnableStreamlinedHostedApps); |
| 423 } | 498 } |
| 424 | 499 |
| 425 void BrowserNonClientFrameViewAsh::LayoutAvatar() { | 500 void BrowserNonClientFrameViewAsh::LayoutAvatar() { |
| 426 DCHECK(avatar_button()); | 501 DCHECK(avatar_button()); |
| 427 #if !defined(OS_CHROMEOS) | 502 #if !defined(OS_CHROMEOS) |
| 428 // ChromeOS shows avatar on V1 app. | 503 // ChromeOS shows avatar on V1 app. |
| 429 DCHECK(browser_view()->IsTabStripVisible()); | 504 DCHECK(browser_view()->IsTabStripVisible()); |
| 430 #endif | 505 #endif |
| 431 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); | 506 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon(); |
| 432 | 507 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 canvas->FillRect( | 617 canvas->FillRect( |
| 543 gfx::Rect(x + kClientEdgeThickness, | 618 gfx::Rect(x + kClientEdgeThickness, |
| 544 toolbar_bounds.bottom() - kClientEdgeThickness, | 619 toolbar_bounds.bottom() - kClientEdgeThickness, |
| 545 w - (2 * kClientEdgeThickness), | 620 w - (2 * kClientEdgeThickness), |
| 546 kClientEdgeThickness), | 621 kClientEdgeThickness), |
| 547 ThemeProperties::GetDefaultColor( | 622 ThemeProperties::GetDefaultColor( |
| 548 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 623 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 549 } | 624 } |
| 550 | 625 |
| 551 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { | 626 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { |
| 552 DCHECK(!UsePackagedAppHeaderStyle()); | 627 DCHECK(!UsePackagedAppHeaderStyle() && !UseWebAppHeaderStyle()); |
| 553 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), | 628 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), |
| 554 width(), kClientEdgeThickness), | 629 width(), kClientEdgeThickness), |
| 555 ThemeProperties::GetDefaultColor( | 630 ThemeProperties::GetDefaultColor( |
| 556 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 631 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 557 } | 632 } |
| 633 | |
| 634 void BrowserNonClientFrameViewAsh::UpdateBackButtonState(bool enabled) { | |
| 635 web_app_back_button_->SetState(enabled ? views::Button::STATE_NORMAL | |
| 636 : views::Button::STATE_DISABLED); | |
| 637 } | |
| OLD | NEW |