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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 DCHECK(!old_signin_manager->GetUsernameForAuthInProgress().empty()); | 315 DCHECK(!old_signin_manager->GetUsernameForAuthInProgress().empty()); |
316 DCHECK(!old_signin_manager->IsAuthenticated()); | 316 DCHECK(!old_signin_manager->IsAuthenticated()); |
317 DCHECK(!new_signin_manager->IsAuthenticated()); | 317 DCHECK(!new_signin_manager->IsAuthenticated()); |
318 | 318 |
319 // Copy credentials from the old profile to the just-created profile, | 319 // Copy credentials from the old profile to the just-created profile, |
320 // and switch over to tracking that profile. | 320 // and switch over to tracking that profile. |
321 new_signin_manager->CopyCredentialsFrom(*old_signin_manager); | 321 new_signin_manager->CopyCredentialsFrom(*old_signin_manager); |
322 FinishProfileSyncServiceSetup(); | 322 FinishProfileSyncServiceSetup(); |
323 Initialize(new_profile, nullptr); | 323 Initialize(new_profile, nullptr); |
324 DCHECK_EQ(profile_, new_profile); | 324 DCHECK_EQ(profile_, new_profile); |
| 325 |
| 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. |
325 skip_sync_confirm_ = true; | 331 skip_sync_confirm_ = true; |
| 332 #endif |
326 | 333 |
327 // We've transferred our credentials to the new profile - notify that | 334 // We've transferred our credentials to the new profile - notify that |
328 // the signin for the original profile was cancelled (must do this after | 335 // the signin for the original profile was cancelled (must do this after |
329 // we have called Initialize() with the new profile, as otherwise this | 336 // we have called Initialize() with the new profile, as otherwise this |
330 // object will get freed when the signin on the old profile is cancelled. | 337 // object will get freed when the signin on the old profile is cancelled. |
331 old_signin_manager->SignOut(signin_metrics::TRANSFER_CREDENTIALS, | 338 old_signin_manager->SignOut(signin_metrics::TRANSFER_CREDENTIALS, |
332 signin_metrics::SignoutDelete::IGNORE_METRIC); | 339 signin_metrics::SignoutDelete::IGNORE_METRIC); |
333 | 340 |
334 if (!dm_token_.empty()) { | 341 if (!dm_token_.empty()) { |
335 // Load policy for the just-created profile - once policy has finished | 342 // Load policy for the just-created profile - once policy has finished |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 void OneClickSigninSyncStarter::AccountAddedToCookie( | 494 void OneClickSigninSyncStarter::AccountAddedToCookie( |
488 const GoogleServiceAuthError& error) { | 495 const GoogleServiceAuthError& error) { |
489 if (first_account_added_to_cookie_) | 496 if (first_account_added_to_cookie_) |
490 return; | 497 return; |
491 | 498 |
492 first_account_added_to_cookie_ = true; | 499 first_account_added_to_cookie_ = true; |
493 | 500 |
494 // Regardless of whether the account was successfully added or not, | 501 // Regardless of whether the account was successfully added or not, |
495 // continue with sync starting. | 502 // continue with sync starting. |
496 | 503 |
497 // TODO(zmin): Remove this hack once the https://crbug.com/657924 fixed. | |
498 // Skip the Sync confirmation dialog if user choose to create a new profile | |
499 // for the corp signin. This is because the dialog doesn't work properly | |
500 // after the corp signin. | |
501 if (skip_sync_confirm_) { | 504 if (skip_sync_confirm_) { |
502 OnSyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN); | 505 OnSyncConfirmationUIClosed(LoginUIService::ABORT_SIGNIN); |
503 return; | 506 return; |
504 } | 507 } |
505 | 508 |
506 if (switches::UsePasswordSeparatedSigninFlow()) { | 509 if (switches::UsePasswordSeparatedSigninFlow()) { |
507 // Under the new signin flow, the sync confirmation dialog should always be | 510 // Under the new signin flow, the sync confirmation dialog should always be |
508 // shown regardless of |start_mode_|. |sync_setup_completed_callback_| will | 511 // shown regardless of |start_mode_|. |sync_setup_completed_callback_| will |
509 // be run after the modal is closed. | 512 // be run after the modal is closed. |
510 DisplayModalSyncConfirmationWindow(); | 513 DisplayModalSyncConfirmationWindow(); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 false /* user_gesture */); | 682 false /* user_gesture */); |
680 } | 683 } |
681 | 684 |
682 void OneClickSigninSyncStarter::LoadContinueUrl() { | 685 void OneClickSigninSyncStarter::LoadContinueUrl() { |
683 web_contents()->GetController().LoadURL( | 686 web_contents()->GetController().LoadURL( |
684 continue_url_, | 687 continue_url_, |
685 content::Referrer(), | 688 content::Referrer(), |
686 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 689 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, |
687 std::string()); | 690 std::string()); |
688 } | 691 } |
OLD | NEW |