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

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

Issue 9432003: Disable multi-profile UI in managed mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 9 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 | Annotate | Revision Log
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_model.h" 5 #include "chrome/browser/profiles/avatar_menu_model.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/avatar_menu_model_observer.h" 12 #include "chrome/browser/profiles/avatar_menu_model_observer.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_info_cache.h" 14 #include "chrome/browser/profiles/profile_info_cache.h"
14 #include "chrome/browser/profiles/profile_info_util.h" 15 #include "chrome/browser/profiles/profile_info_util.h"
15 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/profiles/profile_metrics.h" 17 #include "chrome/browser/profiles/profile_metrics.h"
17 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_init.h" 19 #include "chrome/browser/ui/browser_init.h"
19 #include "chrome/browser/ui/browser_list.h" 20 #include "chrome/browser/ui/browser_list.h"
20 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/common/chrome_notification_types.h" 22 #include "chrome/common/chrome_notification_types.h"
23 #include "chrome/common/pref_names.h"
22 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
23 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
24 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
25 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
26 28
27 using content::BrowserThread; 29 using content::BrowserThread;
28 30
29 namespace { 31 namespace {
30 32
31 void OnProfileCreated(bool always_create, 33 void OnProfileCreated(bool always_create,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 const content::NotificationSource& source, 136 const content::NotificationSource& source,
135 const content::NotificationDetails& details) { 137 const content::NotificationDetails& details) {
136 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); 138 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type);
137 RebuildMenu(); 139 RebuildMenu();
138 observer_->OnAvatarMenuModelChanged(this); 140 observer_->OnAvatarMenuModelChanged(this);
139 } 141 }
140 142
141 // static 143 // static
142 bool AvatarMenuModel::ShouldShowAvatarMenu() { 144 bool AvatarMenuModel::ShouldShowAvatarMenu() {
143 return ProfileManager::IsMultipleProfilesEnabled() && 145 return ProfileManager::IsMultipleProfilesEnabled() &&
146 !g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode) &&
144 g_browser_process->profile_manager()->GetNumberOfProfiles() > 1; 147 g_browser_process->profile_manager()->GetNumberOfProfiles() > 1;
145 } 148 }
146 149
147 void AvatarMenuModel::RebuildMenu() { 150 void AvatarMenuModel::RebuildMenu() {
148 ClearMenu(); 151 ClearMenu();
149 152
150 const size_t count = profile_info_->GetNumberOfProfiles(); 153 const size_t count = profile_info_->GetNumberOfProfiles();
151 for (size_t i = 0; i < count; ++i) { 154 for (size_t i = 0; i < count; ++i) {
152 bool is_gaia_picture = 155 bool is_gaia_picture =
153 profile_info_->IsUsingGAIAPictureOfProfileAtIndex(i) && 156 profile_info_->IsUsingGAIAPictureOfProfileAtIndex(i) &&
(...skipping 13 matching lines...) Expand all
167 item->active = browser_->profile()->GetPath() == path; 170 item->active = browser_->profile()->GetPath() == path;
168 } 171 }
169 items_.push_back(item); 172 items_.push_back(item);
170 } 173 }
171 } 174 }
172 175
173 void AvatarMenuModel::ClearMenu() { 176 void AvatarMenuModel::ClearMenu() {
174 STLDeleteContainerPointers(items_.begin(), items_.end()); 177 STLDeleteContainerPointers(items_.begin(), items_.end());
175 items_.clear(); 178 items_.clear();
176 } 179 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_manager.cc » ('j') | chrome/browser/profiles/profile_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698