Chromium Code Reviews| 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/strings/string_number_conversions.h" | |
| 9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_dialogs.h" | 14 #include "chrome/browser/ui/browser_dialogs.h" |
| 15 #include "chrome/common/url_constants.h" | |
| 14 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
| 16 | 18 |
| 17 #if !defined(OS_IOS) | 19 #if !defined(OS_IOS) |
| 18 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
| 19 #include "chrome/browser/ui/browser_list.h" | 21 #include "chrome/browser/ui/browser_list.h" |
| 20 #include "chrome/browser/ui/browser_list_observer.h" | 22 #include "chrome/browser/ui/browser_list_observer.h" |
| 21 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
| 22 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 24 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 23 #endif // !defined (OS_IOS) | 25 #endif // !defined (OS_IOS) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 // Passing true for |always_create| means we won't duplicate the code that | 113 // Passing true for |always_create| means we won't duplicate the code that |
| 112 // tries to find a browser. | 114 // tries to find a browser. |
| 113 profiles::FindOrCreateNewWindowForProfile( | 115 profiles::FindOrCreateNewWindowForProfile( |
| 114 profile, | 116 profile, |
| 115 is_process_startup, | 117 is_process_startup, |
| 116 is_first_run, | 118 is_first_run, |
| 117 desktop_type, | 119 desktop_type, |
| 118 true); | 120 true); |
| 119 } | 121 } |
| 120 | 122 |
| 123 void OnUserManagerGuestProfileCreated( | |
|
Alexei Svitkine (slow)
2014/03/18 15:50:33
Add a comment.
noms (inactive)
2014/03/19 15:58:20
Done.
| |
| 124 const base::FilePath& profile_path_to_focus, | |
| 125 profiles::UserManagerTutorialMode tutorial_mode, | |
| 126 const base::Callback<void(Profile*, const std::string&)>& callback, | |
| 127 Profile* guest_profile, | |
| 128 Profile::CreateStatus status) { | |
| 129 if (status != Profile::CREATE_STATUS_INITIALIZED) | |
| 130 return; | |
| 131 | |
| 132 // Tell the webui which user pod should be focused. | |
| 133 std::string page = chrome::kChromeUIUserManagerURL; | |
| 134 | |
| 135 if (tutorial_mode == profiles::USER_MANAGER_TUTORIAL_OVERVIEW) { | |
| 136 page += "#tutorial"; | |
| 137 } else if (!profile_path_to_focus.empty()) { | |
| 138 ProfileInfoCache& cache = | |
|
Alexei Svitkine (slow)
2014/03/18 15:50:33
Nit: const
noms (inactive)
2014/03/19 15:58:20
Done.
Alexei Svitkine (slow)
2014/03/19 16:37:01
Optional nit: I think in this case you should be a
| |
| 139 g_browser_process->profile_manager()->GetProfileInfoCache(); | |
| 140 size_t index = cache.GetIndexOfProfileWithPath(profile_path_to_focus); | |
| 141 if (index != std::string::npos) { | |
| 142 page += "#"; | |
| 143 page += base::IntToString(index); | |
| 144 } | |
| 145 } | |
| 146 | |
| 147 if (!callback.is_null()) | |
| 148 callback.Run(guest_profile, page); | |
| 149 } | |
| 150 | |
| 121 } // namespace | 151 } // namespace |
| 122 | 152 |
| 123 namespace profiles { | 153 namespace profiles { |
| 124 | 154 |
| 125 void FindOrCreateNewWindowForProfile( | 155 void FindOrCreateNewWindowForProfile( |
| 126 Profile* profile, | 156 Profile* profile, |
| 127 chrome::startup::IsProcessStartup process_startup, | 157 chrome::startup::IsProcessStartup process_startup, |
| 128 chrome::startup::IsFirstRun is_first_run, | 158 chrome::startup::IsFirstRun is_first_run, |
| 129 chrome::HostDesktopType desktop_type, | 159 chrome::HostDesktopType desktop_type, |
| 130 bool always_create) { | 160 bool always_create) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 DCHECK(profile); | 242 DCHECK(profile); |
| 213 ProfileInfoCache& cache = | 243 ProfileInfoCache& cache = |
| 214 g_browser_process->profile_manager()->GetProfileInfoCache(); | 244 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 215 | 245 |
| 216 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 246 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| 217 cache.SetProfileSigninRequiredAtIndex(index, true); | 247 cache.SetProfileSigninRequiredAtIndex(index, true); |
| 218 chrome::ShowUserManager(profile->GetPath()); | 248 chrome::ShowUserManager(profile->GetPath()); |
| 219 BrowserList::CloseAllBrowsersWithProfile(profile); | 249 BrowserList::CloseAllBrowsersWithProfile(profile); |
| 220 } | 250 } |
| 221 | 251 |
| 252 void CreateGuestProfileForUserManager( | |
| 253 const base::FilePath& profile_path_to_focus, | |
| 254 profiles::UserManagerTutorialMode tutorial_mode, | |
| 255 const base::Callback<void(Profile*, const std::string&)>& callback) { | |
| 256 | |
| 257 // Create the guest profile, if necessary, and open the User Manager | |
| 258 // from the guest profile. | |
| 259 ProfileManager* profile_manager = g_browser_process->profile_manager(); | |
| 260 profile_manager->CreateProfileAsync( | |
| 261 ProfileManager::GetGuestProfilePath(), | |
| 262 base::Bind(&OnUserManagerGuestProfileCreated, | |
| 263 profile_path_to_focus, | |
| 264 tutorial_mode, | |
| 265 callback), | |
| 266 base::string16(), | |
|
Alexei Svitkine (slow)
2014/03/18 15:50:33
Nit: Can you add /* */ comments with the name of t
noms (inactive)
2014/03/19 15:58:20
This is a pretty standard call for this function (
| |
| 267 base::string16(), | |
| 268 std::string()); | |
| 269 } | |
| 270 | |
| 222 } // namespace profiles | 271 } // namespace profiles |
| OLD | NEW |