| 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/frame/caption_buttons/frame_caption_button.h" | 9 #include "ash/frame/caption_buttons/frame_caption_button.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 "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
| 16 #include "chrome/browser/extensions/extension_util.h" | 16 #include "chrome/browser/extensions/extension_util.h" |
| 17 #include "chrome/browser/themes/theme_properties.h" | 17 #include "chrome/browser/themes/theme_properties.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_commands.h" | 19 #include "chrome/browser/ui/browser_commands.h" |
| 20 #include "chrome/browser/ui/views/frame/browser_frame.h" | 20 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 21 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h" | 21 #include "chrome/browser/ui/views/frame/browser_header_painter_ash.h" |
| 22 #include "chrome/browser/ui/views/frame/browser_view.h" | 22 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 23 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 23 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
| 24 #include "chrome/browser/ui/views/profiles/avatar_label.h" | |
| 25 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 24 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 26 #include "chrome/browser/ui/views/tab_icon_view.h" | 25 #include "chrome/browser/ui/views/tab_icon_view.h" |
| 27 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 26 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| 28 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 29 #include "grit/ash_resources.h" | 28 #include "grit/ash_resources.h" |
| 30 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
| 31 #include "ui/accessibility/ax_view_state.h" | 30 #include "ui/accessibility/ax_view_state.h" |
| 32 #include "ui/aura/client/aura_constants.h" | 31 #include "ui/aura/client/aura_constants.h" |
| 33 #include "ui/aura/window.h" | 32 #include "ui/aura/window.h" |
| 34 #include "ui/base/hit_test.h" | 33 #include "ui/base/hit_test.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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 232 |
| 230 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds( | 233 gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds( |
| 231 const gfx::Rect& client_bounds) const { | 234 const gfx::Rect& client_bounds) const { |
| 232 return client_bounds; | 235 return client_bounds; |
| 233 } | 236 } |
| 234 | 237 |
| 235 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { | 238 int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) { |
| 236 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, | 239 int hit_test = ash::FrameBorderHitTestController::NonClientHitTest(this, |
| 237 caption_button_container_, point); | 240 caption_button_container_, point); |
| 238 | 241 |
| 239 // See if the point is actually within the avatar menu button. | 242 // See if the point is actually within the avatar menu button.d |
| 240 if (hit_test == HTCAPTION && avatar_button() && | 243 if (hit_test == HTCAPTION && avatar_button() && |
| 241 ConvertedHitTest(this, avatar_button(), point)) { | 244 ConvertedHitTest(this, avatar_button(), point)) { |
| 242 return HTCLIENT; | 245 return HTCLIENT; |
| 243 } | 246 } |
| 244 | 247 |
| 245 // See if the point is actually within the web app back button. | 248 // See if the point is actually within the web app back button. |
| 246 if (hit_test == HTCAPTION && web_app_back_button_ && | 249 if (hit_test == HTCAPTION && web_app_back_button_ && |
| 247 ConvertedHitTest(this, web_app_back_button_, point)) { | 250 ConvertedHitTest(this, web_app_back_button_, point)) { |
| 248 return HTCLIENT; | 251 return HTCLIENT; |
| 249 } | 252 } |
| 250 | 253 |
| 254 #if defined(ENABLE_MANAGED_USERS) |
| 255 // ...or within the avatar label, if it's a supervised user. |
| 256 if (hit_test == HTCAPTION && supervised_user_avatar_label() && |
| 257 ConvertedHitTest(this, supervised_user_avatar_label(), point)) { |
| 258 return HTCLIENT; |
| 259 } |
| 260 #endif |
| 261 |
| 251 // When the window is restored we want a large click target above the tabs | 262 // When the window is restored we want a large click target above the tabs |
| 252 // to drag the window, so redirect clicks in the tab's shadow to caption. | 263 // to drag the window, so redirect clicks in the tab's shadow to caption. |
| 253 if (hit_test == HTCLIENT && | 264 if (hit_test == HTCLIENT && |
| 254 !(frame()->IsMaximized() || frame()->IsFullscreen())) { | 265 !(frame()->IsMaximized() || frame()->IsFullscreen())) { |
| 255 // Convert point to client coordinates. | 266 // Convert point to client coordinates. |
| 256 gfx::Point client_point(point); | 267 gfx::Point client_point(point); |
| 257 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); | 268 View::ConvertPointToTarget(this, frame()->client_view(), &client_point); |
| 258 // Report hits in shadow at top of tabstrip as caption. | 269 // Report hits in shadow at top of tabstrip as caption. |
| 259 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); | 270 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); |
| 260 if (client_point.y() < tabstrip_bounds.y() + kTabShadowHeight) | 271 if (client_point.y() < tabstrip_bounds.y() + kTabShadowHeight) |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), | 644 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), |
| 634 width(), kClientEdgeThickness), | 645 width(), kClientEdgeThickness), |
| 635 ThemeProperties::GetDefaultColor( | 646 ThemeProperties::GetDefaultColor( |
| 636 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 647 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
| 637 } | 648 } |
| 638 | 649 |
| 639 void BrowserNonClientFrameViewAsh::UpdateBackButtonState(bool enabled) { | 650 void BrowserNonClientFrameViewAsh::UpdateBackButtonState(bool enabled) { |
| 640 web_app_back_button_->SetState(enabled ? views::Button::STATE_NORMAL | 651 web_app_back_button_->SetState(enabled ? views::Button::STATE_NORMAL |
| 641 : views::Button::STATE_DISABLED); | 652 : views::Button::STATE_DISABLED); |
| 642 } | 653 } |
| OLD | NEW |