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

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

Issue 12379014: Hide add new profile menu entry for managed users. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Extract avatar_menu_bubble_view.cc Created 7 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/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 11 matching lines...) Expand all
22 #include "chrome/browser/ui/chrome_pages.h" 22 #include "chrome/browser/ui/chrome_pages.h"
23 #include "chrome/browser/ui/host_desktop.h" 23 #include "chrome/browser/ui/host_desktop.h"
24 #include "chrome/browser/ui/startup/startup_browser_creator.h" 24 #include "chrome/browser/ui/startup/startup_browser_creator.h"
25 #include "chrome/common/chrome_notification_types.h" 25 #include "chrome/common/chrome_notification_types.h"
26 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
27 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
29 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
30 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
31 31
32 #if defined(ENABLE_MANAGED_USERS)
33 #include "chrome/browser/managed_mode/managed_user_service.h"
34 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
35 #endif
36
32 using content::BrowserThread; 37 using content::BrowserThread;
33 38
34 namespace { 39 namespace {
35 40
36 void OnProfileCreated(bool always_create, 41 void OnProfileCreated(bool always_create,
37 chrome::HostDesktopType desktop_type, 42 chrome::HostDesktopType desktop_type,
38 Profile* profile, 43 Profile* profile,
39 Profile::CreateStatus status) { 44 Profile::CreateStatus status) {
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
41 46
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 160
156 DCHECK_LT(index, items_.size()); 161 DCHECK_LT(index, items_.size());
157 return index; 162 return index;
158 } 163 }
159 164
160 const AvatarMenuModel::Item& AvatarMenuModel::GetItemAt(size_t index) { 165 const AvatarMenuModel::Item& AvatarMenuModel::GetItemAt(size_t index) {
161 DCHECK_LT(index, items_.size()); 166 DCHECK_LT(index, items_.size());
162 return *items_[index]; 167 return *items_[index];
163 } 168 }
164 169
170 bool AvatarMenuModel::ShouldShowAddNewProfileLink() const {
171 #if defined(ENABLE_MANAGED_USERS)
172 Profile* active_profile = NULL;
173 if (!browser_)
174 active_profile = ProfileManager::GetLastUsedProfile();
175 else
176 active_profile = browser_->profile();
177 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile(
178 active_profile);
179 return !service->ProfileIsManaged();
180 #endif
181 return true;
182 }
183
165 void AvatarMenuModel::Observe(int type, 184 void AvatarMenuModel::Observe(int type,
166 const content::NotificationSource& source, 185 const content::NotificationSource& source,
167 const content::NotificationDetails& details) { 186 const content::NotificationDetails& details) {
168 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); 187 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type);
169 RebuildMenu(); 188 RebuildMenu();
170 if (observer_) 189 if (observer_)
171 observer_->OnAvatarMenuModelChanged(this); 190 observer_->OnAvatarMenuModelChanged(this);
172 } 191 }
173 192
174 // static 193 // static
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 base::FilePath path = profile_info_->GetPathOfProfileAtIndex(i); 225 base::FilePath path = profile_info_->GetPathOfProfileAtIndex(i);
207 item->active = browser_->profile()->GetPath() == path; 226 item->active = browser_->profile()->GetPath() == path;
208 } 227 }
209 items_.push_back(item); 228 items_.push_back(item);
210 } 229 }
211 } 230 }
212 231
213 void AvatarMenuModel::ClearMenu() { 232 void AvatarMenuModel::ClearMenu() {
214 STLDeleteElements(&items_); 233 STLDeleteElements(&items_);
215 } 234 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/avatar_menu_model.h ('k') | chrome/browser/ui/gtk/avatar_menu_bubble_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698