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

Side by Side Diff: chrome/browser/ui/webui/settings/people_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/settings/people_handler.h" 5 #include "chrome/browser/ui/webui/settings/people_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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 // blank setup overlay on this page by showing the "done" page. This can 594 // blank setup overlay on this page by showing the "done" page. This can
595 // happen if the user navigates to chrome://settings/syncSetup in more than 595 // happen if the user navigates to chrome://settings/syncSetup in more than
596 // one tab. See crbug.com/261566. 596 // one tab. See crbug.com/261566.
597 // Note: The following block will transfer focus to the existing wizard. 597 // Note: The following block will transfer focus to the existing wizard.
598 if (IsExistingWizardPresent() && !IsActiveLogin()) 598 if (IsExistingWizardPresent() && !IsActiveLogin())
599 CloseUI(); 599 CloseUI();
600 600
601 // If a setup wizard is present on this page or another, bring it to focus. 601 // If a setup wizard is present on this page or another, bring it to focus.
602 // Otherwise, display a new one on this page. 602 // Otherwise, display a new one on this page.
603 if (!FocusExistingWizardIfPresent()) 603 if (!FocusExistingWizardIfPresent())
604 OpenSyncSetup(args); 604 OpenSyncSetup(false /* creating_supervised_user */);
605 } 605 }
606 606
607 #if defined(OS_CHROMEOS) 607 #if defined(OS_CHROMEOS)
608 // On ChromeOS, we need to sign out the user session to fix an auth error, so 608 // On ChromeOS, we need to sign out the user session to fix an auth error, so
609 // the user goes through the real signin flow to generate a new auth token. 609 // the user goes through the real signin flow to generate a new auth token.
610 void PeopleHandler::HandleDoSignOutOnAuthError(const base::ListValue* args) { 610 void PeopleHandler::HandleDoSignOutOnAuthError(const base::ListValue* args) {
611 DVLOG(1) << "Signing out the user to fix a sync error."; 611 DVLOG(1) << "Signing out the user to fix a sync error.";
612 chrome::AttemptUserExit(); 612 chrome::AttemptUserExit();
613 } 613 }
614 #endif 614 #endif
615 615
616 #if !defined(OS_CHROMEOS) 616 #if !defined(OS_CHROMEOS)
617 void PeopleHandler::HandleStartSignin(const base::ListValue* args) { 617 void PeopleHandler::HandleStartSignin(const base::ListValue* args) {
618 // Should only be called if the user is not already signed in. 618 // Should only be called if the user is not already signed in.
619 DCHECK(!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); 619 DCHECK(!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated());
620 OpenSyncSetup(args); 620 bool creating_supervised_user = false;
621 std::string access_point;
622 if (args->GetString(0, &access_point))
623 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.
624 OpenSyncSetup(creating_supervised_user);
621 } 625 }
622 626
623 void PeopleHandler::HandleStopSyncing(const base::ListValue* args) { 627 void PeopleHandler::HandleStopSyncing(const base::ListValue* args) {
624 if (GetSyncService()) 628 if (GetSyncService())
625 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); 629 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
626 SigninManagerFactory::GetForProfile(profile_) 630 SigninManagerFactory::GetForProfile(profile_)
627 ->SignOut(signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS); 631 ->SignOut(signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS);
628 632
629 bool delete_profile = false; 633 bool delete_profile = false;
630 if (args->GetBoolean(0, &delete_profile) && delete_profile) { 634 if (args->GetBoolean(0, &delete_profile) && delete_profile) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 696
693 // Alert the sync service anytime the sync setup dialog is closed. This can 697 // Alert the sync service anytime the sync setup dialog is closed. This can
694 // happen due to the user clicking the OK or Cancel button, or due to the 698 // happen due to the user clicking the OK or Cancel button, or due to the
695 // dialog being closed by virtue of sync being disabled in the background. 699 // dialog being closed by virtue of sync being disabled in the background.
696 if (sync_service) 700 if (sync_service)
697 sync_service->SetSetupInProgress(false); 701 sync_service->SetSetupInProgress(false);
698 702
699 configuring_sync_ = false; 703 configuring_sync_ = false;
700 } 704 }
701 705
702 void PeopleHandler::OpenSyncSetup(const base::ListValue* args) { 706 void PeopleHandler::OpenSyncSetup(bool creating_supervised_user) {
703 if (!PrepareSyncSetup()) 707 if (!PrepareSyncSetup())
704 return; 708 return;
705 709
706 // There are several different UI flows that can bring the user here: 710 // There are several different UI flows that can bring the user here:
707 // 1) Signin promo. 711 // 1) Signin promo.
708 // 2) Normal signin through settings page (IsAuthenticated() is false). 712 // 2) Normal signin through settings page (IsAuthenticated() is false).
709 // 3) Previously working credentials have expired. 713 // 3) Previously working credentials have expired.
710 // 4) User is signed in, but has stopped sync via the google dashboard, and 714 // 4) User is signed in, but has stopped sync via the google dashboard, and
711 // signout is prohibited by policy so we need to force a re-auth. 715 // signout is prohibited by policy so we need to force a re-auth.
712 // 5) User clicks [Advanced Settings] button on options page while already 716 // 5) User clicks [Advanced Settings] button on options page while already
713 // logged in. 717 // logged in.
714 // 6) One-click signin (credentials are already available, so should display 718 // 6) One-click signin (credentials are already available, so should display
715 // sync configure UI, not login UI). 719 // sync configure UI, not login UI).
716 // 7) User re-enables sync after disabling it via advanced settings. 720 // 7) User re-enables sync after disabling it via advanced settings.
717 #if !defined(OS_CHROMEOS) 721 #if !defined(OS_CHROMEOS)
718 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_); 722 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_);
719 723
720 if (!signin->IsAuthenticated() || 724 if (!signin->IsAuthenticated() ||
721 SigninErrorControllerFactory::GetForProfile(profile_)->HasError()) { 725 SigninErrorControllerFactory::GetForProfile(profile_)->HasError()) {
722 // User is not logged in (cases 1-2), or login has been specially requested 726 // User is not logged in (cases 1-2), or login has been specially requested
723 // because previously working credentials have expired (case 3). Close sync 727 // because previously working credentials have expired (case 3). Close sync
724 // setup including any visible overlays, and display the gaia auth page. 728 // setup including any visible overlays, and display the gaia auth page.
725 // Control will be returned to the sync settings page once auth is complete. 729 // Control will be returned to the sync settings page once auth is complete.
726 CloseUI(); 730 CloseUI();
727 if (args) { 731 DisplayGaiaLogin(creating_supervised_user ?
728 std::string access_point = base::UTF16ToUTF8(ExtractStringValue(args)); 732 signin_metrics::AccessPoint::ACCESS_POINT_SUPERVISED_USER :
729 if (access_point == "access-point-supervised-user") { 733 signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS);
730 DisplayGaiaLogin(
731 signin_metrics::AccessPoint::ACCESS_POINT_SUPERVISED_USER);
732 return;
733 }
734 }
735 DisplayGaiaLogin(signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS);
736 return; 734 return;
737 } 735 }
738 #endif 736 #endif
739 if (!GetSyncService()) { 737 if (!GetSyncService()) {
740 // This can happen if the user directly navigates to /settings/syncSetup. 738 // This can happen if the user directly navigates to /settings/syncSetup.
741 DLOG(WARNING) << "Cannot display sync UI when sync is disabled"; 739 DLOG(WARNING) << "Cannot display sync UI when sync is disabled";
742 CloseUI(); 740 CloseUI();
743 return; 741 return;
744 } 742 }
745 743
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 void PeopleHandler::UpdateSyncState() { 990 void PeopleHandler::UpdateSyncState() {
993 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.sendSyncStatus", 991 web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.sendSyncStatus",
994 *GetSyncStateDictionary()); 992 *GetSyncStateDictionary());
995 } 993 }
996 994
997 void PeopleHandler::OnSigninAllowedPrefChange() { 995 void PeopleHandler::OnSigninAllowedPrefChange() {
998 UpdateSyncState(); 996 UpdateSyncState();
999 } 997 }
1000 998
1001 } // namespace settings 999 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698