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/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/profiles/profiles_state.h" |
15 #include "chrome/browser/themes/theme_properties.h" | 16 #include "chrome/browser/themes/theme_properties.h" |
16 #include "chrome/browser/ui/views/avatar_label.h" | 17 #include "chrome/browser/ui/views/avatar_label.h" |
17 #include "chrome/browser/ui/views/avatar_menu_button.h" | 18 #include "chrome/browser/ui/views/avatar_menu_button.h" |
18 #include "chrome/browser/ui/views/frame/browser_frame.h" | 19 #include "chrome/browser/ui/views/frame/browser_frame.h" |
19 #include "chrome/browser/ui/views/frame/browser_view.h" | 20 #include "chrome/browser/ui/views/frame/browser_view.h" |
20 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" | 21 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h" |
21 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci
fic.h" | 22 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view_platform_speci
fic.h" |
| 23 #include "chrome/browser/ui/views/new_avatar_button.h" |
22 #include "chrome/browser/ui/views/tab_icon_view.h" | 24 #include "chrome/browser/ui/views/tab_icon_view.h" |
23 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 25 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
24 #include "chrome/browser/ui/views/toolbar_view.h" | 26 #include "chrome/browser/ui/views/toolbar_view.h" |
25 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
27 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
28 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
29 #include "grit/chromium_strings.h" | 31 #include "grit/chromium_strings.h" |
30 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
31 #include "grit/theme_resources.h" | 33 #include "grit/theme_resources.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 BrowserFrame::GetTitleFont()); | 145 BrowserFrame::GetTitleFont()); |
144 window_title_->SetVisible(browser_view->ShouldShowWindowTitle()); | 146 window_title_->SetVisible(browser_view->ShouldShowWindowTitle()); |
145 window_title_->SetEnabledColor(SK_ColorWHITE); | 147 window_title_->SetEnabledColor(SK_ColorWHITE); |
146 // TODO(msw): Use a transparent background color as a workaround to use the | 148 // TODO(msw): Use a transparent background color as a workaround to use the |
147 // gfx::Canvas::NO_SUBPIXEL_RENDERING flag and avoid some visual artifacts. | 149 // gfx::Canvas::NO_SUBPIXEL_RENDERING flag and avoid some visual artifacts. |
148 window_title_->SetBackgroundColor(0x00000000); | 150 window_title_->SetBackgroundColor(0x00000000); |
149 window_title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 151 window_title_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
150 window_title_->set_id(VIEW_ID_WINDOW_TITLE); | 152 window_title_->set_id(VIEW_ID_WINDOW_TITLE); |
151 AddChildView(window_title_); | 153 AddChildView(window_title_); |
152 | 154 |
153 UpdateAvatarInfo(); | 155 if (browser_view->IsRegularOrGuestSession() && |
| 156 profiles::IsNewProfileManagementEnabled()) |
| 157 UpdateNewStyleAvatarInfo(); |
| 158 else |
| 159 UpdateAvatarInfo(); |
| 160 |
154 if (!browser_view->IsOffTheRecord()) { | 161 if (!browser_view->IsOffTheRecord()) { |
155 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 162 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
156 content::NotificationService::AllSources()); | 163 content::NotificationService::AllSources()); |
157 } | 164 } |
158 | 165 |
159 platform_observer_.reset( | 166 platform_observer_.reset( |
160 OpaqueBrowserFrameViewPlatformSpecific::Create(this, layout_)); | 167 OpaqueBrowserFrameViewPlatformSpecific::Create(this, layout_)); |
161 } | 168 } |
162 | 169 |
163 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { | 170 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 213 } |
207 | 214 |
208 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { | 215 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
209 if (!bounds().Contains(point)) | 216 if (!bounds().Contains(point)) |
210 return HTNOWHERE; | 217 return HTNOWHERE; |
211 | 218 |
212 // See if the point is within the avatar menu button or within the avatar | 219 // See if the point is within the avatar menu button or within the avatar |
213 // label. | 220 // label. |
214 if ((avatar_button() && | 221 if ((avatar_button() && |
215 avatar_button()->GetMirroredBounds().Contains(point)) || | 222 avatar_button()->GetMirroredBounds().Contains(point)) || |
216 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point))) | 223 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)) || |
| 224 (new_avatar_button() && |
| 225 new_avatar_button()->GetMirroredBounds().Contains(point))) |
217 return HTCLIENT; | 226 return HTCLIENT; |
218 | 227 |
219 int frame_component = frame()->client_view()->NonClientHitTest(point); | 228 int frame_component = frame()->client_view()->NonClientHitTest(point); |
220 | 229 |
221 // See if we're in the sysmenu region. We still have to check the tabstrip | 230 // See if we're in the sysmenu region. We still have to check the tabstrip |
222 // first so that clicks in a tab don't get treated as sysmenu clicks. | 231 // first so that clicks in a tab don't get treated as sysmenu clicks. |
223 gfx::Rect sysmenu_rect(IconBounds()); | 232 gfx::Rect sysmenu_rect(IconBounds()); |
224 // In maximized mode we extend the rect to the screen corner to take advantage | 233 // In maximized mode we extend the rect to the screen corner to take advantage |
225 // of Fitts' Law. | 234 // of Fitts' Law. |
226 if (frame()->IsMaximized()) | 235 if (frame()->IsMaximized()) |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 | 427 |
419 /////////////////////////////////////////////////////////////////////////////// | 428 /////////////////////////////////////////////////////////////////////////////// |
420 // OpaqueBrowserFrameView, protected: | 429 // OpaqueBrowserFrameView, protected: |
421 | 430 |
422 void OpaqueBrowserFrameView::Observe( | 431 void OpaqueBrowserFrameView::Observe( |
423 int type, | 432 int type, |
424 const content::NotificationSource& source, | 433 const content::NotificationSource& source, |
425 const content::NotificationDetails& details) { | 434 const content::NotificationDetails& details) { |
426 switch (type) { | 435 switch (type) { |
427 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: | 436 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: |
428 UpdateAvatarInfo(); | 437 if (browser_view() ->IsRegularOrGuestSession() && |
| 438 profiles::IsNewProfileManagementEnabled()) |
| 439 UpdateNewStyleAvatarInfo(); |
| 440 else |
| 441 UpdateAvatarInfo(); |
429 break; | 442 break; |
430 default: | 443 default: |
431 NOTREACHED() << "Got a notification we didn't register for!"; | 444 NOTREACHED() << "Got a notification we didn't register for!"; |
432 break; | 445 break; |
433 } | 446 } |
434 } | 447 } |
435 | 448 |
436 /////////////////////////////////////////////////////////////////////////////// | 449 /////////////////////////////////////////////////////////////////////////////// |
437 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: | 450 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: |
438 | 451 |
(...skipping 29 matching lines...) Expand all Loading... |
468 } | 481 } |
469 | 482 |
470 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { | 483 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { |
471 return browser_view()->GetMinimumSize(); | 484 return browser_view()->GetMinimumSize(); |
472 } | 485 } |
473 | 486 |
474 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { | 487 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { |
475 return browser_view()->ShouldShowAvatar(); | 488 return browser_view()->ShouldShowAvatar(); |
476 } | 489 } |
477 | 490 |
| 491 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const { |
| 492 return browser_view()->IsRegularOrGuestSession(); |
| 493 } |
| 494 |
478 gfx::ImageSkia OpaqueBrowserFrameView::GetOTRAvatarIcon() const { | 495 gfx::ImageSkia OpaqueBrowserFrameView::GetOTRAvatarIcon() const { |
479 return browser_view()->GetOTRAvatarIcon(); | 496 return browser_view()->GetOTRAvatarIcon(); |
480 } | 497 } |
481 | 498 |
482 bool OpaqueBrowserFrameView::IsMaximized() const { | 499 bool OpaqueBrowserFrameView::IsMaximized() const { |
483 return frame()->IsMaximized(); | 500 return frame()->IsMaximized(); |
484 } | 501 } |
485 | 502 |
486 bool OpaqueBrowserFrameView::IsMinimized() const { | 503 bool OpaqueBrowserFrameView::IsMinimized() const { |
487 return frame()->IsMinimized(); | 504 return frame()->IsMinimized(); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 | 881 |
865 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 882 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
866 gfx::ImageSkia* frame_image = GetFrameImage(); | 883 gfx::ImageSkia* frame_image = GetFrameImage(); |
867 int top_area_height = frame_image->height(); | 884 int top_area_height = frame_image->height(); |
868 if (browser_view()->IsTabStripVisible()) { | 885 if (browser_view()->IsTabStripVisible()) { |
869 top_area_height = std::max(top_area_height, | 886 top_area_height = std::max(top_area_height, |
870 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 887 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
871 } | 888 } |
872 return top_area_height; | 889 return top_area_height; |
873 } | 890 } |
OLD | NEW |