summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/sync_setup_flow.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/sync/sync_setup_flow.cc')
-rw-r--r--chrome/browser/sync/sync_setup_flow.cc30
1 files changed, 20 insertions, 10 deletions
diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc
index 08dcfa1..643d3c0 100644
--- a/chrome/browser/sync/sync_setup_flow.cc
+++ b/chrome/browser/sync/sync_setup_flow.cc
@@ -12,8 +12,6 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_list.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/user_manager.h"
#endif
@@ -27,6 +25,8 @@
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/net/gaia/google_service_auth_error.h"
#include "chrome/common/pref_names.h"
#include "gfx/font.h"
@@ -68,13 +68,15 @@ static bool GetAuthData(const std::string& json,
return true;
}
-static bool GetPassphrase(const std::string& json, std::string* passphrase) {
+bool GetPassphrase(const std::string& json, std::string* passphrase,
+ std::string* mode) {
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);
+ return result->GetString("passphrase", passphrase) &&
+ result->GetString("mode", mode);
}
static bool GetConfiguration(const std::string& json,
@@ -194,14 +196,15 @@ void FlowHandler::HandlePassphraseEntry(const ListValue* args) {
return;
std::string passphrase;
- if (!GetPassphrase(json, &passphrase)) {
+ std::string mode;
+ if (!GetPassphrase(json, &passphrase, &mode)) {
// Couldn't understand what the page sent. Indicates a programming error.
NOTREACHED();
return;
}
DCHECK(flow_);
- flow_->OnPassphraseEntry(passphrase);
+ flow_->OnPassphraseEntry(passphrase, mode);
}
// Called by SyncSetupFlow::Advance.
@@ -654,6 +657,10 @@ void SyncSetupFlow::OnUserConfigured(const SyncConfiguration& configuration) {
// we need to prompt them to enter one.
if (configuration.use_secondary_passphrase &&
!service_->IsUsingSecondaryPassphrase()) {
+ // TODO(tim): If we could download the Nigori node first before any other
+ // types, we could do that prior to showing the configure page so that we
+ // could pre-populate the 'Use an encryption passphrase' checkbox.
+ // http://crbug.com/60182
Advance(SyncSetupWizard::CREATE_PASSPHRASE);
return;
}
@@ -674,8 +681,9 @@ void SyncSetupFlow::OnConfigurationComplete() {
configuration_.secondary_passphrase.length() > 0);
if (configuration_.use_secondary_passphrase &&
- !service_->IsUsingSecondaryPassphrase())
- service_->SetSecondaryPassphrase(configuration_.secondary_passphrase);
+ !service_->IsUsingSecondaryPassphrase()) {
+ service_->SetPassphrase(configuration_.secondary_passphrase, true);
+ }
service_->OnUserChoseDatatypes(configuration_.sync_everything,
configuration_.data_types);
@@ -683,11 +691,13 @@ void SyncSetupFlow::OnConfigurationComplete() {
configuration_pending_ = false;
}
-void SyncSetupFlow::OnPassphraseEntry(const std::string& passphrase) {
+void SyncSetupFlow::OnPassphraseEntry(const std::string& passphrase,
+ const std::string& mode) {
if (current_state_ == SyncSetupWizard::ENTER_PASSPHRASE) {
- service_->SetSecondaryPassphrase(passphrase);
+ service_->SetPassphrase(passphrase, mode == std::string("enter"));
Advance(SyncSetupWizard::SETTING_UP);
} else if (configuration_pending_) {
+ DCHECK_EQ(SyncSetupWizard::CREATE_PASSPHRASE, current_state_);
configuration_.secondary_passphrase = passphrase;
OnConfigurationComplete();
}