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

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

Issue 14630003: signin: move SigninManagerBase::Signout to SigninManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
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 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 void SyncSetupHandler::HandleStartSignin(const ListValue* args) { 1083 void SyncSetupHandler::HandleStartSignin(const ListValue* args) {
1084 // Should only be called if the user is not already signed in. 1084 // Should only be called if the user is not already signed in.
1085 DCHECK(SigninManagerFactory::GetForProfile(GetProfile())-> 1085 DCHECK(SigninManagerFactory::GetForProfile(GetProfile())->
1086 GetAuthenticatedUsername().empty()); 1086 GetAuthenticatedUsername().empty());
1087 OpenSyncSetup(); 1087 OpenSyncSetup();
1088 } 1088 }
1089 1089
1090 void SyncSetupHandler::HandleStopSyncing(const ListValue* args) { 1090 void SyncSetupHandler::HandleStopSyncing(const ListValue* args) {
1091 if (GetSyncService()) 1091 if (GetSyncService())
1092 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS); 1092 ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
1093 1093 #if !defined(OS_CHROMEOS)
1094 SigninManagerFactory::GetForProfile(GetProfile())->SignOut(); 1094 SigninManagerFactory::GetForProfile(GetProfile())->SignOut();
1095 #endif
1095 } 1096 }
1096 1097
1097 void SyncSetupHandler::HandleCloseTimeout(const ListValue* args) { 1098 void SyncSetupHandler::HandleCloseTimeout(const ListValue* args) {
1098 CloseSyncSetup(); 1099 CloseSyncSetup();
1099 } 1100 }
1100 1101
1101 void SyncSetupHandler::CloseSyncSetup() { 1102 void SyncSetupHandler::CloseSyncSetup() {
1102 // TODO(atwilson): Move UMA tracking of signin events out of sync module. 1103 // TODO(atwilson): Move UMA tracking of signin events out of sync module.
1103 ProfileSyncService* sync_service = GetSyncService(); 1104 ProfileSyncService* sync_service = GetSyncService();
1104 if (IsActiveLogin()) { 1105 if (IsActiveLogin()) {
(...skipping 16 matching lines...) Expand all
1121 1122
1122 GetLoginUIService()->LoginUIClosed(this); 1123 GetLoginUIService()->LoginUIClosed(this);
1123 } 1124 }
1124 1125
1125 if (sync_service) { 1126 if (sync_service) {
1126 // Make sure user isn't left half-logged-in (signed in, but without sync 1127 // Make sure user isn't left half-logged-in (signed in, but without sync
1127 // started up). If the user hasn't finished setting up sync, then sign out 1128 // started up). If the user hasn't finished setting up sync, then sign out
1128 // and shut down sync. 1129 // and shut down sync.
1129 if (!sync_service->HasSyncSetupCompleted()) { 1130 if (!sync_service->HasSyncSetupCompleted()) {
1130 DVLOG(1) << "Signin aborted by user action"; 1131 DVLOG(1) << "Signin aborted by user action";
1132 #if !defined(OS_CHROMEOS)
1133 // TODO(tim): Is this path even reachable on Chrome OS?
Andrew T Wilson (Slow) 2013/05/06 09:06:00 Possibly - the way I'd guess is: 1) User does das
tim (not reviewing) 2013/05/06 17:28:57 Done.
1131 if (signin_tracker_.get() || sync_service->FirstSetupInProgress()) { 1134 if (signin_tracker_.get() || sync_service->FirstSetupInProgress()) {
1132 // User was still in the process of signing in, so sign him out again. 1135 // User was still in the process of signing in, so sign him out again.
1133 // This makes sure that the user isn't left signed in but with sync 1136 // This makes sure that the user isn't left signed in but with sync
1134 // un-configured. 1137 // un-configured.
1135 // 1138 //
1136 // This has the side-effect of signing out the user in the following 1139 // This has the side-effect of signing out the user in the following
1137 // scenario: 1140 // scenario:
1138 // * User signs in while sync is disabled by policy. 1141 // * User signs in while sync is disabled by policy.
1139 // * Sync is re-enabled by policy. 1142 // * Sync is re-enabled by policy.
1140 // * User brings up sync setup dialog to do initial sync config. 1143 // * User brings up sync setup dialog to do initial sync config.
1141 // * User cancels out of the dialog. 1144 // * User cancels out of the dialog.
1142 // 1145 //
1143 // This case is indistinguishable from the "one click signin" case where 1146 // This case is indistinguishable from the "one click signin" case where
1144 // the user checks the "advanced setup" checkbox, then cancels out of 1147 // the user checks the "advanced setup" checkbox, then cancels out of
1145 // the setup box, which is a much more common scenario, so we do the 1148 // the setup box, which is a much more common scenario, so we do the
1146 // right thing for the one-click case. 1149 // right thing for the one-click case.
1147 SigninManagerFactory::GetForProfile(GetProfile())->SignOut(); 1150 SigninManagerFactory::GetForProfile(GetProfile())->SignOut();
1148 } 1151 }
1152 #endif
1149 sync_service->DisableForUser(); 1153 sync_service->DisableForUser();
1150 browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); 1154 browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs());
1151 sync_prefs.SetStartSuppressed(true); 1155 sync_prefs.SetStartSuppressed(true);
1152 } 1156 }
1153 sync_service->SetSetupInProgress(false); 1157 sync_service->SetSetupInProgress(false);
1154 } 1158 }
1155 1159
1156 // Reset the attempted email address and error, otherwise the sync setup 1160 // Reset the attempted email address and error, otherwise the sync setup
1157 // overlay in the settings page will stay in whatever error state it was last 1161 // overlay in the settings page will stay in whatever error state it was last
1158 // when it is reopened. 1162 // when it is reopened.
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 // closing this tab in mid-handler can cause crashes. Instead, close it 1307 // closing this tab in mid-handler can cause crashes. Instead, close it
1304 // via a task so we know we aren't in the middle of any webui code. 1308 // via a task so we know we aren't in the middle of any webui code.
1305 MessageLoop::current()->PostTask( 1309 MessageLoop::current()->PostTask(
1306 FROM_HERE, 1310 FROM_HERE,
1307 base::Bind(&CloseTab, base::Unretained(active_gaia_signin_tab_))); 1311 base::Bind(&CloseTab, base::Unretained(active_gaia_signin_tab_)));
1308 1312
1309 active_gaia_signin_tab_ = NULL; 1313 active_gaia_signin_tab_ = NULL;
1310 } 1314 }
1311 } 1315 }
1312 1316
1317 #if !defined(OS_CHROMEOS)
1318 // Used by HandleSubmitAuth.
1313 bool SyncSetupHandler::IsLoginAuthDataValid(const std::string& username, 1319 bool SyncSetupHandler::IsLoginAuthDataValid(const std::string& username,
1314 string16* error_message) { 1320 string16* error_message) {
1315 if (username.empty()) 1321 if (username.empty())
1316 return true; 1322 return true;
1317 1323
1318 // Can be null during some unit tests. 1324 // Can be null during some unit tests.
1319 if (!web_ui()) 1325 if (!web_ui())
1320 return true; 1326 return true;
1321 1327
1322 if (!SigninManagerFactory::GetForProfile( 1328 if (!SigninManagerFactory::GetForProfile(
(...skipping 16 matching lines...) Expand all
1339 if (i != current_profile_index && AreUserNamesEqual( 1345 if (i != current_profile_index && AreUserNamesEqual(
1340 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { 1346 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) {
1341 *error_message = l10n_util::GetStringUTF16( 1347 *error_message = l10n_util::GetStringUTF16(
1342 IDS_SYNC_USER_NAME_IN_USE_ERROR); 1348 IDS_SYNC_USER_NAME_IN_USE_ERROR);
1343 return false; 1349 return false;
1344 } 1350 }
1345 } 1351 }
1346 1352
1347 return true; 1353 return true;
1348 } 1354 }
1355
1356 #endif // !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698