Chromium Code Reviews| 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 | |
| 155 DCHECK(!(config->sync_everything && config->sync_nothing)) | |
| 156 << "syncAllDataTypes and syncNothing cannot both be true"; | |
| 157 | |
| 148 ModelTypeNameMap type_names = GetSelectableTypeNameMap(); | 158 ModelTypeNameMap type_names = GetSelectableTypeNameMap(); |
| 149 | 159 |
| 150 for (ModelTypeNameMap::const_iterator it = type_names.begin(); | 160 for (ModelTypeNameMap::const_iterator it = type_names.begin(); |
| 151 it != type_names.end(); ++it) { | 161 it != type_names.end(); ++it) { |
| 152 std::string key_name = it->second + std::string("Synced"); | 162 std::string key_name = it->second + std::string("Synced"); |
| 153 bool sync_value; | 163 bool sync_value; |
| 154 if (!result->GetBoolean(key_name, &sync_value)) { | 164 if (!result->GetBoolean(key_name, &sync_value)) { |
| 155 DLOG(ERROR) << "GetConfiguration() not passed a value for " << key_name; | 165 DLOG(ERROR) << "GetConfiguration() not passed a value for " << key_name; |
| 156 return false; | 166 return false; |
| 157 } | 167 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 { "invalidAccessCode", IDS_SYNC_INVALID_ACCESS_CODE_LABEL }, | 359 { "invalidAccessCode", IDS_SYNC_INVALID_ACCESS_CODE_LABEL }, |
| 350 { "enterAccessCode", IDS_SYNC_ENTER_ACCESS_CODE_LABEL }, | 360 { "enterAccessCode", IDS_SYNC_ENTER_ACCESS_CODE_LABEL }, |
| 351 { "getAccessCodeHelp", IDS_SYNC_ACCESS_CODE_HELP_LABEL }, | 361 { "getAccessCodeHelp", IDS_SYNC_ACCESS_CODE_HELP_LABEL }, |
| 352 { "getAccessCodeURL", IDS_SYNC_GET_ACCESS_CODE_URL }, | 362 { "getAccessCodeURL", IDS_SYNC_GET_ACCESS_CODE_URL }, |
| 353 { "invalidOtp", IDS_SYNC_INVALID_OTP_LABEL }, | 363 { "invalidOtp", IDS_SYNC_INVALID_OTP_LABEL }, |
| 354 { "enterOtp", IDS_SYNC_ENTER_OTP_LABEL }, | 364 { "enterOtp", IDS_SYNC_ENTER_OTP_LABEL }, |
| 355 { "getOtpHelp", IDS_SYNC_OTP_HELP_LABEL }, | 365 { "getOtpHelp", IDS_SYNC_OTP_HELP_LABEL }, |
| 356 { "getOtpURL", IDS_SYNC_GET_OTP_URL }, | 366 { "getOtpURL", IDS_SYNC_GET_OTP_URL }, |
| 357 { "syncAllDataTypes", IDS_SYNC_EVERYTHING }, | 367 { "syncAllDataTypes", IDS_SYNC_EVERYTHING }, |
| 358 { "chooseDataTypes", IDS_SYNC_CHOOSE_DATATYPES }, | 368 { "chooseDataTypes", IDS_SYNC_CHOOSE_DATATYPES }, |
| 369 { "syncNothing", IDS_SYNC_NOTHING }, | |
| 359 { "bookmarks", IDS_SYNC_DATATYPE_BOOKMARKS }, | 370 { "bookmarks", IDS_SYNC_DATATYPE_BOOKMARKS }, |
| 360 { "preferences", IDS_SYNC_DATATYPE_PREFERENCES }, | 371 { "preferences", IDS_SYNC_DATATYPE_PREFERENCES }, |
| 361 { "autofill", IDS_SYNC_DATATYPE_AUTOFILL }, | 372 { "autofill", IDS_SYNC_DATATYPE_AUTOFILL }, |
| 362 { "themes", IDS_SYNC_DATATYPE_THEMES }, | 373 { "themes", IDS_SYNC_DATATYPE_THEMES }, |
| 363 { "passwords", IDS_SYNC_DATATYPE_PASSWORDS }, | 374 { "passwords", IDS_SYNC_DATATYPE_PASSWORDS }, |
| 364 { "extensions", IDS_SYNC_DATATYPE_EXTENSIONS }, | 375 { "extensions", IDS_SYNC_DATATYPE_EXTENSIONS }, |
| 365 { "typedURLs", IDS_SYNC_DATATYPE_TYPED_URLS }, | 376 { "typedURLs", IDS_SYNC_DATATYPE_TYPED_URLS }, |
| 366 { "apps", IDS_SYNC_DATATYPE_APPS }, | 377 { "apps", IDS_SYNC_DATATYPE_APPS }, |
| 367 { "openTabs", IDS_SYNC_DATATYPE_TABS }, | 378 { "openTabs", IDS_SYNC_DATATYPE_TABS }, |
| 368 { "syncZeroDataTypesError", IDS_SYNC_ZERO_DATA_TYPES_ERROR }, | 379 { "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 | 445 // Should only be called if user is signed in, so no longer need our |
| 435 // SigninTracker. | 446 // SigninTracker. |
| 436 signin_tracker_.reset(); | 447 signin_tracker_.reset(); |
| 437 configuring_sync_ = true; | 448 configuring_sync_ = true; |
| 438 DCHECK(service->sync_initialized()) << | 449 DCHECK(service->sync_initialized()) << |
| 439 "Cannot configure sync until the sync backend is initialized"; | 450 "Cannot configure sync until the sync backend is initialized"; |
| 440 | 451 |
| 441 // Setup args for the sync configure screen: | 452 // Setup args for the sync configure screen: |
| 442 // showSyncEverythingPage: false to skip directly to the configure screen | 453 // showSyncEverythingPage: false to skip directly to the configure screen |
| 443 // syncAllDataTypes: true if the user wants to sync everything | 454 // syncAllDataTypes: true if the user wants to sync everything |
| 455 // syncNothing: true if the user wants to sync nothing | |
| 444 // <data_type>Registered: true if the associated data type is supported | 456 // <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 | 457 // <data_type>Synced: true if the user wants to sync that specific data type |
| 446 // encryptionEnabled: true if sync supports encryption | 458 // encryptionEnabled: true if sync supports encryption |
| 447 // encryptAllData: true if user wants to encrypt all data (not just | 459 // encryptAllData: true if user wants to encrypt all data (not just |
| 448 // passwords) | 460 // passwords) |
| 449 // usePassphrase: true if the data is encrypted with a secondary passphrase | 461 // 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 | 462 // show_passphrase: true if a passphrase is needed to decrypt the sync data |
| 451 DictionaryValue args; | 463 DictionaryValue args; |
| 452 | 464 |
| 453 // Tell the UI layer which data types are registered/enabled by the user. | 465 // Tell the UI layer which data types are registered/enabled by the user. |
| 454 const syncer::ModelTypeSet registered_types = | 466 const syncer::ModelTypeSet registered_types = |
| 455 service->GetRegisteredDataTypes(); | 467 service->GetRegisteredDataTypes(); |
| 456 const syncer::ModelTypeSet preferred_types = | 468 const syncer::ModelTypeSet preferred_types = |
| 457 service->GetPreferredDataTypes(); | 469 service->GetPreferredDataTypes(); |
| 458 ModelTypeNameMap type_names = GetSelectableTypeNameMap(); | 470 ModelTypeNameMap type_names = GetSelectableTypeNameMap(); |
| 459 for (ModelTypeNameMap::const_iterator it = type_names.begin(); | 471 for (ModelTypeNameMap::const_iterator it = type_names.begin(); |
| 460 it != type_names.end(); ++it) { | 472 it != type_names.end(); ++it) { |
| 461 syncer::ModelType sync_type = it->first; | 473 syncer::ModelType sync_type = it->first; |
| 462 const std::string key_name = it->second; | 474 const std::string key_name = it->second; |
| 463 args.SetBoolean(key_name + "Registered", | 475 args.SetBoolean(key_name + "Registered", |
| 464 registered_types.Has(sync_type)); | 476 registered_types.Has(sync_type)); |
| 465 args.SetBoolean(key_name + "Synced", preferred_types.Has(sync_type)); | 477 args.SetBoolean(key_name + "Synced", preferred_types.Has(sync_type)); |
| 466 } | 478 } |
| 467 browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); | 479 browser_sync::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); |
| 468 args.SetBoolean("passphraseFailed", passphrase_failed); | 480 args.SetBoolean("passphraseFailed", passphrase_failed); |
| 469 args.SetBoolean("showSyncEverythingPage", !show_advanced); | 481 args.SetBoolean("showSyncEverythingPage", !show_advanced); |
| 470 args.SetBoolean("syncAllDataTypes", sync_prefs.HasKeepEverythingSynced()); | 482 args.SetBoolean("syncAllDataTypes", sync_prefs.HasKeepEverythingSynced()); |
| 483 args.SetBoolean("syncNothing", false); // Always false during initial setup. | |
| 471 args.SetBoolean("encryptAllData", service->EncryptEverythingEnabled()); | 484 args.SetBoolean("encryptAllData", service->EncryptEverythingEnabled()); |
| 472 | 485 |
| 473 // We call IsPassphraseRequired() here, instead of calling | 486 // We call IsPassphraseRequired() here, instead of calling |
| 474 // IsPassphraseRequiredForDecryption(), because we want to show the passphrase | 487 // IsPassphraseRequiredForDecryption(), because we want to show the passphrase |
| 475 // UI even if no encrypted data types are enabled. | 488 // UI even if no encrypted data types are enabled. |
| 476 args.SetBoolean("showPassphrase", service->IsPassphraseRequired()); | 489 args.SetBoolean("showPassphrase", service->IsPassphraseRequired()); |
| 477 // Keystore encryption is behind a flag. Only show the new encryption settings | 490 // Keystore encryption is behind a flag. Only show the new encryption settings |
| 478 // if keystore encryption is enabled. | 491 // if keystore encryption is enabled. |
| 479 args.SetBoolean("keystoreEncryptionEnabled", IsKeystoreEncryptionEnabled()); | 492 args.SetBoolean("keystoreEncryptionEnabled", IsKeystoreEncryptionEnabled()); |
| 480 | 493 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 | 564 |
| 552 ProfileSyncService* service = GetSyncService(); | 565 ProfileSyncService* service = GetSyncService(); |
| 553 DCHECK(service); | 566 DCHECK(service); |
| 554 if (!service->HasSyncSetupCompleted()) { | 567 if (!service->HasSyncSetupCompleted()) { |
| 555 // This is the first time configuring sync, so log it. | 568 // This is the first time configuring sync, so log it. |
| 556 base::FilePath profile_file_path = GetProfile()->GetPath(); | 569 base::FilePath profile_file_path = GetProfile()->GetPath(); |
| 557 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); | 570 ProfileMetrics::LogProfileSyncSignIn(profile_file_path); |
| 558 | 571 |
| 559 // We're done configuring, so notify ProfileSyncService that it is OK to | 572 // We're done configuring, so notify ProfileSyncService that it is OK to |
| 560 // start syncing. | 573 // start syncing. |
| 574 service->SetSetupInProgress(false); | |
|
Andrew T Wilson (Slow)
2013/05/16 08:39:30
Where was this done previously (i.e. why is this n
Raghu Simha
2013/05/17 05:14:17
Earlier, this was being called in CloseSyncSetup a
| |
| 561 service->SetSyncSetupCompleted(); | 575 service->SetSyncSetupCompleted(); |
| 562 } | 576 } |
| 563 } | 577 } |
| 564 | 578 |
| 565 bool SyncSetupHandler::IsActiveLogin() const { | 579 bool SyncSetupHandler::IsActiveLogin() const { |
| 566 // LoginUIService can be NULL if page is brought up in incognito mode | 580 // 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). | 581 // (i.e. if the user is running in guest mode in cros and brings up settings). |
| 568 LoginUIService* service = GetLoginUIService(); | 582 LoginUIService* service = GetLoginUIService(); |
| 569 return service && (service->current_login_ui() == this); | 583 return service && (service->current_login_ui() == this); |
| 570 } | 584 } |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 885 // Gaia credentials are valid - update the UI. | 899 // Gaia credentials are valid - update the UI. |
| 886 DisplayGaiaSuccessAndSettingUp(); | 900 DisplayGaiaSuccessAndSettingUp(); |
| 887 } | 901 } |
| 888 | 902 |
| 889 void SyncSetupHandler::SigninFailed(const GoogleServiceAuthError& error) { | 903 void SyncSetupHandler::SigninFailed(const GoogleServiceAuthError& error) { |
| 890 // Stop a timer to handle timeout in waiting for checking network connection. | 904 // Stop a timer to handle timeout in waiting for checking network connection. |
| 891 backend_start_timer_.reset(); | 905 backend_start_timer_.reset(); |
| 892 | 906 |
| 893 last_signin_error_ = error; | 907 last_signin_error_ = error; |
| 894 | 908 |
| 895 // If using web-based sign in flow, don't show the gaia sign in page again | 909 if (!retry_on_signin_failure_ && |
| 896 // since there is no way to show the user an error message. | 910 (error.state() == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS || |
| 897 if (SyncPromoUI::UseWebBasedSigninFlow()) { | 911 error.state() == GoogleServiceAuthError::ACCOUNT_DELETED || |
| 912 error.state() == GoogleServiceAuthError::ACCOUNT_DISABLED)) { | |
| 913 // The user received an auth error while re-enabling sync after having | |
| 914 // chosen to "Sync nothing". This can happen if the gaia password has been | |
| 915 // changed since the user last signed in, or if the account has been deleted | |
| 916 // or disabled. Leave the sync backend initialized, and close the setup | |
| 917 // dialog. An error message will be shown on the settings page. | |
| 918 CloseOverlay(); | |
|
Andrew T Wilson (Slow)
2013/05/16 08:39:30
It seems dangerous to just call CloseOverlay() - C
Raghu Simha
2013/05/17 05:14:17
As a matter of fact, CloseOverlay() calls CloseSyn
Andrew T Wilson (Slow)
2013/05/17 07:26:10
Hah, apparently I forgot about my own refactorings
| |
| 919 } else if (SyncPromoUI::UseWebBasedSigninFlow()) { | |
| 920 // If using web-based sign in flow, don't show the gaia sign in page again | |
| 921 // since there is no way to show the user an error message. | |
| 898 CloseSyncSetup(); | 922 CloseSyncSetup(); |
| 899 } else if (retry_on_signin_failure_) { | 923 } else if (retry_on_signin_failure_) { |
| 900 // Got a failed signin - this is either just a typical auth error, or a | 924 // 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). | 925 // 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 | 926 // On ChromeOS, this condition can happen when auth token is invalid and |
| 903 // cannot start sync backend. | 927 // 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(); | 928 ProfileSyncService* service = GetSyncService(); |
| 907 DisplayGaiaLogin(service && service->HasUnrecoverableError()); | 929 DisplayGaiaLogin(service && service->HasUnrecoverableError()); |
| 908 } else { | 930 } else { |
| 909 // TODO(peria): Show error dialog for prompting sign in and out on | 931 // TODO(peria): Show error dialog for prompting sign in and out on |
| 910 // Chrome OS. http://crbug.com/128692 | 932 // Chrome OS. http://crbug.com/128692 |
| 911 CloseOverlay(); | 933 CloseOverlay(); |
| 912 } | 934 } |
| 913 } | 935 } |
| 914 | 936 |
| 915 Profile* SyncSetupHandler::GetProfile() const { | 937 Profile* SyncSetupHandler::GetProfile() const { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 931 // If we have signed in while sync is already setup, it must be due to some | 953 // If we have signed in while sync is already setup, it must be due to some |
| 932 // kind of re-authentication flow. In that case, just close the signin dialog | 954 // kind of re-authentication flow. In that case, just close the signin dialog |
| 933 // rather than forcing the user to go through sync configuration. | 955 // rather than forcing the user to go through sync configuration. |
| 934 if (!service || service->HasSyncSetupCompleted()) | 956 if (!service || service->HasSyncSetupCompleted()) |
| 935 DisplayGaiaSuccessAndClose(); | 957 DisplayGaiaSuccessAndClose(); |
| 936 else | 958 else |
| 937 DisplayConfigureSync(false, false); | 959 DisplayConfigureSync(false, false); |
| 938 } | 960 } |
| 939 | 961 |
| 940 void SyncSetupHandler::HandleConfigure(const ListValue* args) { | 962 void SyncSetupHandler::HandleConfigure(const ListValue* args) { |
| 941 std::string json; | 963 std::string json; |
|
Andrew T Wilson (Slow)
2013/05/16 08:39:30
Can you please add a DCHECK(!signin_tracker.get())
Raghu Simha
2013/05/17 05:14:17
Done.
| |
| 942 if (!args->GetString(0, &json)) { | 964 if (!args->GetString(0, &json)) { |
| 943 NOTREACHED() << "Could not read JSON argument"; | 965 NOTREACHED() << "Could not read JSON argument"; |
| 944 return; | 966 return; |
| 945 } | 967 } |
| 946 if (json.empty()) { | 968 if (json.empty()) { |
| 947 NOTREACHED(); | 969 NOTREACHED(); |
| 948 return; | 970 return; |
| 949 } | 971 } |
| 950 | 972 |
| 951 SyncConfigInfo configuration; | 973 SyncConfigInfo configuration; |
| 952 if (!GetConfiguration(json, &configuration)) { | 974 if (!GetConfiguration(json, &configuration)) { |
| 953 // The page sent us something that we didn't understand. | 975 // The page sent us something that we didn't understand. |
| 954 // This probably indicates a programming error. | 976 // This probably indicates a programming error. |
| 955 NOTREACHED(); | 977 NOTREACHED(); |
| 956 return; | 978 return; |
| 957 } | 979 } |
| 958 | 980 |
| 959 // Start configuring the ProfileSyncService using the configuration passed | 981 // Start configuring the ProfileSyncService using the configuration passed |
| 960 // to us from the JS layer. | 982 // to us from the JS layer. |
| 961 ProfileSyncService* service = GetSyncService(); | 983 ProfileSyncService* service = GetSyncService(); |
| 962 | 984 |
| 963 // If the sync engine has shutdown for some reason, just close the sync | 985 // If the sync engine has shutdown for some reason, just close the sync |
| 964 // dialog. | 986 // dialog. |
| 965 if (!service || !service->sync_initialized()) { | 987 if (!service || !service->sync_initialized()) { |
| 966 CloseOverlay(); | 988 CloseOverlay(); |
| 967 return; | 989 return; |
| 968 } | 990 } |
| 969 | 991 |
| 992 // Disable sync, but remain signed in if the user selected "Sync nothing" in | |
| 993 // the advanced settings dialog. Note: In order to disable sync across | |
| 994 // restarts on Chrome OS, we must call OnStopSyncingPermanently(), which | |
| 995 // suppresses sync startup in addition to disabling it. | |
| 996 if (configuration.sync_nothing) { | |
| 997 ProfileSyncService::SyncEvent( | |
| 998 ProfileSyncService::STOP_FROM_ADVANCED_DIALOG); | |
| 999 CloseOverlay(); | |
| 1000 service->OnStopSyncingPermanently(); | |
| 1001 service->SetSetupInProgress(false); | |
| 1002 return; | |
| 1003 } | |
| 1004 | |
| 970 // Note: Data encryption will not occur until configuration is complete | 1005 // Note: Data encryption will not occur until configuration is complete |
| 971 // (when the PSS receives its CONFIGURE_DONE notification from the sync | 1006 // (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 | 1007 // 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. | 1008 // if (for example) some kind of passphrase error is encountered. |
| 974 if (configuration.encrypt_all) | 1009 if (configuration.encrypt_all) |
| 975 service->EnableEncryptEverything(); | 1010 service->EnableEncryptEverything(); |
| 976 | 1011 |
| 977 bool passphrase_failed = false; | 1012 bool passphrase_failed = false; |
| 978 if (!configuration.passphrase.empty()) { | 1013 if (!configuration.passphrase.empty()) { |
| 979 // We call IsPassphraseRequired() here (instead of | 1014 // We call IsPassphraseRequired() here (instead of |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1096 } | 1131 } |
| 1097 | 1132 |
| 1098 void SyncSetupHandler::HandleCloseTimeout(const ListValue* args) { | 1133 void SyncSetupHandler::HandleCloseTimeout(const ListValue* args) { |
| 1099 CloseSyncSetup(); | 1134 CloseSyncSetup(); |
| 1100 } | 1135 } |
| 1101 | 1136 |
| 1102 void SyncSetupHandler::CloseSyncSetup() { | 1137 void SyncSetupHandler::CloseSyncSetup() { |
| 1103 // TODO(atwilson): Move UMA tracking of signin events out of sync module. | 1138 // TODO(atwilson): Move UMA tracking of signin events out of sync module. |
| 1104 ProfileSyncService* sync_service = GetSyncService(); | 1139 ProfileSyncService* sync_service = GetSyncService(); |
| 1105 if (IsActiveLogin()) { | 1140 if (IsActiveLogin()) { |
| 1106 if (!sync_service || !sync_service->HasSyncSetupCompleted()) { | 1141 // Don't log a cancel event if the sync setup dialog is being |
| 1142 // automatically closed due to an auth error. | |
| 1143 if ((!sync_service || !sync_service->HasSyncSetupCompleted()) && | |
| 1144 last_signin_error_.state() == GoogleServiceAuthError::NONE) { | |
| 1107 if (signin_tracker_.get()) { | 1145 if (signin_tracker_.get()) { |
| 1108 ProfileSyncService::SyncEvent( | 1146 ProfileSyncService::SyncEvent( |
| 1109 ProfileSyncService::CANCEL_DURING_SIGNON); | 1147 ProfileSyncService::CANCEL_DURING_SIGNON); |
| 1110 } else if (configuring_sync_) { | 1148 } else if (configuring_sync_) { |
| 1111 ProfileSyncService::SyncEvent( | 1149 ProfileSyncService::SyncEvent( |
| 1112 ProfileSyncService::CANCEL_DURING_CONFIGURE); | 1150 ProfileSyncService::CANCEL_DURING_CONFIGURE); |
| 1113 } else { | 1151 } else { |
| 1114 ProfileSyncService::SyncEvent( | 1152 ProfileSyncService::SyncEvent( |
| 1115 ProfileSyncService::CANCEL_FROM_SIGNON_WITHOUT_AUTH); | 1153 ProfileSyncService::CANCEL_FROM_SIGNON_WITHOUT_AUTH); |
| 1116 } | 1154 } |
| 1155 | |
| 1156 // If the user clicked "Cancel" while setting up sync, disable sync | |
| 1157 // because we don't want the sync backend to remain in the initialized | |
| 1158 // state. Note: In order to disable sync across restarts on Chrome OS, we | |
| 1159 // must call OnStopSyncingPermanently(), which suppresses sync startup in | |
| 1160 // addition to disabling it. | |
| 1161 if (sync_service) { | |
| 1162 DVLOG(1) << "Sync setup aborted by user action"; | |
| 1163 sync_service->OnStopSyncingPermanently(); | |
| 1164 sync_service->SetSetupInProgress(false); | |
| 1165 } | |
| 1117 } | 1166 } |
| 1118 | 1167 |
| 1119 // Let the various services know that we're no longer active. | 1168 // Let the various services know that we're no longer active. |
| 1120 if (SyncPromoUI::UseWebBasedSigninFlow()) | 1169 if (SyncPromoUI::UseWebBasedSigninFlow()) |
| 1121 CloseGaiaSigninPage(); | 1170 CloseGaiaSigninPage(); |
| 1122 | 1171 |
| 1123 GetLoginUIService()->LoginUIClosed(this); | 1172 GetLoginUIService()->LoginUIClosed(this); |
| 1124 } | 1173 } |
| 1125 | 1174 |
| 1126 if (sync_service) { | |
| 1127 // Make sure user isn't left half-logged-in (signed in, but without sync | |
| 1128 // started up). If the user hasn't finished setting up sync, then sign out | |
| 1129 // and shut down sync. | |
| 1130 if (!sync_service->HasSyncSetupCompleted()) { | |
| 1131 DVLOG(1) << "Signin aborted by user action"; | |
| 1132 // We can get here on Chrome OS (e.g dashboard clear), but "do nothing" | |
| 1133 // is the correct behavior. | |
| 1134 #if !defined(OS_CHROMEOS) | |
| 1135 if (signin_tracker_.get() || sync_service->FirstSetupInProgress()) { | |
| 1136 // User was still in the process of signing in, so sign him out again. | |
| 1137 // This makes sure that the user isn't left signed in but with sync | |
| 1138 // un-configured. | |
| 1139 // | |
| 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); | |
| 1159 } | |
| 1160 | |
| 1161 // Reset the attempted email address and error, otherwise the sync setup | 1175 // 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 | 1176 // overlay in the settings page will stay in whatever error state it was last |
| 1163 // when it is reopened. | 1177 // when it is reopened. |
| 1164 last_attempted_user_email_.clear(); | 1178 last_attempted_user_email_.clear(); |
| 1165 last_signin_error_ = GoogleServiceAuthError::AuthErrorNone(); | 1179 last_signin_error_ = GoogleServiceAuthError::AuthErrorNone(); |
| 1166 | 1180 |
| 1167 configuring_sync_ = false; | 1181 configuring_sync_ = false; |
| 1168 signin_tracker_.reset(); | 1182 signin_tracker_.reset(); |
| 1169 | 1183 |
| 1170 // Stop a timer to handle timeout in waiting for checking network connection. | 1184 // Stop a timer to handle timeout in waiting for checking network connection. |
| 1171 backend_start_timer_.reset(); | 1185 backend_start_timer_.reset(); |
| 1172 } | 1186 } |
| 1173 | 1187 |
| 1174 void SyncSetupHandler::OpenSyncSetup() { | 1188 void SyncSetupHandler::OpenSyncSetup() { |
| 1175 if (!PrepareSyncSetup()) | 1189 if (!PrepareSyncSetup()) |
| 1176 return; | 1190 return; |
| 1177 | 1191 |
| 1178 // There are several different UI flows that can bring the user here: | 1192 // There are several different UI flows that can bring the user here: |
| 1179 // 1) Signin promo. | 1193 // 1) Signin promo. |
| 1180 // 2) Normal signin through settings page (GetAuthenticatedUsername() is | 1194 // 2) Normal signin through settings page (GetAuthenticatedUsername() is |
| 1181 // empty). | 1195 // empty). |
| 1182 // 3) Previously working credentials have expired. | 1196 // 3) Previously working credentials have expired. |
| 1183 // 4) User is signed in, but has stopped sync via the google dashboard, and | 1197 // 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. | 1198 // 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 | 1199 // 5) User clicks [Advanced Settings] button on options page while already |
| 1186 // logged in. | 1200 // logged in. |
| 1187 // 6) One-click signin (credentials are already available, so should display | 1201 // 6) One-click signin (credentials are already available, so should display |
| 1188 // sync configure UI, not login UI). | 1202 // sync configure UI, not login UI). |
| 1189 // 7) ChromeOS re-enable after disabling sync. | 1203 // 7) User re-enables sync after disabling it via advanced settings. |
| 1190 SigninManagerBase* signin = | 1204 SigninManagerBase* signin = |
| 1191 SigninManagerFactory::GetForProfile(GetProfile()); | 1205 SigninManagerFactory::GetForProfile(GetProfile()); |
| 1192 if (signin->GetAuthenticatedUsername().empty() || | 1206 if (signin->GetAuthenticatedUsername().empty() || |
| 1193 #if !defined(OS_CHROMEOS) | |
| 1194 (GetSyncService() && GetSyncService()->IsStartSuppressed()) || | |
| 1195 #endif | |
| 1196 signin->signin_global_error()->HasMenuItem()) { | 1207 signin->signin_global_error()->HasMenuItem()) { |
| 1197 // User is not logged in, or login has been specially requested - need to | 1208 // User is not logged in, or login has been specially requested - need to |
| 1198 // display login UI (cases 1-3). | 1209 // display login UI (cases 1-3). |
| 1199 DisplayGaiaLogin(false); | 1210 DisplayGaiaLogin(false); |
| 1200 } else { | 1211 } else { |
| 1201 if (!GetSyncService()) { | 1212 if (!GetSyncService()) { |
| 1202 // This can happen if the user directly navigates to /settings/syncSetup. | 1213 // This can happen if the user directly navigates to /settings/syncSetup. |
| 1203 DLOG(WARNING) << "Cannot display sync UI when sync is disabled"; | 1214 DLOG(WARNING) << "Cannot display sync UI when sync is disabled"; |
| 1204 CloseOverlay(); | 1215 CloseOverlay(); |
| 1205 return; | 1216 return; |
| 1206 } | 1217 } |
| 1207 | 1218 |
| 1208 // User is already logged in. They must have brought up the config wizard | 1219 // 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 | 1220 // via the "Advanced..." button or through One-Click signin (cases 4-6), or |
| 1210 // they are re-enabling sync on Chrome OS. | 1221 // they are re-enabling sync after having disabled it (case 7). |
| 1211 DisplayConfigureSync(true, false); | 1222 DisplayConfigureSync(true, false); |
| 1212 } | 1223 } |
| 1213 | 1224 |
| 1214 if (!SyncPromoUI::UseWebBasedSigninFlow()) | 1225 if (!SyncPromoUI::UseWebBasedSigninFlow()) |
| 1215 ShowSetupUI(); | 1226 ShowSetupUI(); |
| 1216 } | 1227 } |
| 1217 | 1228 |
| 1218 void SyncSetupHandler::OpenConfigureSync() { | 1229 void SyncSetupHandler::OpenConfigureSync() { |
| 1219 if (!PrepareSyncSetup()) | 1230 if (!PrepareSyncSetup()) |
| 1220 return; | 1231 return; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1348 *error_message = l10n_util::GetStringUTF16( | 1359 *error_message = l10n_util::GetStringUTF16( |
| 1349 IDS_SYNC_USER_NAME_IN_USE_ERROR); | 1360 IDS_SYNC_USER_NAME_IN_USE_ERROR); |
| 1350 return false; | 1361 return false; |
| 1351 } | 1362 } |
| 1352 } | 1363 } |
| 1353 | 1364 |
| 1354 return true; | 1365 return true; |
| 1355 } | 1366 } |
| 1356 | 1367 |
| 1357 #endif // !defined(OS_CHROMEOS) | 1368 #endif // !defined(OS_CHROMEOS) |
| OLD | NEW |