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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 } | 76 } |
77 | 77 |
78 void AvatarMenuModel::SwitchToProfile(size_t index) { | 78 void AvatarMenuModel::SwitchToProfile(size_t index) { |
79 const Item& item = GetItemAt(index); | 79 const Item& item = GetItemAt(index); |
80 FilePath path = profile_info_->GetPathOfProfileAtIndex(item.model_index); | 80 FilePath path = profile_info_->GetPathOfProfileAtIndex(item.model_index); |
81 | 81 |
82 // This will be deleted by the manager after the profile is ready. | 82 // This will be deleted by the manager after the profile is ready. |
83 ProfileSwitchObserver* observer = new ProfileSwitchObserver(); | 83 ProfileSwitchObserver* observer = new ProfileSwitchObserver(); |
84 g_browser_process->profile_manager()->CreateProfileAsync( | 84 g_browser_process->profile_manager()->CreateProfileAsync( |
85 path, observer); | 85 path, observer); |
86 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::SWITCH_PROFILE_ICON); | 86 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_ICON); |
87 } | 87 } |
88 | 88 |
89 void AvatarMenuModel::EditProfile(size_t index) { | 89 void AvatarMenuModel::EditProfile(size_t index) { |
90 Browser* browser = browser_; | 90 Browser* browser = browser_; |
91 if (!browser) { | 91 if (!browser) { |
92 Profile* profile = g_browser_process->profile_manager()->GetProfileByPath( | 92 Profile* profile = g_browser_process->profile_manager()->GetProfileByPath( |
93 profile_info_->GetPathOfProfileAtIndex(GetItemAt(index).model_index)); | 93 profile_info_->GetPathOfProfileAtIndex(GetItemAt(index).model_index)); |
94 browser = Browser::Create(profile); | 94 browser = Browser::Create(profile); |
95 } | 95 } |
96 std::string page = chrome::kManageProfileSubPage; | 96 std::string page = chrome::kManageProfileSubPage; |
97 page += "#"; | 97 page += "#"; |
98 page += base::IntToString(static_cast<int>(index)); | 98 page += base::IntToString(static_cast<int>(index)); |
99 browser->ShowOptionsTab(page); | 99 browser->ShowOptionsTab(page); |
100 } | 100 } |
101 | 101 |
102 void AvatarMenuModel::AddNewProfile() { | 102 void AvatarMenuModel::AddNewProfile() { |
103 ProfileManager::CreateMultiProfileAsync(); | 103 ProfileManager::CreateMultiProfileAsync(); |
104 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ADD_NEW_USER); | 104 ProfileMetrics::LogProfileAddNewUser(ProfileMetrics::ADD_NEW_USER_ICON); |
105 ProfileMetrics::LogProfileOpenMethod(ProfileMetrics::ADD_NEW_USER_ICON); | |
106 } | 105 } |
107 | 106 |
108 size_t AvatarMenuModel::GetNumberOfItems() { | 107 size_t AvatarMenuModel::GetNumberOfItems() { |
109 return items_.size(); | 108 return items_.size(); |
110 } | 109 } |
111 | 110 |
112 size_t AvatarMenuModel::GetActiveProfileIndex() { | 111 size_t AvatarMenuModel::GetActiveProfileIndex() { |
113 // During singleton profile deletion, this function can be called with no | 112 // During singleton profile deletion, this function can be called with no |
114 // profiles in the model - crbug.com/102278 . | 113 // profiles in the model - crbug.com/102278 . |
115 if (items_.size() == 0) | 114 if (items_.size() == 0) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 item->active = browser_->profile()->GetPath() == path; | 163 item->active = browser_->profile()->GetPath() == path; |
165 } | 164 } |
166 items_.push_back(item); | 165 items_.push_back(item); |
167 } | 166 } |
168 } | 167 } |
169 | 168 |
170 void AvatarMenuModel::ClearMenu() { | 169 void AvatarMenuModel::ClearMenu() { |
171 STLDeleteContainerPointers(items_.begin(), items_.end()); | 170 STLDeleteContainerPointers(items_.begin(), items_.end()); |
172 items_.clear(); | 171 items_.clear(); |
173 } | 172 } |
OLD | NEW |