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/webui/options/sync_setup_handler.h" | 5 #include "chrome/browser/ui/webui/options/sync_setup_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 // blank setup overlay on this page by showing the "done" page. This can | 644 // blank setup overlay on this page by showing the "done" page. This can |
645 // happen if the user navigates to chrome://settings/syncSetup in more than | 645 // happen if the user navigates to chrome://settings/syncSetup in more than |
646 // one tab. See crbug.com/261566. | 646 // one tab. See crbug.com/261566. |
647 // Note: The following block will transfer focus to the existing wizard. | 647 // Note: The following block will transfer focus to the existing wizard. |
648 if (IsExistingWizardPresent() && !IsActiveLogin()) | 648 if (IsExistingWizardPresent() && !IsActiveLogin()) |
649 CloseUI(); | 649 CloseUI(); |
650 | 650 |
651 // If a setup wizard is present on this page or another, bring it to focus. | 651 // If a setup wizard is present on this page or another, bring it to focus. |
652 // Otherwise, display a new one on this page. | 652 // Otherwise, display a new one on this page. |
653 if (!FocusExistingWizardIfPresent()) | 653 if (!FocusExistingWizardIfPresent()) |
654 OpenSyncSetup(args); | 654 OpenSyncSetup(false /* creating_supervised_user */); |
655 } | 655 } |
656 | 656 |
657 #if defined(OS_CHROMEOS) | 657 #if defined(OS_CHROMEOS) |
658 // On ChromeOS, we need to sign out the user session to fix an auth error, so | 658 // On ChromeOS, we need to sign out the user session to fix an auth error, so |
659 // the user goes through the real signin flow to generate a new auth token. | 659 // the user goes through the real signin flow to generate a new auth token. |
660 void SyncSetupHandler::HandleDoSignOutOnAuthError(const base::ListValue* args) { | 660 void SyncSetupHandler::HandleDoSignOutOnAuthError(const base::ListValue* args) { |
661 DVLOG(1) << "Signing out the user to fix a sync error."; | 661 DVLOG(1) << "Signing out the user to fix a sync error."; |
662 chrome::AttemptUserExit(); | 662 chrome::AttemptUserExit(); |
663 } | 663 } |
664 #endif | 664 #endif |
665 | 665 |
666 #if !defined(OS_CHROMEOS) | 666 #if !defined(OS_CHROMEOS) |
667 void SyncSetupHandler::HandleStartSignin(const base::ListValue* args) { | 667 void SyncSetupHandler::HandleStartSignin(const base::ListValue* args) { |
668 // Should only be called if the user is not already signed in. | 668 // Should only be called if the user is not already signed in. |
669 DCHECK(!SigninManagerFactory::GetForProfile(GetProfile())-> | 669 DCHECK(!SigninManagerFactory::GetForProfile(GetProfile())->IsAuthenticated()); |
670 IsAuthenticated()); | 670 bool creating_supervised_user = false; |
671 OpenSyncSetup(args); | 671 args->GetBoolean(0, &creating_supervised_user); |
| 672 OpenSyncSetup(creating_supervised_user); |
672 } | 673 } |
673 | 674 |
674 void SyncSetupHandler::HandleStopSyncing(const base::ListValue* args) { | 675 void SyncSetupHandler::HandleStopSyncing(const base::ListValue* args) { |
675 if (GetSyncService()) | 676 if (GetSyncService()) |
676 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); | 677 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); |
677 | 678 |
678 bool delete_profile = false; | 679 bool delete_profile = false; |
679 args->GetBoolean(0, &delete_profile); | 680 args->GetBoolean(0, &delete_profile); |
680 signin_metrics::SignoutDelete delete_metric = | 681 signin_metrics::SignoutDelete delete_metric = |
681 delete_profile ? signin_metrics::SignoutDelete::DELETED | 682 delete_profile ? signin_metrics::SignoutDelete::DELETED |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 | 741 |
741 // Alert the sync service anytime the sync setup dialog is closed. This can | 742 // Alert the sync service anytime the sync setup dialog is closed. This can |
742 // happen due to the user clicking the OK or Cancel button, or due to the | 743 // happen due to the user clicking the OK or Cancel button, or due to the |
743 // dialog being closed by virtue of sync being disabled in the background. | 744 // dialog being closed by virtue of sync being disabled in the background. |
744 if (sync_service) | 745 if (sync_service) |
745 sync_service->SetSetupInProgress(false); | 746 sync_service->SetSetupInProgress(false); |
746 | 747 |
747 configuring_sync_ = false; | 748 configuring_sync_ = false; |
748 } | 749 } |
749 | 750 |
750 void SyncSetupHandler::OpenSyncSetup(const base::ListValue* args) { | 751 void SyncSetupHandler::OpenSyncSetup(bool creating_supervised_user) { |
751 if (!PrepareSyncSetup()) | 752 if (!PrepareSyncSetup()) |
752 return; | 753 return; |
753 | 754 |
754 // There are several different UI flows that can bring the user here: | 755 // There are several different UI flows that can bring the user here: |
755 // 1) Signin promo. | 756 // 1) Signin promo. |
756 // 2) Normal signin through settings page (IsAuthenticated() is false). | 757 // 2) Normal signin through settings page (IsAuthenticated() is false). |
757 // 3) Previously working credentials have expired. | 758 // 3) Previously working credentials have expired. |
758 // 4) User is signed in, but has stopped sync via the google dashboard, and | 759 // 4) User is signed in, but has stopped sync via the google dashboard, and |
759 // signout is prohibited by policy so we need to force a re-auth. | 760 // signout is prohibited by policy so we need to force a re-auth. |
760 // 5) User clicks [Advanced Settings] button on options page while already | 761 // 5) User clicks [Advanced Settings] button on options page while already |
761 // logged in. | 762 // logged in. |
762 // 6) One-click signin (credentials are already available, so should display | 763 // 6) One-click signin (credentials are already available, so should display |
763 // sync configure UI, not login UI). | 764 // sync configure UI, not login UI). |
764 // 7) User re-enables sync after disabling it via advanced settings. | 765 // 7) User re-enables sync after disabling it via advanced settings. |
765 #if !defined(OS_CHROMEOS) | 766 #if !defined(OS_CHROMEOS) |
766 SigninManagerBase* signin = | 767 SigninManagerBase* signin = |
767 SigninManagerFactory::GetForProfile(GetProfile()); | 768 SigninManagerFactory::GetForProfile(GetProfile()); |
768 | 769 |
769 if (!signin->IsAuthenticated() || | 770 if (!signin->IsAuthenticated() || |
770 SigninErrorControllerFactory::GetForProfile(GetProfile())->HasError()) { | 771 SigninErrorControllerFactory::GetForProfile(GetProfile())->HasError()) { |
771 // User is not logged in (cases 1-2), or login has been specially requested | 772 // User is not logged in (cases 1-2), or login has been specially requested |
772 // because previously working credentials have expired (case 3). Close sync | 773 // because previously working credentials have expired (case 3). Close sync |
773 // setup including any visible overlays, and display the gaia auth page. | 774 // setup including any visible overlays, and display the gaia auth page. |
774 // Control will be returned to the sync settings page once auth is complete. | 775 // Control will be returned to the sync settings page once auth is complete. |
775 CloseUI(); | 776 CloseUI(); |
776 if (args) { | 777 DisplayGaiaLogin( |
777 std::string access_point = base::UTF16ToUTF8(ExtractStringValue(args)); | 778 creating_supervised_user ? |
778 if (access_point == "access-point-supervised-user") { | 779 signin_metrics::AccessPoint::ACCESS_POINT_SUPERVISED_USER : |
779 DisplayGaiaLogin( | 780 signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS); |
780 signin_metrics::AccessPoint::ACCESS_POINT_SUPERVISED_USER); | |
781 return; | |
782 } | |
783 } | |
784 DisplayGaiaLogin(signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS); | |
785 return; | 781 return; |
786 } | 782 } |
787 #endif | 783 #endif |
788 if (!GetSyncService()) { | 784 if (!GetSyncService()) { |
789 // This can happen if the user directly navigates to /settings/syncSetup. | 785 // This can happen if the user directly navigates to /settings/syncSetup. |
790 DLOG(WARNING) << "Cannot display sync UI when sync is disabled"; | 786 DLOG(WARNING) << "Cannot display sync UI when sync is disabled"; |
791 CloseUI(); | 787 CloseUI(); |
792 return; | 788 return; |
793 } | 789 } |
794 | 790 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
962 "SyncSetupOverlay.showSyncSetupPage", page, args); | 958 "SyncSetupOverlay.showSyncSetupPage", page, args); |
963 | 959 |
964 // Make sure the tab used for the Gaia sign in does not cover the settings | 960 // Make sure the tab used for the Gaia sign in does not cover the settings |
965 // tab. | 961 // tab. |
966 FocusUI(); | 962 FocusUI(); |
967 } | 963 } |
968 | 964 |
969 LoginUIService* SyncSetupHandler::GetLoginUIService() const { | 965 LoginUIService* SyncSetupHandler::GetLoginUIService() const { |
970 return LoginUIServiceFactory::GetForProfile(GetProfile()); | 966 return LoginUIServiceFactory::GetForProfile(GetProfile()); |
971 } | 967 } |
OLD | NEW |