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/ui/sync/one_click_signin_sync_starter.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 | 10 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 181 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
182 DCHECK(!signin->GetUsernameForAuthInProgress().empty()); | 182 DCHECK(!signin->GetUsernameForAuthInProgress().empty()); |
183 DCHECK(policy_client_); | 183 DCHECK(policy_client_); |
184 // Create a new profile and have it call back when done so we can inject our | 184 // Create a new profile and have it call back when done so we can inject our |
185 // signin credentials. | 185 // signin credentials. |
186 size_t icon_index = g_browser_process->profile_manager()-> | 186 size_t icon_index = g_browser_process->profile_manager()-> |
187 GetProfileInfoCache().ChooseAvatarIconIndexForNewProfile(); | 187 GetProfileInfoCache().ChooseAvatarIconIndexForNewProfile(); |
188 ProfileManager::CreateMultiProfileAsync( | 188 ProfileManager::CreateMultiProfileAsync( |
189 UTF8ToUTF16(signin->GetUsernameForAuthInProgress()), | 189 UTF8ToUTF16(signin->GetUsernameForAuthInProgress()), |
190 UTF8ToUTF16(ProfileInfoCache::GetDefaultAvatarIconUrl(icon_index)), | 190 UTF8ToUTF16(ProfileInfoCache::GetDefaultAvatarIconUrl(icon_index)), |
191 base::Bind(&OneClickSigninSyncStarter::CompleteSigninForNewProfile, | 191 base::Bind(&OneClickSigninSyncStarter::CompleteInitForNewProfile, |
192 weak_pointer_factory_.GetWeakPtr()), | 192 weak_pointer_factory_.GetWeakPtr(), desktop_type_), |
193 desktop_type_, | |
194 false); | 193 false); |
195 } | 194 } |
196 | 195 |
197 void OneClickSigninSyncStarter::CompleteSigninForNewProfile( | 196 void OneClickSigninSyncStarter::CompleteInitForNewProfile( |
| 197 chrome::HostDesktopType desktop_type, |
198 Profile* new_profile, | 198 Profile* new_profile, |
199 Profile::CreateStatus status) { | 199 Profile::CreateStatus status) { |
200 DCHECK_NE(profile_, new_profile); | 200 DCHECK_NE(profile_, new_profile); |
201 if (status == Profile::CREATE_STATUS_FAIL) { | 201 if (status == Profile::CREATE_STATUS_FAIL) { |
202 // TODO(atwilson): On error, unregister the client to release the DMToken | 202 // TODO(atwilson): On error, unregister the client to release the DMToken |
203 // and surface a better error for the user. | 203 // and surface a better error for the user. |
204 NOTREACHED() << "Error creating new profile"; | 204 NOTREACHED() << "Error creating new profile"; |
205 CancelSigninAndDelete(); | 205 CancelSigninAndDelete(); |
206 return; | 206 return; |
207 } | 207 } |
(...skipping 20 matching lines...) Expand all Loading... |
228 | 228 |
229 // We've transferred our credentials to the new profile - notify that | 229 // We've transferred our credentials to the new profile - notify that |
230 // the signin for the original profile was cancelled (must do this after | 230 // the signin for the original profile was cancelled (must do this after |
231 // we have called Initialize() with the new profile, as otherwise this | 231 // we have called Initialize() with the new profile, as otherwise this |
232 // object will get freed when the signin on the old profile is cancelled. | 232 // object will get freed when the signin on the old profile is cancelled. |
233 old_signin_manager->SignOut(); | 233 old_signin_manager->SignOut(); |
234 | 234 |
235 // Load policy for the just-created profile - once policy has finished | 235 // Load policy for the just-created profile - once policy has finished |
236 // loading the signin process will complete. | 236 // loading the signin process will complete. |
237 LoadPolicyWithCachedClient(); | 237 LoadPolicyWithCachedClient(); |
| 238 |
| 239 // Open the profile's first window, after all initialization. |
| 240 ProfileManager::FindOrCreateNewWindowForProfile( |
| 241 new_profile, |
| 242 chrome::startup::IS_PROCESS_STARTUP, |
| 243 chrome::startup::IS_FIRST_RUN, |
| 244 desktop_type, |
| 245 false); |
238 } | 246 } |
239 } | 247 } |
240 #endif | 248 #endif |
241 | 249 |
242 void OneClickSigninSyncStarter::ConfirmAndSignin() { | 250 void OneClickSigninSyncStarter::ConfirmAndSignin() { |
243 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 251 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
244 // browser_ can be null for unit tests. | 252 // browser_ can be null for unit tests. |
245 if (browser_ && confirmation_required_ == CONFIRM_UNTRUSTED_SIGNIN) { | 253 if (browser_ && confirmation_required_ == CONFIRM_UNTRUSTED_SIGNIN) { |
246 // Display a confirmation dialog to the user. | 254 // Display a confirmation dialog to the user. |
247 browser_->window()->ShowOneClickSigninBubble( | 255 browser_->window()->ShowOneClickSigninBubble( |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 391 |
384 void OneClickSigninSyncStarter::ShowSyncSettingsPageOnSameTab() { | 392 void OneClickSigninSyncStarter::ShowSyncSettingsPageOnSameTab() { |
385 std::string url = std::string(chrome::kChromeUISettingsURL) + | 393 std::string url = std::string(chrome::kChromeUISettingsURL) + |
386 chrome::kSyncSetupSubPage; | 394 chrome::kSyncSetupSubPage; |
387 chrome::NavigateParams params( | 395 chrome::NavigateParams params( |
388 browser_, GURL(url), content::PAGE_TRANSITION_AUTO_TOPLEVEL); | 396 browser_, GURL(url), content::PAGE_TRANSITION_AUTO_TOPLEVEL); |
389 params.disposition = CURRENT_TAB; | 397 params.disposition = CURRENT_TAB; |
390 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 398 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
391 chrome::Navigate(¶ms); | 399 chrome::Navigate(¶ms); |
392 } | 400 } |
OLD | NEW |