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

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: add notreached() Created 8 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
Joao da Silva 2012/02/23 12:05:14 Nit: copyright year
Bernhard Bauer 2012/02/23 12:14:36 That's fixed up by the commit queue automatically,
Joao da Silva 2012/02/23 15:28:18 Didn't know that, cool.
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(Profile* profile, 33 void OnProfileCreated(Profile* profile,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 const content::NotificationSource& source, 133 const content::NotificationSource& source,
132 const content::NotificationDetails& details) { 134 const content::NotificationDetails& details) {
133 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); 135 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type);
134 RebuildMenu(); 136 RebuildMenu();
135 observer_->OnAvatarMenuModelChanged(this); 137 observer_->OnAvatarMenuModelChanged(this);
136 } 138 }
137 139
138 // static 140 // static
139 bool AvatarMenuModel::ShouldShowAvatarMenu() { 141 bool AvatarMenuModel::ShouldShowAvatarMenu() {
140 return ProfileManager::IsMultipleProfilesEnabled() && 142 return ProfileManager::IsMultipleProfilesEnabled() &&
143 !g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode) &&
141 g_browser_process->profile_manager()->GetNumberOfProfiles() > 1; 144 g_browser_process->profile_manager()->GetNumberOfProfiles() > 1;
142 } 145 }
143 146
144 void AvatarMenuModel::RebuildMenu() { 147 void AvatarMenuModel::RebuildMenu() {
145 ClearMenu(); 148 ClearMenu();
146 149
147 const size_t count = profile_info_->GetNumberOfProfiles(); 150 const size_t count = profile_info_->GetNumberOfProfiles();
148 for (size_t i = 0; i < count; ++i) { 151 for (size_t i = 0; i < count; ++i) {
149 bool is_gaia_picture = 152 bool is_gaia_picture =
150 profile_info_->IsUsingGAIAPictureOfProfileAtIndex(i) && 153 profile_info_->IsUsingGAIAPictureOfProfileAtIndex(i) &&
(...skipping 13 matching lines...) Expand all
164 item->active = browser_->profile()->GetPath() == path; 167 item->active = browser_->profile()->GetPath() == path;
165 } 168 }
166 items_.push_back(item); 169 items_.push_back(item);
167 } 170 }
168 } 171 }
169 172
170 void AvatarMenuModel::ClearMenu() { 173 void AvatarMenuModel::ClearMenu() {
171 STLDeleteContainerPointers(items_.begin(), items_.end()); 174 STLDeleteContainerPointers(items_.begin(), items_.end());
172 items_.clear(); 175 items_.clear();
173 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698