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/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 "base/utf_string_conversions.h" | |
10 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.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_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
19 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 profile_info_->GetPathOfProfileAtIndex(GetItemAt(index).model_index)); | 96 profile_info_->GetPathOfProfileAtIndex(GetItemAt(index).model_index)); |
96 browser = new Browser(Browser::CreateParams(profile)); | 97 browser = new Browser(Browser::CreateParams(profile)); |
97 } | 98 } |
98 std::string page = chrome::kManageProfileSubPage; | 99 std::string page = chrome::kManageProfileSubPage; |
99 page += "#"; | 100 page += "#"; |
100 page += base::IntToString(static_cast<int>(index)); | 101 page += base::IntToString(static_cast<int>(index)); |
101 chrome::ShowSettingsSubPage(browser, page); | 102 chrome::ShowSettingsSubPage(browser, page); |
102 } | 103 } |
103 | 104 |
104 void AvatarMenuModel::AddNewProfile() { | 105 void AvatarMenuModel::AddNewProfile() { |
105 ProfileManager::CreateMultiProfileAsync(string16(), string16()); | 106 // Temporarily generate a random icon/name pair to create the profile with |
107 // instead of opening a dialog for creating a profile | |
SteveT
2012/08/15 18:29:41
nit: profile -> profile.
Halli
2012/08/15 19:29:59
Done.
| |
108 // Remove on completion of BUG 134904 | |
SteveT
2012/08/15 18:29:41
nit: 134904 -> 134904.
Halli
2012/08/15 19:29:59
Done.
| |
109 if (ProfileShortcutManager::IsFeatureEnabled()) { | |
110 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
111 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | |
112 size_t icon_index = cache.ChooseAvatarIconIndexForNewProfile(); | |
113 | |
114 g_browser_process->profile_manager()->CreateMultiProfileAsync( | |
115 cache.ChooseNameForNewProfile(icon_index), | |
116 ASCIIToUTF16(cache.GetDefaultAvatarIconUrl(icon_index))); | |
117 } else { | |
118 ProfileManager::CreateMultiProfileAsync(string16(), string16()); | |
119 } | |
120 | |
106 ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_ICON); | 121 ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_ICON); |
107 } | 122 } |
108 | 123 |
109 size_t AvatarMenuModel::GetNumberOfItems() { | 124 size_t AvatarMenuModel::GetNumberOfItems() { |
110 return items_.size(); | 125 return items_.size(); |
111 } | 126 } |
112 | 127 |
113 size_t AvatarMenuModel::GetActiveProfileIndex() { | 128 size_t AvatarMenuModel::GetActiveProfileIndex() { |
114 // During singleton profile deletion, this function can be called with no | 129 // During singleton profile deletion, this function can be called with no |
115 // profiles in the model - crbug.com/102278 . | 130 // profiles in the model - crbug.com/102278 . |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 item->active = browser_->profile()->GetPath() == path; | 188 item->active = browser_->profile()->GetPath() == path; |
174 } | 189 } |
175 items_.push_back(item); | 190 items_.push_back(item); |
176 } | 191 } |
177 } | 192 } |
178 | 193 |
179 void AvatarMenuModel::ClearMenu() { | 194 void AvatarMenuModel::ClearMenu() { |
180 STLDeleteContainerPointers(items_.begin(), items_.end()); | 195 STLDeleteContainerPointers(items_.begin(), items_.end()); |
181 items_.clear(); | 196 items_.clear(); |
182 } | 197 } |
OLD | NEW |