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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/profiles/avatar_menu_actions.h" | 14 #include "chrome/browser/profiles/avatar_menu_actions.h" |
15 #include "chrome/browser/profiles/avatar_menu_observer.h" | 15 #include "chrome/browser/profiles/avatar_menu_observer.h" |
16 #include "chrome/browser/profiles/profile_list.h" | 16 #include "chrome/browser/profiles/profile_list.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/profiles/profile_metrics.h" | 18 #include "chrome/browser/profiles/profile_metrics.h" |
19 #include "chrome/browser/profiles/profile_window.h" | 19 #include "chrome/browser/profiles/profile_window.h" |
20 #include "chrome/browser/profiles/profiles_state.h" | 20 #include "chrome/browser/profiles/profiles_state.h" |
21 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" | 21 #include "chrome/browser/ui/ash/chrome_shell_delegate.h" |
22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/browser_dialogs.h" | 23 #include "chrome/browser/ui/browser_dialogs.h" |
24 #include "chrome/browser/ui/host_desktop.h" | 24 #include "chrome/browser/ui/host_desktop.h" |
25 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 25 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 26 #include "chrome/browser/ui/user_manager.h" |
26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/grit/generated_resources.h" | 28 #include "chrome/grit/generated_resources.h" |
28 #include "components/signin/core/common/profile_management_switches.h" | 29 #include "components/signin/core/common/profile_management_switches.h" |
29 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
30 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
31 #include "grit/theme_resources.h" | 32 #include "grit/theme_resources.h" |
32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
34 | 35 |
35 #if defined(ENABLE_MANAGED_USERS) | 36 #if defined(ENABLE_MANAGED_USERS) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 void AvatarMenu::SwitchToProfile(size_t index, | 116 void AvatarMenu::SwitchToProfile(size_t index, |
116 bool always_create, | 117 bool always_create, |
117 ProfileMetrics::ProfileOpen metric) { | 118 ProfileMetrics::ProfileOpen metric) { |
118 DCHECK(profiles::IsMultipleProfilesEnabled() || | 119 DCHECK(profiles::IsMultipleProfilesEnabled() || |
119 index == GetActiveProfileIndex()); | 120 index == GetActiveProfileIndex()); |
120 const Item& item = GetItemAt(index); | 121 const Item& item = GetItemAt(index); |
121 | 122 |
122 if (switches::IsNewAvatarMenu()) { | 123 if (switches::IsNewAvatarMenu()) { |
123 // Don't open a browser window for signed-out profiles. | 124 // Don't open a browser window for signed-out profiles. |
124 if (item.signin_required) { | 125 if (item.signin_required) { |
125 chrome::ShowUserManager(item.profile_path); | 126 UserManager::Show(item.profile_path, |
| 127 profiles::USER_MANAGER_NO_TUTORIAL, |
| 128 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
126 return; | 129 return; |
127 } | 130 } |
128 } | 131 } |
129 | 132 |
130 base::FilePath path = | 133 base::FilePath path = |
131 profile_info_->GetPathOfProfileAtIndex(item.profile_index); | 134 profile_info_->GetPathOfProfileAtIndex(item.profile_index); |
132 | 135 |
133 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 136 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
134 if (browser_) | 137 if (browser_) |
135 desktop_type = browser_->host_desktop_type(); | 138 desktop_type = browser_->host_desktop_type(); |
136 | 139 |
137 profiles::SwitchToProfile(path, desktop_type, always_create, | 140 profiles::SwitchToProfile(path, desktop_type, always_create, |
138 profiles::ProfileSwitchingDoneCallback(), | 141 ProfileManager::CreateCallback(), |
139 metric); | 142 metric); |
140 } | 143 } |
141 | 144 |
142 void AvatarMenu::AddNewProfile(ProfileMetrics::ProfileAdd type) { | 145 void AvatarMenu::AddNewProfile(ProfileMetrics::ProfileAdd type) { |
143 menu_actions_->AddNewProfile(type); | 146 menu_actions_->AddNewProfile(type); |
144 } | 147 } |
145 | 148 |
146 void AvatarMenu::EditProfile(size_t index) { | 149 void AvatarMenu::EditProfile(size_t index) { |
147 // Get the index in the profile cache from the menu index. | 150 // Get the index in the profile cache from the menu index. |
148 size_t profile_index = profile_list_->GetItemAt(index).profile_index; | 151 size_t profile_index = profile_list_->GetItemAt(index).profile_index; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 227 } |
225 | 228 |
226 void AvatarMenu::Observe(int type, | 229 void AvatarMenu::Observe(int type, |
227 const content::NotificationSource& source, | 230 const content::NotificationSource& source, |
228 const content::NotificationDetails& details) { | 231 const content::NotificationDetails& details) { |
229 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); | 232 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, type); |
230 RebuildMenu(); | 233 RebuildMenu(); |
231 if (observer_) | 234 if (observer_) |
232 observer_->OnAvatarMenuChanged(this); | 235 observer_->OnAvatarMenuChanged(this); |
233 } | 236 } |
OLD | NEW |