Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: chrome/browser/ui/webui/options/sync_setup_handler.cc

Issue 1608103002: Settings Rewrite: Fix Opening Sync User login (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 // blank setup overlay on this page by showing the "done" page. This can 642 // blank setup overlay on this page by showing the "done" page. This can
643 // happen if the user navigates to chrome://settings/syncSetup in more than 643 // happen if the user navigates to chrome://settings/syncSetup in more than
644 // one tab. See crbug.com/261566. 644 // one tab. See crbug.com/261566.
645 // Note: The following block will transfer focus to the existing wizard. 645 // Note: The following block will transfer focus to the existing wizard.
646 if (IsExistingWizardPresent() && !IsActiveLogin()) 646 if (IsExistingWizardPresent() && !IsActiveLogin())
647 CloseUI(); 647 CloseUI();
648 648
649 // If a setup wizard is present on this page or another, bring it to focus. 649 // If a setup wizard is present on this page or another, bring it to focus.
650 // Otherwise, display a new one on this page. 650 // Otherwise, display a new one on this page.
651 if (!FocusExistingWizardIfPresent()) 651 if (!FocusExistingWizardIfPresent())
652 OpenSyncSetup(args); 652 OpenSyncSetup(false /* creating_supervised_user */);
653 } 653 }
654 654
655 #if defined(OS_CHROMEOS) 655 #if defined(OS_CHROMEOS)
656 // On ChromeOS, we need to sign out the user session to fix an auth error, so 656 // On ChromeOS, we need to sign out the user session to fix an auth error, so
657 // the user goes through the real signin flow to generate a new auth token. 657 // the user goes through the real signin flow to generate a new auth token.
658 void SyncSetupHandler::HandleDoSignOutOnAuthError(const base::ListValue* args) { 658 void SyncSetupHandler::HandleDoSignOutOnAuthError(const base::ListValue* args) {
659 DVLOG(1) << "Signing out the user to fix a sync error."; 659 DVLOG(1) << "Signing out the user to fix a sync error.";
660 chrome::AttemptUserExit(); 660 chrome::AttemptUserExit();
661 } 661 }
662 #endif 662 #endif
663 663
664 #if !defined(OS_CHROMEOS) 664 #if !defined(OS_CHROMEOS)
665 void SyncSetupHandler::HandleStartSignin(const base::ListValue* args) { 665 void SyncSetupHandler::HandleStartSignin(const base::ListValue* args) {
666 // Should only be called if the user is not already signed in. 666 // Should only be called if the user is not already signed in.
667 DCHECK(!SigninManagerFactory::GetForProfile(GetProfile())-> 667 DCHECK(!SigninManagerFactory::GetForProfile(GetProfile())->IsAuthenticated());
668 IsAuthenticated()); 668 bool creating_supervised_user = false;
669 OpenSyncSetup(args); 669 std::string access_point;
670 if (args->GetString(0, &access_point))
671 creating_supervised_user = access_point == "access-point-supervised-user";
dschuyler 2016/01/20 02:16:21 (optional) What do you think of: std::string acce
tommycli 2016/01/20 19:17:12 Done. Yes that def better.
672 OpenSyncSetup(creating_supervised_user);
670 } 673 }
671 674
672 void SyncSetupHandler::HandleStopSyncing(const base::ListValue* args) { 675 void SyncSetupHandler::HandleStopSyncing(const base::ListValue* args) {
673 if (GetSyncService()) 676 if (GetSyncService())
674 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); 677 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
675 SigninManagerFactory::GetForProfile(GetProfile())->SignOut( 678 SigninManagerFactory::GetForProfile(GetProfile())->SignOut(
676 signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS); 679 signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS);
677 680
678 bool delete_profile = false; 681 bool delete_profile = false;
679 if (args->GetBoolean(0, &delete_profile) && delete_profile) { 682 if (args->GetBoolean(0, &delete_profile) && delete_profile) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 734
732 // Alert the sync service anytime the sync setup dialog is closed. This can 735 // Alert the sync service anytime the sync setup dialog is closed. This can
733 // happen due to the user clicking the OK or Cancel button, or due to the 736 // happen due to the user clicking the OK or Cancel button, or due to the
734 // dialog being closed by virtue of sync being disabled in the background. 737 // dialog being closed by virtue of sync being disabled in the background.
735 if (sync_service) 738 if (sync_service)
736 sync_service->SetSetupInProgress(false); 739 sync_service->SetSetupInProgress(false);
737 740
738 configuring_sync_ = false; 741 configuring_sync_ = false;
739 } 742 }
740 743
741 void SyncSetupHandler::OpenSyncSetup(const base::ListValue* args) { 744 void SyncSetupHandler::OpenSyncSetup(bool creating_supervised_user) {
742 if (!PrepareSyncSetup()) 745 if (!PrepareSyncSetup())
743 return; 746 return;
744 747
745 // There are several different UI flows that can bring the user here: 748 // There are several different UI flows that can bring the user here:
746 // 1) Signin promo. 749 // 1) Signin promo.
747 // 2) Normal signin through settings page (IsAuthenticated() is false). 750 // 2) Normal signin through settings page (IsAuthenticated() is false).
748 // 3) Previously working credentials have expired. 751 // 3) Previously working credentials have expired.
749 // 4) User is signed in, but has stopped sync via the google dashboard, and 752 // 4) User is signed in, but has stopped sync via the google dashboard, and
750 // signout is prohibited by policy so we need to force a re-auth. 753 // signout is prohibited by policy so we need to force a re-auth.
751 // 5) User clicks [Advanced Settings] button on options page while already 754 // 5) User clicks [Advanced Settings] button on options page while already
752 // logged in. 755 // logged in.
753 // 6) One-click signin (credentials are already available, so should display 756 // 6) One-click signin (credentials are already available, so should display
754 // sync configure UI, not login UI). 757 // sync configure UI, not login UI).
755 // 7) User re-enables sync after disabling it via advanced settings. 758 // 7) User re-enables sync after disabling it via advanced settings.
756 #if !defined(OS_CHROMEOS) 759 #if !defined(OS_CHROMEOS)
757 SigninManagerBase* signin = 760 SigninManagerBase* signin =
758 SigninManagerFactory::GetForProfile(GetProfile()); 761 SigninManagerFactory::GetForProfile(GetProfile());
759 762
760 if (!signin->IsAuthenticated() || 763 if (!signin->IsAuthenticated() ||
761 SigninErrorControllerFactory::GetForProfile(GetProfile())->HasError()) { 764 SigninErrorControllerFactory::GetForProfile(GetProfile())->HasError()) {
762 // User is not logged in (cases 1-2), or login has been specially requested 765 // User is not logged in (cases 1-2), or login has been specially requested
763 // because previously working credentials have expired (case 3). Close sync 766 // because previously working credentials have expired (case 3). Close sync
764 // setup including any visible overlays, and display the gaia auth page. 767 // setup including any visible overlays, and display the gaia auth page.
765 // Control will be returned to the sync settings page once auth is complete. 768 // Control will be returned to the sync settings page once auth is complete.
766 CloseUI(); 769 CloseUI();
767 if (args) { 770 DisplayGaiaLogin(creating_supervised_user ?
768 std::string access_point = base::UTF16ToUTF8(ExtractStringValue(args)); 771 signin_metrics::AccessPoint::ACCESS_POINT_SUPERVISED_USER :
769 if (access_point == "access-point-supervised-user") { 772 signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS);
770 DisplayGaiaLogin(
771 signin_metrics::AccessPoint::ACCESS_POINT_SUPERVISED_USER);
772 return;
773 }
774 }
775 DisplayGaiaLogin(signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS);
776 return; 773 return;
777 } 774 }
778 #endif 775 #endif
779 if (!GetSyncService()) { 776 if (!GetSyncService()) {
780 // This can happen if the user directly navigates to /settings/syncSetup. 777 // This can happen if the user directly navigates to /settings/syncSetup.
781 DLOG(WARNING) << "Cannot display sync UI when sync is disabled"; 778 DLOG(WARNING) << "Cannot display sync UI when sync is disabled";
782 CloseUI(); 779 CloseUI();
783 return; 780 return;
784 } 781 }
785 782
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 "SyncSetupOverlay.showSyncSetupPage", page, args); 950 "SyncSetupOverlay.showSyncSetupPage", page, args);
954 951
955 // Make sure the tab used for the Gaia sign in does not cover the settings 952 // Make sure the tab used for the Gaia sign in does not cover the settings
956 // tab. 953 // tab.
957 FocusUI(); 954 FocusUI();
958 } 955 }
959 956
960 LoginUIService* SyncSetupHandler::GetLoginUIService() const { 957 LoginUIService* SyncSetupHandler::GetLoginUIService() const {
961 return LoginUIServiceFactory::GetForProfile(GetProfile()); 958 return LoginUIServiceFactory::GetForProfile(GetProfile());
962 } 959 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698