diff options
Diffstat (limited to 'chrome/browser/sync')
-rw-r--r-- | chrome/browser/sync/profile_sync_service.cc | 21 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_service.h | 26 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_service_password_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/sync/resources/configure.html | 4 | ||||
-rw-r--r-- | chrome/browser/sync/resources/passphrase.html | 45 | ||||
-rw-r--r-- | chrome/browser/sync/sync_setup_flow.cc | 28 | ||||
-rw-r--r-- | chrome/browser/sync/sync_setup_flow.h | 7 | ||||
-rw-r--r-- | chrome/browser/sync/sync_setup_wizard.cc | 10 |
8 files changed, 101 insertions, 42 deletions
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index 094eee4..0fdd265 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -66,6 +66,8 @@ ProfileSyncService::ProfileSyncService(ProfileSyncFactory* factory, Profile* profile, const std::string& cros_user) : last_auth_error_(AuthError::None()), + tried_creating_explicit_passphrase_(false), + tried_setting_explicit_passphrase_(false), observed_passphrase_required_(false), passphrase_required_for_decryption_(false), factory_(factory), @@ -1013,13 +1015,20 @@ void ProfileSyncService::DeactivateDataType( } void ProfileSyncService::SetPassphrase(const std::string& passphrase, - bool is_explicit) { + bool is_explicit, + bool is_creation) { if (ShouldPushChanges() || observed_passphrase_required_) { backend_->SetPassphrase(passphrase, is_explicit); } else { cached_passphrase_.value = passphrase; cached_passphrase_.is_explicit = is_explicit; + cached_passphrase_.is_creation = is_creation; } + + if (is_explicit && is_creation) + tried_creating_explicit_passphrase_ = true; + else if (is_explicit) + tried_setting_explicit_passphrase_ = true; } void ProfileSyncService::Observe(NotificationType type, @@ -1047,7 +1056,8 @@ void ProfileSyncService::Observe(NotificationType type, if (!cached_passphrase_.value.empty()) { // Don't hold on to the passphrase in raw form longer than needed. SetPassphrase(cached_passphrase_.value, - cached_passphrase_.is_explicit); + cached_passphrase_.is_explicit, + cached_passphrase_.is_creation); cached_passphrase_ = CachedPassphrase(); } @@ -1066,7 +1076,8 @@ void ProfileSyncService::Observe(NotificationType type, if (!cached_passphrase_.value.empty()) { SetPassphrase(cached_passphrase_.value, - cached_passphrase_.is_explicit); + cached_passphrase_.is_explicit, + cached_passphrase_.is_creation); cached_passphrase_ = CachedPassphrase(); break; } @@ -1095,6 +1106,8 @@ void ProfileSyncService::Observe(NotificationType type, FOR_EACH_OBSERVER(Observer, observers_, OnStateChanged()); observed_passphrase_required_ = false; + tried_setting_explicit_passphrase_ = false; + tried_creating_explicit_passphrase_ = false; wizard_.Step(SyncSetupWizard::DONE); break; @@ -1120,7 +1133,7 @@ void ProfileSyncService::Observe(NotificationType type, // actually change), or the user has an explicit passphrase set so this // becomes a no-op. tried_implicit_gaia_remove_when_bug_62103_fixed_ = true; - SetPassphrase(successful->password, false); + SetPassphrase(successful->password, false, true); break; } case NotificationType::GOOGLE_SIGNIN_FAILED: { diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h index 62a8e07..9b2e98d 100644 --- a/chrome/browser/sync/profile_sync_service.h +++ b/chrome/browser/sync/profile_sync_service.h @@ -256,6 +256,14 @@ class ProfileSyncService : public browser_sync::SyncFrontend, return is_auth_in_progress_; } + bool tried_creating_explicit_passphrase() const { + return tried_creating_explicit_passphrase_; + } + + bool tried_setting_explicit_passphrase() const { + return tried_setting_explicit_passphrase_; + } + bool observed_passphrase_required() const { return observed_passphrase_required_; } @@ -364,7 +372,12 @@ class ProfileSyncService : public browser_sync::SyncFrontend, // setting a passphrase as opposed to implicitly (from the users' perspective) // using their Google Account password. An implicit SetPassphrase will *not* // *not* override an explicit passphrase set previously. - virtual void SetPassphrase(const std::string& passphrase, bool is_explicit); + // |is_creation| is true if the call is in response to the user setting + // up a new passphrase, and false if it's being set in response to a prompt + // for an existing passphrase. + virtual void SetPassphrase(const std::string& passphrase, + bool is_explicit, + bool is_creation); // Returns whether processing changes is allowed. Check this before doing // any model-modifying operations. @@ -417,6 +430,14 @@ class ProfileSyncService : public browser_sync::SyncFrontend, // Cache of the last name the client attempted to authenticate. std::string last_attempted_user_email_; + // Whether the user has tried creating an explicit passphrase on this + // machine. + bool tried_creating_explicit_passphrase_; + + // Whether the user has tried setting an explicit passphrase on this + // machine. + bool tried_setting_explicit_passphrase_; + // Whether we have seen a SYNC_PASSPHRASE_REQUIRED since initializing the // backend, telling us that it is safe to send a passphrase down ASAP. bool observed_passphrase_required_; @@ -527,7 +548,8 @@ class ProfileSyncService : public browser_sync::SyncFrontend, struct CachedPassphrase { std::string value; bool is_explicit; - CachedPassphrase() : is_explicit(false) {} + bool is_creation; + CachedPassphrase() : is_explicit(false), is_creation(false) {} }; CachedPassphrase cached_passphrase_; diff --git a/chrome/browser/sync/profile_sync_service_password_unittest.cc b/chrome/browser/sync/profile_sync_service_password_unittest.cc index 899b40c..632c3d9 100644 --- a/chrome/browser/sync/profile_sync_service_password_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_password_unittest.cc @@ -191,7 +191,7 @@ class ProfileSyncServicePasswordTest : public AbstractProfileSyncServiceTest { NotificationType(NotificationType::SYNC_CONFIGURE_DONE), _,_)). WillOnce(QuitUIMessageLoop()); - service_->SetPassphrase("foo", false); + service_->SetPassphrase("foo", false, true); MessageLoop::current()->Run(); } } diff --git a/chrome/browser/sync/resources/configure.html b/chrome/browser/sync/resources/configure.html index a728643..9ca66b9 100644 --- a/chrome/browser/sync/resources/configure.html +++ b/chrome/browser/sync/resources/configure.html @@ -424,10 +424,10 @@ html[os='mac'] input[type='submit'] { emptyError.style.display = "none"; mismatchError.style.display = "none"; - if (getRadioCheckedValue() != "explicit") { + var f = document.getElementById("chooseDataTypesForm"); + if (getRadioCheckedValue() != "explicit" || f.option[0].disabled) { return true; } - var f = document.getElementById("chooseDataTypesForm"); if (f.passphrase.value.length == 0) { emptyError.style.display = "block"; return false; diff --git a/chrome/browser/sync/resources/passphrase.html b/chrome/browser/sync/resources/passphrase.html index 55b633c..251b0ee 100644 --- a/chrome/browser/sync/resources/passphrase.html +++ b/chrome/browser/sync/resources/passphrase.html @@ -19,8 +19,9 @@ form { font-weight: bold; margin-bottom: 10px; } -.sync-instructions { +.sync-instructions-start-hidden { margin-top: 10px; + display: none; } .sync-footer { position: fixed; @@ -44,16 +45,19 @@ html[os='mac'] input[type='button'], html[os='mac'] input[type='submit'] { font-size: 12pt; } - #passphrase-input { + margin-top: 20px; + margin-bottom: 20px; +} +#incorrectPassphrase { margin-top: 5px; - margin-bottom: 50px; +} +.error { + color: red; } </style> <script src="chrome://resources/js/cr.js"></script> <script>
- var currentMode; - // Called once, when this html/js is loaded. function setupPassphraseDialog(args) { // Allow platform specific rules @@ -62,12 +66,25 @@ html[os='mac'] input[type='submit'] { } else if (!cr.isWindows) { document.documentElement.setAttribute('os', 'linux'); } + + document.getElementById("passphraseRejectedBody").style.display = "none"; + document.getElementById("normalBody").style.display = "none"; + document.getElementById("incorrectPassphrase").style.display = "none"; + + if (args["passphrase_creation_rejected"]) { + document.getElementById("passphraseRejectedBody").style.display = "block"; + } else { + document.getElementById("normalBody").style.display = "block"; + } + + if (args["passphrase_setting_rejected"]) { + document.getElementById("incorrectPassphrase").style.display = "block"; + } } function sendPassphraseAndClose() { var f = document.getElementById("passphraseForm"); - var result = JSON.stringify({"passphrase": f.passphrase.value, - "mode": currentMode}); + var result = JSON.stringify({"passphrase": f.passphrase.value}); chrome.send("Passphrase", [result]); } @@ -78,14 +95,16 @@ html[os='mac'] input[type='submit'] { </script> </head> <body i18n-values=".style.fontFamily:fontfamily" - onload="setupPassphraseDialog();"> + onload="setupPassphraseDialog(JSON.parse(chrome.dialogArguments));"> <form id="passphraseForm" onSubmit="sendPassphraseAndClose(); return false;"> <div id="enter-passphrase"> <div class="sync-header" id="enterTitle" i18n-content="enterPassphraseTitle"></div> - <div class="sync-instructions" id="enterInstructions" + <div class="sync-instructions-start-hidden" id="normalBody" i18n-content="enterPassphraseBody"></div> + <div class="sync-instructions-start-hidden" id="passphraseRejectedBody" + i18n-content="enterOtherPassphraseBody"></div> </div> <div id="passphrase-input"> @@ -93,11 +112,13 @@ html[os='mac'] input[type='submit'] { for="passphrase" i18n-content="passphraseLabel"> </label> <input id="passphrase" name="passphrase" type="password" /> + <div class="error" id="incorrectPassphrase" + i18n-content="incorrectPassphrase"> + </div> </div> - <div id="sync-passphrase-warning" i18n-content="passphraseWarning"> - </div> - <a id="clear-data-link" i18n-content="cleardatalink" href="#" + <span id="sync-passphrase-warning" i18n-content="passphraseRecover"> + </span> <a id="clear-data-link" i18n-content="cleardatalink" href="#" onclick='goToDashboard(); return false;'></a> <div class="sync-footer"> diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc index 083b8d8..3c2fe94 100644 --- a/chrome/browser/sync/sync_setup_flow.cc +++ b/chrome/browser/sync/sync_setup_flow.cc @@ -69,15 +69,13 @@ static bool GetAuthData(const std::string& json, return true; } -bool GetPassphrase(const std::string& json, std::string* passphrase, - std::string* mode) { +bool GetPassphrase(const std::string& json, std::string* passphrase) { scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) return false; DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get()); - return result->GetString("passphrase", passphrase) && - result->GetString("mode", mode); + return result->GetString("passphrase", passphrase); } bool GetFirstPassphrase(const std::string& json, @@ -212,15 +210,14 @@ void FlowHandler::HandlePassphraseEntry(const ListValue* args) { return; std::string passphrase; - std::string mode; - if (!GetPassphrase(json, &passphrase, &mode)) { + if (!GetPassphrase(json, &passphrase)) { // Couldn't understand what the page sent. Indicates a programming error. NOTREACHED(); return; } DCHECK(flow_); - flow_->OnPassphraseEntry(passphrase, mode); + flow_->OnPassphraseEntry(passphrase); } void FlowHandler::HandleFirstPassphrase(const ListValue* args) { @@ -480,10 +477,10 @@ void SyncSetupFlow::GetArgsForGaiaLogin(const ProfileSyncService* service, void SyncSetupFlow::GetArgsForEnterPassphrase( const ProfileSyncService* service, DictionaryValue* args) { args->SetString("iframeToShow", "passphrase"); - if (service->IsUsingSecondaryPassphrase()) - args->SetString("mode", "enter"); - else - args->SetString("mode", "gaia"); + args->SetBoolean("passphrase_creation_rejected", + service->tried_creating_explicit_passphrase()); + args->SetBoolean("passphrase_setting_rejected", + service->tried_setting_explicit_passphrase()); } // static @@ -726,24 +723,23 @@ void SyncSetupFlow::OnUserConfigured(const SyncConfiguration& configuration) { if (configuration.use_secondary_passphrase && !service_->IsUsingSecondaryPassphrase()) { - service_->SetPassphrase(configuration.secondary_passphrase, true); + service_->SetPassphrase(configuration.secondary_passphrase, true, true); } service_->OnUserChoseDatatypes(configuration.sync_everything, configuration.data_types); } -void SyncSetupFlow::OnPassphraseEntry(const std::string& passphrase, - const std::string& mode) { +void SyncSetupFlow::OnPassphraseEntry(const std::string& passphrase) { Advance(SyncSetupWizard::SETTING_UP); - service_->SetPassphrase(passphrase, true); + service_->SetPassphrase(passphrase, true, false); } void SyncSetupFlow::OnFirstPassphraseEntry(const std::string& option, const std::string& passphrase) { Advance(SyncSetupWizard::SETTING_UP); if (option == "explicit") { - service_->SetPassphrase(passphrase, true); + service_->SetPassphrase(passphrase, true, true); } else if (option == "nothanks") { // User opted out of encrypted sync, need to turn off encrypted // data types. diff --git a/chrome/browser/sync/sync_setup_flow.h b/chrome/browser/sync/sync_setup_flow.h index f6c0233..b47c103 100644 --- a/chrome/browser/sync/sync_setup_flow.h +++ b/chrome/browser/sync/sync_setup_flow.h @@ -107,9 +107,12 @@ class SyncSetupFlow : public HtmlDialogUIDelegate { void OnUserConfigured(const SyncConfiguration& configuration); - void OnPassphraseEntry(const std::string& passphrase, - const std::string& mode); + // The 'passphrase' screen is used when the user is prompted to enter + // an existing passphrase. + void OnPassphraseEntry(const std::string& passphrase); + // The 'first passphrase' screen is for users migrating from a build + // without passwords, who are prompted to make a passphrase choice. void OnFirstPassphraseEntry(const std::string& option, const std::string& passphrase); diff --git a/chrome/browser/sync/sync_setup_wizard.cc b/chrome/browser/sync/sync_setup_wizard.cc index 5df5536..64391c1 100644 --- a/chrome/browser/sync/sync_setup_wizard.cc +++ b/chrome/browser/sync/sync_setup_wizard.cc @@ -171,12 +171,16 @@ void SyncResourcesSource::StartDataRequest(const std::string& path_raw, html_resource_id = IDR_SYNC_PASSPHRASE_HTML; AddString(dict, "enterPassphraseTitle", IDS_SYNC_ENTER_PASSPHRASE_TITLE); AddString(dict, "enterPassphraseBody", IDS_SYNC_ENTER_PASSPHRASE_BODY); + AddString(dict, "enterOtherPassphraseBody", + IDS_SYNC_ENTER_OTHER_PASSPHRASE_BODY); AddString(dict, "passphraseLabel", IDS_SYNC_PASSPHRASE_LABEL); - AddString(dict, "ok", IDS_OK); - AddString(dict, "cancel", IDS_CANCEL); - + AddString(dict, "incorrectPassphrase", IDS_SYNC_INCORRECT_PASSPHRASE); + AddString(dict, "passphraseRecover", IDS_SYNC_PASSPHRASE_RECOVER); AddString(dict, "passphraseWarning", IDS_SYNC_PASSPHRASE_WARNING); AddString(dict, "cleardatalink", IDS_SYNC_CLEAR_DATA_LINK); + + AddString(dict, "ok", IDS_OK); + AddString(dict, "cancel", IDS_CANCEL); } else if (path_raw == kSyncFirstPassphrasePath) { html_resource_id = IDR_SYNC_FIRST_PASSPHRASE_HTML; AddString(dict, "title", IDS_SYNC_FIRST_PASSPHRASE_TITLE); |