Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: chrome/browser/profiles/avatar_menu.cc

Issue 597783003: Update the AvatarMenu when a supervised user's custodian info changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 supervised_user_observer_.Add(
76 SupervisedUserServiceFactory::GetForProfile(browser_->profile()));
77 }
78 #endif
67 } 79 }
68 80
69 AvatarMenu::~AvatarMenu() { 81 AvatarMenu::~AvatarMenu() {
70 } 82 }
71 83
72 AvatarMenu::Item::Item(size_t menu_index, 84 AvatarMenu::Item::Item(size_t menu_index,
73 size_t profile_index, 85 size_t profile_index,
74 const gfx::Image& icon) 86 const gfx::Image& icon)
75 : icon(icon), 87 : icon(icon),
76 active(false), 88 active(false),
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 239 }
228 240
229 void AvatarMenu::Observe(int type, 241 void AvatarMenu::Observe(int type,
230 const content::NotificationSource& source, 242 const content::NotificationSource& source,
231 const content::NotificationDetails& details) { 243 const content::NotificationDetails& details) {
232 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); 244 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type);
233 RebuildMenu(); 245 RebuildMenu();
234 if (observer_) 246 if (observer_)
235 observer_->OnAvatarMenuChanged(this); 247 observer_->OnAvatarMenuChanged(this);
236 } 248 }
249
250 #if defined(ENABLE_MANAGED_USERS)
251 void AvatarMenu::OnCustodianInfoChanged() {
252 RebuildMenu();
253 if (observer_)
254 observer_->OnAvatarMenuChanged(this);
255 }
256 #endif
OLDNEW
« no previous file with comments | « chrome/browser/profiles/avatar_menu.h ('k') | chrome/browser/profiles/profile_list_desktop_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698