summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-18 01:14:57 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-18 01:14:57 +0000
commit1f721485621cbdd7c3a8a9a316a4acf6e23b1f58 (patch)
treed897a02016ce06cf8edc2651bf9836f76fed7e90
parentca3955353c07dd4a92250dabb332b00999f310c3 (diff)
downloadchromium_src-1f721485621cbdd7c3a8a9a316a4acf6e23b1f58.zip
chromium_src-1f721485621cbdd7c3a8a9a316a4acf6e23b1f58.tar.gz
chromium_src-1f721485621cbdd7c3a8a9a316a4acf6e23b1f58.tar.bz2
DOMUI: Move the meat of SyncOptionsHandler into PersonalOptionsHandler.
(This was a TODO for jhawkins). BUG=None TEST=manual Review URL: http://codereview.chromium.org/6344004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71615 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/dom_ui/options/options_ui.cc4
-rw-r--r--chrome/browser/dom_ui/options/personal_options_handler.cc57
-rw-r--r--chrome/browser/dom_ui/options/personal_options_handler.h6
-rw-r--r--chrome/browser/dom_ui/options/sync_options_handler.cc83
-rw-r--r--chrome/browser/dom_ui/options/sync_options_handler.h32
-rw-r--r--chrome/chrome_browser.gypi2
6 files changed, 55 insertions, 129 deletions
diff --git a/chrome/browser/dom_ui/options/options_ui.cc b/chrome/browser/dom_ui/options/options_ui.cc
index 826fb64..5b0ed39 100644
--- a/chrome/browser/dom_ui/options/options_ui.cc
+++ b/chrome/browser/dom_ui/options/options_ui.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -36,7 +36,6 @@
#include "chrome/browser/dom_ui/options/search_engine_manager_handler.h"
#include "chrome/browser/dom_ui/options/startup_page_manager_handler.h"
#include "chrome/browser/dom_ui/options/stop_syncing_handler.h"
-#include "chrome/browser/dom_ui/options/sync_options_handler.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/profiles/profile.h"
@@ -160,7 +159,6 @@ OptionsUI::OptionsUI(TabContents* contents) : DOMUI(contents) {
AddOptionsPageUIHandler(localized_strings, new StartupPageManagerHandler());
AddOptionsPageUIHandler(localized_strings, new ImportDataHandler());
AddOptionsPageUIHandler(localized_strings, new StopSyncingHandler());
- AddOptionsPageUIHandler(localized_strings, new SyncOptionsHandler());
#if defined(OS_CHROMEOS)
AddOptionsPageUIHandler(localized_strings, new AboutPageHandler());
AddOptionsPageUIHandler(localized_strings,
diff --git a/chrome/browser/dom_ui/options/personal_options_handler.cc b/chrome/browser/dom_ui/options/personal_options_handler.cc
index 7102a7a..0b31d8f 100644
--- a/chrome/browser/dom_ui/options/personal_options_handler.cc
+++ b/chrome/browser/dom_ui/options/personal_options_handler.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -20,6 +20,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/sync/sync_setup_flow.h"
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/themes/browser_theme_provider.h"
#include "chrome/browser/ui/options/options_page_base.h"
@@ -124,6 +125,30 @@ void PersonalOptionsHandler::GetLocalizedValues(
l10n_util::GetStringUTF8(IDS_SYNC_OPTIONS_SELECT_EVERYTHING)));
sync_select_list->Append(everything);
localized_strings->Set("syncSelectList", sync_select_list);
+
+ // Sync page.
+ localized_strings->SetString("syncPage",
+ l10n_util::GetStringUTF16(IDS_SYNC_NTP_SYNC_SECTION_TITLE));
+ localized_strings->SetString("sync_title",
+ l10n_util::GetStringUTF16(IDS_CUSTOMIZE_SYNC_DESCRIPTION));
+ localized_strings->SetString("syncsettings",
+ l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_PREFERENCES));
+ localized_strings->SetString("syncbookmarks",
+ l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_BOOKMARKS));
+ localized_strings->SetString("synctypedurls",
+ l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_TYPED_URLS));
+ localized_strings->SetString("syncpasswords",
+ l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_PASSWORDS));
+ localized_strings->SetString("syncextensions",
+ l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_EXTENSIONS));
+ localized_strings->SetString("syncautofill",
+ l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_AUTOFILL));
+ localized_strings->SetString("syncthemes",
+ l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_THEMES));
+ localized_strings->SetString("syncapps",
+ l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_APPS));
+ localized_strings->SetString("syncsessions",
+ l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_SESSIONS));
}
void PersonalOptionsHandler::RegisterMessages() {
@@ -139,6 +164,8 @@ void PersonalOptionsHandler::RegisterMessages() {
"themesSetGTK",
NewCallback(this, &PersonalOptionsHandler::ThemesSetGTK));
#endif
+ dom_ui_->RegisterMessageCallback("updatePreferredDataTypes",
+ NewCallback(this, &PersonalOptionsHandler::OnPreferredDataTypesUpdated));
}
void PersonalOptionsHandler::Observe(NotificationType type,
@@ -225,6 +252,15 @@ void PersonalOptionsHandler::OnStateChanged() {
#endif
}
+void PersonalOptionsHandler::OnLoginSuccess() {
+ OnStateChanged();
+}
+
+void PersonalOptionsHandler::OnLoginFailure(
+ const GoogleServiceAuthError& error) {
+ OnStateChanged();
+}
+
void PersonalOptionsHandler::ObserveThemeChanged() {
Profile* profile = dom_ui_->GetProfile();
#if defined(TOOLKIT_GTK)
@@ -261,6 +297,12 @@ void PersonalOptionsHandler::Initialize() {
if (sync_service) {
sync_service->AddObserver(this);
OnStateChanged();
+
+ DictionaryValue args;
+ SyncSetupFlow::GetArgsForConfigure(sync_service, &args);
+
+ dom_ui_->CallJavascriptFunction(
+ L"PersonalOptions.setRegisteredDataTypes", args);
} else {
dom_ui_->CallJavascriptFunction(L"options.PersonalOptions.hideSyncSection");
}
@@ -294,11 +336,10 @@ void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) {
}
#endif
-void PersonalOptionsHandler::OnLoginSuccess() {
- OnStateChanged();
-}
-
-void PersonalOptionsHandler::OnLoginFailure(
- const GoogleServiceAuthError& error) {
- OnStateChanged();
+void PersonalOptionsHandler::OnPreferredDataTypesUpdated(
+ const ListValue* args) {
+ NotificationService::current()->Notify(
+ NotificationType::SYNC_DATA_TYPES_UPDATED,
+ Source<Profile>(dom_ui_->GetProfile()),
+ NotificationService::NoDetails());
}
diff --git a/chrome/browser/dom_ui/options/personal_options_handler.h b/chrome/browser/dom_ui/options/personal_options_handler.h
index 451ccff..808738a 100644
--- a/chrome/browser/dom_ui/options/personal_options_handler.h
+++ b/chrome/browser/dom_ui/options/personal_options_handler.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -47,6 +47,10 @@ class PersonalOptionsHandler : public OptionsPageUIHandler,
void ThemesSetGTK(const ListValue* args);
#endif
+ // Called when the user updates the set of enabled data types to sync. |args|
+ // is ignored.
+ void OnPreferredDataTypesUpdated(const ListValue* args);
+
scoped_ptr<OptionsManagedBannerHandler> banner_handler_;
DISALLOW_COPY_AND_ASSIGN(PersonalOptionsHandler);
diff --git a/chrome/browser/dom_ui/options/sync_options_handler.cc b/chrome/browser/dom_ui/options/sync_options_handler.cc
deleted file mode 100644
index da9b080..0000000
--- a/chrome/browser/dom_ui/options/sync_options_handler.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/sync_options_handler.h"
-
-#include "app/l10n_util.h"
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "base/stl_util-inl.h"
-#include "base/time.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/sync/profile_sync_service.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"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "grit/theme_resources.h"
-
-SyncOptionsHandler::SyncOptionsHandler() {}
-
-SyncOptionsHandler::~SyncOptionsHandler() {}
-
-bool SyncOptionsHandler::IsEnabled() {
- return ProfileSyncService::IsSyncEnabled();
-}
-
-void SyncOptionsHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
- // Sync page - ChromeOS
- localized_strings->SetString("syncPage",
- l10n_util::GetStringUTF16(IDS_SYNC_NTP_SYNC_SECTION_TITLE));
- localized_strings->SetString("sync_title",
- l10n_util::GetStringUTF16(IDS_CUSTOMIZE_SYNC_DESCRIPTION));
- localized_strings->SetString("syncsettings",
- l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_PREFERENCES));
- localized_strings->SetString("syncbookmarks",
- l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_BOOKMARKS));
- localized_strings->SetString("synctypedurls",
- l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_TYPED_URLS));
- localized_strings->SetString("syncpasswords",
- l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_PASSWORDS));
- localized_strings->SetString("syncextensions",
- l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_EXTENSIONS));
- localized_strings->SetString("syncautofill",
- l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_AUTOFILL));
- localized_strings->SetString("syncthemes",
- l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_THEMES));
- localized_strings->SetString("syncapps",
- l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_APPS));
- localized_strings->SetString("syncsessions",
- l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_SESSIONS));
-}
-
-void SyncOptionsHandler::Initialize() {
- ProfileSyncService* service =
- dom_ui_->GetProfile()->GetProfileSyncService();
- if (!service)
- return; // Can happen in ChromeOS if called before login.
-
- DictionaryValue args;
- SyncSetupFlow::GetArgsForConfigure(service, &args);
-
- dom_ui_->CallJavascriptFunction(
- L"PersonalOptions.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,
- Source<Profile>(dom_ui_->GetProfile()),
- NotificationService::NoDetails());
-}
diff --git a/chrome/browser/dom_ui/options/sync_options_handler.h b/chrome/browser/dom_ui/options/sync_options_handler.h
deleted file mode 100644
index 79bf46d..0000000
--- a/chrome/browser/dom_ui/options/sync_options_handler.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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.
-
-#ifndef CHROME_BROWSER_DOM_UI_OPTIONS_SYNC_OPTIONS_HANDLER_H_
-#define CHROME_BROWSER_DOM_UI_OPTIONS_SYNC_OPTIONS_HANDLER_H_
-#pragma once
-
-#include "chrome/browser/dom_ui/options/options_ui.h"
-
-// Chrome sync options page UI handler.
-// TODO(jhawkins): Move the meat of this class to PersonalOptionsHandler.
-class SyncOptionsHandler : public OptionsPageUIHandler {
- public:
- SyncOptionsHandler();
- virtual ~SyncOptionsHandler();
-
- // OptionsUIHandler implementation.
- virtual bool IsEnabled();
- 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);
-};
-
-#endif // CHROME_BROWSER_DOM_UI_OPTIONS_SYNC_OPTIONS_HANDLER_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index cd17225..361a59f 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -981,8 +981,6 @@
'browser/dom_ui/options/startup_page_manager_handler.h',
'browser/dom_ui/options/stop_syncing_handler.cc',
'browser/dom_ui/options/stop_syncing_handler.h',
- 'browser/dom_ui/options/sync_options_handler.cc',
- 'browser/dom_ui/options/sync_options_handler.h',
'browser/dom_ui/shared_resources_data_source.cc',
'browser/dom_ui/shared_resources_data_source.h',
'browser/dom_ui/shown_sections_handler.cc',