| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/avatar_menu_model_observer.h" | 10 #include "chrome/browser/profiles/avatar_menu_model_observer.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } | 96 } |
| 97 | 97 |
| 98 void AvatarMenuModel::AddNewProfile() { | 98 void AvatarMenuModel::AddNewProfile() { |
| 99 ProfileManager::CreateMultiProfileAsync(); | 99 ProfileManager::CreateMultiProfileAsync(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 size_t AvatarMenuModel::GetNumberOfItems() { | 102 size_t AvatarMenuModel::GetNumberOfItems() { |
| 103 return items_.size(); | 103 return items_.size(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 size_t AvatarMenuModel::GetActiveProfileIndex() { |
| 107 Profile* active_profile = NULL; |
| 108 if (!browser_) |
| 109 active_profile = ProfileManager::GetLastUsedProfile(); |
| 110 else |
| 111 active_profile = browser_->profile(); |
| 112 |
| 113 size_t index = |
| 114 profile_info_->GetIndexOfProfileWithPath(active_profile->GetPath()); |
| 115 |
| 116 DCHECK_LT(index, items_.size()); |
| 117 return index; |
| 118 } |
| 119 |
| 106 const AvatarMenuModel::Item& AvatarMenuModel::GetItemAt(size_t index) { | 120 const AvatarMenuModel::Item& AvatarMenuModel::GetItemAt(size_t index) { |
| 107 DCHECK_LT(index, items_.size()); | 121 DCHECK_LT(index, items_.size()); |
| 108 return *items_[index]; | 122 return *items_[index]; |
| 109 } | 123 } |
| 110 | 124 |
| 111 void AvatarMenuModel::Observe(int type, | 125 void AvatarMenuModel::Observe(int type, |
| 112 const content::NotificationSource& source, | 126 const content::NotificationSource& source, |
| 113 const content::NotificationDetails& details) { | 127 const content::NotificationDetails& details) { |
| 114 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); | 128 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); |
| 115 RebuildMenu(); | 129 RebuildMenu(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 139 item->active = browser_->profile()->GetPath() == path; | 153 item->active = browser_->profile()->GetPath() == path; |
| 140 } | 154 } |
| 141 items_.push_back(item); | 155 items_.push_back(item); |
| 142 } | 156 } |
| 143 } | 157 } |
| 144 | 158 |
| 145 void AvatarMenuModel::ClearMenu() { | 159 void AvatarMenuModel::ClearMenu() { |
| 146 STLDeleteContainerPointers(items_.begin(), items_.end()); | 160 STLDeleteContainerPointers(items_.begin(), items_.end()); |
| 147 items_.clear(); | 161 items_.clear(); |
| 148 } | 162 } |
| OLD | NEW |