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 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender, | 396 void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender, |
388 const ui::Event& event) { | 397 const ui::Event& event) { |
389 if (sender == minimize_button_) | 398 if (sender == minimize_button_) |
390 frame()->Minimize(); | 399 frame()->Minimize(); |
391 else if (sender == maximize_button_) | 400 else if (sender == maximize_button_) |
392 frame()->Maximize(); | 401 frame()->Maximize(); |
393 else if (sender == restore_button_) | 402 else if (sender == restore_button_) |
394 frame()->Restore(); | 403 frame()->Restore(); |
395 else if (sender == close_button_) | 404 else if (sender == close_button_) |
396 frame()->Close(); | 405 frame()->Close(); |
| 406 else if (sender == new_avatar_button()) |
| 407 ShowProfileChooserViewBubble(); |
397 } | 408 } |
398 | 409 |
399 /////////////////////////////////////////////////////////////////////////////// | 410 /////////////////////////////////////////////////////////////////////////////// |
400 // OpaqueBrowserFrameView, TabIconView::TabContentsProvider implementation: | 411 // OpaqueBrowserFrameView, TabIconView::TabContentsProvider implementation: |
401 | 412 |
402 bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const { | 413 bool OpaqueBrowserFrameView::ShouldTabIconViewAnimate() const { |
403 // This function is queried during the creation of the window as the | 414 // This function is queried during the creation of the window as the |
404 // TabIconView we host is initialized, so we need to NULL check the selected | 415 // TabIconView we host is initialized, so we need to NULL check the selected |
405 // WebContents because in this condition there is not yet a selected tab. | 416 // WebContents because in this condition there is not yet a selected tab. |
406 WebContents* current_tab = browser_view()->GetActiveWebContents(); | 417 WebContents* current_tab = browser_view()->GetActiveWebContents(); |
(...skipping 11 matching lines...) Expand all Loading... |
418 | 429 |
419 /////////////////////////////////////////////////////////////////////////////// | 430 /////////////////////////////////////////////////////////////////////////////// |
420 // OpaqueBrowserFrameView, protected: | 431 // OpaqueBrowserFrameView, protected: |
421 | 432 |
422 void OpaqueBrowserFrameView::Observe( | 433 void OpaqueBrowserFrameView::Observe( |
423 int type, | 434 int type, |
424 const content::NotificationSource& source, | 435 const content::NotificationSource& source, |
425 const content::NotificationDetails& details) { | 436 const content::NotificationDetails& details) { |
426 switch (type) { | 437 switch (type) { |
427 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: | 438 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: |
428 UpdateAvatarInfo(); | 439 if (browser_view() ->IsRegularOrGuestSession() && |
| 440 profiles::IsNewProfileManagementEnabled()) |
| 441 UpdateNewStyleAvatarInfo(this, NewAvatarButton::THEMED_BUTTON); |
| 442 else |
| 443 UpdateAvatarInfo(); |
429 break; | 444 break; |
430 default: | 445 default: |
431 NOTREACHED() << "Got a notification we didn't register for!"; | 446 NOTREACHED() << "Got a notification we didn't register for!"; |
432 break; | 447 break; |
433 } | 448 } |
434 } | 449 } |
435 | 450 |
436 /////////////////////////////////////////////////////////////////////////////// | 451 /////////////////////////////////////////////////////////////////////////////// |
437 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: | 452 // OpaqueBrowserFrameView, OpaqueBrowserFrameViewLayoutDelegate implementation: |
438 | 453 |
(...skipping 29 matching lines...) Expand all Loading... |
468 } | 483 } |
469 | 484 |
470 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { | 485 gfx::Size OpaqueBrowserFrameView::GetBrowserViewMinimumSize() const { |
471 return browser_view()->GetMinimumSize(); | 486 return browser_view()->GetMinimumSize(); |
472 } | 487 } |
473 | 488 |
474 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { | 489 bool OpaqueBrowserFrameView::ShouldShowAvatar() const { |
475 return browser_view()->ShouldShowAvatar(); | 490 return browser_view()->ShouldShowAvatar(); |
476 } | 491 } |
477 | 492 |
| 493 bool OpaqueBrowserFrameView::IsRegularOrGuestSession() const { |
| 494 return browser_view()->IsRegularOrGuestSession(); |
| 495 } |
| 496 |
478 gfx::ImageSkia OpaqueBrowserFrameView::GetOTRAvatarIcon() const { | 497 gfx::ImageSkia OpaqueBrowserFrameView::GetOTRAvatarIcon() const { |
479 return browser_view()->GetOTRAvatarIcon(); | 498 return browser_view()->GetOTRAvatarIcon(); |
480 } | 499 } |
481 | 500 |
482 bool OpaqueBrowserFrameView::IsMaximized() const { | 501 bool OpaqueBrowserFrameView::IsMaximized() const { |
483 return frame()->IsMaximized(); | 502 return frame()->IsMaximized(); |
484 } | 503 } |
485 | 504 |
486 bool OpaqueBrowserFrameView::IsMinimized() const { | 505 bool OpaqueBrowserFrameView::IsMinimized() const { |
487 return frame()->IsMinimized(); | 506 return frame()->IsMinimized(); |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 | 883 |
865 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 884 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
866 gfx::ImageSkia* frame_image = GetFrameImage(); | 885 gfx::ImageSkia* frame_image = GetFrameImage(); |
867 int top_area_height = frame_image->height(); | 886 int top_area_height = frame_image->height(); |
868 if (browser_view()->IsTabStripVisible()) { | 887 if (browser_view()->IsTabStripVisible()) { |
869 top_area_height = std::max(top_area_height, | 888 top_area_height = std::max(top_area_height, |
870 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 889 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
871 } | 890 } |
872 return top_area_height; | 891 return top_area_height; |
873 } | 892 } |
OLD | NEW |