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/profiles/avatar_menu.h" | 5 #include "chrome/browser/profiles/avatar_menu.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 const char kShowProfileSwitcherFieldTrialName[] = "ShowProfileSwitcher"; | 46 const char kShowProfileSwitcherFieldTrialName[] = "ShowProfileSwitcher"; |
47 const char kAlwaysShowSwitcherGroupName[] = "AlwaysShow"; | 47 const char kAlwaysShowSwitcherGroupName[] = "AlwaysShow"; |
48 | 48 |
49 } // namespace | 49 } // namespace |
50 | 50 |
51 AvatarMenu::AvatarMenu(ProfileInfoInterface* profile_cache, | 51 AvatarMenu::AvatarMenu(ProfileInfoInterface* profile_cache, |
52 AvatarMenuObserver* observer, | 52 AvatarMenuObserver* observer, |
53 Browser* browser) | 53 Browser* browser) |
54 : profile_list_(ProfileList::Create(profile_cache)), | 54 : profile_list_(ProfileList::Create(profile_cache)), |
55 menu_actions_(AvatarMenuActions::Create()), | 55 menu_actions_(AvatarMenuActions::Create()), |
56 #if defined(ENABLE_MANAGED_USERS) | |
57 supervised_user_observer_(this), | |
58 #endif | |
56 profile_info_(profile_cache), | 59 profile_info_(profile_cache), |
57 observer_(observer), | 60 observer_(observer), |
58 browser_(browser) { | 61 browser_(browser) { |
59 DCHECK(profile_info_); | 62 DCHECK(profile_info_); |
60 // Don't DCHECK(browser_) so that unit tests can reuse this ctor. | 63 // Don't DCHECK(browser_) so that unit tests can reuse this ctor. |
61 | 64 |
62 ActiveBrowserChanged(browser_); | 65 ActiveBrowserChanged(browser_); |
63 | 66 |
64 // Register this as an observer of the info cache. | 67 // Register this as an observer of the info cache. |
65 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 68 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
66 content::NotificationService::AllSources()); | 69 content::NotificationService::AllSources()); |
70 | |
71 #if defined(ENABLE_MANAGED_USERS) | |
72 // Register this as an observer of the SupervisedUserService to be notified | |
73 // of changes to the custodian info. | |
74 if (browser_) { | |
75 SupervisedUserService* service = | |
76 SupervisedUserServiceFactory::GetForProfile(browser_->profile()); | |
77 supervised_user_observer_.Add(service); | |
Bernhard Bauer
2014/09/25 16:11:19
You could even inline |service| now?
Marc Treib
2014/09/25 16:17:16
Done.
| |
78 } | |
79 #endif | |
67 } | 80 } |
68 | 81 |
69 AvatarMenu::~AvatarMenu() { | 82 AvatarMenu::~AvatarMenu() { |
70 } | 83 } |
71 | 84 |
72 AvatarMenu::Item::Item(size_t menu_index, | 85 AvatarMenu::Item::Item(size_t menu_index, |
73 size_t profile_index, | 86 size_t profile_index, |
74 const gfx::Image& icon) | 87 const gfx::Image& icon) |
75 : icon(icon), | 88 : icon(icon), |
76 active(false), | 89 active(false), |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 } | 240 } |
228 | 241 |
229 void AvatarMenu::Observe(int type, | 242 void AvatarMenu::Observe(int type, |
230 const content::NotificationSource& source, | 243 const content::NotificationSource& source, |
231 const content::NotificationDetails& details) { | 244 const content::NotificationDetails& details) { |
232 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); | 245 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); |
233 RebuildMenu(); | 246 RebuildMenu(); |
234 if (observer_) | 247 if (observer_) |
235 observer_->OnAvatarMenuChanged(this); | 248 observer_->OnAvatarMenuChanged(this); |
236 } | 249 } |
250 | |
251 #if defined(ENABLE_MANAGED_USERS) | |
252 void AvatarMenu::OnCustodianInfoChanged() { | |
253 RebuildMenu(); | |
254 if (observer_) | |
255 observer_->OnAvatarMenuChanged(this); | |
256 } | |
257 #endif | |
OLD | NEW |