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(this, NewAvatarButton::THEMED_BUTTON); |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 } | 215 } |
209 | 216 |
210 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { | 217 int OpaqueBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
211 if (!bounds().Contains(point)) | 218 if (!bounds().Contains(point)) |
212 return HTNOWHERE; | 219 return HTNOWHERE; |
213 | 220 |
214 // See if the point is within the avatar menu button or within the avatar | 221 // See if the point is within the avatar menu button or within the avatar |
215 // label. | 222 // label. |
216 if ((avatar_button() && | 223 if ((avatar_button() && |
217 avatar_button()->GetMirroredBounds().Contains(point)) || | 224 avatar_button()->GetMirroredBounds().Contains(point)) || |
218 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point))) | 225 (avatar_label() && avatar_label()->GetMirroredBounds().Contains(point)) || |
| 226 (new_avatar_button() && |
| 227 new_avatar_button()->GetMirroredBounds().Contains(point))) |
219 return HTCLIENT; | 228 return HTCLIENT; |
220 | 229 |
221 int frame_component = frame()->client_view()->NonClientHitTest(point); | 230 int frame_component = frame()->client_view()->NonClientHitTest(point); |
222 | 231 |
223 // See if we're in the sysmenu region. We still have to check the tabstrip | 232 // 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. | 233 // first so that clicks in a tab don't get treated as sysmenu clicks. |
225 gfx::Rect sysmenu_rect(IconBounds()); | 234 gfx::Rect sysmenu_rect(IconBounds()); |
226 // In maximized mode we extend the rect to the screen corner to take advantage | 235 // In maximized mode we extend the rect to the screen corner to take advantage |
227 // of Fitts' Law. | 236 // of Fitts' Law. |
228 if (frame()->IsMaximized()) | 237 if (frame()->IsMaximized()) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender, | 398 void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender, |
390 const ui::Event& event) { | 399 const ui::Event& event) { |
391 if (sender == minimize_button_) | 400 if (sender == minimize_button_) |
392 frame()->Minimize(); | 401 frame()->Minimize(); |
393 else if (sender == maximize_button_) | 402 else if (sender == maximize_button_) |
394 frame()->Maximize(); | 403 frame()->Maximize(); |
395 else if (sender == restore_button_) | 404 else if (sender == restore_button_) |
396 frame()->Restore(); | 405 frame()->Restore(); |
397 else if (sender == close_button_) | 406 else if (sender == close_button_) |
398 frame()->Close(); | 407 frame()->Close(); |
| 408 else if (sender == new_avatar_button()) |
| 409 ShowProfileChooserViewBubble(); |
399 } | 410 } |
400 | 411 |
401 /////////////////////////////////////////////////////////////////////////////// | 412 /////////////////////////////////////////////////////////////////////////////// |
402 // OpaqueBrowserFrameView, TabIconView::TabContentsProvider implementation: | 413 // OpaqueBrowserFrameView, TabIconView::TabContentsProvider implementation: |
403 | 414 |
404 bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const { | 415 bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const { |
405 // This function is queried during the creation of the window as the | 416 // This function is queried during the creation of the window as the |
406 // TabIconView we host is initialized, so we need to NULL check the selected | 417 // TabIconView we host is initialized, so we need to NULL check the selected |
407 // WebContents because in this condition there is not yet a selected tab. | 418 // WebContents because in this condition there is not yet a selected tab. |
408 WebContents* current_tab = browser_view()->GetActiveWebContents(); | 419 WebContents* current_tab = browser_view()->GetActiveWebContents(); |
(...skipping 11 matching lines...) Expand all Loading... |
420 | 431 |
421 /////////////////////////////////////////////////////////////////////////////// | 432 /////////////////////////////////////////////////////////////////////////////// |
422 // OpaqueBrowserFrameView, protected: | 433 // OpaqueBrowserFrameView, protected: |
423 | 434 |
424 void OpaqueBrowserFrameView::Observe( | 435 void OpaqueBrowserFrameView::Observe( |
425 int type, | 436 int type, |
426 const content::NotificationSource& source, | 437 const content::NotificationSource& source, |
427 const content::NotificationDetails& details) { | 438 const content::NotificationDetails& details) { |
428 switch (type) { | 439 switch (type) { |
429 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: | 440 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: |
430 UpdateAvatarInfo(); | 441 if (browser_view() ->IsRegularOrGuestSession() && |
| 442 profiles::IsNewProfileManagementEnabled()) |
| 443 UpdateNewStyleAvatarInfo(this, NewAvatarButton::THEMED_BUTTON); |
| 444 else |
| 445 UpdateAvatarInfo(); |
431 break; | 446 break; |
432 default: | 447 default: |
433 NOTREACHED() << "Got a notification we didn't register for!"; | 448 NOTREACHED() << "Got a notification we didn't register for!"; |
434 break; | 449 break; |
435 } | 450 } |
436 } | 451 } |
437 | 452 |
438 /////////////////////////////////////////////////////////////////////////////// | 453 /////////////////////////////////////////////////////////////////////////////// |
439 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: | 454 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: |
440 | 455 |
(...skipping 29 matching lines...) Expand all Loading... |
470 } | 485 } |
471 | 486 |
472 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { | 487 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { |
473 return browser_view()->GetMinimumSize(); | 488 return browser_view()->GetMinimumSize(); |
474 } | 489 } |
475 | 490 |
476 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { | 491 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { |
477 return browser_view()->ShouldShowAvatar(); | 492 return browser_view()->ShouldShowAvatar(); |
478 } | 493 } |
479 | 494 |
| 495 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const { |
| 496 return browser_view()->IsRegularOrGuestSession(); |
| 497 } |
| 498 |
480 gfx::ImageSkia OpaqueBrowserFrameView::GetOTRAvatarIcon() const { | 499 gfx::ImageSkia OpaqueBrowserFrameView::GetOTRAvatarIcon() const { |
481 return browser_view()->GetOTRAvatarIcon(); | 500 return browser_view()->GetOTRAvatarIcon(); |
482 } | 501 } |
483 | 502 |
484 bool OpaqueBrowserFrameView::IsMaximized() const { | 503 bool OpaqueBrowserFrameView::IsMaximized() const { |
485 return frame()->IsMaximized(); | 504 return frame()->IsMaximized(); |
486 } | 505 } |
487 | 506 |
488 bool OpaqueBrowserFrameView::IsMinimized() const { | 507 bool OpaqueBrowserFrameView::IsMinimized() const { |
489 return frame()->IsMinimized(); | 508 return frame()->IsMinimized(); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 | 885 |
867 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 886 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
868 gfx::ImageSkia* frame_image = GetFrameImage(); | 887 gfx::ImageSkia* frame_image = GetFrameImage(); |
869 int top_area_height = frame_image->height(); | 888 int top_area_height = frame_image->height(); |
870 if (browser_view()->IsTabStripVisible()) { | 889 if (browser_view()->IsTabStripVisible()) { |
871 top_area_height = std::max(top_area_height, | 890 top_area_height = std::max(top_area_height, |
872 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 891 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
873 } | 892 } |
874 return top_area_height; | 893 return top_area_height; |
875 } | 894 } |
OLD | NEW |