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.h" | 5 #include "chrome/browser/profiles/avatar_menu.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 #endif | 105 #endif |
106 } | 106 } |
107 return false; | 107 return false; |
108 } | 108 } |
109 | 109 |
110 bool AvatarMenu::CompareItems(const Item* item1, const Item* item2) { | 110 bool AvatarMenu::CompareItems(const Item* item1, const Item* item2) { |
111 return base::i18n::ToLower(item1->name).compare( | 111 return base::i18n::ToLower(item1->name).compare( |
112 base::i18n::ToLower(item2->name)) < 0; | 112 base::i18n::ToLower(item2->name)) < 0; |
113 } | 113 } |
114 | 114 |
115 void AvatarMenu::SwitchToProfile(size_t index, bool always_create) { | 115 void AvatarMenu::SwitchToProfile(size_t index, |
| 116 bool always_create, |
| 117 ProfileMetrics::ProfileOpen metric) { |
116 DCHECK(profiles::IsMultipleProfilesEnabled() || | 118 DCHECK(profiles::IsMultipleProfilesEnabled() || |
117 index == GetActiveProfileIndex()); | 119 index == GetActiveProfileIndex()); |
118 const Item& item = GetItemAt(index); | 120 const Item& item = GetItemAt(index); |
119 | 121 |
120 if (switches::IsNewProfileManagement()) { | 122 if (switches::IsNewProfileManagement()) { |
121 // Don't open a browser window for signed-out profiles. | 123 // Don't open a browser window for signed-out profiles. |
122 if (item.signin_required) { | 124 if (item.signin_required) { |
123 chrome::ShowUserManager(item.profile_path); | 125 chrome::ShowUserManager(item.profile_path); |
124 return; | 126 return; |
125 } | 127 } |
126 } | 128 } |
127 | 129 |
128 base::FilePath path = | 130 base::FilePath path = |
129 profile_info_->GetPathOfProfileAtIndex(item.profile_index); | 131 profile_info_->GetPathOfProfileAtIndex(item.profile_index); |
130 | 132 |
131 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 133 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
132 if (browser_) | 134 if (browser_) |
133 desktop_type = browser_->host_desktop_type(); | 135 desktop_type = browser_->host_desktop_type(); |
134 | 136 |
135 profiles::SwitchToProfile(path, desktop_type, always_create, | 137 profiles::SwitchToProfile(path, desktop_type, always_create, |
136 profiles::ProfileSwitchingDoneCallback()); | 138 profiles::ProfileSwitchingDoneCallback(), |
137 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_ICON); | 139 metric); |
138 } | 140 } |
139 | 141 |
140 void AvatarMenu::AddNewProfile(ProfileMetrics::ProfileAdd type) { | 142 void AvatarMenu::AddNewProfile(ProfileMetrics::ProfileAdd type) { |
141 menu_actions_->AddNewProfile(type); | 143 menu_actions_->AddNewProfile(type); |
142 } | 144 } |
143 | 145 |
144 void AvatarMenu::EditProfile(size_t index) { | 146 void AvatarMenu::EditProfile(size_t index) { |
145 // Get the index in the profile cache from the menu index. | 147 // Get the index in the profile cache from the menu index. |
146 size_t profile_index = profile_list_->GetItemAt(index).profile_index; | 148 size_t profile_index = profile_list_->GetItemAt(index).profile_index; |
147 | 149 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 } | 224 } |
223 | 225 |
224 void AvatarMenu::Observe(int type, | 226 void AvatarMenu::Observe(int type, |
225 const content::NotificationSource& source, | 227 const content::NotificationSource& source, |
226 const content::NotificationDetails& details) { | 228 const content::NotificationDetails& details) { |
227 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); | 229 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); |
228 RebuildMenu(); | 230 RebuildMenu(); |
229 if (observer_) | 231 if (observer_) |
230 observer_->OnAvatarMenuChanged(this); | 232 observer_->OnAvatarMenuChanged(this); |
231 } | 233 } |
OLD | NEW |