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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // Let the sync service know that setup is in progress so it doesn't start | 133 // Let the sync service know that setup is in progress so it doesn't start |
134 // syncing until the user has finished any configuration. | 134 // syncing until the user has finished any configuration. |
135 ProfileSyncService* profile_sync_service = GetProfileSyncService(); | 135 ProfileSyncService* profile_sync_service = GetProfileSyncService(); |
136 if (profile_sync_service) | 136 if (profile_sync_service) |
137 sync_blocker_ = profile_sync_service->GetSetupInProgressHandle(); | 137 sync_blocker_ = profile_sync_service->GetSetupInProgressHandle(); |
138 | 138 |
139 // Make sure the syncing is requested, otherwise the SigninManager | 139 // Make sure the syncing is requested, otherwise the SigninManager |
140 // will not be able to complete successfully. | 140 // will not be able to complete successfully. |
141 syncer::SyncPrefs sync_prefs(profile_->GetPrefs()); | 141 syncer::SyncPrefs sync_prefs(profile_->GetPrefs()); |
142 sync_prefs.SetSyncRequested(true); | 142 sync_prefs.SetSyncRequested(true); |
143 skip_sync_confirm_ = false; | |
144 } | 143 } |
145 | 144 |
146 void OneClickSigninSyncStarter::ConfirmSignin(ProfileMode profile_mode, | 145 void OneClickSigninSyncStarter::ConfirmSignin(ProfileMode profile_mode, |
147 const std::string& oauth_token) { | 146 const std::string& oauth_token) { |
148 DCHECK(!oauth_token.empty()); | 147 DCHECK(!oauth_token.empty()); |
149 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 148 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
150 if (signin->IsAuthenticated()) { | 149 if (signin->IsAuthenticated()) { |
151 // The user is already signed in - just tell SigninManager to continue | 150 // The user is already signed in - just tell SigninManager to continue |
152 // with its re-auth flow. | 151 // with its re-auth flow. |
153 DCHECK_EQ(CURRENT_PROFILE, profile_mode); | 152 DCHECK_EQ(CURRENT_PROFILE, profile_mode); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 DCHECK(!old_signin_manager->IsAuthenticated()); | 315 DCHECK(!old_signin_manager->IsAuthenticated()); |
317 DCHECK(!new_signin_manager->IsAuthenticated()); | 316 DCHECK(!new_signin_manager->IsAuthenticated()); |
318 | 317 |
319 // Copy credentials from the old profile to the just-created profile, | 318 // Copy credentials from the old profile to the just-created profile, |
320 // and switch over to tracking that profile. | 319 // and switch over to tracking that profile. |
321 new_signin_manager->CopyCredentialsFrom(*old_signin_manager); | 320 new_signin_manager->CopyCredentialsFrom(*old_signin_manager); |
322 FinishProfileSyncServiceSetup(); | 321 FinishProfileSyncServiceSetup(); |
323 Initialize(new_profile, nullptr); | 322 Initialize(new_profile, nullptr); |
324 DCHECK_EQ(profile_, new_profile); | 323 DCHECK_EQ(profile_, new_profile); |
325 | 324 |
326 #if defined(OS_MACOSX) | |
327 // On macOS, the sync confirmation dialog is web-contents modal and thus | |
328 // it is dismissed on tab navigation (which always occurs when signing in | |
329 // to a new profile). | |
330 // Skip sync confirmation on macOS to workaround this issue. | |
331 skip_sync_confirm_ = true; | |
332 #endif | |
333 | |
334 // We've transferred our credentials to the new profile - notify that | 325 // We've transferred our credentials to the new profile - notify that |
335 // the signin for the original profile was cancelled (must do this after | 326 // the signin for the original profile was cancelled (must do this after |
336 // we have called Initialize() with the new profile, as otherwise this | 327 // we have called Initialize() with the new profile, as otherwise this |
337 // object will get freed when the signin on the old profile is cancelled. | 328 // object will get freed when the signin on the old profile is cancelled. |
338 old_signin_manager->SignOut(signin_metrics::TRANSFER_CREDENTIALS, | 329 old_signin_manager->SignOut(signin_metrics::TRANSFER_CREDENTIALS, |
339 signin_metrics::SignoutDelete::IGNORE_METRIC); | 330 signin_metrics::SignoutDelete::IGNORE_METRIC); |
340 | 331 |
341 if (!dm_token_.empty()) { | 332 if (!dm_token_.empty()) { |
342 // Load policy for the just-created profile - once policy has finished | 333 // Load policy for the just-created profile - once policy has finished |
343 // loading the signin process will complete. | 334 // loading the signin process will complete. |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 void OneClickSigninSyncStarter::AccountAddedToCookie( | 485 void OneClickSigninSyncStarter::AccountAddedToCookie( |
495 const GoogleServiceAuthError& error) { | 486 const GoogleServiceAuthError& error) { |
496 if (first_account_added_to_cookie_) | 487 if (first_account_added_to_cookie_) |
497 return; | 488 return; |
498 | 489 |
499 first_account_added_to_cookie_ = true; | 490 first_account_added_to_cookie_ = true; |
500 | 491 |
501 // Regardless of whether the account was successfully added or not, | 492 // Regardless of whether the account was successfully added or not, |
502 // continue with sync starting. | 493 // continue with sync starting. |
503 | 494 |
504 if (skip_sync_confirm_) { | |
505 OnSyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN); | |
506 return; | |
507 } | |
508 | |
509 if (switches::UsePasswordSeparatedSigninFlow()) { | 495 if (switches::UsePasswordSeparatedSigninFlow()) { |
510 // Under the new signin flow, the sync confirmation dialog should always be | 496 // Under the new signin flow, the sync confirmation dialog should always be |
511 // shown regardless of |start_mode_|. |sync_setup_completed_callback_| will | 497 // shown regardless of |start_mode_|. |sync_setup_completed_callback_| will |
512 // be run after the modal is closed. | 498 // be run after the modal is closed. |
513 DisplayModalSyncConfirmationWindow(); | 499 DisplayModalSyncConfirmationWindow(); |
514 return; | 500 return; |
515 } | 501 } |
516 | 502 |
517 if (!sync_setup_completed_callback_.is_null()) | 503 if (!sync_setup_completed_callback_.is_null()) |
518 sync_setup_completed_callback_.Run(SYNC_SETUP_SUCCESS); | 504 sync_setup_completed_callback_.Run(SYNC_SETUP_SUCCESS); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 false /* user_gesture */); | 668 false /* user_gesture */); |
683 } | 669 } |
684 | 670 |
685 void OneClickSigninSyncStarter::LoadContinueUrl() { | 671 void OneClickSigninSyncStarter::LoadContinueUrl() { |
686 web_contents()->GetController().LoadURL( | 672 web_contents()->GetController().LoadURL( |
687 continue_url_, | 673 continue_url_, |
688 content::Referrer(), | 674 content::Referrer(), |
689 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 675 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
690 std::string()); | 676 std::string()); |
691 } | 677 } |
OLD | NEW |