OLD | NEW |
---|---|
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 | 58 |
59 namespace { | 59 namespace { |
60 | 60 |
61 // A structure which contains all the configuration information for sync. | 61 // A structure which contains all the configuration information for sync. |
62 struct SyncConfigInfo { | 62 struct SyncConfigInfo { |
63 SyncConfigInfo(); | 63 SyncConfigInfo(); |
64 ~SyncConfigInfo(); | 64 ~SyncConfigInfo(); |
65 | 65 |
66 bool encrypt_all; | 66 bool encrypt_all; |
67 bool sync_everything; | 67 bool sync_everything; |
68 bool sync_nothing; | |
68 syncer::ModelTypeSet data_types; | 69 syncer::ModelTypeSet data_types; |
69 std::string passphrase; | 70 std::string passphrase; |
70 bool passphrase_is_gaia; | 71 bool passphrase_is_gaia; |
71 }; | 72 }; |
72 | 73 |
73 SyncConfigInfo::SyncConfigInfo() | 74 SyncConfigInfo::SyncConfigInfo() |
74 : encrypt_all(false), | 75 : encrypt_all(false), |
75 sync_everything(false), | 76 sync_everything(false), |
77 sync_nothing(false), | |
76 passphrase_is_gaia(false) { | 78 passphrase_is_gaia(false) { |
77 } | 79 } |
78 | 80 |
79 SyncConfigInfo::~SyncConfigInfo() {} | 81 SyncConfigInfo::~SyncConfigInfo() {} |
80 | 82 |
81 // Note: The order of these types must match the ordering of | 83 // Note: The order of these types must match the ordering of |
82 // the respective types in ModelType | 84 // the respective types in ModelType |
83 const char* kDataTypeNames[] = { | 85 const char* kDataTypeNames[] = { |
84 "bookmarks", | 86 "bookmarks", |
85 "preferences", | 87 "preferences", |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 if (!parsed_value.get() || !parsed_value->GetAsDictionary(&result)) { | 140 if (!parsed_value.get() || !parsed_value->GetAsDictionary(&result)) { |
139 DLOG(ERROR) << "GetConfiguration() not passed a Dictionary"; | 141 DLOG(ERROR) << "GetConfiguration() not passed a Dictionary"; |
140 return false; | 142 return false; |
141 } | 143 } |
142 | 144 |
143 if (!result->GetBoolean("syncAllDataTypes", &config->sync_everything)) { | 145 if (!result->GetBoolean("syncAllDataTypes", &config->sync_everything)) { |
144 DLOG(ERROR) << "GetConfiguration() not passed a syncAllDataTypes value"; | 146 DLOG(ERROR) << "GetConfiguration() not passed a syncAllDataTypes value"; |
145 return false; | 147 return false; |
146 } | 148 } |
147 | 149 |
150 if (!result->GetBoolean("syncNothing", &config->sync_nothing)) { | |
151 DLOG(ERROR) << "GetConfiguration() not passed a syncNothing value"; | |
152 return false; | |
153 } | |
154 | |
Andrew T Wilson (Slow)
2013/05/15 15:01:24
Add a DCHECK(!(sync_nothing && sync_everything)) s
Raghu Simha
2013/05/16 02:13:20
Done.
| |
148 ModelTypeNameMap type_names = GetSelectableTypeNameMap(); | 155 ModelTypeNameMap type_names = GetSelectableTypeNameMap(); |
149 | 156 |
150 for (ModelTypeNameMap::const_iterator it = type_names.begin(); | 157 for (ModelTypeNameMap::const_iterator it = type_names.begin(); |
151 it != type_names.end(); ++it) { | 158 it != type_names.end(); ++it) { |
152 std::string key_name = it->second + std::string("Synced"); | 159 std::string key_name = it->second + std::string("Synced"); |
153 bool sync_value; | 160 bool sync_value; |
154 if (!result->GetBoolean(key_name, &sync_value)) { | 161 if (!result->GetBoolean(key_name, &sync_value)) { |
155 DLOG(ERROR) << "GetConfiguration() not passed a value for " << key_name; | 162 DLOG(ERROR) << "GetConfiguration() not passed a value for " << key_name; |
156 return false; | 163 return false; |
157 } | 164 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 { "invalidAccessCode", IDS_SYNC_INVALID_ACCESS_CODE_LABEL }, | 356 { "invalidAccessCode", IDS_SYNC_INVALID_ACCESS_CODE_LABEL }, |
350 { "enterAccessCode", IDS_SYNC_ENTER_ACCESS_CODE_LABEL }, | 357 { "enterAccessCode", IDS_SYNC_ENTER_ACCESS_CODE_LABEL }, |
351 { "getAccessCodeHelp", IDS_SYNC_ACCESS_CODE_HELP_LABEL }, | 358 { "getAccessCodeHelp", IDS_SYNC_ACCESS_CODE_HELP_LABEL }, |
352 { "getAccessCodeURL", IDS_SYNC_GET_ACCESS_CODE_URL }, | 359 { "getAccessCodeURL", IDS_SYNC_GET_ACCESS_CODE_URL }, |
353 { "invalidOtp", IDS_SYNC_INVALID_OTP_LABEL }, | 360 { "invalidOtp", IDS_SYNC_INVALID_OTP_LABEL }, |
354 { "enterOtp", IDS_SYNC_ENTER_OTP_LABEL }, | 361 { "enterOtp", IDS_SYNC_ENTER_OTP_LABEL }, |
355 { "getOtpHelp", IDS_SYNC_OTP_HELP_LABEL }, | 362 { "getOtpHelp", IDS_SYNC_OTP_HELP_LABEL }, |
356 { "getOtpURL", IDS_SYNC_GET_OTP_URL }, | 363 { "getOtpURL", IDS_SYNC_GET_OTP_URL }, |
357 { "syncAllDataTypes", IDS_SYNC_EVERYTHING }, | 364 { "syncAllDataTypes", IDS_SYNC_EVERYTHING }, |
358 { "chooseDataTypes", IDS_SYNC_CHOOSE_DATATYPES }, | 365 { "chooseDataTypes", IDS_SYNC_CHOOSE_DATATYPES }, |
366 { "syncNothing", IDS_SYNC_NOTHING }, | |
359 { "bookmarks", IDS_SYNC_DATATYPE_BOOKMARKS }, | 367 { "bookmarks", IDS_SYNC_DATATYPE_BOOKMARKS }, |
360 { "preferences", IDS_SYNC_DATATYPE_PREFERENCES }, | 368 { "preferences", IDS_SYNC_DATATYPE_PREFERENCES }, |
361 { "autofill", IDS_SYNC_DATATYPE_AUTOFILL }, | 369 { "autofill", IDS_SYNC_DATATYPE_AUTOFILL }, |
362 { "themes", IDS_SYNC_DATATYPE_THEMES }, | 370 { "themes", IDS_SYNC_DATATYPE_THEMES }, |
363 { "passwords", IDS_SYNC_DATATYPE_PASSWORDS }, | 371 { "passwords", IDS_SYNC_DATATYPE_PASSWORDS }, |
364 { "extensions", IDS_SYNC_DATATYPE_EXTENSIONS }, | 372 { "extensions", IDS_SYNC_DATATYPE_EXTENSIONS }, |
365 { "typedURLs", IDS_SYNC_DATATYPE_TYPED_URLS }, | 373 { "typedURLs", IDS_SYNC_DATATYPE_TYPED_URLS }, |
366 { "apps", IDS_SYNC_DATATYPE_APPS }, | 374 { "apps", IDS_SYNC_DATATYPE_APPS }, |
367 { "openTabs", IDS_SYNC_DATATYPE_TABS }, | 375 { "openTabs", IDS_SYNC_DATATYPE_TABS }, |
368 { "syncZeroDataTypesError", IDS_SYNC_ZERO_DATA_TYPES_ERROR }, | 376 { "syncZeroDataTypesError", IDS_SYNC_ZERO_DATA_TYPES_ERROR }, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
434 // Should only be called if user is signed in, so no longer need our | 442 // Should only be called if user is signed in, so no longer need our |
435 // SigninTracker. | 443 // SigninTracker. |
436 signin_tracker_.reset(); | 444 signin_tracker_.reset(); |
437 configuring_sync_ = true; | 445 configuring_sync_ = true; |
438 DCHECK(service->sync_initialized()) << | 446 DCHECK(service->sync_initialized()) << |
439 "Cannot configure sync until the sync backend is initialized"; | 447 "Cannot configure sync until the sync backend is initialized"; |
440 | 448 |
441 // Setup args for the sync configure screen: | 449 // Setup args for the sync configure screen: |
442 // showSyncEverythingPage: false to skip directly to the configure screen | 450 // showSyncEverythingPage: false to skip directly to the configure screen |
443 // syncAllDataTypes: true if the user wants to sync everything | 451 // syncAllDataTypes: true if the user wants to sync everything |
452 // syncNothing: true if the user wants to sync nothing | |
444 // <data_type>Registered: true if the associated data type is supported | 453 // <data_type>Registered: true if the associated data type is supported |
445 // <data_type>Synced: true if the user wants to sync that specific data type | 454 // <data_type>Synced: true if the user wants to sync that specific data type |
446 // encryptionEnabled: true if sync supports encryption | 455 // encryptionEnabled: true if sync supports encryption |
447 // encryptAllData: true if user wants to encrypt all data (not just | 456 // encryptAllData: true if user wants to encrypt all data (not just |
448 // passwords) | 457 // passwords) |
449 // usePassphrase: true if the data is encrypted with a secondary passphrase | 458 // usePassphrase: true if the data is encrypted with a secondary passphrase |
450 // show_passphrase: true if a passphrase is needed to decrypt the sync data | 459 // show_passphrase: true if a passphrase is needed to decrypt the sync data |
451 DictionaryValue args; | 460 DictionaryValue args; |
452 | 461 |
453 // Tell the UI layer which data types are registered/enabled by the user. | 462 // Tell the UI layer which data types are registered/enabled by the user. |
454 const syncer::ModelTypeSet registered_types = | 463 const syncer::ModelTypeSet registered_types = |
455 service->GetRegisteredDataTypes(); | 464 service->GetRegisteredDataTypes(); |
456 const syncer::ModelTypeSet preferred_types = | 465 const syncer::ModelTypeSet preferred_types = |
457 service->GetPreferredDataTypes(); | 466 service->GetPreferredDataTypes(); |
458 ModelTypeNameMap type_names = GetSelectableTypeNameMap(); | 467 ModelTypeNameMap type_names = GetSelectableTypeNameMap(); |
459 for (ModelTypeNameMap::const_iterator it = type_names.begin(); | 468 for (ModelTypeNameMap::const_iterator it = type_names.begin(); |
460 it != type_names.end(); ++it) { | 469 it != type_names.end(); ++it) { |
461 syncer::ModelType sync_type = it->first; | 470 syncer::ModelType sync_type = it->first; |
462 const std::string key_name = it->second; | 471 const std::string key_name = it->second; |
463 args.SetBoolean(key_name + "Registered", | 472 args.SetBoolean(key_name + "Registered", |
464 registered_types.Has(sync_type)); | 473 registered_types.Has(sync_type)); |
465 args.SetBoolean(key_name + "Synced", preferred_types.Has(sync_type)); | 474 args.SetBoolean(key_name + "Synced", preferred_types.Has(sync_type)); |
466 } | 475 } |
467 browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); | 476 browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); |
468 args.SetBoolean("passphraseFailed", passphrase_failed); | 477 args.SetBoolean("passphraseFailed", passphrase_failed); |
469 args.SetBoolean("showSyncEverythingPage", !show_advanced); | 478 args.SetBoolean("showSyncEverythingPage", !show_advanced); |
470 args.SetBoolean("syncAllDataTypes", sync_prefs.HasKeepEverythingSynced()); | 479 args.SetBoolean("syncAllDataTypes", sync_prefs.HasKeepEverythingSynced()); |
480 args.SetBoolean("syncNothing", false); // Always false during initial setup. | |
471 args.SetBoolean("encryptAllData", service->EncryptEverythingEnabled()); | 481 args.SetBoolean("encryptAllData", service->EncryptEverythingEnabled()); |
472 | 482 |
473 // We call IsPassphraseRequired() here, instead of calling | 483 // We call IsPassphraseRequired() here, instead of calling |
474 // IsPassphraseRequiredForDecryption(), because we want to show the passphrase | 484 // IsPassphraseRequiredForDecryption(), because we want to show the passphrase |
475 // UI even if no encrypted data types are enabled. | 485 // UI even if no encrypted data types are enabled. |
476 args.SetBoolean("showPassphrase", service->IsPassphraseRequired()); | 486 args.SetBoolean("showPassphrase", service->IsPassphraseRequired()); |
477 // Keystore encryption is behind a flag. Only show the new encryption settings | 487 // Keystore encryption is behind a flag. Only show the new encryption settings |
478 // if keystore encryption is enabled. | 488 // if keystore encryption is enabled. |
479 args.SetBoolean("keystoreEncryptionEnabled", IsKeystoreEncryptionEnabled()); | 489 args.SetBoolean("keystoreEncryptionEnabled", IsKeystoreEncryptionEnabled()); |
480 | 490 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 | 561 |
552 ProfileSyncService* service = GetSyncService(); | 562 ProfileSyncService* service = GetSyncService(); |
553 DCHECK(service); | 563 DCHECK(service); |
554 if (!service->HasSyncSetupCompleted()) { | 564 if (!service->HasSyncSetupCompleted()) { |
555 // This is the first time configuring sync, so log it. | 565 // This is the first time configuring sync, so log it. |
556 base::FilePath profile_file_path = GetProfile()->GetPath(); | 566 base::FilePath profile_file_path = GetProfile()->GetPath(); |
557 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); | 567 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); |
558 | 568 |
559 // We're done configuring, so notify ProfileSyncService that it is OK to | 569 // We're done configuring, so notify ProfileSyncService that it is OK to |
560 // start syncing. | 570 // start syncing. |
571 service->SetSetupInProgress(false); | |
561 service->SetSyncSetupCompleted(); | 572 service->SetSyncSetupCompleted(); |
562 } | 573 } |
563 } | 574 } |
564 | 575 |
565 bool SyncSetupHandler::IsActiveLogin() const { | 576 bool SyncSetupHandler::IsActiveLogin() const { |
566 // LoginUIService can be NULL if page is brought up in incognito mode | 577 // LoginUIService can be NULL if page is brought up in incognito mode |
567 // (i.e. if the user is running in guest mode in cros and brings up settings). | 578 // (i.e. if the user is running in guest mode in cros and brings up settings). |
568 LoginUIService* service = GetLoginUIService(); | 579 LoginUIService* service = GetLoginUIService(); |
569 return service && (service->current_login_ui() == this); | 580 return service && (service->current_login_ui() == this); |
570 } | 581 } |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
885 // Gaia credentials are valid - update the UI. | 896 // Gaia credentials are valid - update the UI. |
886 DisplayGaiaSuccessAndSettingUp(); | 897 DisplayGaiaSuccessAndSettingUp(); |
887 } | 898 } |
888 | 899 |
889 void SyncSetupHandler::SigninFailed(const GoogleServiceAuthError& error) { | 900 void SyncSetupHandler::SigninFailed(const GoogleServiceAuthError& error) { |
890 // Stop a timer to handle timeout in waiting for checking network connection. | 901 // Stop a timer to handle timeout in waiting for checking network connection. |
891 backend_start_timer_.reset(); | 902 backend_start_timer_.reset(); |
892 | 903 |
893 last_signin_error_ = error; | 904 last_signin_error_ = error; |
894 | 905 |
895 // If using web-based sign in flow, don't show the gaia sign in page again | 906 if (!retry_on_signin_failure_ && |
896 // since there is no way to show the user an error message. | 907 error.state() == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS) { |
Andrew T Wilson (Slow)
2013/05/15 15:01:24
Why would we only do this on INVALID_GAIA_CREDENTI
Raghu Simha
2013/05/16 02:13:20
Good catch. I've added those cases, and we now mat
| |
897 if (SyncPromoUI::UseWebBasedSigninFlow()) { | 908 // The user received an auth error while re-enabling sync after having |
909 // chosen to "Sync nothing", and the gaia password has been changed since | |
910 // the user last signed in. Leave the sync backend initialized, and close | |
911 // the setup dialog. An error message will be shown on the settings page. | |
912 web_ui()->CallJavascriptFunction("OptionsPage.closeOverlay"); | |
913 } else if (SyncPromoUI::UseWebBasedSigninFlow()) { | |
914 // If using web-based sign in flow, don't show the gaia sign in page again | |
915 // since there is no way to show the user an error message. | |
898 CloseSyncSetup(); | 916 CloseSyncSetup(); |
899 } else if (retry_on_signin_failure_) { | 917 } else if (retry_on_signin_failure_) { |
900 // Got a failed signin - this is either just a typical auth error, or a | 918 // Got a failed signin - this is either just a typical auth error, or a |
901 // sync error (treat sync errors as "fatal errors" - i.e. non-auth errors). | 919 // sync error (treat sync errors as "fatal errors" - i.e. non-auth errors). |
902 // On ChromeOS, this condition can happen when auth token is invalid and | 920 // On ChromeOS, this condition can happen when auth token is invalid and |
903 // cannot start sync backend. | 921 // cannot start sync backend. |
904 // If using web-based sign in flow, don't show the gaia sign in page again | |
905 // since there is no way to show the user an error message. | |
906 ProfileSyncService* service = GetSyncService(); | 922 ProfileSyncService* service = GetSyncService(); |
907 DisplayGaiaLogin(service && service->HasUnrecoverableError()); | 923 DisplayGaiaLogin(service && service->HasUnrecoverableError()); |
908 } else { | 924 } else { |
909 // TODO(peria): Show error dialog for prompting sign in and out on | 925 // TODO(peria): Show error dialog for prompting sign in and out on |
910 // Chrome OS. http://crbug.com/128692 | 926 // Chrome OS. http://crbug.com/128692 |
911 CloseOverlay(); | 927 CloseOverlay(); |
912 } | 928 } |
913 } | 929 } |
914 | 930 |
915 Profile* SyncSetupHandler::GetProfile() const { | 931 Profile* SyncSetupHandler::GetProfile() const { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
960 // to us from the JS layer. | 976 // to us from the JS layer. |
961 ProfileSyncService* service = GetSyncService(); | 977 ProfileSyncService* service = GetSyncService(); |
962 | 978 |
963 // If the sync engine has shutdown for some reason, just close the sync | 979 // If the sync engine has shutdown for some reason, just close the sync |
964 // dialog. | 980 // dialog. |
965 if (!service || !service->sync_initialized()) { | 981 if (!service || !service->sync_initialized()) { |
966 CloseOverlay(); | 982 CloseOverlay(); |
967 return; | 983 return; |
968 } | 984 } |
969 | 985 |
986 // Disable sync, but remain signed in if the user selected "Sync nothing" in | |
987 // the advanced settings dialog. | |
988 if (configuration.sync_nothing) { | |
989 ProfileSyncService::SyncEvent( | |
990 ProfileSyncService::STOP_FROM_ADVANCED_DIALOG); | |
991 CloseOverlay(); | |
992 service->DisableForUser(); | |
993 service->SetSetupInProgress(false); | |
994 return; | |
995 } | |
996 | |
970 // Note: Data encryption will not occur until configuration is complete | 997 // Note: Data encryption will not occur until configuration is complete |
971 // (when the PSS receives its CONFIGURE_DONE notification from the sync | 998 // (when the PSS receives its CONFIGURE_DONE notification from the sync |
972 // backend), so the user still has a chance to cancel out of the operation | 999 // backend), so the user still has a chance to cancel out of the operation |
973 // if (for example) some kind of passphrase error is encountered. | 1000 // if (for example) some kind of passphrase error is encountered. |
974 if (configuration.encrypt_all) | 1001 if (configuration.encrypt_all) |
975 service->EnableEncryptEverything(); | 1002 service->EnableEncryptEverything(); |
976 | 1003 |
977 bool passphrase_failed = false; | 1004 bool passphrase_failed = false; |
978 if (!configuration.passphrase.empty()) { | 1005 if (!configuration.passphrase.empty()) { |
979 // We call IsPassphraseRequired() here (instead of | 1006 // We call IsPassphraseRequired() here (instead of |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1095 #endif | 1122 #endif |
1096 } | 1123 } |
1097 | 1124 |
1098 void SyncSetupHandler::HandleCloseTimeout(const ListValue* args) { | 1125 void SyncSetupHandler::HandleCloseTimeout(const ListValue* args) { |
1099 CloseSyncSetup(); | 1126 CloseSyncSetup(); |
1100 } | 1127 } |
1101 | 1128 |
1102 void SyncSetupHandler::CloseSyncSetup() { | 1129 void SyncSetupHandler::CloseSyncSetup() { |
1103 // TODO(atwilson): Move UMA tracking of signin events out of sync module. | 1130 // TODO(atwilson): Move UMA tracking of signin events out of sync module. |
1104 ProfileSyncService* sync_service = GetSyncService(); | 1131 ProfileSyncService* sync_service = GetSyncService(); |
1105 if (IsActiveLogin()) { | 1132 // If there was a sign in error, do not log a cancel event. |
1133 if (IsActiveLogin() && | |
1134 last_signin_error_.state() == GoogleServiceAuthError::NONE) { | |
1106 if (!sync_service || !sync_service->HasSyncSetupCompleted()) { | 1135 if (!sync_service || !sync_service->HasSyncSetupCompleted()) { |
1107 if (signin_tracker_.get()) { | 1136 if (signin_tracker_.get()) { |
1108 ProfileSyncService::SyncEvent( | 1137 ProfileSyncService::SyncEvent( |
1109 ProfileSyncService::CANCEL_DURING_SIGNON); | 1138 ProfileSyncService::CANCEL_DURING_SIGNON); |
1110 } else if (configuring_sync_) { | 1139 } else if (configuring_sync_) { |
1111 ProfileSyncService::SyncEvent( | 1140 ProfileSyncService::SyncEvent( |
1112 ProfileSyncService::CANCEL_DURING_CONFIGURE); | 1141 ProfileSyncService::CANCEL_DURING_CONFIGURE); |
1113 } else { | 1142 } else { |
1114 ProfileSyncService::SyncEvent( | 1143 ProfileSyncService::SyncEvent( |
1115 ProfileSyncService::CANCEL_FROM_SIGNON_WITHOUT_AUTH); | 1144 ProfileSyncService::CANCEL_FROM_SIGNON_WITHOUT_AUTH); |
1116 } | 1145 } |
1117 } | 1146 } |
1118 | 1147 |
1119 // Let the various services know that we're no longer active. | 1148 // Let the various services know that we're no longer active. |
1120 if (SyncPromoUI::UseWebBasedSigninFlow()) | 1149 if (SyncPromoUI::UseWebBasedSigninFlow()) |
1121 CloseGaiaSigninPage(); | 1150 CloseGaiaSigninPage(); |
1122 | 1151 |
1123 GetLoginUIService()->LoginUIClosed(this); | 1152 GetLoginUIService()->LoginUIClosed(this); |
1124 } | 1153 } |
1125 | 1154 |
1126 if (sync_service) { | 1155 // If the setup dialog is being closed during configuration, and sync setup is |
1127 // Make sure user isn't left half-logged-in (signed in, but without sync | 1156 // incomplete, and there is no signin error, it's because the user clicked |
1128 // started up). If the user hasn't finished setting up sync, then sign out | 1157 // "Cancel" while setting up sync. In this case, we don't want the sync |
1129 // and shut down sync. | 1158 // backend to remain in the initialized state. |
1130 if (!sync_service->HasSyncSetupCompleted()) { | 1159 // Note: If we get here and there is a signin error, it's because a signed in |
1131 DVLOG(1) << "Signin aborted by user action"; | 1160 // user is trying to set up sync, and their gaia password has been changed |
1132 // We can get here on Chrome OS (e.g dashboard clear), but "do nothing" | 1161 // since they last signed in. In this case, we leave the backend initialized |
1133 // is the correct behavior. | 1162 // and allow the user to respond to the error message via the settings page. |
1134 #if !defined(OS_CHROMEOS) | 1163 if (sync_service && |
1135 if (signin_tracker_.get() || sync_service->FirstSetupInProgress()) { | 1164 !sync_service->HasSyncSetupCompleted() && |
1136 // User was still in the process of signing in, so sign him out again. | 1165 configuring_sync_ && |
Andrew T Wilson (Slow)
2013/05/15 15:01:24
You can't really rely on configuring_sync_ - it's
Raghu Simha
2013/05/16 02:13:20
If the user clicks cancel, we want to disable sync
| |
1137 // This makes sure that the user isn't left signed in but with sync | 1166 last_signin_error_.state() == GoogleServiceAuthError::NONE) { |
1138 // un-configured. | 1167 DVLOG(1) << "Sync setup aborted by user action"; |
1139 // | 1168 sync_service->DisableForUser(); |
1140 // This has the side-effect of signing out the user in the following | |
1141 // scenario: | |
1142 // * User signs in while sync is disabled by policy. | |
1143 // * Sync is re-enabled by policy. | |
1144 // * User brings up sync setup dialog to do initial sync config. | |
1145 // * User cancels out of the dialog. | |
1146 // | |
1147 // This case is indistinguishable from the "one click signin" case where | |
1148 // the user checks the "advanced setup" checkbox, then cancels out of | |
1149 // the setup box, which is a much more common scenario, so we do the | |
1150 // right thing for the one-click case. | |
1151 SigninManagerFactory::GetForProfile(GetProfile())->SignOut(); | |
1152 } | |
1153 #endif | |
1154 sync_service->DisableForUser(); | |
1155 browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); | |
1156 sync_prefs.SetStartSuppressed(true); | |
1157 } | |
1158 sync_service->SetSetupInProgress(false); | 1169 sync_service->SetSetupInProgress(false); |
1159 } | 1170 } |
1160 | 1171 |
1161 // Reset the attempted email address and error, otherwise the sync setup | 1172 // Reset the attempted email address and error, otherwise the sync setup |
1162 // overlay in the settings page will stay in whatever error state it was last | 1173 // overlay in the settings page will stay in whatever error state it was last |
1163 // when it is reopened. | 1174 // when it is reopened. |
1164 last_attempted_user_email_.clear(); | 1175 last_attempted_user_email_.clear(); |
1165 last_signin_error_ = GoogleServiceAuthError::AuthErrorNone(); | 1176 last_signin_error_ = GoogleServiceAuthError::AuthErrorNone(); |
1166 | 1177 |
1167 configuring_sync_ = false; | 1178 configuring_sync_ = false; |
(...skipping 11 matching lines...) Expand all Loading... | |
1179 // 1) Signin promo. | 1190 // 1) Signin promo. |
1180 // 2) Normal signin through settings page (GetAuthenticatedUsername() is | 1191 // 2) Normal signin through settings page (GetAuthenticatedUsername() is |
1181 // empty). | 1192 // empty). |
1182 // 3) Previously working credentials have expired. | 1193 // 3) Previously working credentials have expired. |
1183 // 4) User is signed in, but has stopped sync via the google dashboard, and | 1194 // 4) User is signed in, but has stopped sync via the google dashboard, and |
1184 // signout is prohibited by policy so we need to force a re-auth. | 1195 // signout is prohibited by policy so we need to force a re-auth. |
1185 // 5) User clicks [Advanced Settings] button on options page while already | 1196 // 5) User clicks [Advanced Settings] button on options page while already |
1186 // logged in. | 1197 // logged in. |
1187 // 6) One-click signin (credentials are already available, so should display | 1198 // 6) One-click signin (credentials are already available, so should display |
1188 // sync configure UI, not login UI). | 1199 // sync configure UI, not login UI). |
1189 // 7) ChromeOS re-enable after disabling sync. | 1200 // 7) User re-enables sync after disabling it via advanced settings. |
1190 SigninManagerBase* signin = | 1201 SigninManagerBase* signin = |
1191 SigninManagerFactory::GetForProfile(GetProfile()); | 1202 SigninManagerFactory::GetForProfile(GetProfile()); |
1192 if (signin->GetAuthenticatedUsername().empty() || | 1203 if (signin->GetAuthenticatedUsername().empty() || |
1193 #if !defined(OS_CHROMEOS) | |
1194 (GetSyncService() && GetSyncService()->IsStartSuppressed()) || | |
1195 #endif | |
1196 signin->signin_global_error()->HasMenuItem()) { | 1204 signin->signin_global_error()->HasMenuItem()) { |
1197 // User is not logged in, or login has been specially requested - need to | 1205 // User is not logged in, or login has been specially requested - need to |
1198 // display login UI (cases 1-3). | 1206 // display login UI (cases 1-3). |
1199 DisplayGaiaLogin(false); | 1207 DisplayGaiaLogin(false); |
1200 } else { | 1208 } else { |
1201 if (!GetSyncService()) { | 1209 if (!GetSyncService()) { |
1202 // This can happen if the user directly navigates to /settings/syncSetup. | 1210 // This can happen if the user directly navigates to /settings/syncSetup. |
1203 DLOG(WARNING) << "Cannot display sync UI when sync is disabled"; | 1211 DLOG(WARNING) << "Cannot display sync UI when sync is disabled"; |
1204 CloseOverlay(); | 1212 CloseOverlay(); |
1205 return; | 1213 return; |
1206 } | 1214 } |
1207 | 1215 |
1208 // User is already logged in. They must have brought up the config wizard | 1216 // User is already logged in. They must have brought up the config wizard |
1209 // via the "Advanced..." button or through One-Click signin (cases 4-6), or | 1217 // via the "Advanced..." button or through One-Click signin (cases 4-6), or |
1210 // they are re-enabling sync on Chrome OS. | 1218 // they are re-enabling sync after having disabled it (case 7). |
1211 DisplayConfigureSync(true, false); | 1219 DisplayConfigureSync(true, false); |
1212 } | 1220 } |
1213 | 1221 |
1214 if (!SyncPromoUI::UseWebBasedSigninFlow()) | 1222 if (!SyncPromoUI::UseWebBasedSigninFlow()) |
1215 ShowSetupUI(); | 1223 ShowSetupUI(); |
1216 } | 1224 } |
1217 | 1225 |
1218 void SyncSetupHandler::OpenConfigureSync() { | 1226 void SyncSetupHandler::OpenConfigureSync() { |
1219 if (!PrepareSyncSetup()) | 1227 if (!PrepareSyncSetup()) |
1220 return; | 1228 return; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1348 *error_message = l10n_util::GetStringUTF16( | 1356 *error_message = l10n_util::GetStringUTF16( |
1349 IDS_SYNC_USER_NAME_IN_USE_ERROR); | 1357 IDS_SYNC_USER_NAME_IN_USE_ERROR); |
1350 return false; | 1358 return false; |
1351 } | 1359 } |
1352 } | 1360 } |
1353 | 1361 |
1354 return true; | 1362 return true; |
1355 } | 1363 } |
1356 | 1364 |
1357 #endif // !defined(OS_CHROMEOS) | 1365 #endif // !defined(OS_CHROMEOS) |
OLD | NEW |