summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authoralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-15 18:41:08 +0000
committeralbertb@chromium.org <albertb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-15 18:41:08 +0000
commit2c936bf562756d8521f422d589410d570bc3bcff (patch)
treeb20a996c3d48c8094a65cca2c5c24d7ebf0b56fc /chrome/browser/dom_ui
parent6ef445eeeca97681c0d152d3b36e1dac9f20e75e (diff)
downloadchromium_src-2c936bf562756d8521f422d589410d570bc3bcff.zip
chromium_src-2c936bf562756d8521f422d589410d570bc3bcff.tar.gz
chromium_src-2c936bf562756d8521f422d589410d570bc3bcff.tar.bz2
Re-land: Hook up the dom_ui sync options to the sync service.
TBR=tim BUG=chromiumos:6363 TEST=manual Review URL: http://codereview.chromium.org/3447003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59530 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/sync_options_handler.cc24
-rw-r--r--chrome/browser/dom_ui/sync_options_handler.h6
2 files changed, 30 insertions, 0 deletions
diff --git a/chrome/browser/dom_ui/sync_options_handler.cc b/chrome/browser/dom_ui/sync_options_handler.cc
index bcf8580..a8798bb 100644
--- a/chrome/browser/dom_ui/sync_options_handler.cc
+++ b/chrome/browser/dom_ui/sync_options_handler.cc
@@ -11,6 +11,7 @@
#include "base/time.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/sync/sync_setup_flow.h"
#include "chrome/common/notification_service.h"
#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
@@ -47,3 +48,26 @@ void SyncOptionsHandler::GetLocalizedValues(
localized_strings->SetString("syncapps",
l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_APPS));
}
+
+void SyncOptionsHandler::Initialize() {
+ ProfileSyncService* service =
+ dom_ui_->GetProfile()->GetOriginalProfile()->GetProfileSyncService();
+ DCHECK(service);
+
+ DictionaryValue args;
+ SyncSetupFlow::GetArgsForChooseDataTypes(service, &args);
+
+ dom_ui_->CallJavascriptFunction(L"SyncOptions.setRegisteredDataTypes", args);
+}
+
+void SyncOptionsHandler::RegisterMessages() {
+ dom_ui_->RegisterMessageCallback("updatePreferredDataTypes",
+ NewCallback(this, &SyncOptionsHandler::OnPreferredDataTypesUpdated));
+}
+
+void SyncOptionsHandler::OnPreferredDataTypesUpdated(const ListValue* args) {
+ NotificationService::current()->Notify(
+ NotificationType::SYNC_DATA_TYPES_UPDATED,
+ NotificationService::AllSources(),
+ NotificationService::NoDetails());
+}
diff --git a/chrome/browser/dom_ui/sync_options_handler.h b/chrome/browser/dom_ui/sync_options_handler.h
index 15a77e6..76de737 100644
--- a/chrome/browser/dom_ui/sync_options_handler.h
+++ b/chrome/browser/dom_ui/sync_options_handler.h
@@ -16,8 +16,14 @@ class SyncOptionsHandler : public OptionsPageUIHandler {
// OptionsUIHandler implementation.
virtual void GetLocalizedValues(DictionaryValue* localized_strings);
+ virtual void Initialize();
+ virtual void RegisterMessages();
private:
+ // Called when the user updates the set of enabled data types to sync. |args|
+ // is ignored.
+ void OnPreferredDataTypesUpdated(const ListValue* args);
+
DISALLOW_COPY_AND_ASSIGN(SyncOptionsHandler);
};