| 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 "chrome/grit/generated_resources.h" | 28 #include "chrome/grit/generated_resources.h" |
| 30 #include "components/signin/core/common/profile_management_switches.h" | 29 #include "components/signin/core/common/profile_management_switches.h" |
| 31 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 45 #include "ui/resources/grit/ui_resources.h" | 44 #include "ui/resources/grit/ui_resources.h" |
| 46 #include "ui/views/controls/button/image_button.h" | 45 #include "ui/views/controls/button/image_button.h" |
| 47 #include "ui/views/controls/image_view.h" | 46 #include "ui/views/controls/image_view.h" |
| 48 #include "ui/views/controls/label.h" | 47 #include "ui/views/controls/label.h" |
| 49 #include "ui/views/layout/layout_constants.h" | 48 #include "ui/views/layout/layout_constants.h" |
| 50 #include "ui/views/views_delegate.h" | 49 #include "ui/views/views_delegate.h" |
| 51 #include "ui/views/widget/root_view.h" | 50 #include "ui/views/widget/root_view.h" |
| 52 #include "ui/views/window/frame_background.h" | 51 #include "ui/views/window/frame_background.h" |
| 53 #include "ui/views/window/window_shape.h" | 52 #include "ui/views/window/window_shape.h" |
| 54 | 53 |
| 54 #if defined(ENABLE_MANAGED_USERS) |
| 55 #include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h" |
| 56 #endif |
| 57 |
| 55 #if defined(OS_LINUX) | 58 #if defined(OS_LINUX) |
| 56 #include "ui/views/controls/menu/menu_runner.h" | 59 #include "ui/views/controls/menu/menu_runner.h" |
| 57 #endif | 60 #endif |
| 58 | 61 |
| 59 using content::WebContents; | 62 using content::WebContents; |
| 60 | 63 |
| 61 namespace { | 64 namespace { |
| 62 | 65 |
| 63 // While resize areas on Windows are normally the same size as the window | 66 // While resize areas on Windows are normally the same size as the window |
| 64 // borders, our top area is shrunk by 1 px to make it easier to move the window | 67 // 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... |
| 197 | 200 |
| 198 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { | 201 gfx::Rect OpaqueBrowserFrameView::GetBoundsForClientView() const { |
| 199 return layout_->client_view_bounds(); | 202 return layout_->client_view_bounds(); |
| 200 } | 203 } |
| 201 | 204 |
| 202 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( | 205 gfx::Rect OpaqueBrowserFrameView::GetWindowBoundsForClientBounds( |
| 203 const gfx::Rect& client_bounds) const { | 206 const gfx::Rect& client_bounds) const { |
| 204 return layout_->GetWindowBoundsForClientBounds(client_bounds); | 207 return layout_->GetWindowBoundsForClientBounds(client_bounds); |
| 205 } | 208 } |
| 206 | 209 |
| 210 bool OpaqueBrowserFrameView::IsWithinAvatarMenuButtons( |
| 211 const gfx::Point& point) const { |
| 212 if (avatar_button() && |
| 213 avatar_button()->GetMirroredBounds().Contains(point)) { |
| 214 return true; |
| 215 } |
| 216 if (new_avatar_button() && |
| 217 new_avatar_button()->GetMirroredBounds().Contains(point)) { |
| 218 return true; |
| 219 } |
| 220 |
| 221 return false; |
| 222 } |
| 223 |
| 207 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { | 224 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
| 208 if (!bounds().Contains(point)) | 225 if (!bounds().Contains(point)) |
| 209 return HTNOWHERE; | 226 return HTNOWHERE; |
| 210 | 227 |
| 211 // See if the point is within the avatar menu button or within the avatar | 228 // See if the point is within the avatar menu button. |
| 212 // label. | 229 if (IsWithinAvatarMenuButtons(point)) |
| 213 if ((avatar_button() && | |
| 214 avatar_button()->GetMirroredBounds().Contains(point)) || | |
| 215 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)) || | |
| 216 (new_avatar_button() && | |
| 217 new_avatar_button()->GetMirroredBounds().Contains(point))) | |
| 218 return HTCLIENT; | 230 return HTCLIENT; |
| 231 #if defined(ENABLE_MANAGED_USERS) |
| 232 // ...or within the avatar label, if it's a supervised user. |
| 233 if ((supervised_user_avatar_label() && |
| 234 supervised_user_avatar_label()->GetMirroredBounds().Contains(point))) |
| 235 return HTCLIENT; |
| 236 #endif |
| 219 | 237 |
| 220 int frame_component = frame()->client_view()->NonClientHitTest(point); | 238 int frame_component = frame()->client_view()->NonClientHitTest(point); |
| 221 | 239 |
| 222 // See if we're in the sysmenu region. We still have to check the tabstrip | 240 // See if we're in the sysmenu region. We still have to check the tabstrip |
| 223 // first so that clicks in a tab don't get treated as sysmenu clicks. | 241 // first so that clicks in a tab don't get treated as sysmenu clicks. |
| 224 gfx::Rect sysmenu_rect(IconBounds()); | 242 gfx::Rect sysmenu_rect(IconBounds()); |
| 225 // In maximized mode we extend the rect to the screen corner to take advantage | 243 // In maximized mode we extend the rect to the screen corner to take advantage |
| 226 // of Fitts' Law. | 244 // of Fitts' Law. |
| 227 if (layout_->IsTitleBarCondensed()) | 245 if (layout_->IsTitleBarCondensed()) |
| 228 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); | 246 sysmenu_rect.SetRect(0, 0, sysmenu_rect.right(), sysmenu_rect.bottom()); |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 | 925 |
| 908 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 926 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
| 909 gfx::ImageSkia* frame_image = GetFrameImage(); | 927 gfx::ImageSkia* frame_image = GetFrameImage(); |
| 910 int top_area_height = frame_image->height(); | 928 int top_area_height = frame_image->height(); |
| 911 if (browser_view()->IsTabStripVisible()) { | 929 if (browser_view()->IsTabStripVisible()) { |
| 912 top_area_height = std::max(top_area_height, | 930 top_area_height = std::max(top_area_height, |
| 913 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 931 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
| 914 } | 932 } |
| 915 return top_area_height; | 933 return top_area_height; |
| 916 } | 934 } |
| OLD | NEW |