| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profile_window.h" | 5 #include "chrome/browser/profiles/profile_window.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/about_flags.h" | 12 #include "chrome/browser/about_flags.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/lifetime/application_lifetime.h" | 14 #include "chrome/browser/lifetime/application_lifetime.h" |
| 15 #include "chrome/browser/pref_service_flags_storage.h" | 15 #include "chrome/browser/pref_service_flags_storage.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 17 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/signin/account_reconcilor_factory.h" | 19 #include "chrome/browser/signin/account_reconcilor_factory.h" |
| 20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/browser_dialogs.h" | 21 #include "chrome/browser/ui/browser_dialogs.h" |
| 22 #include "chrome/browser/ui/profile_chooser_constants.h" | 22 #include "chrome/browser/ui/profile_chooser_constants.h" |
| 23 #include "chrome/browser/ui/user_manager.h" |
| 23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 26 #include "components/signin/core/browser/account_reconcilor.h" | 27 #include "components/signin/core/browser/account_reconcilor.h" |
| 27 #include "components/signin/core/common/profile_management_switches.h" | 28 #include "components/signin/core/common/profile_management_switches.h" |
| 28 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/browser/user_metrics.h" | 30 #include "content/public/browser/user_metrics.h" |
| 30 | 31 |
| 31 #if !defined(OS_IOS) | 32 #if !defined(OS_IOS) |
| 32 #include "chrome/browser/ui/browser_finder.h" | 33 #include "chrome/browser/ui/browser_finder.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 43 | 44 |
| 44 const char kNewProfileManagementExperimentInternalName[] = | 45 const char kNewProfileManagementExperimentInternalName[] = |
| 45 "enable-new-profile-management"; | 46 "enable-new-profile-management"; |
| 46 | 47 |
| 47 // Handles running a callback when a new Browser for the given profile | 48 // Handles running a callback when a new Browser for the given profile |
| 48 // has been completely created. | 49 // has been completely created. |
| 49 class BrowserAddedForProfileObserver : public chrome::BrowserListObserver { | 50 class BrowserAddedForProfileObserver : public chrome::BrowserListObserver { |
| 50 public: | 51 public: |
| 51 BrowserAddedForProfileObserver( | 52 BrowserAddedForProfileObserver( |
| 52 Profile* profile, | 53 Profile* profile, |
| 53 profiles::ProfileSwitchingDoneCallback callback) | 54 ProfileManager::CreateCallback callback) |
| 54 : profile_(profile), | 55 : profile_(profile), |
| 55 callback_(callback) { | 56 callback_(callback) { |
| 56 DCHECK(!callback_.is_null()); | 57 DCHECK(!callback_.is_null()); |
| 57 BrowserList::AddObserver(this); | 58 BrowserList::AddObserver(this); |
| 58 } | 59 } |
| 59 virtual ~BrowserAddedForProfileObserver() { | 60 virtual ~BrowserAddedForProfileObserver() { |
| 60 } | 61 } |
| 61 | 62 |
| 62 private: | 63 private: |
| 63 // Overridden from BrowserListObserver: | 64 // Overridden from BrowserListObserver: |
| 64 virtual void OnBrowserAdded(Browser* browser) OVERRIDE { | 65 virtual void OnBrowserAdded(Browser* browser) OVERRIDE { |
| 65 if (browser->profile() == profile_) { | 66 if (browser->profile() == profile_) { |
| 66 BrowserList::RemoveObserver(this); | 67 BrowserList::RemoveObserver(this); |
| 67 callback_.Run(); | 68 callback_.Run(profile_, Profile::CREATE_STATUS_INITIALIZED); |
| 68 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 69 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 69 } | 70 } |
| 70 } | 71 } |
| 71 | 72 |
| 72 // Profile for which the browser should be opened. | 73 // Profile for which the browser should be opened. |
| 73 Profile* profile_; | 74 Profile* profile_; |
| 74 profiles::ProfileSwitchingDoneCallback callback_; | 75 ProfileManager::CreateCallback callback_; |
| 75 | 76 |
| 76 DISALLOW_COPY_AND_ASSIGN(BrowserAddedForProfileObserver); | 77 DISALLOW_COPY_AND_ASSIGN(BrowserAddedForProfileObserver); |
| 77 }; | 78 }; |
| 78 | 79 |
| 79 void OpenBrowserWindowForProfile( | 80 void OpenBrowserWindowForProfile( |
| 80 profiles::ProfileSwitchingDoneCallback callback, | 81 ProfileManager::CreateCallback callback, |
| 81 bool always_create, | 82 bool always_create, |
| 82 bool is_new_profile, | 83 bool is_new_profile, |
| 83 chrome::HostDesktopType desktop_type, | 84 chrome::HostDesktopType desktop_type, |
| 84 Profile* profile, | 85 Profile* profile, |
| 85 Profile::CreateStatus status) { | 86 Profile::CreateStatus status) { |
| 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 87 | 88 |
| 88 if (status != Profile::CREATE_STATUS_INITIALIZED) | 89 if (status != Profile::CREATE_STATUS_INITIALIZED) |
| 89 return; | 90 return; |
| 90 | 91 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 101 // If |always_create| is false, and we have a |callback| to run, check | 102 // If |always_create| is false, and we have a |callback| to run, check |
| 102 // whether a browser already exists so that we can run the callback. We don't | 103 // whether a browser already exists so that we can run the callback. We don't |
| 103 // want to rely on the observer listening to OnBrowserSetLastActive in this | 104 // want to rely on the observer listening to OnBrowserSetLastActive in this |
| 104 // case, as you could manually activate an incorrect browser and trigger | 105 // case, as you could manually activate an incorrect browser and trigger |
| 105 // a false positive. | 106 // a false positive. |
| 106 if (!always_create) { | 107 if (!always_create) { |
| 107 Browser* browser = chrome::FindTabbedBrowser(profile, false, desktop_type); | 108 Browser* browser = chrome::FindTabbedBrowser(profile, false, desktop_type); |
| 108 if (browser) { | 109 if (browser) { |
| 109 browser->window()->Activate(); | 110 browser->window()->Activate(); |
| 110 if (!callback.is_null()) | 111 if (!callback.is_null()) |
| 111 callback.Run(); | 112 callback.Run(profile, Profile::CREATE_STATUS_INITIALIZED); |
| 112 return; | 113 return; |
| 113 } | 114 } |
| 114 } | 115 } |
| 115 | 116 |
| 116 // If there is a callback, create an observer to make sure it is only | 117 // If there is a callback, create an observer to make sure it is only |
| 117 // run when the browser has been completely created. This observer will | 118 // run when the browser has been completely created. This observer will |
| 118 // delete itself once that happens. This should not leak, because we are | 119 // delete itself once that happens. This should not leak, because we are |
| 119 // passing |always_create| = true to FindOrCreateNewWindow below, which ends | 120 // passing |always_create| = true to FindOrCreateNewWindow below, which ends |
| 120 // up calling LaunchBrowser and opens a new window. If for whatever reason | 121 // up calling LaunchBrowser and opens a new window. If for whatever reason |
| 121 // that fails, either something has crashed, or the observer will be cleaned | 122 // that fails, either something has crashed, or the observer will be cleaned |
| 122 // up when a different browser for this profile is opened. | 123 // up when a different browser for this profile is opened. |
| 123 if (!callback.is_null()) | 124 if (!callback.is_null()) |
| 124 new BrowserAddedForProfileObserver(profile, callback); | 125 new BrowserAddedForProfileObserver(profile, callback); |
| 125 | 126 |
| 126 // We already dealt with the case when |always_create| was false and a browser | 127 // We already dealt with the case when |always_create| was false and a browser |
| 127 // existed, which means that here a browser definitely needs to be created. | 128 // existed, which means that here a browser definitely needs to be created. |
| 128 // Passing true for |always_create| means we won't duplicate the code that | 129 // Passing true for |always_create| means we won't duplicate the code that |
| 129 // tries to find a browser. | 130 // tries to find a browser. |
| 130 profiles::FindOrCreateNewWindowForProfile( | 131 profiles::FindOrCreateNewWindowForProfile( |
| 131 profile, | 132 profile, |
| 132 is_process_startup, | 133 is_process_startup, |
| 133 is_first_run, | 134 is_first_run, |
| 134 desktop_type, | 135 desktop_type, |
| 135 true); | 136 true); |
| 136 } | 137 } |
| 137 | 138 |
| 138 // Called after a |guest_profile| is available to be used by the user manager. | 139 // Called after a |guest_profile| is available to be used by the user manager. |
| 139 // Based on the value of |tutorial_mode| we determine a url to be displayed | 140 // Based on the value of |tutorial_mode| we determine a url to be displayed |
| 140 // by the webui and run the |callback|, if it exists. | 141 // by the webui and run the |callback|, if it exists. After opening a profile, |
| 142 // perform |profile_open_action|. |
| 141 void OnUserManagerGuestProfileCreated( | 143 void OnUserManagerGuestProfileCreated( |
| 142 const base::FilePath& profile_path_to_focus, | 144 const base::FilePath& profile_path_to_focus, |
| 143 profiles::UserManagerTutorialMode tutorial_mode, | 145 profiles::UserManagerTutorialMode tutorial_mode, |
| 146 profiles::UserManagerProfileSelected profile_open_action, |
| 144 const base::Callback<void(Profile*, const std::string&)>& callback, | 147 const base::Callback<void(Profile*, const std::string&)>& callback, |
| 145 Profile* guest_profile, | 148 Profile* guest_profile, |
| 146 Profile::CreateStatus status) { | 149 Profile::CreateStatus status) { |
| 147 if (status != Profile::CREATE_STATUS_INITIALIZED || callback.is_null()) | 150 if (status != Profile::CREATE_STATUS_INITIALIZED || callback.is_null()) |
| 148 return; | 151 return; |
| 149 | 152 |
| 150 // Tell the webui which user should be focused. | 153 // Tell the webui which user should be focused. |
| 151 std::string page = chrome::kChromeUIUserManagerURL; | 154 std::string page = chrome::kChromeUIUserManagerURL; |
| 152 | 155 |
| 153 if (tutorial_mode == profiles::USER_MANAGER_TUTORIAL_OVERVIEW) { | 156 if (tutorial_mode == profiles::USER_MANAGER_TUTORIAL_OVERVIEW) { |
| 154 page += "#tutorial"; | 157 page += profiles::kUserManagerDisplayTutorial; |
| 155 } else if (!profile_path_to_focus.empty()) { | 158 } else if (!profile_path_to_focus.empty()) { |
| 156 const ProfileInfoCache& cache = | 159 const ProfileInfoCache& cache = |
| 157 g_browser_process->profile_manager()->GetProfileInfoCache(); | 160 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 158 size_t index = cache.GetIndexOfProfileWithPath(profile_path_to_focus); | 161 size_t index = cache.GetIndexOfProfileWithPath(profile_path_to_focus); |
| 159 if (index != std::string::npos) { | 162 if (index != std::string::npos) { |
| 160 page += "#"; | 163 page += "#"; |
| 161 page += base::IntToString(index); | 164 page += base::IntToString(index); |
| 162 } | 165 } |
| 166 } else if (profile_open_action == |
| 167 profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER) { |
| 168 page += profiles::kUserManagerSelectProfileTaskManager; |
| 169 } else if (profile_open_action == |
| 170 profiles::USER_MANAGER_SELECT_PROFILE_ABOUT_CHROME) { |
| 171 page += profiles::kUserManagerSelectProfileAboutChrome; |
| 163 } | 172 } |
| 164 | |
| 165 callback.Run(guest_profile, page); | 173 callback.Run(guest_profile, page); |
| 166 } | 174 } |
| 167 | 175 |
| 168 // Updates Chrome services that require notification when | 176 // Updates Chrome services that require notification when |
| 169 // the new_profile_management's status changes. | 177 // the new_profile_management's status changes. |
| 170 void UpdateServicesWithNewProfileManagementFlag(Profile* profile, | 178 void UpdateServicesWithNewProfileManagementFlag(Profile* profile, |
| 171 bool new_flag_status) { | 179 bool new_flag_status) { |
| 172 AccountReconcilor* account_reconcilor = | 180 AccountReconcilor* account_reconcilor = |
| 173 AccountReconcilorFactory::GetForProfile(profile); | 181 AccountReconcilorFactory::GetForProfile(profile); |
| 174 account_reconcilor->OnNewProfileManagementFlagChanged(new_flag_status); | 182 account_reconcilor->OnNewProfileManagementFlagChanged(new_flag_status); |
| 175 } | 183 } |
| 176 | 184 |
| 177 } // namespace | 185 } // namespace |
| 178 | 186 |
| 179 namespace profiles { | 187 namespace profiles { |
| 180 | 188 |
| 189 // User Manager parameters are prefixed with hash. |
| 190 const char kUserManagerDisplayTutorial[] = "#tutorial"; |
| 191 const char kUserManagerSelectProfileTaskManager[] = "#task-manager"; |
| 192 const char kUserManagerSelectProfileAboutChrome[] = "#about-chrome"; |
| 193 |
| 181 void FindOrCreateNewWindowForProfile( | 194 void FindOrCreateNewWindowForProfile( |
| 182 Profile* profile, | 195 Profile* profile, |
| 183 chrome::startup::IsProcessStartup process_startup, | 196 chrome::startup::IsProcessStartup process_startup, |
| 184 chrome::startup::IsFirstRun is_first_run, | 197 chrome::startup::IsFirstRun is_first_run, |
| 185 chrome::HostDesktopType desktop_type, | 198 chrome::HostDesktopType desktop_type, |
| 186 bool always_create) { | 199 bool always_create) { |
| 187 #if defined(OS_IOS) | 200 #if defined(OS_IOS) |
| 188 NOTREACHED(); | 201 NOTREACHED(); |
| 189 #else | 202 #else |
| 190 DCHECK(profile); | 203 DCHECK(profile); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 202 int return_code; | 215 int return_code; |
| 203 StartupBrowserCreator browser_creator; | 216 StartupBrowserCreator browser_creator; |
| 204 browser_creator.LaunchBrowser(command_line, profile, base::FilePath(), | 217 browser_creator.LaunchBrowser(command_line, profile, base::FilePath(), |
| 205 process_startup, is_first_run, &return_code); | 218 process_startup, is_first_run, &return_code); |
| 206 #endif // defined(OS_IOS) | 219 #endif // defined(OS_IOS) |
| 207 } | 220 } |
| 208 | 221 |
| 209 void SwitchToProfile(const base::FilePath& path, | 222 void SwitchToProfile(const base::FilePath& path, |
| 210 chrome::HostDesktopType desktop_type, | 223 chrome::HostDesktopType desktop_type, |
| 211 bool always_create, | 224 bool always_create, |
| 212 ProfileSwitchingDoneCallback callback, | 225 ProfileManager::CreateCallback callback, |
| 213 ProfileMetrics::ProfileOpen metric) { | 226 ProfileMetrics::ProfileOpen metric) { |
| 214 g_browser_process->profile_manager()->CreateProfileAsync( | 227 g_browser_process->profile_manager()->CreateProfileAsync( |
| 215 path, | 228 path, |
| 216 base::Bind(&OpenBrowserWindowForProfile, | 229 base::Bind(&OpenBrowserWindowForProfile, |
| 217 callback, | 230 callback, |
| 218 always_create, | 231 always_create, |
| 219 false, | 232 false, |
| 220 desktop_type), | 233 desktop_type), |
| 221 base::string16(), | 234 base::string16(), |
| 222 base::string16(), | 235 base::string16(), |
| 223 std::string()); | 236 std::string()); |
| 224 ProfileMetrics::LogProfileSwitchUser(metric); | 237 ProfileMetrics::LogProfileSwitchUser(metric); |
| 225 } | 238 } |
| 226 | 239 |
| 227 void SwitchToGuestProfile(chrome::HostDesktopType desktop_type, | 240 void SwitchToGuestProfile(chrome::HostDesktopType desktop_type, |
| 228 ProfileSwitchingDoneCallback callback) { | 241 ProfileManager::CreateCallback callback) { |
| 229 g_browser_process->profile_manager()->CreateProfileAsync( | 242 g_browser_process->profile_manager()->CreateProfileAsync( |
| 230 ProfileManager::GetGuestProfilePath(), | 243 ProfileManager::GetGuestProfilePath(), |
| 231 base::Bind(&OpenBrowserWindowForProfile, | 244 base::Bind(&OpenBrowserWindowForProfile, |
| 232 callback, | 245 callback, |
| 233 false, | 246 false, |
| 234 false, | 247 false, |
| 235 desktop_type), | 248 desktop_type), |
| 236 base::string16(), | 249 base::string16(), |
| 237 base::string16(), | 250 base::string16(), |
| 238 std::string()); | 251 std::string()); |
| 239 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_GUEST); | 252 ProfileMetrics::LogProfileSwitchUser(ProfileMetrics::SWITCH_PROFILE_GUEST); |
| 240 } | 253 } |
| 241 | 254 |
| 242 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type, | 255 void CreateAndSwitchToNewProfile(chrome::HostDesktopType desktop_type, |
| 243 ProfileSwitchingDoneCallback callback, | 256 ProfileManager::CreateCallback callback, |
| 244 ProfileMetrics::ProfileAdd metric) { | 257 ProfileMetrics::ProfileAdd metric) { |
| 245 ProfileInfoCache& cache = | 258 ProfileInfoCache& cache = |
| 246 g_browser_process->profile_manager()->GetProfileInfoCache(); | 259 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 247 | 260 |
| 248 int placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); | 261 int placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); |
| 249 ProfileManager::CreateMultiProfileAsync( | 262 ProfileManager::CreateMultiProfileAsync( |
| 250 cache.ChooseNameForNewProfile(placeholder_avatar_index), | 263 cache.ChooseNameForNewProfile(placeholder_avatar_index), |
| 251 base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl( | 264 base::UTF8ToUTF16(profiles::GetDefaultAvatarIconUrl( |
| 252 placeholder_avatar_index)), | 265 placeholder_avatar_index)), |
| 253 base::Bind(&OpenBrowserWindowForProfile, | 266 base::Bind(&OpenBrowserWindowForProfile, |
| 254 callback, | 267 callback, |
| 255 true, | 268 true, |
| 256 true, | 269 true, |
| 257 desktop_type), | 270 desktop_type), |
| 258 std::string()); | 271 std::string()); |
| 259 ProfileMetrics::LogProfileAddNewUser(metric); | 272 ProfileMetrics::LogProfileAddNewUser(metric); |
| 260 } | 273 } |
| 261 | 274 |
| 262 void GuestBrowserCloseSuccess(const base::FilePath& profile_path) { | 275 void GuestBrowserCloseSuccess(const base::FilePath& profile_path) { |
| 263 chrome::ShowUserManager(profile_path); | 276 UserManager::Show(profile_path, |
| 277 profiles::USER_MANAGER_NO_TUTORIAL, |
| 278 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 264 } | 279 } |
| 265 | 280 |
| 266 void CloseGuestProfileWindows() { | 281 void CloseGuestProfileWindows() { |
| 267 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 282 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 268 Profile* profile = profile_manager->GetProfileByPath( | 283 Profile* profile = profile_manager->GetProfileByPath( |
| 269 ProfileManager::GetGuestProfilePath()); | 284 ProfileManager::GetGuestProfilePath()); |
| 270 | 285 |
| 271 if (profile) { | 286 if (profile) { |
| 272 BrowserList::CloseAllBrowsersWithProfile( | 287 BrowserList::CloseAllBrowsersWithProfile( |
| 273 profile, base::Bind(&GuestBrowserCloseSuccess)); | 288 profile, base::Bind(&GuestBrowserCloseSuccess)); |
| 274 } | 289 } |
| 275 } | 290 } |
| 276 | 291 |
| 277 void LockBrowserCloseSuccess(const base::FilePath& profile_path) { | 292 void LockBrowserCloseSuccess(const base::FilePath& profile_path) { |
| 278 ProfileInfoCache* cache = | 293 ProfileInfoCache* cache = |
| 279 &g_browser_process->profile_manager()->GetProfileInfoCache(); | 294 &g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 280 | 295 |
| 281 cache->SetProfileSigninRequiredAtIndex( | 296 cache->SetProfileSigninRequiredAtIndex( |
| 282 cache->GetIndexOfProfileWithPath(profile_path), true); | 297 cache->GetIndexOfProfileWithPath(profile_path), true); |
| 283 chrome::ShowUserManager(profile_path); | 298 UserManager::Show(profile_path, |
| 299 profiles::USER_MANAGER_NO_TUTORIAL, |
| 300 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 284 } | 301 } |
| 285 | 302 |
| 286 void LockProfile(Profile* profile) { | 303 void LockProfile(Profile* profile) { |
| 287 DCHECK(profile); | 304 DCHECK(profile); |
| 288 if (profile) { | 305 if (profile) { |
| 289 BrowserList::CloseAllBrowsersWithProfile( | 306 BrowserList::CloseAllBrowsersWithProfile( |
| 290 profile, base::Bind(&LockBrowserCloseSuccess)); | 307 profile, base::Bind(&LockBrowserCloseSuccess)); |
| 291 } | 308 } |
| 292 } | 309 } |
| 293 | 310 |
| 294 void CreateGuestProfileForUserManager( | 311 void CreateGuestProfileForUserManager( |
| 295 const base::FilePath& profile_path_to_focus, | 312 const base::FilePath& profile_path_to_focus, |
| 296 profiles::UserManagerTutorialMode tutorial_mode, | 313 profiles::UserManagerTutorialMode tutorial_mode, |
| 314 profiles::UserManagerProfileSelected profile_open_action, |
| 297 const base::Callback<void(Profile*, const std::string&)>& callback) { | 315 const base::Callback<void(Profile*, const std::string&)>& callback) { |
| 298 // Create the guest profile, if necessary, and open the User Manager | 316 // Create the guest profile, if necessary, and open the User Manager |
| 299 // from the guest profile. | 317 // from the guest profile. |
| 300 g_browser_process->profile_manager()->CreateProfileAsync( | 318 g_browser_process->profile_manager()->CreateProfileAsync( |
| 301 ProfileManager::GetGuestProfilePath(), | 319 ProfileManager::GetGuestProfilePath(), |
| 302 base::Bind(&OnUserManagerGuestProfileCreated, | 320 base::Bind(&OnUserManagerGuestProfileCreated, |
| 303 profile_path_to_focus, | 321 profile_path_to_focus, |
| 304 tutorial_mode, | 322 tutorial_mode, |
| 323 profile_open_action, |
| 305 callback), | 324 callback), |
| 306 base::string16(), | 325 base::string16(), |
| 307 base::string16(), | 326 base::string16(), |
| 308 std::string()); | 327 std::string()); |
| 309 } | 328 } |
| 310 | 329 |
| 311 void ShowUserManagerMaybeWithTutorial(Profile* profile) { | 330 void ShowUserManagerMaybeWithTutorial(Profile* profile) { |
| 312 // Guest users cannot appear in the User Manager, nor display a tutorial. | 331 // Guest users cannot appear in the User Manager, nor display a tutorial. |
| 313 if (!profile || profile->IsGuestSession()) { | 332 if (!profile || profile->IsGuestSession()) { |
| 314 chrome::ShowUserManager(base::FilePath()); | 333 UserManager::Show(base::FilePath(), |
| 334 profiles::USER_MANAGER_NO_TUTORIAL, |
| 335 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 315 return; | 336 return; |
| 316 } | 337 } |
| 317 chrome::ShowUserManagerWithTutorial(profiles::USER_MANAGER_TUTORIAL_OVERVIEW); | 338 UserManager::Show(base::FilePath(), |
| 339 profiles::USER_MANAGER_TUTORIAL_OVERVIEW, |
| 340 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 318 } | 341 } |
| 319 | 342 |
| 320 void EnableNewProfileManagementPreview(Profile* profile) { | 343 void EnableNewProfileManagementPreview(Profile* profile) { |
| 321 #if defined(OS_ANDROID) | 344 #if defined(OS_ANDROID) |
| 322 NOTREACHED(); | 345 NOTREACHED(); |
| 323 #else | 346 #else |
| 324 // TODO(rogerta): instead of setting experiment flags and command line | 347 // TODO(rogerta): instead of setting experiment flags and command line |
| 325 // args, we should set a profile preference. | 348 // args, we should set a profile preference. |
| 326 const about_flags::Experiment experiment = { | 349 const about_flags::Experiment experiment = { |
| 327 kNewProfileManagementExperimentInternalName, | 350 kNewProfileManagementExperimentInternalName, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 338 }; | 361 }; |
| 339 about_flags::PrefServiceFlagsStorage flags_storage( | 362 about_flags::PrefServiceFlagsStorage flags_storage( |
| 340 g_browser_process->local_state()); | 363 g_browser_process->local_state()); |
| 341 about_flags::SetExperimentEnabled( | 364 about_flags::SetExperimentEnabled( |
| 342 &flags_storage, | 365 &flags_storage, |
| 343 experiment.NameForChoice(1), | 366 experiment.NameForChoice(1), |
| 344 true); | 367 true); |
| 345 | 368 |
| 346 switches::EnableNewProfileManagementForTesting( | 369 switches::EnableNewProfileManagementForTesting( |
| 347 CommandLine::ForCurrentProcess()); | 370 CommandLine::ForCurrentProcess()); |
| 348 chrome::ShowUserManagerWithTutorial(profiles::USER_MANAGER_TUTORIAL_OVERVIEW); | 371 UserManager::Show(base::FilePath(), |
| 372 profiles::USER_MANAGER_TUTORIAL_OVERVIEW, |
| 373 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 349 UpdateServicesWithNewProfileManagementFlag(profile, true); | 374 UpdateServicesWithNewProfileManagementFlag(profile, true); |
| 350 #endif | 375 #endif |
| 351 } | 376 } |
| 352 | 377 |
| 353 void DisableNewProfileManagementPreview(Profile* profile) { | 378 void DisableNewProfileManagementPreview(Profile* profile) { |
| 354 about_flags::PrefServiceFlagsStorage flags_storage( | 379 about_flags::PrefServiceFlagsStorage flags_storage( |
| 355 g_browser_process->local_state()); | 380 g_browser_process->local_state()); |
| 356 about_flags::SetExperimentEnabled( | 381 about_flags::SetExperimentEnabled( |
| 357 &flags_storage, | 382 &flags_storage, |
| 358 kNewProfileManagementExperimentInternalName, | 383 kNewProfileManagementExperimentInternalName, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 386 case BrowserWindow::AVATAR_BUBBLE_MODE_SHOW_ERROR: | 411 case BrowserWindow::AVATAR_BUBBLE_MODE_SHOW_ERROR: |
| 387 *bubble_view_mode = BUBBLE_VIEW_MODE_PROFILE_CHOOSER; | 412 *bubble_view_mode = BUBBLE_VIEW_MODE_PROFILE_CHOOSER; |
| 388 *tutorial_mode = TUTORIAL_MODE_SHOW_ERROR; | 413 *tutorial_mode = TUTORIAL_MODE_SHOW_ERROR; |
| 389 return; | 414 return; |
| 390 default: | 415 default: |
| 391 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; | 416 *bubble_view_mode = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; |
| 392 } | 417 } |
| 393 } | 418 } |
| 394 | 419 |
| 395 } // namespace profiles | 420 } // namespace profiles |
| OLD | NEW |