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/glass_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
11 #include "chrome/browser/chrome_notification_types.h" | |
12 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/signin/signin_header_helper.h" | 12 #include "chrome/browser/signin/signin_header_helper.h" |
14 #include "chrome/browser/themes/theme_properties.h" | 13 #include "chrome/browser/themes/theme_properties.h" |
15 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
16 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 15 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
17 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" | 16 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" |
18 #include "chrome/browser/ui/views/tabs/tab.h" | 17 #include "chrome/browser/ui/views/tabs/tab.h" |
19 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 18 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
20 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 19 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
21 #include "components/signin/core/common/profile_management_switches.h" | 20 #include "components/signin/core/common/profile_management_switches.h" |
22 #include "content/public/browser/notification_service.h" | |
23 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
24 #include "skia/ext/image_operations.h" | 22 #include "skia/ext/image_operations.h" |
25 #include "ui/base/resource/resource_bundle_win.h" | 23 #include "ui/base/resource/resource_bundle_win.h" |
26 #include "ui/base/theme_provider.h" | 24 #include "ui/base/theme_provider.h" |
27 #include "ui/gfx/canvas.h" | 25 #include "ui/gfx/canvas.h" |
28 #include "ui/gfx/icon_util.h" | 26 #include "ui/gfx/icon_util.h" |
29 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
30 #include "ui/gfx/win/dpi.h" | 28 #include "ui/gfx/win/dpi.h" |
31 #include "ui/resources/grit/ui_resources.h" | 29 #include "ui/resources/grit/ui_resources.h" |
32 #include "ui/views/controls/label.h" | 30 #include "ui/views/controls/label.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 : BrowserNonClientFrameView(frame, browser_view), | 92 : BrowserNonClientFrameView(frame, browser_view), |
95 throbber_running_(false), | 93 throbber_running_(false), |
96 throbber_frame_(0) { | 94 throbber_frame_(0) { |
97 if (browser_view->ShouldShowWindowIcon()) | 95 if (browser_view->ShouldShowWindowIcon()) |
98 InitThrobberIcons(); | 96 InitThrobberIcons(); |
99 | 97 |
100 if (browser_view->IsRegularOrGuestSession() && switches::IsNewAvatarMenu()) | 98 if (browser_view->IsRegularOrGuestSession() && switches::IsNewAvatarMenu()) |
101 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); | 99 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); |
102 else | 100 else |
103 UpdateAvatarInfo(); | 101 UpdateAvatarInfo(); |
104 | |
105 if (!browser_view->IsOffTheRecord()) { | |
106 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | |
107 content::NotificationService::AllSources()); | |
108 } | |
109 } | 102 } |
110 | 103 |
111 GlassBrowserFrameView::~GlassBrowserFrameView() { | 104 GlassBrowserFrameView::~GlassBrowserFrameView() { |
112 } | 105 } |
113 | 106 |
114 /////////////////////////////////////////////////////////////////////////////// | 107 /////////////////////////////////////////////////////////////////////////////// |
115 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: | 108 // GlassBrowserFrameView, BrowserNonClientFrameView implementation: |
116 | 109 |
117 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( | 110 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip( |
118 views::View* tabstrip) const { | 111 views::View* tabstrip) const { |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 } | 580 } |
588 } | 581 } |
589 | 582 |
590 void GlassBrowserFrameView::DisplayNextThrobberFrame() { | 583 void GlassBrowserFrameView::DisplayNextThrobberFrame() { |
591 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; | 584 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; |
592 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, | 585 SendMessage(views::HWNDForWidget(frame()), WM_SETICON, |
593 static_cast<WPARAM>(ICON_SMALL), | 586 static_cast<WPARAM>(ICON_SMALL), |
594 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); | 587 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); |
595 } | 588 } |
596 | 589 |
597 void GlassBrowserFrameView::Observe( | 590 void GlassBrowserFrameView::OnProfileAdded(const base::FilePath& profile_path) { |
598 int type, | 591 if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu()) |
rpetterson
2015/02/07 00:04:58
I feel like I'm seeing this update code frequently
noms (inactive)
2015/02/12 21:46:02
Done.
| |
599 const content::NotificationSource& source, | 592 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); |
600 const content::NotificationDetails& details) { | 593 else |
601 switch (type) { | 594 UpdateAvatarInfo(); |
602 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: | 595 } |
603 if (browser_view()->IsRegularOrGuestSession() && | 596 |
604 switches::IsNewAvatarMenu()) { | 597 void GlassBrowserFrameView::OnProfileWasRemoved( |
605 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); | 598 const base::FilePath& profile_path, |
606 } else { | 599 const base::string16& profile_name) { |
607 UpdateAvatarInfo(); | 600 if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu()) |
608 } | 601 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); |
609 break; | 602 else |
610 default: | 603 UpdateAvatarInfo(); |
611 NOTREACHED() << "Got a notification we didn't register for!"; | 604 } |
612 break; | 605 |
613 } | 606 void GlassBrowserFrameView::OnProfileNameChanged( |
607 const base::FilePath& profile_path, | |
608 const base::string16& old_profile_name) { | |
609 // Profile names are only displayed in the new UI. | |
610 if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu()) | |
611 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON); | |
612 } | |
613 | |
614 void GlassBrowserFrameView::OnProfileAvatarChanged( | |
615 const base::FilePath& profile_path) { | |
616 // Profile avatars are only displayed in the old UI or incognito. | |
617 if (browser_view()->IsOffTheRecord() || !switches::IsNewAvatarMenu()) | |
618 UpdateAvatarInfo(); | |
614 } | 619 } |
615 | 620 |
616 // static | 621 // static |
617 void GlassBrowserFrameView::InitThrobberIcons() { | 622 void GlassBrowserFrameView::InitThrobberIcons() { |
618 static bool initialized = false; | 623 static bool initialized = false; |
619 if (!initialized) { | 624 if (!initialized) { |
620 for (int i = 0; i < kThrobberIconCount; ++i) { | 625 for (int i = 0; i < kThrobberIconCount; ++i) { |
621 throbber_icons_[i] = | 626 throbber_icons_[i] = |
622 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); | 627 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i); |
623 DCHECK(throbber_icons_[i]); | 628 DCHECK(throbber_icons_[i]); |
624 } | 629 } |
625 initialized = true; | 630 initialized = true; |
626 } | 631 } |
627 } | 632 } |
OLD | NEW |