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

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

Issue 23005016: [sync] Force re-auth during sync setup if Oauth2 token is unavailable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/sync_setup_handler.h" 5 #include "chrome/browser/ui/webui/sync_setup_handler.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 void SyncSetupHandler::OpenSyncSetup() { 837 void SyncSetupHandler::OpenSyncSetup() {
838 if (!PrepareSyncSetup()) 838 if (!PrepareSyncSetup())
839 return; 839 return;
840 840
841 // There are several different UI flows that can bring the user here: 841 // There are several different UI flows that can bring the user here:
842 // 1) Signin promo. 842 // 1) Signin promo.
843 // 2) Normal signin through settings page (GetAuthenticatedUsername() is 843 // 2) Normal signin through settings page (GetAuthenticatedUsername() is
844 // empty). 844 // empty).
845 // 3) Previously working credentials have expired. 845 // 3) Previously working credentials have expired.
846 // 4) User is signed in, but has stopped sync via the google dashboard, and 846 // 4) User is signed in, but has stopped sync via the google dashboard, and
847 // signout is prohibited by policy so we need to force a re-auth. 847 // signout is prohibited by policy so we need to force a re-auth to update
848 // ProfileSyncService's auth token.
848 // 5) User clicks [Advanced Settings] button on options page while already 849 // 5) User clicks [Advanced Settings] button on options page while already
849 // logged in. 850 // logged in.
850 // 6) One-click signin (credentials are already available, so should display 851 // 6) One-click signin (credentials are already available, so should display
851 // sync configure UI, not login UI). 852 // sync configure UI, not login UI).
852 // 7) User re-enables sync after disabling it via advanced settings. 853 // 7) User re-enables sync after disabling it via advanced settings.
853 #if !defined(OS_CHROMEOS) 854 #if !defined(OS_CHROMEOS)
854 SigninManagerBase* signin = 855 SigninManagerBase* signin =
855 SigninManagerFactory::GetForProfile(GetProfile()); 856 SigninManagerFactory::GetForProfile(GetProfile());
856 857 ProfileSyncService* service = GetSyncService();
857 if (signin->GetAuthenticatedUsername().empty() || 858 if (signin->GetAuthenticatedUsername().empty() ||
858 SigninGlobalError::GetForProfile(GetProfile())->HasMenuItem()) { 859 SigninGlobalError::GetForProfile(GetProfile())->HasMenuItem() ||
860 (service && !service->IsOAuthRefreshTokenAvailable())) {
Andrew T Wilson (Slow) 2013/08/21 08:30:46 I think this probably isn't the right way to do th
Raghu Simha 2013/08/22 00:05:12 Agreed. I've sent out a new CL with a different ap
859 // User is not logged in (cases 1-2), or login has been specially requested 861 // User is not logged in (cases 1-2), or login has been specially requested
860 // because previously working credentials have expired (case 3). Close sync 862 // because previously working credentials have expired (case 3), or sync
861 // setup including any visible overlays, and display the gaia auth page. 863 // no longer has a valid auth token (case 4). Close sync setup including any
862 // Control will be returned to the sync settings page once auth is complete. 864 // visible overlays, and display the gaia auth page. Control will be
865 // returned to the sync settings page once auth is complete.
863 CloseSyncSetup(); 866 CloseSyncSetup();
864 DisplayGaiaLogin(); 867 DisplayGaiaLogin();
865 return; 868 return;
866 } 869 }
867 #endif 870 #endif
868 if (!GetSyncService()) { 871 if (!GetSyncService()) {
869 // This can happen if the user directly navigates to /settings/syncSetup. 872 // This can happen if the user directly navigates to /settings/syncSetup.
870 DLOG(WARNING) << "Cannot display sync UI when sync is disabled"; 873 DLOG(WARNING) << "Cannot display sync UI when sync is disabled";
871 CloseSyncSetup(); 874 CloseSyncSetup();
872 return; 875 return;
873 } 876 }
874 877
875 // User is already logged in. They must have brought up the config wizard 878 // User is already logged in. They must have brought up the config wizard
876 // via the "Advanced..." button or through One-Click signin (cases 4-6), or 879 // via the "Advanced..." button or through One-Click signin (cases 5-6), or
877 // they are re-enabling sync after having disabled it (case 7). 880 // they are re-enabling sync after having disabled it (case 7).
878 DisplayConfigureSync(true, false); 881 DisplayConfigureSync(true, false);
879 } 882 }
880 883
881 void SyncSetupHandler::OpenConfigureSync() { 884 void SyncSetupHandler::OpenConfigureSync() {
882 if (!PrepareSyncSetup()) 885 if (!PrepareSyncSetup())
883 return; 886 return;
884 887
885 DisplayConfigureSync(true, false); 888 DisplayConfigureSync(true, false);
886 } 889 }
(...skipping 21 matching lines...) Expand all
908 911
909 LoginUIService* service = GetLoginUIService(); 912 LoginUIService* service = GetLoginUIService();
910 DCHECK(service); 913 DCHECK(service);
911 service->current_login_ui()->FocusUI(); 914 service->current_login_ui()->FocusUI();
912 return true; 915 return true;
913 } 916 }
914 917
915 LoginUIService* SyncSetupHandler::GetLoginUIService() const { 918 LoginUIService* SyncSetupHandler::GetLoginUIService() const {
916 return LoginUIServiceFactory::GetForProfile(GetProfile()); 919 return LoginUIServiceFactory::GetForProfile(GetProfile());
917 } 920 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698