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_container_view.h" | 10 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
| 11 #include "ash/frame/default_header_painter.h" | 11 #include "ash/frame/default_header_painter.h" |
| 12 #include "ash/frame/frame_border_hit_test_controller.h" | 12 #include "ash/frame/frame_border_hit_test_controller.h" |
| 13 #include "ash/frame/header_painter_util.h" | 13 #include "ash/frame/header_painter_util.h" |
| 14 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "chrome/browser/themes/theme_properties.h" | 16 #include "chrome/browser/themes/theme_properties.h" |
| 17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/views/frame/browser_frame.h" | 18 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 19 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h" | 19 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h" |
| 20 #include "chrome/browser/ui/views/frame/browser_view.h" | 20 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 21 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 21 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
| 22 #include "chrome/browser/ui/views/profiles/avatar_label.h" | |
| 23 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 22 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 24 #include "chrome/browser/ui/views/tab_icon_view.h" | 23 #include "chrome/browser/ui/views/tab_icon_view.h" |
| 25 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 24 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 26 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 27 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 28 #include "grit/ash_resources.h" | 27 #include "grit/ash_resources.h" |
| 29 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| 30 #include "ui/accessibility/ax_view_state.h" | 29 #include "ui/accessibility/ax_view_state.h" |
| 31 #include "ui/aura/client/aura_constants.h" | 30 #include "ui/aura/client/aura_constants.h" |
| 32 #include "ui/aura/window.h" | 31 #include "ui/aura/window.h" |
| 33 #include "ui/base/hit_test.h" | 32 #include "ui/base/hit_test.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 35 #include "ui/base/layout.h" | 34 #include "ui/base/layout.h" |
| 36 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
| 37 #include "ui/base/theme_provider.h" | 36 #include "ui/base/theme_provider.h" |
| 38 #include "ui/compositor/layer_animator.h" | 37 #include "ui/compositor/layer_animator.h" |
| 39 #include "ui/gfx/canvas.h" | 38 #include "ui/gfx/canvas.h" |
| 40 #include "ui/gfx/image/image_skia.h" | 39 #include "ui/gfx/image/image_skia.h" |
| 41 #include "ui/gfx/rect_conversions.h" | 40 #include "ui/gfx/rect_conversions.h" |
| 42 #include "ui/views/controls/label.h" | 41 #include "ui/views/controls/label.h" |
| 43 #include "ui/views/layout/layout_constants.h" | 42 #include "ui/views/layout/layout_constants.h" |
| 44 #include "ui/views/widget/widget.h" | 43 #include "ui/views/widget/widget.h" |
| 45 #include "ui/views/widget/widget_delegate.h" | 44 #include "ui/views/widget/widget_delegate.h" |
| 46 | 45 |
| 46 #if defined(ENABLE_MANAGED_USERS) | |
| 47 #include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h" | |
| 48 #endif | |
| 49 | |
| 47 namespace { | 50 namespace { |
| 48 | 51 |
| 49 // The avatar ends 2 px above the bottom of the tabstrip (which, given the | 52 // The avatar ends 2 px above the bottom of the tabstrip (which, given the |
| 50 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the | 53 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the |
| 51 // user). | 54 // user). |
| 52 const int kAvatarBottomSpacing = 2; | 55 const int kAvatarBottomSpacing = 2; |
| 53 // There are 2 px on each side of the avatar (between the frame border and | 56 // There are 2 px on each side of the avatar (between the frame border and |
| 54 // it on the left, and between it and the tabstrip on the right). | 57 // it on the left, and between it and the tabstrip on the right). |
| 55 const int kAvatarSideSpacing = 2; | 58 const int kAvatarSideSpacing = 2; |
| 56 // Space between left edge of window and tabstrip. | 59 // Space between left edge of window and tabstrip. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 const gfx::Rect& client_bounds) const { | 197 const gfx::Rect& client_bounds) const { |
| 195 return client_bounds; | 198 return client_bounds; |
| 196 } | 199 } |
| 197 | 200 |
| 198 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { | 201 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { |
| 199 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, | 202 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, |
| 200 caption_button_container_, point); | 203 caption_button_container_, point); |
| 201 | 204 |
| 202 // See if the point is actually within the avatar menu button or within | 205 // See if the point is actually within the avatar menu button or within |
| 203 // the avatar label. | 206 // the avatar label. |
| 204 if (hit_test == HTCAPTION && ((avatar_button() && | 207 #if defined(ENABLE_MANAGED_USERS) |
| 205 avatar_button()->GetMirroredBounds().Contains(point)) || | 208 if (IsWithinAvatarMenuButton(hit_test, point) || |
|
Bernhard Bauer
2014/07/14 16:39:05
You could probably pull this check out of the #ifd
mckev
2014/07/14 23:50:03
Yep, certainly. Would you prefer it to still be e
Bernhard Bauer
2014/07/16 09:53:59
Yeah, it might make sense to inline this.
| |
| 206 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)))) | 209 (supervised_user_avatar_label() && |
| 210 supervised_user_avatar_label()->GetMirroredBounds().Contains(point))) | |
| 207 return HTCLIENT; | 211 return HTCLIENT; |
| 212 #else | |
| 213 if (IsWithinAvatarMenuButton(hit_test, point)) | |
| 214 return HTCLIENT; | |
| 215 #endif | |
| 208 | 216 |
| 209 // When the window is restored we want a large click target above the tabs | 217 // When the window is restored we want a large click target above the tabs |
| 210 // to drag the window, so redirect clicks in the tab's shadow to caption. | 218 // to drag the window, so redirect clicks in the tab's shadow to caption. |
| 211 if (hit_test == HTCLIENT && | 219 if (hit_test == HTCLIENT && |
| 212 !(frame()->IsMaximized() || frame()->IsFullscreen())) { | 220 !(frame()->IsMaximized() || frame()->IsFullscreen())) { |
| 213 // Convert point to client coordinates. | 221 // Convert point to client coordinates. |
| 214 gfx::Point client_point(point); | 222 gfx::Point client_point(point); |
| 215 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); | 223 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); |
| 216 // Report hits in shadow at top of tabstrip as caption. | 224 // Report hits in shadow at top of tabstrip as caption. |
| 217 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); | 225 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); |
| 218 if (client_point.y() < tabstrip_bounds.y() + kTabShadowHeight) | 226 if (client_point.y() < tabstrip_bounds.y() + kTabShadowHeight) |
| 219 hit_test = HTCAPTION; | 227 hit_test = HTCAPTION; |
| 220 } | 228 } |
| 221 return hit_test; | 229 return hit_test; |
| 222 } | 230 } |
| 223 | 231 |
| 232 bool BrowserNonClientFrameViewAsh::IsWithinAvatarMenuButton( | |
| 233 const int hit_test, | |
| 234 const gfx::Point& point) const { | |
| 235 return hit_test == HTCAPTION && ((avatar_button() && | |
| 236 avatar_button()->GetMirroredBounds().Contains(point))); | |
| 237 } | |
| 238 | |
| 224 void BrowserNonClientFrameViewAsh::GetWindowMask(const gfx::Size& size, | 239 void BrowserNonClientFrameViewAsh::GetWindowMask(const gfx::Size& size, |
| 225 gfx::Path* window_mask) { | 240 gfx::Path* window_mask) { |
| 226 // Aura does not use window masks. | 241 // Aura does not use window masks. |
| 227 } | 242 } |
| 228 | 243 |
| 229 void BrowserNonClientFrameViewAsh::ResetWindowControls() { | 244 void BrowserNonClientFrameViewAsh::ResetWindowControls() { |
| 230 // Hide the caption buttons in immersive fullscreen when the tab light bar | 245 // Hide the caption buttons in immersive fullscreen when the tab light bar |
| 231 // is visible because it's confusing when the user hovers or clicks in the | 246 // is visible because it's confusing when the user hovers or clicks in the |
| 232 // top-right of the screen and hits one. | 247 // top-right of the screen and hits one. |
| 233 bool button_visibility = !UseImmersiveLightbarHeaderStyle(); | 248 bool button_visibility = !UseImmersiveLightbarHeaderStyle(); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 549 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 535 } | 550 } |
| 536 | 551 |
| 537 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { | 552 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { |
| 538 DCHECK(!UsePackagedAppHeaderStyle()); | 553 DCHECK(!UsePackagedAppHeaderStyle()); |
| 539 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), | 554 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), |
| 540 width(), kClientEdgeThickness), | 555 width(), kClientEdgeThickness), |
| 541 ThemeProperties::GetDefaultColor( | 556 ThemeProperties::GetDefaultColor( |
| 542 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 557 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 543 } | 558 } |
| OLD | NEW |