Chromium Code Reviews| Index: chrome/browser/sync/sync_setup_flow.cc |
| =================================================================== |
| --- chrome/browser/sync/sync_setup_flow.cc (revision 72509) |
| +++ chrome/browser/sync/sync_setup_flow.cc (working copy) |
| @@ -45,6 +45,8 @@ |
| NewCallback(this, &FlowHandler::HandleConfigure)); |
| dom_ui_->RegisterMessageCallback("Passphrase", |
| NewCallback(this, &FlowHandler::HandlePassphraseEntry)); |
| + dom_ui_->RegisterMessageCallback("PassphraseCancel", |
| + NewCallback(this, &FlowHandler::HandlePassphraseCancel)); |
| dom_ui_->RegisterMessageCallback("FirstPassphrase", |
| NewCallback(this, &FlowHandler::HandleFirstPassphrase)); |
| dom_ui_->RegisterMessageCallback("GoToDashboard", |
| @@ -167,6 +169,13 @@ |
| return true; |
| } |
| +static void DisablePasswordSync(ProfileSyncService* service) { |
|
tim (not reviewing)
2011/01/26 18:41:31
at first I didn't like this, then I spent 10 minut
|
| + syncable::ModelTypeSet types; |
| + service->GetPreferredDataTypes(&types); |
| + types.erase(syncable::PASSWORDS); |
| + service->OnUserChoseDatatypes(false, types); |
| +} |
| + |
| void FlowHandler::HandleSubmitAuth(const ListValue* args) { |
| std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(args)); |
| std::string username, password, captcha, access_code; |
| @@ -221,6 +230,11 @@ |
| flow_->OnPassphraseEntry(passphrase); |
| } |
| +void FlowHandler::HandlePassphraseCancel(const ListValue* args) { |
| + DCHECK(flow_); |
| + flow_->OnPassphraseCancel(); |
| +} |
| + |
| void FlowHandler::HandleFirstPassphrase(const ListValue* args) { |
| std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(args)); |
| @@ -738,6 +752,15 @@ |
| service_->SetPassphrase(passphrase, true, false); |
| } |
| +void SyncSetupFlow::OnPassphraseCancel() { |
| + // If the user cancels when being asked for the passphrase, |
| + // just disable encrypted sync and continue setting up. |
| + if (current_state_ == SyncSetupWizard::ENTER_PASSPHRASE) |
| + DisablePasswordSync(service_); |
| + |
| + Advance(SyncSetupWizard::SETTING_UP); |
| +} |
| + |
| void SyncSetupFlow::OnFirstPassphraseEntry(const std::string& option, |
| const std::string& passphrase) { |
| Advance(SyncSetupWizard::SETTING_UP); |
| @@ -747,10 +770,7 @@ |
| } else if (option == "nothanks") { |
| // User opted out of encrypted sync, need to turn off encrypted |
| // data types. |
| - syncable::ModelTypeSet registered_types; |
| - service_->GetRegisteredDataTypes(®istered_types); |
| - registered_types.erase(syncable::PASSWORDS); |
| - service_->OnUserChoseDatatypes(false, registered_types); |
| + DisablePasswordSync(service_); |
| } else if (option == "google") { |
| // Implicit passphrase already set up. |
| Advance(SyncSetupWizard::DONE); |