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

Side by Side Diff: chrome/browser/ui/webui/settings/people_handler.cc

Issue 2603283003: [MD Settings][People] Force sign out only in the case of unrecoverable error (Closed)
Patch Set: Created 3 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 <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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (args->Get(0, callback_id) && args->GetString(1, &json) && !json.empty()) 149 if (args->Get(0, callback_id) && args->GetString(1, &json) && !json.empty())
150 CHECK(GetConfiguration(json, config)); 150 CHECK(GetConfiguration(json, config));
151 else 151 else
152 NOTREACHED(); 152 NOTREACHED();
153 } 153 }
154 154
155 std::string GetSyncErrorAction(sync_ui_util::ActionType action_type) { 155 std::string GetSyncErrorAction(sync_ui_util::ActionType action_type) {
156 switch (action_type) { 156 switch (action_type) {
157 case sync_ui_util::REAUTHENTICATE: 157 case sync_ui_util::REAUTHENTICATE:
158 return "reauthenticate"; 158 return "reauthenticate";
159 case sync_ui_util::SIGNOUT_AND_SIGNIN:
160 return "signOutAndSignIn";
159 case sync_ui_util::UPGRADE_CLIENT: 161 case sync_ui_util::UPGRADE_CLIENT:
160 return "upgradeClient"; 162 return "upgradeClient";
161 case sync_ui_util::ENTER_PASSPHRASE: 163 case sync_ui_util::ENTER_PASSPHRASE:
162 return "enterPassphrase"; 164 return "enterPassphrase";
163 default: 165 default:
164 return "noAction"; 166 return "noAction";
165 } 167 }
166 } 168 }
167 169
168 } // namespace 170 } // namespace
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // For web-based signin, the signin page is not displayed in an overlay 500 // For web-based signin, the signin page is not displayed in an overlay
499 // on the settings page. So if we get here, it must be due to the user 501 // on the settings page. So if we get here, it must be due to the user
500 // cancelling signin (by reloading the sync settings page during initial 502 // cancelling signin (by reloading the sync settings page during initial
501 // signin) or by directly navigating to settings/syncSetup 503 // signin) or by directly navigating to settings/syncSetup
502 // (http://crbug.com/229836). So just exit and go back to the settings page. 504 // (http://crbug.com/229836). So just exit and go back to the settings page.
503 DLOG(WARNING) << "Cannot display sync setup UI when not signed in"; 505 DLOG(WARNING) << "Cannot display sync setup UI when not signed in";
504 CloseUI(); 506 CloseUI();
505 return; 507 return;
506 } 508 }
507 509
508 OpenSyncSetup(false /* creating_supervised_user */); 510 OpenSyncSetup();
509 } 511 }
510 512
511 #if defined(OS_CHROMEOS) 513 #if defined(OS_CHROMEOS)
512 // On ChromeOS, we need to sign out the user session to fix an auth error, so 514 // On ChromeOS, we need to sign out the user session to fix an auth error, so
513 // the user goes through the real signin flow to generate a new auth token. 515 // the user goes through the real signin flow to generate a new auth token.
514 void PeopleHandler::HandleAttemptUserExit(const base::ListValue* args) { 516 void PeopleHandler::HandleAttemptUserExit(const base::ListValue* args) {
515 DVLOG(1) << "Signing out the user to fix a sync error."; 517 DVLOG(1) << "Signing out the user to fix a sync error.";
516 chrome::AttemptUserExit(); 518 chrome::AttemptUserExit();
517 } 519 }
518 #endif 520 #endif
519 521
520 #if !defined(OS_CHROMEOS) 522 #if !defined(OS_CHROMEOS)
521 void PeopleHandler::HandleStartSignin(const base::ListValue* args) { 523 void PeopleHandler::HandleStartSignin(const base::ListValue* args) {
522 AllowJavascript(); 524 AllowJavascript();
523 525
524 // Should only be called if the user is not already signed in. 526 // Should only be called if the user is not already signed in or has an auth
525 DCHECK(!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated()); 527 // error.
526 bool creating_supervised_user = false; 528 DCHECK(!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated() ||
527 args->GetBoolean(0, &creating_supervised_user); 529 SigninErrorControllerFactory::GetForProfile(profile_)->HasError());
528 OpenSyncSetup(creating_supervised_user); 530
531 OpenSyncSetup();
529 } 532 }
530 533
531 void PeopleHandler::HandleStopSyncing(const base::ListValue* args) { 534 void PeopleHandler::HandleStopSyncing(const base::ListValue* args) {
532 bool delete_profile = false; 535 bool delete_profile = false;
533 args->GetBoolean(0, &delete_profile); 536 args->GetBoolean(0, &delete_profile);
534 537
535 if (!SigninManagerFactory::GetForProfile(profile_)->IsSignoutProhibited()) { 538 if (!SigninManagerFactory::GetForProfile(profile_)->IsSignoutProhibited()) {
536 if (GetSyncService()) 539 if (GetSyncService())
537 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); 540 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
538 541
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 } 619 }
617 620
618 // Alert the sync service anytime the sync setup dialog is closed. This can 621 // Alert the sync service anytime the sync setup dialog is closed. This can
619 // happen due to the user clicking the OK or Cancel button, or due to the 622 // happen due to the user clicking the OK or Cancel button, or due to the
620 // dialog being closed by virtue of sync being disabled in the background. 623 // dialog being closed by virtue of sync being disabled in the background.
621 sync_blocker_.reset(); 624 sync_blocker_.reset();
622 625
623 configuring_sync_ = false; 626 configuring_sync_ = false;
624 } 627 }
625 628
626 void PeopleHandler::OpenSyncSetup(bool creating_supervised_user) { 629 void PeopleHandler::OpenSyncSetup() {
627 // Notify services that login UI is now active. 630 // Notify services that login UI is now active.
628 GetLoginUIService()->SetLoginUI(this); 631 GetLoginUIService()->SetLoginUI(this);
629 632
630 ProfileSyncService* service = GetSyncService(); 633 ProfileSyncService* service = GetSyncService();
631 if (service) 634 if (service)
632 sync_blocker_ = service->GetSetupInProgressHandle(); 635 sync_blocker_ = service->GetSetupInProgressHandle();
633 636
634 // There are several different UI flows that can bring the user here: 637 // There are several different UI flows that can bring the user here:
635 // 1) Signin promo. 638 // 1) Signin promo.
636 // 2) Normal signin through settings page (IsAuthenticated() is false). 639 // 2) Normal signin through settings page (IsAuthenticated() is false).
637 // 3) Previously working credentials have expired. 640 // 3) Previously working credentials have expired.
638 // 4) User is signed in, but has stopped sync via the google dashboard, and 641 // 4) User is signed in, but has stopped sync via the google dashboard, and
639 // signout is prohibited by policy so we need to force a re-auth. 642 // signout is prohibited by policy so we need to force a re-auth.
640 // 5) User clicks [Advanced Settings] button on options page while already 643 // 5) User clicks [Advanced Settings] button on options page while already
641 // logged in. 644 // logged in.
642 // 6) One-click signin (credentials are already available, so should display 645 // 6) One-click signin (credentials are already available, so should display
643 // sync configure UI, not login UI). 646 // sync configure UI, not login UI).
644 // 7) User re-enables sync after disabling it via advanced settings. 647 // 7) User re-enables sync after disabling it via advanced settings.
645 #if !defined(OS_CHROMEOS) 648 #if !defined(OS_CHROMEOS)
646 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile_); 649 if (!SigninManagerFactory::GetForProfile(profile_)->IsAuthenticated() ||
647 if (!signin->IsAuthenticated() ||
648 SigninErrorControllerFactory::GetForProfile(profile_)->HasError()) { 650 SigninErrorControllerFactory::GetForProfile(profile_)->HasError()) {
649 // User is not logged in (cases 1-2), or login has been specially requested 651 // User is not logged in (cases 1-2), or login has been specially requested
650 // because previously working credentials have expired (case 3). Close sync 652 // because previously working credentials have expired (case 3). Close sync
651 // setup including any visible overlays, and display the gaia auth page. 653 // setup including any visible overlays, and display the gaia auth page.
652 // Control will be returned to the sync settings page once auth is complete. 654 // Control will be returned to the sync settings page once auth is complete.
653 CloseUI(); 655 CloseUI();
654 DisplayGaiaLogin( 656 DisplayGaiaLogin(signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS);
655 creating_supervised_user ?
656 signin_metrics::AccessPoint::ACCESS_POINT_SUPERVISED_USER :
657 signin_metrics::AccessPoint::ACCESS_POINT_SETTINGS);
658 return; 657 return;
659 } 658 }
660 #endif 659 #endif
661 if (!service) { 660 if (!service) {
662 // This can happen if the user directly navigates to /settings/syncSetup. 661 // This can happen if the user directly navigates to /settings/syncSetup.
663 DLOG(WARNING) << "Cannot display sync UI when sync is disabled"; 662 DLOG(WARNING) << "Cannot display sync UI when sync is disabled";
664 CloseUI(); 663 CloseUI();
665 return; 664 return;
666 } 665 }
667 666
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 base::FilePath profile_file_path = profile_->GetPath(); 912 base::FilePath profile_file_path = profile_->GetPath();
914 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); 913 ProfileMetrics::LogProfileSyncSignIn(profile_file_path);
915 914
916 // We're done configuring, so notify ProfileSyncService that it is OK to 915 // We're done configuring, so notify ProfileSyncService that it is OK to
917 // start syncing. 916 // start syncing.
918 sync_blocker_.reset(); 917 sync_blocker_.reset();
919 service->SetFirstSetupComplete(); 918 service->SetFirstSetupComplete();
920 } 919 }
921 920
922 } // namespace settings 921 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/people_handler.h ('k') | chrome/browser/ui/webui/settings/people_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698