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_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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 return index; | 162 return index; |
163 } | 163 } |
164 | 164 |
165 const AvatarMenuModel::Item& AvatarMenuModel::GetItemAt(size_t index) { | 165 const AvatarMenuModel::Item& AvatarMenuModel::GetItemAt(size_t index) { |
166 DCHECK_LT(index, items_.size()); | 166 DCHECK_LT(index, items_.size()); |
167 return *items_[index]; | 167 return *items_[index]; |
168 } | 168 } |
169 | 169 |
170 bool AvatarMenuModel::ShouldShowAddNewProfileLink() const { | 170 bool AvatarMenuModel::ShouldShowAddNewProfileLink() const { |
171 #if defined(ENABLE_MANAGED_USERS) | 171 #if defined(ENABLE_MANAGED_USERS) |
172 Profile* active_profile = NULL; | |
173 if (!browser_) | 172 if (!browser_) |
174 active_profile = ProfileManager::GetLastUsedProfile(); | 173 return true; |
175 else | |
176 active_profile = browser_->profile(); | |
177 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile( | 174 ManagedUserService* service = ManagedUserServiceFactory::GetForProfile( |
178 active_profile); | 175 browser_->profile()); |
179 return !service->ProfileIsManaged(); | 176 return !service->ProfileIsManaged(); |
180 #endif | 177 #endif |
181 return true; | 178 return true; |
182 } | 179 } |
183 | 180 |
184 void AvatarMenuModel::Observe(int type, | 181 void AvatarMenuModel::Observe(int type, |
185 const content::NotificationSource& source, | 182 const content::NotificationSource& source, |
186 const content::NotificationDetails& details) { | 183 const content::NotificationDetails& details) { |
187 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); | 184 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); |
188 RebuildMenu(); | 185 RebuildMenu(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 base::FilePath path = profile_info_->GetPathOfProfileAtIndex(i); | 227 base::FilePath path = profile_info_->GetPathOfProfileAtIndex(i); |
231 item->active = browser_->profile()->GetPath() == path; | 228 item->active = browser_->profile()->GetPath() == path; |
232 } | 229 } |
233 items_.push_back(item); | 230 items_.push_back(item); |
234 } | 231 } |
235 } | 232 } |
236 | 233 |
237 void AvatarMenuModel::ClearMenu() { | 234 void AvatarMenuModel::ClearMenu() { |
238 STLDeleteElements(&items_); | 235 STLDeleteElements(&items_); |
239 } | 236 } |
OLD | NEW |