Chromium Code Reviews| 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 |
|
sail
2012/08/10 18:01:14
This will break creating a new profile.
Do you re
Halli
2012/08/13 21:50:10
Shortcuts can't be generated from the avatar menu
sail
2012/08/13 22:09:36
Yea, if you really need this then you should just
Halli
2012/08/14 18:25:57
Done.
| |
| 107 // instead of opening a dialog for creating a profile | |
| 108 // Remove on completion of BUG 134904 | |
| 109 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 110 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | |
| 111 size_t icon_index = cache.ChooseAvatarIconIndexForNewProfile(); | |
| 112 | |
| 113 g_browser_process->profile_manager()->CreateMultiProfileAsync( | |
| 114 cache.ChooseNameForNewProfile(icon_index), | |
| 115 ASCIIToUTF16(cache.GetDefaultAvatarIconUrl(icon_index))); | |
| 106 ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_ICON); | 116 ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_ICON); |
| 107 } | 117 } |
| 108 | 118 |
| 109 size_t AvatarMenuModel::GetNumberOfItems() { | 119 size_t AvatarMenuModel::GetNumberOfItems() { |
| 110 return items_.size(); | 120 return items_.size(); |
| 111 } | 121 } |
| 112 | 122 |
| 113 size_t AvatarMenuModel::GetActiveProfileIndex() { | 123 size_t AvatarMenuModel::GetActiveProfileIndex() { |
| 114 // During singleton profile deletion, this function can be called with no | 124 // During singleton profile deletion, this function can be called with no |
| 115 // profiles in the model - crbug.com/102278 . | 125 // 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; | 183 item->active = browser_->profile()->GetPath() == path; |
| 174 } | 184 } |
| 175 items_.push_back(item); | 185 items_.push_back(item); |
| 176 } | 186 } |
| 177 } | 187 } |
| 178 | 188 |
| 179 void AvatarMenuModel::ClearMenu() { | 189 void AvatarMenuModel::ClearMenu() { |
| 180 STLDeleteContainerPointers(items_.begin(), items_.end()); | 190 STLDeleteContainerPointers(items_.begin(), items_.end()); |
| 181 items_.clear(); | 191 items_.clear(); |
| 182 } | 192 } |
| OLD | NEW |