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

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

Issue 1307093004: Remove references to IsNewAvatarMenu since the flag was removed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review feedback Created 5 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
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 21 matching lines...) Expand all
32 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
33 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
34 34
35 #if defined(ENABLE_SUPERVISED_USERS) 35 #if defined(ENABLE_SUPERVISED_USERS)
36 #include "chrome/browser/supervised_user/supervised_user_service.h" 36 #include "chrome/browser/supervised_user/supervised_user_service.h"
37 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" 37 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
38 #endif 38 #endif
39 39
40 using content::BrowserThread; 40 using content::BrowserThread;
41 41
42 namespace {
43
44 // Constants for the show profile switcher experiment
45 const char kShowProfileSwitcherFieldTrialName[] = "ShowProfileSwitcher";
46 const char kAlwaysShowSwitcherGroupName[] = "AlwaysShow";
47
48 } // namespace
49
50 AvatarMenu::AvatarMenu(ProfileInfoInterface* profile_cache, 42 AvatarMenu::AvatarMenu(ProfileInfoInterface* profile_cache,
51 AvatarMenuObserver* observer, 43 AvatarMenuObserver* observer,
52 Browser* browser) 44 Browser* browser)
53 : profile_list_(ProfileList::Create(profile_cache)), 45 : profile_list_(ProfileList::Create(profile_cache)),
54 menu_actions_(AvatarMenuActions::Create()), 46 menu_actions_(AvatarMenuActions::Create()),
55 #if defined(ENABLE_SUPERVISED_USERS) 47 #if defined(ENABLE_SUPERVISED_USERS)
56 supervised_user_observer_(this), 48 supervised_user_observer_(this),
57 #endif 49 #endif
58 profile_info_(profile_cache), 50 profile_info_(profile_cache),
59 observer_(observer), 51 observer_(observer),
(...skipping 30 matching lines...) Expand all
90 signin_required(false), 82 signin_required(false),
91 menu_index(menu_index), 83 menu_index(menu_index),
92 profile_index(profile_index) { 84 profile_index(profile_index) {
93 } 85 }
94 86
95 AvatarMenu::Item::~Item() { 87 AvatarMenu::Item::~Item() {
96 } 88 }
97 89
98 // static 90 // static
99 bool AvatarMenu::ShouldShowAvatarMenu() { 91 bool AvatarMenu::ShouldShowAvatarMenu() {
100 if (base::FieldTrialList::FindFullName(kShowProfileSwitcherFieldTrialName) ==
101 kAlwaysShowSwitcherGroupName) {
102 // We should only be in this group when multi-profiles is enabled.
103 DCHECK(profiles::IsMultipleProfilesEnabled());
104 return true;
105 }
106
107 // TODO: Eliminate this ifdef. Add a delegate interface for the menu which 92 // TODO: Eliminate this ifdef. Add a delegate interface for the menu which
108 // would also help remove the Browser dependency in AvatarMenuActions 93 // would also help remove the Browser dependency in AvatarMenuActions
109 // implementations. 94 // implementations.
110 if (profiles::IsMultipleProfilesEnabled()) {
111 #if defined(OS_CHROMEOS) 95 #if defined(OS_CHROMEOS)
112 // On ChromeOS the menu will not be shown. 96 // On ChromeOS the menu will not be shown.
113 return false; 97 return false;
114 #else 98 #else
115 return switches::IsNewAvatarMenu() || 99 return true;
116 (g_browser_process->profile_manager() &&
117 g_browser_process->profile_manager()->GetNumberOfProfiles() > 1);
118 #endif 100 #endif
119 }
120 return false;
121 } 101 }
122 102
123 bool AvatarMenu::CompareItems(const Item* item1, const Item* item2) { 103 bool AvatarMenu::CompareItems(const Item* item1, const Item* item2) {
124 return base::i18n::ToLower(item1->name).compare( 104 return base::i18n::ToLower(item1->name).compare(
125 base::i18n::ToLower(item2->name)) < 0; 105 base::i18n::ToLower(item2->name)) < 0;
126 } 106 }
127 107
128 void AvatarMenu::SwitchToProfile(size_t index, 108 void AvatarMenu::SwitchToProfile(size_t index,
129 bool always_create, 109 bool always_create,
130 ProfileMetrics::ProfileOpen metric) { 110 ProfileMetrics::ProfileOpen metric) {
131 DCHECK(profiles::IsMultipleProfilesEnabled() || 111 DCHECK(profiles::IsMultipleProfilesEnabled() ||
132 index == GetActiveProfileIndex()); 112 index == GetActiveProfileIndex());
133 const Item& item = GetItemAt(index); 113 const Item& item = GetItemAt(index);
134 114
135 if (switches::IsNewAvatarMenu()) { 115 #if !defined(OS_CHROMEOS)
136 // Don't open a browser window for signed-out profiles. 116 // ChromeOS doesn't have the User Manager, it can't open it.
137 if (item.signin_required) { 117 // Don't open a browser window for signed-out profiles.
138 UserManager::Show(item.profile_path, 118 if (item.signin_required) {
139 profiles::USER_MANAGER_NO_TUTORIAL, 119 UserManager::Show(item.profile_path,
140 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 120 profiles::USER_MANAGER_NO_TUTORIAL,
141 return; 121 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
142 } 122 return;
143 } 123 }
124 #endif
144 125
145 base::FilePath path = 126 base::FilePath path =
146 profile_info_->GetPathOfProfileAtIndex(item.profile_index); 127 profile_info_->GetPathOfProfileAtIndex(item.profile_index);
147 128
148 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); 129 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop();
149 if (browser_) 130 if (browser_)
150 desktop_type = browser_->host_desktop_type(); 131 desktop_type = browser_->host_desktop_type();
151 132
152 profiles::SwitchToProfile(path, desktop_type, always_create, 133 profiles::SwitchToProfile(path, desktop_type, always_create,
153 ProfileManager::CreateCallback(), 134 ProfileManager::CreateCallback(),
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 if (observer_) 272 if (observer_)
292 observer_->OnAvatarMenuChanged(this); 273 observer_->OnAvatarMenuChanged(this);
293 } 274 }
294 #endif 275 #endif
295 276
296 void AvatarMenu::Update() { 277 void AvatarMenu::Update() {
297 RebuildMenu(); 278 RebuildMenu();
298 if (observer_) 279 if (observer_)
299 observer_->OnAvatarMenuChanged(this); 280 observer_->OnAvatarMenuChanged(this);
300 } 281 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_browser_main.cc ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698