| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/i18n/case_conversion.h" | 8 #include "base/i18n/case_conversion.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/profiler/scoped_tracker.h" | 10 #include "base/profiler/scoped_tracker.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 using content::BrowserThread; | 40 using content::BrowserThread; |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 // Constants for the show profile switcher experiment | 44 // Constants for the show profile switcher experiment |
| 45 const char kShowProfileSwitcherFieldTrialName[] = "ShowProfileSwitcher"; | 45 const char kShowProfileSwitcherFieldTrialName[] = "ShowProfileSwitcher"; |
| 46 const char kAlwaysShowSwitcherGroupName[] = "AlwaysShow"; | 46 const char kAlwaysShowSwitcherGroupName[] = "AlwaysShow"; |
| 47 | 47 |
| 48 } // namespace | 48 } // namespace |
| 49 | 49 |
| 50 #if defined(OS_ANDROID) |
| 50 AvatarMenu::AvatarMenu(ProfileInfoInterface* profile_cache, | 51 AvatarMenu::AvatarMenu(ProfileInfoInterface* profile_cache, |
| 51 AvatarMenuObserver* observer, | 52 AvatarMenuObserver* observer, |
| 52 Browser* browser) | 53 Browser* browser) |
| 54 : profile_list_(nullptr), |
| 55 menu_actions_(nullptr), |
| 56 #if defined(ENABLE_SUPERVISED_USERS) |
| 57 supervised_user_observer_(this), |
| 58 #endif |
| 59 profile_info_(profile_cache), |
| 60 observer_(observer), |
| 61 browser_(browser) { |
| 62 NOTIMPLEMENTED(); |
| 63 } |
| 64 #else |
| 65 AvatarMenu::AvatarMenu(ProfileInfoInterface* profile_cache, |
| 66 AvatarMenuObserver* observer, |
| 67 Browser* browser) |
| 53 : profile_list_(ProfileList::Create(profile_cache)), | 68 : profile_list_(ProfileList::Create(profile_cache)), |
| 54 menu_actions_(AvatarMenuActions::Create()), | 69 menu_actions_(AvatarMenuActions::Create()), |
| 55 #if defined(ENABLE_SUPERVISED_USERS) | 70 #if defined(ENABLE_SUPERVISED_USERS) |
| 56 supervised_user_observer_(this), | 71 supervised_user_observer_(this), |
| 57 #endif | 72 #endif |
| 58 profile_info_(profile_cache), | 73 profile_info_(profile_cache), |
| 59 observer_(observer), | 74 observer_(observer), |
| 60 browser_(browser) { | 75 browser_(browser) { |
| 61 DCHECK(profile_info_); | 76 DCHECK(profile_info_); |
| 62 // Don't DCHECK(browser_) so that unit tests can reuse this ctor. | 77 // Don't DCHECK(browser_) so that unit tests can reuse this ctor. |
| 63 | 78 |
| 64 ActiveBrowserChanged(browser_); | 79 ActiveBrowserChanged(browser_); |
| 65 | 80 |
| 66 // Register this as an observer of the info cache. | 81 // Register this as an observer of the info cache. |
| 67 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this); | 82 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this); |
| 68 | 83 |
| 69 #if defined(ENABLE_SUPERVISED_USERS) | 84 #if defined(ENABLE_SUPERVISED_USERS) |
| 70 // Register this as an observer of the SupervisedUserService to be notified | 85 // Register this as an observer of the SupervisedUserService to be notified |
| 71 // of changes to the custodian info. | 86 // of changes to the custodian info. |
| 72 if (browser_) { | 87 if (browser_) { |
| 73 supervised_user_observer_.Add( | 88 supervised_user_observer_.Add( |
| 74 SupervisedUserServiceFactory::GetForProfile(browser_->profile())); | 89 SupervisedUserServiceFactory::GetForProfile(browser_->profile())); |
| 75 } | 90 } |
| 76 #endif | 91 #endif |
| 77 } | 92 } |
| 93 #endif // OS_ANDROID |
| 78 | 94 |
| 79 AvatarMenu::~AvatarMenu() { | 95 AvatarMenu::~AvatarMenu() { |
| 80 g_browser_process->profile_manager()-> | 96 g_browser_process->profile_manager()-> |
| 81 GetProfileInfoCache().RemoveObserver(this); | 97 GetProfileInfoCache().RemoveObserver(this); |
| 82 } | 98 } |
| 83 | 99 |
| 84 AvatarMenu::Item::Item(size_t menu_index, | 100 AvatarMenu::Item::Item(size_t menu_index, |
| 85 size_t profile_index, | 101 size_t profile_index, |
| 86 const gfx::Image& icon) | 102 const gfx::Image& icon) |
| 87 : icon(icon), | 103 : icon(icon), |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 if (observer_) | 315 if (observer_) |
| 300 observer_->OnAvatarMenuChanged(this); | 316 observer_->OnAvatarMenuChanged(this); |
| 301 } | 317 } |
| 302 #endif | 318 #endif |
| 303 | 319 |
| 304 void AvatarMenu::Update() { | 320 void AvatarMenu::Update() { |
| 305 RebuildMenu(); | 321 RebuildMenu(); |
| 306 if (observer_) | 322 if (observer_) |
| 307 observer_->OnAvatarMenuChanged(this); | 323 observer_->OnAvatarMenuChanged(this); |
| 308 } | 324 } |
| OLD | NEW |