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.cc104
1 files changed, 59 insertions, 45 deletions
diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc
index 5eb62d6..0931a3f 100644
--- a/chrome/browser/sync/sync_setup_flow.cc
+++ b/chrome/browser/sync/sync_setup_flow.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -18,14 +18,14 @@
#include "chrome/browser/cocoa/html_dialog_window_controller_cppsafe.h"
#endif
#include "chrome/browser/dom_ui/dom_ui_util.h"
-#include "chrome/browser/google_service_auth_error.h"
#include "chrome/browser/platform_util.h"
-#include "chrome/browser/pref_service.h"
+#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/syncable/model_type.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/net/gaia/google_service_auth_error.h"
#include "chrome/common/pref_names.h"
#include "gfx/font.h"
#include "grit/locale_settings.h"
@@ -50,9 +50,9 @@ static bool GetAuthData(const std::string& json,
return false;
DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get());
- if (!result->GetString(L"user", username) ||
- !result->GetString(L"pass", password) ||
- !result->GetString(L"captcha", captcha)) {
+ if (!result->GetString("user", username) ||
+ !result->GetString("pass", password) ||
+ !result->GetString("captcha", captcha)) {
return false;
}
return true;
@@ -65,58 +65,64 @@ static bool GetDataTypeChoiceData(const std::string& json,
return false;
DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get());
- if (!result->GetBoolean(L"keepEverythingSynced", sync_everything))
+ if (!result->GetBoolean("keepEverythingSynced", sync_everything))
return false;
// These values need to be kept in sync with where they are written in
// choose_datatypes.html.
bool sync_bookmarks;
- if (!result->GetBoolean(L"syncBookmarks", &sync_bookmarks))
+ if (!result->GetBoolean("syncBookmarks", &sync_bookmarks))
return false;
if (sync_bookmarks)
data_types->insert(syncable::BOOKMARKS);
bool sync_preferences;
- if (!result->GetBoolean(L"syncPreferences", &sync_preferences))
+ if (!result->GetBoolean("syncPreferences", &sync_preferences))
return false;
if (sync_preferences)
data_types->insert(syncable::PREFERENCES);
bool sync_themes;
- if (!result->GetBoolean(L"syncThemes", &sync_themes))
+ if (!result->GetBoolean("syncThemes", &sync_themes))
return false;
if (sync_themes)
data_types->insert(syncable::THEMES);
bool sync_passwords;
- if (!result->GetBoolean(L"syncPasswords", &sync_passwords))
+ if (!result->GetBoolean("syncPasswords", &sync_passwords))
return false;
if (sync_passwords)
data_types->insert(syncable::PASSWORDS);
bool sync_autofill;
- if (!result->GetBoolean(L"syncAutofill", &sync_autofill))
+ if (!result->GetBoolean("syncAutofill", &sync_autofill))
return false;
if (sync_autofill)
data_types->insert(syncable::AUTOFILL);
bool sync_extensions;
- if (!result->GetBoolean(L"syncExtensions", &sync_extensions))
+ if (!result->GetBoolean("syncExtensions", &sync_extensions))
return false;
if (sync_extensions)
data_types->insert(syncable::EXTENSIONS);
bool sync_typed_urls;
- if (!result->GetBoolean(L"syncTypedUrls", &sync_typed_urls))
+ if (!result->GetBoolean("syncTypedUrls", &sync_typed_urls))
return false;
if (sync_typed_urls)
data_types->insert(syncable::TYPED_URLS);
+ bool sync_apps;
+ if (!result->GetBoolean("syncApps", &sync_apps))
+ return false;
+ if (sync_apps)
+ data_types->insert(syncable::APPS);
+
return true;
}
-void FlowHandler::HandleSubmitAuth(const Value* value) {
- std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(value));
+void FlowHandler::HandleSubmitAuth(const ListValue* args) {
+ std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(args));
std::string username, password, captcha;
if (json.empty())
return;
@@ -132,8 +138,8 @@ void FlowHandler::HandleSubmitAuth(const Value* value) {
flow_->OnUserSubmittedAuth(username, password, captcha);
}
-void FlowHandler::HandleChooseDataTypes(const Value* value) {
- std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(value));
+void FlowHandler::HandleChooseDataTypes(const ListValue* args) {
+ std::string json(dom_ui_util::GetJsonResponseFromFirstArgumentInList(args));
bool sync_everything;
syncable::ModelTypeSet chosen_types;
if (json.empty())
@@ -182,7 +188,6 @@ void FlowHandler::ShowGaiaSuccessAndSettingUp() {
// Called by SyncSetupFlow::Advance.
void FlowHandler::ShowChooseDataTypes(const DictionaryValue& args) {
-
// If you're starting the wizard at the Choose Data Types screen (i.e. from
// "Customize Sync"), this will be redundant. However, if you're coming from
// another wizard state, this will make sure Choose Data Types is on top.
@@ -197,8 +202,8 @@ void FlowHandler::ShowChooseDataTypes(const DictionaryValue& args) {
}
void FlowHandler::ShowSetupDone(const std::wstring& user) {
- StringValue synced_to_string(WideToUTF8(l10n_util::GetStringF(
- IDS_SYNC_NTP_SYNCED_TO, user)));
+ StringValue synced_to_string(l10n_util::GetStringFUTF8(
+ IDS_SYNC_NTP_SYNCED_TO, WideToUTF16Hack(user)));
std::string json;
base::JSONWriter::Write(&synced_to_string, false, &json);
std::wstring javascript = std::wstring(L"setSyncedToUser") +
@@ -253,7 +258,7 @@ SyncSetupFlow::~SyncSetupFlow() {
void SyncSetupFlow::GetDialogSize(gfx::Size* size) const {
PrefService* prefs = service_->profile()->GetPrefs();
- gfx::Font approximate_web_font = gfx::Font::CreateFont(
+ gfx::Font approximate_web_font = gfx::Font(
UTF8ToWide(prefs->GetString(prefs::kWebKitSansSerifFontFamily)),
prefs->GetInteger(prefs::kWebKitDefaultFontSize));
@@ -318,54 +323,63 @@ void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) {
// static
void SyncSetupFlow::GetArgsForGaiaLogin(const ProfileSyncService* service,
DictionaryValue* args) {
- args->SetString(L"iframeToShow", "login");
+ args->SetString("iframeToShow", "login");
const GoogleServiceAuthError& error = service->GetAuthError();
if (!service->last_attempted_user_email().empty()) {
- args->SetString(L"user", service->last_attempted_user_email());
- args->SetInteger(L"error", error.state());
+ args->SetString("user", service->last_attempted_user_email());
+ args->SetInteger("error", error.state());
+ args->SetBoolean("editable_user", true);
} else {
- std::wstring user(UTF16ToWide(service->GetAuthenticatedUsername()));
- args->SetString(L"user", user);
- args->SetInteger(L"error", user.empty() ? 0 : error.state());
+ string16 user(service->GetAuthenticatedUsername());
+ args->SetString("user", user);
+ args->SetInteger("error", 0);
+ args->SetBoolean("editable_user", user.empty());
}
- args->SetString(L"captchaUrl", error.captcha().image_url.spec());
+ args->SetString("captchaUrl", error.captcha().image_url.spec());
}
// static
void SyncSetupFlow::GetArgsForChooseDataTypes(ProfileSyncService* service,
DictionaryValue* args) {
- args->SetString(L"iframeToShow", "choose_data_types");
- args->SetBoolean(L"keepEverythingSynced",
+ args->SetString("iframeToShow", "choose_data_types");
+ args->SetBoolean("keepEverythingSynced",
service->profile()->GetPrefs()->GetBoolean(prefs::kKeepEverythingSynced));
// Bookmarks, Preferences, and Themes are launched for good, there's no
// going back now. Check if the other data types are registered though.
syncable::ModelTypeSet registered_types;
service->GetRegisteredDataTypes(&registered_types);
- args->SetBoolean(L"passwordsRegistered",
+ args->SetBoolean("passwordsRegistered",
registered_types.count(syncable::PASSWORDS) > 0);
- args->SetBoolean(L"autofillRegistered",
+ args->SetBoolean("autofillRegistered",
registered_types.count(syncable::AUTOFILL) > 0);
- args->SetBoolean(L"extensionsRegistered",
+ args->SetBoolean("extensionsRegistered",
registered_types.count(syncable::EXTENSIONS) > 0);
- args->SetBoolean(L"typedUrlsRegistered",
+ args->SetBoolean("typedUrlsRegistered",
registered_types.count(syncable::TYPED_URLS) > 0);
-
- args->SetBoolean(L"syncBookmarks",
+ args->SetBoolean("appsRegistered",
+ registered_types.count(syncable::APPS) > 0);
+ args->SetBoolean("sessionsRegistered",
+ registered_types.count(syncable::SESSIONS) > 0);
+ args->SetBoolean("syncBookmarks",
service->profile()->GetPrefs()->GetBoolean(prefs::kSyncBookmarks));
- args->SetBoolean(L"syncPreferences",
+ args->SetBoolean("syncPreferences",
service->profile()->GetPrefs()->GetBoolean(prefs::kSyncPreferences));
- args->SetBoolean(L"syncThemes",
+ args->SetBoolean("syncThemes",
service->profile()->GetPrefs()->GetBoolean(prefs::kSyncThemes));
- args->SetBoolean(L"syncPasswords",
+ args->SetBoolean("syncPasswords",
service->profile()->GetPrefs()->GetBoolean(prefs::kSyncPasswords));
- args->SetBoolean(L"syncAutofill",
+ args->SetBoolean("syncAutofill",
service->profile()->GetPrefs()->GetBoolean(prefs::kSyncAutofill));
- args->SetBoolean(L"syncExtensions",
+ args->SetBoolean("syncExtensions",
service->profile()->GetPrefs()->GetBoolean(prefs::kSyncExtensions));
- args->SetBoolean(L"syncTypedUrls",
+ args->SetBoolean("syncSessions",
+ service->profile()->GetPrefs()->GetBoolean(prefs::kSyncSessions));
+ args->SetBoolean("syncTypedUrls",
service->profile()->GetPrefs()->GetBoolean(prefs::kSyncTypedUrls));
+ args->SetBoolean("syncApps",
+ service->profile()->GetPrefs()->GetBoolean(prefs::kSyncApps));
}
void SyncSetupFlow::GetDOMMessageHandlers(
@@ -425,7 +439,7 @@ void SyncSetupFlow::Advance(SyncSetupWizard::State advance_state) {
case SyncSetupWizard::SETUP_ABORTED_BY_PENDING_CLEAR: {
DictionaryValue args;
SyncSetupFlow::GetArgsForChooseDataTypes(service_, &args);
- args.SetBoolean(L"was_aborted", true);
+ args.SetBoolean("was_aborted", true);
flow_handler_->ShowChooseDataTypes(args);
break;
}
@@ -434,7 +448,7 @@ void SyncSetupFlow::Advance(SyncSetupWizard::State advance_state) {
// TODO(sync): Update this error messaging.
DictionaryValue args;
SyncSetupFlow::GetArgsForGaiaLogin(service_, &args);
- args.SetInteger(L"error", GoogleServiceAuthError::CONNECTION_FAILED);
+ args.SetInteger("error", GoogleServiceAuthError::CONNECTION_FAILED);
flow_handler_->ShowGaiaLogin(args);
break;
}