| 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/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/profiles/profiles_state.h" | 14 #include "chrome/browser/profiles/profiles_state.h" |
| 15 #include "chrome/browser/signin/signin_header_helper.h" | 15 #include "chrome/browser/signin/signin_header_helper.h" |
| 16 #include "chrome/browser/themes/theme_properties.h" | 16 #include "chrome/browser/themes/theme_properties.h" |
| 17 #include "chrome/browser/ui/views/frame/browser_frame.h" | 17 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 18 #include "chrome/browser/ui/views/frame/browser_view.h" | 18 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 19 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" | 19 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
| 20 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci
fic.h" | 20 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci
fic.h" |
| 21 #include "chrome/browser/ui/views/profiles/avatar_label.h" | |
| 22 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 21 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| 23 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" | 22 #include "chrome/browser/ui/views/profiles/new_avatar_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/browser/ui/views/theme_image_mapper.h" | 25 #include "chrome/browser/ui/views/theme_image_mapper.h" |
| 27 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 26 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 28 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 29 #include "components/signin/core/common/profile_management_switches.h" | 28 #include "components/signin/core/common/profile_management_switches.h" |
| 30 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 31 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 46 #include "ui/gfx/rect_conversions.h" | 45 #include "ui/gfx/rect_conversions.h" |
| 47 #include "ui/views/controls/button/image_button.h" | 46 #include "ui/views/controls/button/image_button.h" |
| 48 #include "ui/views/controls/image_view.h" | 47 #include "ui/views/controls/image_view.h" |
| 49 #include "ui/views/controls/label.h" | 48 #include "ui/views/controls/label.h" |
| 50 #include "ui/views/layout/layout_constants.h" | 49 #include "ui/views/layout/layout_constants.h" |
| 51 #include "ui/views/views_delegate.h" | 50 #include "ui/views/views_delegate.h" |
| 52 #include "ui/views/widget/root_view.h" | 51 #include "ui/views/widget/root_view.h" |
| 53 #include "ui/views/window/frame_background.h" | 52 #include "ui/views/window/frame_background.h" |
| 54 #include "ui/views/window/window_shape.h" | 53 #include "ui/views/window/window_shape.h" |
| 55 | 54 |
| 55 #if defined(ENABLE_MANAGED_USERS) |
| 56 #include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h" |
| 57 #endif |
| 58 |
| 56 #if defined(OS_LINUX) | 59 #if defined(OS_LINUX) |
| 57 #include "ui/views/controls/menu/menu_runner.h" | 60 #include "ui/views/controls/menu/menu_runner.h" |
| 58 #endif | 61 #endif |
| 59 | 62 |
| 60 using content::WebContents; | 63 using content::WebContents; |
| 61 | 64 |
| 62 namespace { | 65 namespace { |
| 63 | 66 |
| 64 // While resize areas on Windows are normally the same size as the window | 67 // While resize areas on Windows are normally the same size as the window |
| 65 // borders, our top area is shrunk by 1 px to make it easier to move the window | 68 // borders, our top area is shrunk by 1 px to make it easier to move the window |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 201 |
| 199 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { | 202 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { |
| 200 return layout_->client_view_bounds(); | 203 return layout_->client_view_bounds(); |
| 201 } | 204 } |
| 202 | 205 |
| 203 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( | 206 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( |
| 204 const gfx::Rect& client_bounds) const { | 207 const gfx::Rect& client_bounds) const { |
| 205 return layout_->GetWindowBoundsForClientBounds(client_bounds); | 208 return layout_->GetWindowBoundsForClientBounds(client_bounds); |
| 206 } | 209 } |
| 207 | 210 |
| 211 bool OpaqueBrowserFrameView::IsWithinAvatarMenuButtons( |
| 212 const gfx::Point& point) const { |
| 213 if (avatar_button() && |
| 214 avatar_button()->GetMirroredBounds().Contains(point)) { |
| 215 return true; |
| 216 } |
| 217 if (new_avatar_button() && |
| 218 new_avatar_button()->GetMirroredBounds().Contains(point)) { |
| 219 return true; |
| 220 } |
| 221 |
| 222 return false; |
| 223 } |
| 224 |
| 208 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { | 225 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
| 209 if (!bounds().Contains(point)) | 226 if (!bounds().Contains(point)) |
| 210 return HTNOWHERE; | 227 return HTNOWHERE; |
| 211 | 228 |
| 212 // See if the point is within the avatar menu button or within the avatar | 229 // See if the point is within the avatar menu button. |
| 213 // label. | 230 if (IsWithinAvatarMenuButtons(point)) |
| 214 if ((avatar_button() && | |
| 215 avatar_button()->GetMirroredBounds().Contains(point)) || | |
| 216 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)) || | |
| 217 (new_avatar_button() && | |
| 218 new_avatar_button()->GetMirroredBounds().Contains(point))) | |
| 219 return HTCLIENT; | 231 return HTCLIENT; |
| 232 #if defined(ENABLE_MANAGED_USERS) |
| 233 // ...or within the avatar label, if it's a supervised user. |
| 234 if ((supervised_user_avatar_label() && |
| 235 supervised_user_avatar_label()->GetMirroredBounds().Contains(point))) |
| 236 return HTCLIENT; |
| 237 #endif |
| 220 | 238 |
| 221 int frame_component = frame()->client_view()->NonClientHitTest(point); | 239 int frame_component = frame()->client_view()->NonClientHitTest(point); |
| 222 | 240 |
| 223 // See if we're in the sysmenu region. We still have to check the tabstrip | 241 // See if we're in the sysmenu region. We still have to check the tabstrip |
| 224 // first so that clicks in a tab don't get treated as sysmenu clicks. | 242 // first so that clicks in a tab don't get treated as sysmenu clicks. |
| 225 gfx::Rect sysmenu_rect(IconBounds()); | 243 gfx::Rect sysmenu_rect(IconBounds()); |
| 226 // In maximized mode we extend the rect to the screen corner to take advantage | 244 // In maximized mode we extend the rect to the screen corner to take advantage |
| 227 // of Fitts' Law. | 245 // of Fitts' Law. |
| 228 if (layout_->IsTitleBarCondensed()) | 246 if (layout_->IsTitleBarCondensed()) |
| 229 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); | 247 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 | 920 |
| 903 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 921 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
| 904 gfx::ImageSkia* frame_image = GetFrameImage(); | 922 gfx::ImageSkia* frame_image = GetFrameImage(); |
| 905 int top_area_height = frame_image->height(); | 923 int top_area_height = frame_image->height(); |
| 906 if (browser_view()->IsTabStripVisible()) { | 924 if (browser_view()->IsTabStripVisible()) { |
| 907 top_area_height = std::max(top_area_height, | 925 top_area_height = std::max(top_area_height, |
| 908 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 926 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
| 909 } | 927 } |
| 910 return top_area_height; | 928 return top_area_height; |
| 911 } | 929 } |
| OLD | NEW |