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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 #endif | 108 #endif |
109 } | 109 } |
110 return false; | 110 return false; |
111 } | 111 } |
112 | 112 |
113 bool AvatarMenu::CompareItems(const Item* item1, const Item* item2) { | 113 bool AvatarMenu::CompareItems(const Item* item1, const Item* item2) { |
114 return base::i18n::ToLower(item1->name).compare( | 114 return base::i18n::ToLower(item1->name).compare( |
115 base::i18n::ToLower(item2->name)) < 0; | 115 base::i18n::ToLower(item2->name)) < 0; |
116 } | 116 } |
117 | 117 |
118 void AvatarMenu::SwitchToProfile(size_t index, bool always_create) { | 118 void AvatarMenu::SwitchToProfile( |
119 size_t index, bool always_create, ProfileMetrics::ProfileOpen metric) { | |
Alexei Svitkine (slow)
2014/01/28 16:25:31
If you wrap params, it should be 1 per line.
bcwhite
2014/01/28 17:03:03
Done.
| |
119 DCHECK(profiles::IsMultipleProfilesEnabled() || | 120 DCHECK(profiles::IsMultipleProfilesEnabled() || |
120 index == GetActiveProfileIndex()); | 121 index == GetActiveProfileIndex()); |
121 const Item& item = GetItemAt(index); | 122 const Item& item = GetItemAt(index); |
122 | 123 |
123 if (switches::IsNewProfileManagement()) { | 124 if (switches::IsNewProfileManagement()) { |
124 // Don't open a browser window for signed-out profiles. | 125 // Don't open a browser window for signed-out profiles. |
125 if (item.signin_required) { | 126 if (item.signin_required) { |
126 chrome::ShowUserManager(item.profile_path); | 127 chrome::ShowUserManager(item.profile_path); |
127 return; | 128 return; |
128 } | 129 } |
129 } | 130 } |
130 | 131 |
131 base::FilePath path = | 132 base::FilePath path = |
132 profile_info_->GetPathOfProfileAtIndex(item.profile_index); | 133 profile_info_->GetPathOfProfileAtIndex(item.profile_index); |
133 | 134 |
134 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 135 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
135 if (browser_) | 136 if (browser_) |
136 desktop_type = browser_->host_desktop_type(); | 137 desktop_type = browser_->host_desktop_type(); |
137 | 138 |
138 profiles::SwitchToProfile(path, desktop_type, always_create, | 139 profiles::SwitchToProfile(path, desktop_type, always_create, |
139 profiles::ProfileSwitchingDoneCallback()); | 140 profiles::ProfileSwitchingDoneCallback(), |
140 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_ICON); | 141 metric); |
141 } | 142 } |
142 | 143 |
143 void AvatarMenu::AddNewProfile(ProfileMetrics::ProfileAdd type) { | 144 void AvatarMenu::AddNewProfile(ProfileMetrics::ProfileAdd type) { |
144 menu_actions_->AddNewProfile(type); | 145 menu_actions_->AddNewProfile(type); |
145 } | 146 } |
146 | 147 |
147 void AvatarMenu::EditProfile(size_t index) { | 148 void AvatarMenu::EditProfile(size_t index) { |
148 // Get the index in the profile cache from the menu index. | 149 // Get the index in the profile cache from the menu index. |
149 size_t profile_index = profile_list_->GetItemAt(index).profile_index; | 150 size_t profile_index = profile_list_->GetItemAt(index).profile_index; |
150 | 151 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
225 } | 226 } |
226 | 227 |
227 void AvatarMenu::Observe(int type, | 228 void AvatarMenu::Observe(int type, |
228 const content::NotificationSource& source, | 229 const content::NotificationSource& source, |
229 const content::NotificationDetails& details) { | 230 const content::NotificationDetails& details) { |
230 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); | 231 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); |
231 RebuildMenu(); | 232 RebuildMenu(); |
232 if (observer_) | 233 if (observer_) |
233 observer_->OnAvatarMenuChanged(this); | 234 observer_->OnAvatarMenuChanged(this); |
234 } | 235 } |
OLD | NEW |