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