OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/common/ash_layout_constants.h" | 9 #include "ash/common/ash_layout_constants.h" |
10 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h " | 10 #include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h " |
11 #include "ash/common/frame/default_header_painter.h" | 11 #include "ash/common/frame/default_header_painter.h" |
12 #include "ash/common/frame/frame_border_hit_test.h" | 12 #include "ash/common/frame/frame_border_hit_test.h" |
13 #include "ash/common/frame/header_painter_util.h" | 13 #include "ash/common/frame/header_painter_util.h" |
14 #include "ash/common/wm_lookup.h" | 14 #include "ash/common/wm_lookup.h" |
15 #include "ash/common/wm_shell.h" | 15 #include "ash/common/wm_shell.h" |
16 #include "ash/common/wm_window.h" | 16 #include "ash/common/wm_window.h" |
17 #include "build/build_config.h" | 17 #include "build/build_config.h" |
18 #include "chrome/app/chrome_command_ids.h" | |
19 #include "chrome/browser/extensions/extension_util.h" | |
20 #include "chrome/browser/profiles/profiles_state.h" | 18 #include "chrome/browser/profiles/profiles_state.h" |
21 #include "chrome/browser/themes/theme_properties.h" | 19 #include "chrome/browser/themes/theme_properties.h" |
22 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 20 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
23 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_commands.h" | |
25 #include "chrome/browser/ui/layout_constants.h" | 22 #include "chrome/browser/ui/layout_constants.h" |
26 #include "chrome/browser/ui/views/frame/browser_frame.h" | 23 #include "chrome/browser/ui/views/frame/browser_frame.h" |
27 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h" | 24 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h" |
28 #include "chrome/browser/ui/views/frame/browser_view.h" | 25 #include "chrome/browser/ui/views/frame/browser_view.h" |
29 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 26 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
30 #include "chrome/browser/ui/views/frame/web_app_left_header_view_ash.h" | 27 #include "chrome/browser/ui/views/frame/web_app_left_header_view_ash.h" |
31 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h" | 28 #include "chrome/browser/ui/views/profiles/profile_indicator_icon.h" |
32 #include "chrome/browser/ui/views/tab_icon_view.h" | 29 #include "chrome/browser/ui/views/tab_icon_view.h" |
33 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 30 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
34 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 31 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
35 #include "chrome/browser/web_applications/web_app.h" | 32 #include "chrome/browser/web_applications/web_app.h" |
36 #include "chrome/grit/theme_resources.h" | 33 #include "chrome/grit/theme_resources.h" |
37 #include "components/signin/core/common/profile_management_switches.h" | |
38 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
39 #include "extensions/browser/extension_registry.h" | |
40 #include "ui/accessibility/ax_view_state.h" | 35 #include "ui/accessibility/ax_view_state.h" |
41 #include "ui/aura/client/aura_constants.h" | 36 #include "ui/aura/client/aura_constants.h" |
42 #include "ui/aura/window.h" | 37 #include "ui/aura/window.h" |
43 #include "ui/base/hit_test.h" | 38 #include "ui/base/hit_test.h" |
44 #include "ui/base/layout.h" | 39 #include "ui/base/layout.h" |
45 #include "ui/base/material_design/material_design_controller.h" | |
46 #include "ui/base/resource/resource_bundle.h" | |
47 #include "ui/base/theme_provider.h" | 40 #include "ui/base/theme_provider.h" |
48 #include "ui/compositor/layer_animator.h" | 41 #include "ui/compositor/layer_animator.h" |
49 #include "ui/gfx/canvas.h" | 42 #include "ui/gfx/canvas.h" |
50 #include "ui/gfx/geometry/rect_conversions.h" | |
51 #include "ui/gfx/image/image_skia.h" | 43 #include "ui/gfx/image/image_skia.h" |
52 #include "ui/gfx/scoped_canvas.h" | 44 #include "ui/gfx/scoped_canvas.h" |
53 #include "ui/views/controls/label.h" | 45 #include "ui/views/controls/label.h" |
54 #include "ui/views/layout/layout_constants.h" | 46 #include "ui/views/layout/layout_constants.h" |
55 #include "ui/views/widget/widget.h" | 47 #include "ui/views/widget/widget.h" |
56 #include "ui/views/widget/widget_delegate.h" | 48 #include "ui/views/widget/widget_delegate.h" |
57 | 49 |
58 #if defined(OS_CHROMEOS) | 50 #if defined(OS_CHROMEOS) |
59 #include "ash/shared/app_types.h" | 51 #include "ash/shared/app_types.h" |
60 #endif | 52 #endif |
61 | 53 |
62 namespace { | 54 namespace { |
63 | 55 |
64 // Space between right edge of tabstrip and maximize button. | 56 // Space between right edge of tabstrip and maximize button. |
65 const int kTabstripRightSpacing = 10; | 57 const int kTabstripRightSpacing = 10; |
66 // Height of the shadow of the content area, at the top of the toolbar. | |
67 const int kContentShadowHeight = 1; | |
68 // Space between top of window and top of tabstrip for tall headers, such as | |
69 // for restored windows, apps, etc. | |
70 const int kTabstripTopSpacingTall = 7; | |
71 // Space between top of window and top of tabstrip for short headers, such as | |
72 // for maximized windows, pop-ups, etc. | |
73 const int kTabstripTopSpacingShort = 0; | |
74 // Height of the shadow in the tab image, used to ensure clicks in the shadow | 58 // Height of the shadow in the tab image, used to ensure clicks in the shadow |
75 // area still drag restored windows. This keeps the clickable area large enough | 59 // area still drag restored windows. This keeps the clickable area large enough |
76 // to hit easily. | 60 // to hit easily. |
77 const int kTabShadowHeight = 4; | 61 const int kTabShadowHeight = 4; |
78 | 62 |
79 // Combines View::ConvertPointToTarget() and View::HitTest() for a given | 63 // Combines View::ConvertPointToTarget() and View::HitTest() for a given |
80 // |point|. Converts |point| from |src| to |dst| and hit tests it against |dst|. | 64 // |point|. Converts |point| from |src| to |dst| and hit tests it against |dst|. |
81 bool ConvertedHitTest(views::View* src, | 65 bool ConvertedHitTest(views::View* src, |
82 views::View* dst, | 66 views::View* dst, |
83 const gfx::Point& point) { | 67 const gfx::Point& point) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 int BrowserNonClientFrameViewAsh::GetTopInset(bool restored) const { | 158 int BrowserNonClientFrameViewAsh::GetTopInset(bool restored) const { |
175 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) | 159 if (!ShouldPaint() || UseImmersiveLightbarHeaderStyle()) |
176 return 0; | 160 return 0; |
177 | 161 |
178 if (!browser_view()->IsTabStripVisible()) { | 162 if (!browser_view()->IsTabStripVisible()) { |
179 return (UsePackagedAppHeaderStyle() || UseWebAppHeaderStyle()) | 163 return (UsePackagedAppHeaderStyle() || UseWebAppHeaderStyle()) |
180 ? header_painter_->GetHeaderHeight() | 164 ? header_painter_->GetHeaderHeight() |
181 : caption_button_container_->bounds().bottom(); | 165 : caption_button_container_->bounds().bottom(); |
182 } | 166 } |
183 | 167 |
184 if (!ui::MaterialDesignController::IsModeMaterial()) { | |
185 return ((frame()->IsMaximized() || frame()->IsFullscreen()) && !restored) ? | |
186 kTabstripTopSpacingShort : kTabstripTopSpacingTall; | |
187 } | |
188 | |
189 const int header_height = restored | 168 const int header_height = restored |
190 ? GetAshLayoutSize( | 169 ? GetAshLayoutSize( |
191 AshLayoutSize::BROWSER_RESTORED_CAPTION_BUTTON).height() | 170 AshLayoutSize::BROWSER_RESTORED_CAPTION_BUTTON).height() |
192 : header_painter_->GetHeaderHeight(); | 171 : header_painter_->GetHeaderHeight(); |
193 return header_height - browser_view()->GetTabStripHeight(); | 172 return header_height - browser_view()->GetTabStripHeight(); |
194 } | 173 } |
195 | 174 |
196 int BrowserNonClientFrameViewAsh::GetThemeBackgroundXInset() const { | 175 int BrowserNonClientFrameViewAsh::GetThemeBackgroundXInset() const { |
197 return ash::HeaderPainterUtil::GetThemeBackgroundXInset(); | 176 return ash::HeaderPainterUtil::GetThemeBackgroundXInset(); |
198 } | 177 } |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
466 #if !defined(OS_CHROMEOS) | 445 #if !defined(OS_CHROMEOS) |
467 // ChromeOS shows avatar on V1 app. | 446 // ChromeOS shows avatar on V1 app. |
468 DCHECK(browser_view()->IsTabStripVisible()); | 447 DCHECK(browser_view()->IsTabStripVisible()); |
469 #endif | 448 #endif |
470 | 449 |
471 const gfx::ImageSkia incognito_icon = GetIncognitoAvatarIcon(); | 450 const gfx::ImageSkia incognito_icon = GetIncognitoAvatarIcon(); |
472 const gfx::Insets avatar_insets = GetLayoutInsets(AVATAR_ICON); | 451 const gfx::Insets avatar_insets = GetLayoutInsets(AVATAR_ICON); |
473 const int avatar_bottom = GetTopInset(false) + | 452 const int avatar_bottom = GetTopInset(false) + |
474 browser_view()->GetTabStripHeight() - avatar_insets.bottom(); | 453 browser_view()->GetTabStripHeight() - avatar_insets.bottom(); |
475 int avatar_y = avatar_bottom - incognito_icon.height(); | 454 int avatar_y = avatar_bottom - incognito_icon.height(); |
476 if (!ui::MaterialDesignController::IsModeMaterial() && | |
477 browser_view()->IsTabStripVisible() && | |
478 (frame()->IsMaximized() || frame()->IsFullscreen())) { | |
479 avatar_y = GetTopInset(false) + kContentShadowHeight; | |
480 } | |
481 | 455 |
482 // Hide the incognito icon in immersive fullscreen when the tab light bar is | 456 // Hide the incognito icon in immersive fullscreen when the tab light bar is |
483 // visible because the header is too short for the icognito icon to be | 457 // visible because the header is too short for the icognito icon to be |
484 // recognizable. | 458 // recognizable. |
485 const bool avatar_visible = !UseImmersiveLightbarHeaderStyle(); | 459 const bool avatar_visible = !UseImmersiveLightbarHeaderStyle(); |
486 const int avatar_height = avatar_visible ? (avatar_bottom - avatar_y) : 0; | 460 const int avatar_height = avatar_visible ? (avatar_bottom - avatar_y) : 0; |
487 profile_indicator_icon()->SetBounds(avatar_insets.left(), avatar_y, | 461 profile_indicator_icon()->SetBounds(avatar_insets.left(), avatar_y, |
488 incognito_icon.width(), avatar_height); | 462 incognito_icon.width(), avatar_height); |
489 profile_indicator_icon()->SetVisible(avatar_visible); | 463 profile_indicator_icon()->SetVisible(avatar_visible); |
490 } | 464 } |
(...skipping 14 matching lines...) Expand all Loading... | |
505 | 479 |
506 void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) { | 480 void BrowserNonClientFrameViewAsh::PaintToolbarBackground(gfx::Canvas* canvas) { |
507 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); | 481 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds()); |
508 if (toolbar_bounds.IsEmpty()) | 482 if (toolbar_bounds.IsEmpty()) |
509 return; | 483 return; |
510 gfx::Point toolbar_origin(toolbar_bounds.origin()); | 484 gfx::Point toolbar_origin(toolbar_bounds.origin()); |
511 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); | 485 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin); |
512 toolbar_bounds.set_origin(toolbar_origin); | 486 toolbar_bounds.set_origin(toolbar_origin); |
513 | 487 |
514 const ui::ThemeProvider* tp = GetThemeProvider(); | 488 const ui::ThemeProvider* tp = GetThemeProvider(); |
515 const gfx::ImageSkia* const bg = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR); | 489 // Background. |
Peter Kasting
2016/10/21 21:07:50
Nit: Maybe move this above the above line? (Or mo
Evan Stade
2016/10/21 22:11:12
Done.
| |
516 const int x = toolbar_bounds.x(); | 490 if (tp->HasCustomImage(IDR_THEME_TOOLBAR)) { |
517 const int y = toolbar_bounds.y(); | 491 const int bg_y = GetTopInset(false) + GetLayoutInsets(TAB).top(); |
518 const int bg_y = GetTopInset(false) + GetLayoutInsets(TAB).top(); | 492 const int x = toolbar_bounds.x(); |
519 const int w = toolbar_bounds.width(); | 493 const int y = toolbar_bounds.y(); |
520 const int h = toolbar_bounds.height(); | 494 canvas->TileImageInt(*tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR), |
521 const SkColor separator_color = | 495 x + GetThemeBackgroundXInset(), y - bg_y, x, y, |
522 tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR); | 496 toolbar_bounds.width(), toolbar_bounds.height()); |
523 if (ui::MaterialDesignController::IsModeMaterial()) { | 497 } else { |
524 // Background. The top stroke is drawn above the toolbar bounds, so | 498 canvas->FillRect(toolbar_bounds, |
525 // unlike in the non-Material Design code below, we don't need to exclude | 499 tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); |
526 // any region from having the background image drawn over it. | 500 } |
527 if (tp->HasCustomImage(IDR_THEME_TOOLBAR)) { | |
528 canvas->TileImageInt(*bg, x + GetThemeBackgroundXInset(), y - bg_y, x, y, | |
529 w, h); | |
530 } else { | |
531 canvas->FillRect(toolbar_bounds, | |
532 tp->GetColor(ThemeProperties::COLOR_TOOLBAR)); | |
533 } | |
534 | 501 |
535 // Top stroke. | 502 // Top stroke. |
536 gfx::Rect separator_rect(x, y, w, 0); | 503 gfx::Rect separator_rect = toolbar_bounds; |
Peter Kasting
2016/10/21 21:07:50
Nit: Can move down lower and then replace this and
Evan Stade
2016/10/21 22:11:12
Done.
| |
537 gfx::ScopedCanvas scoped_canvas(canvas); | 504 gfx::ScopedCanvas scoped_canvas(canvas); |
538 gfx::Rect tabstrip_bounds(GetBoundsForTabStrip(browser_view()->tabstrip())); | 505 gfx::Rect tabstrip_bounds(GetBoundsForTabStrip(browser_view()->tabstrip())); |
539 tabstrip_bounds.set_x(GetMirroredXForRect(tabstrip_bounds)); | 506 tabstrip_bounds.set_x(GetMirroredXForRect(tabstrip_bounds)); |
540 canvas->ClipRect(tabstrip_bounds, SkRegion::kDifference_Op); | 507 canvas->ClipRect(tabstrip_bounds, SkRegion::kDifference_Op); |
541 separator_rect.set_y(tabstrip_bounds.bottom()); | 508 separator_rect.set_y(tabstrip_bounds.bottom()); |
542 BrowserView::Paint1pxHorizontalLine(canvas, GetToolbarTopSeparatorColor(), | 509 separator_rect.set_height(0); |
543 separator_rect, true); | 510 BrowserView::Paint1pxHorizontalLine(canvas, GetToolbarTopSeparatorColor(), |
511 separator_rect, true); | |
544 | 512 |
545 // Toolbar/content separator. | 513 // Toolbar/content separator. |
546 toolbar_bounds.Inset(kClientEdgeThickness, 0); | 514 toolbar_bounds.Inset(kClientEdgeThickness, 0); |
547 BrowserView::Paint1pxHorizontalLine(canvas, separator_color, toolbar_bounds, | 515 BrowserView::Paint1pxHorizontalLine( |
548 true); | 516 canvas, tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR), |
549 } else { | 517 toolbar_bounds, |
Peter Kasting
2016/10/21 21:07:50
Nit: Unusual line-break here
Evan Stade
2016/10/21 22:11:11
Done.
| |
550 // Background. The top stroke is drawn using the IDR_TOOLBAR_SHADE_TOP | 518 true); |
551 // image, which overlays the toolbar. The top 2 px of this image is the | |
552 // actual top stroke + shadow, and is partly transparent, so the toolbar | |
553 // background shouldn't be drawn over it. | |
554 const int kContentEdgeShadowThickness = 2; | |
555 const int bg_dest_y = y + kContentEdgeShadowThickness; | |
556 const int bottom = toolbar_bounds.bottom(); | |
557 canvas->TileImageInt(*bg, x + GetThemeBackgroundXInset(), bg_dest_y - bg_y, | |
558 x, bg_dest_y, w, bottom - bg_dest_y); | |
559 | |
560 const gfx::ImageSkia* const top = | |
561 tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_TOP); | |
562 canvas->TileImageInt(*top, 0, 0, x, y, w, top->height()); | |
563 | |
564 // Draw the "lightening" shade line around the edges of the toolbar. | |
565 const gfx::ImageSkia* const left = | |
566 tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_LEFT); | |
567 const int img_y = y + top->height(); | |
568 const int img_w = left->width(); | |
569 const int img_h = bottom - img_y; | |
570 canvas->TileImageInt(*left, 0, 0, x + kClientEdgeThickness, img_y, img_w, | |
571 img_h); | |
572 const gfx::ImageSkia* const right = | |
573 tp->GetImageSkiaNamed(IDR_TOOLBAR_SHADE_RIGHT); | |
574 // TODO(pkasting): The "2 *" part of this makes no sense to me. | |
Evan Stade
2016/10/20 23:02:15
you can sleep better now
| |
575 canvas->TileImageInt(*right, 0, 0, w - (2 * kClientEdgeThickness) - img_w, | |
576 img_y, img_w, img_h); | |
577 | |
578 // Toolbar/content separator. | |
579 toolbar_bounds.Inset(kClientEdgeThickness, h - kClientEdgeThickness, | |
580 kClientEdgeThickness, 0); | |
581 canvas->FillRect(toolbar_bounds, separator_color); | |
582 } | |
583 } | 519 } |
OLD | NEW |