diff options
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r-- | chrome/browser/dom_ui/sync_options_handler.cc | 24 | ||||
-rw-r--r-- | chrome/browser/dom_ui/sync_options_handler.h | 6 |
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); }; |