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" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // Passing true for |always_create| means we won't duplicate the code that | 115 // Passing true for |always_create| means we won't duplicate the code that |
116 // tries to find a browser. | 116 // tries to find a browser. |
117 profiles::FindOrCreateNewWindowForProfile( | 117 profiles::FindOrCreateNewWindowForProfile( |
118 profile, | 118 profile, |
119 is_process_startup, | 119 is_process_startup, |
120 is_first_run, | 120 is_first_run, |
121 desktop_type, | 121 desktop_type, |
122 true); | 122 true); |
123 } | 123 } |
124 | 124 |
125 // Called after a |guest_profile| is available to be used by the user manager. | 125 // Called after a |profile| is available to be used by the user manager. |
126 // Based on the value of |tutorial_mode| we determine a url to be displayed | 126 // Based on the value of |tutorial_mode| we determine a url to be displayed |
127 // by the webui and run the |callback|, if it exists. | 127 // by the webui and run the |callback|, if it exists. |
128 void OnUserManagerGuestProfileCreated( | 128 void OnUserManagerProfileCreated( |
129 const base::FilePath& profile_path_to_focus, | 129 const base::FilePath& profile_path_to_focus, |
130 profiles::UserManagerTutorialMode tutorial_mode, | 130 profiles::UserManagerTutorialMode tutorial_mode, |
131 const base::Callback<void(Profile*, const std::string&)>& callback, | 131 const base::Callback<void(Profile*, const std::string&)>& callback, |
132 Profile* guest_profile, | 132 Profile* profile, |
133 Profile::CreateStatus status) { | 133 Profile::CreateStatus status) { |
134 if (status != Profile::CREATE_STATUS_INITIALIZED || callback.is_null()) | 134 if (status != Profile::CREATE_STATUS_INITIALIZED || callback.is_null()) |
135 return; | 135 return; |
136 | 136 |
137 // Tell the webui which user should be focused. | 137 // Tell the webui which user should be focused. |
138 std::string page = chrome::kChromeUIUserManagerURL; | 138 std::string page = chrome::kChromeUIUserManagerURL; |
139 | 139 |
140 if (tutorial_mode == profiles::USER_MANAGER_TUTORIAL_OVERVIEW) { | 140 if (tutorial_mode == profiles::USER_MANAGER_TUTORIAL_OVERVIEW) { |
141 page += "#tutorial"; | 141 page += "#tutorial"; |
142 } else if (!profile_path_to_focus.empty()) { | 142 } else if (!profile_path_to_focus.empty()) { |
143 const ProfileInfoCache& cache = | 143 const ProfileInfoCache& cache = |
144 g_browser_process->profile_manager()->GetProfileInfoCache(); | 144 g_browser_process->profile_manager()->GetProfileInfoCache(); |
145 size_t index = cache.GetIndexOfProfileWithPath(profile_path_to_focus); | 145 size_t index = cache.GetIndexOfProfileWithPath(profile_path_to_focus); |
146 if (index != std::string::npos) { | 146 if (index != std::string::npos) { |
147 page += "#"; | 147 page += "#"; |
148 page += base::IntToString(index); | 148 page += base::IntToString(index); |
149 } | 149 } |
150 } | 150 } |
151 | 151 |
152 callback.Run(guest_profile, page); | 152 callback.Run(profile, page); |
153 } | 153 } |
154 | 154 |
155 } // namespace | 155 } // namespace |
156 | 156 |
157 namespace profiles { | 157 namespace profiles { |
158 | 158 |
159 void FindOrCreateNewWindowForProfile( | 159 void FindOrCreateNewWindowForProfile( |
160 Profile* profile, | 160 Profile* profile, |
161 chrome::startup::IsProcessStartup process_startup, | 161 chrome::startup::IsProcessStartup process_startup, |
162 chrome::startup::IsFirstRun is_first_run, | 162 chrome::startup::IsFirstRun is_first_run, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 DCHECK(profile); | 246 DCHECK(profile); |
247 ProfileInfoCache& cache = | 247 ProfileInfoCache& cache = |
248 g_browser_process->profile_manager()->GetProfileInfoCache(); | 248 g_browser_process->profile_manager()->GetProfileInfoCache(); |
249 | 249 |
250 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 250 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
251 cache.SetProfileSigninRequiredAtIndex(index, true); | 251 cache.SetProfileSigninRequiredAtIndex(index, true); |
252 chrome::ShowUserManager(profile->GetPath()); | 252 chrome::ShowUserManager(profile->GetPath()); |
253 BrowserList::CloseAllBrowsersWithProfile(profile); | 253 BrowserList::CloseAllBrowsersWithProfile(profile); |
254 } | 254 } |
255 | 255 |
256 void CreateGuestProfileForUserManager( | 256 void CreateUserManagerProfile( |
257 const base::FilePath& profile_path_to_focus, | 257 const base::FilePath& profile_path_to_focus, |
258 profiles::UserManagerTutorialMode tutorial_mode, | 258 profiles::UserManagerTutorialMode tutorial_mode, |
259 const base::Callback<void(Profile*, const std::string&)>& callback) { | 259 const base::Callback<void(Profile*, const std::string&)>& callback) { |
260 // Create the guest profile, if necessary, and open the User Manager | 260 // Create the guest profile, if necessary, and open the User Manager |
261 // from the guest profile. | 261 // from the guest profile. |
262 g_browser_process->profile_manager()->CreateProfileAsync( | 262 g_browser_process->profile_manager()->CreateProfileAsync( |
263 ProfileManager::GetGuestProfilePath(), | 263 ProfileManager::GetUserManagerProfilePath(), |
264 base::Bind(&OnUserManagerGuestProfileCreated, | 264 base::Bind(&OnUserManagerProfileCreated, |
265 profile_path_to_focus, | 265 profile_path_to_focus, |
266 tutorial_mode, | 266 tutorial_mode, |
267 callback), | 267 callback), |
268 base::string16(), | 268 base::string16(), |
269 base::string16(), | 269 base::string16(), |
270 std::string()); | 270 std::string()); |
271 } | 271 } |
272 | 272 |
273 void ShowUserManagerMaybeWithTutorial(Profile* profile) { | 273 void ShowUserManagerMaybeWithTutorial(Profile* profile) { |
274 // Guest users cannot appear in the User Manager, nor display a tutorial. | 274 // Guest users cannot appear in the User Manager, nor display a tutorial. |
(...skipping 10 matching lines...) Expand all Loading... |
285 | 285 |
286 if (tutorial_shown) { | 286 if (tutorial_shown) { |
287 chrome::ShowUserManager(profile->GetPath()); | 287 chrome::ShowUserManager(profile->GetPath()); |
288 } else { | 288 } else { |
289 chrome::ShowUserManagerWithTutorial( | 289 chrome::ShowUserManagerWithTutorial( |
290 profiles::USER_MANAGER_TUTORIAL_OVERVIEW); | 290 profiles::USER_MANAGER_TUTORIAL_OVERVIEW); |
291 } | 291 } |
292 } | 292 } |
293 | 293 |
294 } // namespace profiles | 294 } // namespace profiles |
OLD | NEW |