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

Unified Diff: chrome/browser/ui/webui/sync_setup_handler.cc

Issue 14691004: [sync] Separate sign in from sync on Desktop Chrome (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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/sync_setup_handler.cc
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
index dffb73940cebbb809bbd940a8f6b9da36ce90b6a..dd2328ebd39d7ae01188a2f5908863552b751f8f 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -65,6 +65,7 @@ struct SyncConfigInfo {
bool encrypt_all;
bool sync_everything;
+ bool sync_nothing;
syncer::ModelTypeSet data_types;
std::string passphrase;
bool passphrase_is_gaia;
@@ -73,6 +74,7 @@ struct SyncConfigInfo {
SyncConfigInfo::SyncConfigInfo()
: encrypt_all(false),
sync_everything(false),
+ sync_nothing(false),
passphrase_is_gaia(false) {
}
@@ -145,6 +147,11 @@ bool GetConfiguration(const std::string& json, SyncConfigInfo* config) {
return false;
}
+ if (!result->GetBoolean("syncNothing", &config->sync_nothing)) {
+ DLOG(ERROR) << "GetConfiguration() not passed a syncNothing value";
+ return false;
+ }
+
ModelTypeNameMap type_names = GetSelectableTypeNameMap();
for (ModelTypeNameMap::const_iterator it = type_names.begin();
@@ -356,6 +363,7 @@ void SyncSetupHandler::GetStaticLocalizedValues(
{ "getOtpURL", IDS_SYNC_GET_OTP_URL },
{ "syncAllDataTypes", IDS_SYNC_EVERYTHING },
{ "chooseDataTypes", IDS_SYNC_CHOOSE_DATATYPES },
+ { "syncNothing", IDS_SYNC_NOTHING },
{ "bookmarks", IDS_SYNC_DATATYPE_BOOKMARKS },
{ "preferences", IDS_SYNC_DATATYPE_PREFERENCES },
{ "autofill", IDS_SYNC_DATATYPE_AUTOFILL },
@@ -441,6 +449,7 @@ void SyncSetupHandler::DisplayConfigureSync(bool show_advanced,
// Setup args for the sync configure screen:
// showSyncEverythingPage: false to skip directly to the configure screen
// syncAllDataTypes: true if the user wants to sync everything
+ // syncNothing: true if the user wants to sync nothing
// <data_type>Registered: true if the associated data type is supported
// <data_type>Synced: true if the user wants to sync that specific data type
// encryptionEnabled: true if sync supports encryption
@@ -468,6 +477,7 @@ void SyncSetupHandler::DisplayConfigureSync(bool show_advanced,
args.SetBoolean("passphraseFailed", passphrase_failed);
args.SetBoolean("showSyncEverythingPage", !show_advanced);
args.SetBoolean("syncAllDataTypes", sync_prefs.HasKeepEverythingSynced());
+ args.SetBoolean("syncNothing", false); // Always false during initial setup.
args.SetBoolean("encryptAllData", service->EncryptEverythingEnabled());
// We call IsPassphraseRequired() here, instead of calling
@@ -558,6 +568,7 @@ void SyncSetupHandler::ConfigureSyncDone() {
// We're done configuring, so notify ProfileSyncService that it is OK to
// start syncing.
+ service->SetSetupInProgress(false);
service->SetSyncSetupCompleted();
}
}
@@ -892,19 +903,22 @@ void SyncSetupHandler::SigninFailed(const GoogleServiceAuthError& error) {
last_signin_error_ = error;
- // If using web-based sign in flow, don't show the gaia sign in page again
- // since there is no way to show the user an error message.
- if (SyncPromoUI::UseWebBasedSigninFlow()) {
- CloseSyncSetup();
- } else if (retry_on_signin_failure_) {
- // Got a failed signin - this is either just a typical auth error, or a
- // sync error (treat sync errors as "fatal errors" - i.e. non-auth errors).
- // On ChromeOS, this condition can happen when auth token is invalid and
- // cannot start sync backend.
- // If using web-based sign in flow, don't show the gaia sign in page again
- // since there is no way to show the user an error message.
+ if (retry_on_signin_failure_ ||
+ error.state() == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) {
+ // We can get here under two scenarios:
+ // 1) We got a failed signin. This is either just a typical auth error, or a
+ // sync error (we treat sync errors as "fatal errors" - i.e. non-auth
+ // errors). On ChromeOS, this condition can happen when auth token is
+ // invalid and cannot start the sync backend.
+ // 2) The user receives an auth error while re-enabling sync after having
+ // chosen to "Sync nothing", and the gaia password has been changed since
+ // the user last signed in.
ProfileSyncService* service = GetSyncService();
DisplayGaiaLogin(service && service->HasUnrecoverableError());
+ } else if (SyncPromoUI::UseWebBasedSigninFlow()) {
+ // If using web-based sign in flow, don't show the gaia sign in page again
+ // since there is no way to show the user an error message.
+ CloseSyncSetup();
} else {
// TODO(peria): Show error dialog for prompting sign in and out on
// Chrome OS. http://crbug.com/128692
@@ -967,6 +981,16 @@ void SyncSetupHandler::HandleConfigure(const ListValue* args) {
return;
}
+ // Disable sync, but remain signed in if the user selected "Sync nothing" in
+ // the advanced settings dialog.
+ if (configuration.sync_nothing) {
+ ProfileSyncService::SyncEvent(
+ ProfileSyncService::STOP_FROM_ADVANCED_DIALOG);
+ service->DisableForUser();
+ CloseOverlay();
+ return;
+ }
+
// Note: Data encryption will not occur until configuration is complete
// (when the PSS receives its CONFIGURE_DONE notification from the sync
// backend), so the user still has a chance to cancel out of the operation
@@ -1124,33 +1148,10 @@ void SyncSetupHandler::CloseSyncSetup() {
}
if (sync_service) {
- // Make sure user isn't left half-logged-in (signed in, but without sync
- // started up). If the user hasn't finished setting up sync, then sign out
- // and shut down sync.
if (!sync_service->HasSyncSetupCompleted()) {
- DVLOG(1) << "Signin aborted by user action";
- // We can get here on Chrome OS (e.g dashboard clear), but "do nothing"
- // is the correct behavior.
-#if !defined(OS_CHROMEOS)
- if (signin_tracker_.get() || sync_service->FirstSetupInProgress()) {
- // User was still in the process of signing in, so sign him out again.
- // This makes sure that the user isn't left signed in but with sync
- // un-configured.
- //
- // This has the side-effect of signing out the user in the following
- // scenario:
- // * User signs in while sync is disabled by policy.
- // * Sync is re-enabled by policy.
- // * User brings up sync setup dialog to do initial sync config.
- // * User cancels out of the dialog.
- //
- // This case is indistinguishable from the "one click signin" case where
- // the user checks the "advanced setup" checkbox, then cancels out of
- // the setup box, which is a much more common scenario, so we do the
- // right thing for the one-click case.
- SigninManagerFactory::GetForProfile(GetProfile())->SignOut();
- }
-#endif
+ // If the user clicks "Cancel" while setting up sync, we don't want the
+ // sync backend to remain in the initialized state.
+ DVLOG(1) << "Sync setup aborted by user action";
sync_service->DisableForUser();
browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs());
sync_prefs.SetStartSuppressed(true);
@@ -1186,13 +1187,10 @@ void SyncSetupHandler::OpenSyncSetup() {
// logged in.
// 6) One-click signin (credentials are already available, so should display
// sync configure UI, not login UI).
- // 7) ChromeOS re-enable after disabling sync.
+ // 7) User re-enables sync after disabling it via advanced settings.
SigninManagerBase* signin =
SigninManagerFactory::GetForProfile(GetProfile());
if (signin->GetAuthenticatedUsername().empty() ||
-#if !defined(OS_CHROMEOS)
- (GetSyncService() && GetSyncService()->IsStartSuppressed()) ||
-#endif
signin->signin_global_error()->HasMenuItem()) {
// User is not logged in, or login has been specially requested - need to
// display login UI (cases 1-3).
@@ -1207,7 +1205,7 @@ void SyncSetupHandler::OpenSyncSetup() {
// User is already logged in. They must have brought up the config wizard
// via the "Advanced..." button or through One-Click signin (cases 4-6), or
- // they are re-enabling sync on Chrome OS.
+ // they are re-enabling sync after having disabled it (case 7).
DisplayConfigureSync(true, false);
}

Powered by Google App Engine
This is Rietveld 408576698