summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/options/OWNERS4
-rw-r--r--chrome/browser/dom_ui/options/about_page_handler.cc419
-rw-r--r--chrome/browser/dom_ui/options/about_page_handler.h61
-rw-r--r--chrome/browser/dom_ui/options/add_startup_page_handler.cc98
-rw-r--r--chrome/browser/dom_ui/options/add_startup_page_handler.h35
-rw-r--r--chrome/browser/dom_ui/options/advanced_options_handler.cc659
-rw-r--r--chrome/browser/dom_ui/options/advanced_options_handler.h175
-rw-r--r--chrome/browser/dom_ui/options/advanced_options_utils.h21
-rw-r--r--chrome/browser/dom_ui/options/advanced_options_utils_gtk.cc145
-rw-r--r--chrome/browser/dom_ui/options/advanced_options_utils_mac.mm41
-rw-r--r--chrome/browser/dom_ui/options/advanced_options_utils_win.cc67
-rw-r--r--chrome/browser/dom_ui/options/autofill_options_handler.cc395
-rw-r--r--chrome/browser/dom_ui/options/autofill_options_handler.h72
-rw-r--r--chrome/browser/dom_ui/options/browser_options_handler.cc415
-rw-r--r--chrome/browser/dom_ui/options/browser_options_handler.h104
-rw-r--r--chrome/browser/dom_ui/options/certificate_manager_handler.cc938
-rw-r--r--chrome/browser/dom_ui/options/certificate_manager_handler.h153
-rw-r--r--chrome/browser/dom_ui/options/clear_browser_data_handler.cc169
-rw-r--r--chrome/browser/dom_ui/options/clear_browser_data_handler.h48
-rw-r--r--chrome/browser/dom_ui/options/content_settings_handler.cc728
-rw-r--r--chrome/browser/dom_ui/options/content_settings_handler.h104
-rw-r--r--chrome/browser/dom_ui/options/cookies_view_handler.cc413
-rw-r--r--chrome/browser/dom_ui/options/cookies_view_handler.h58
-rw-r--r--chrome/browser/dom_ui/options/core_options_handler.cc373
-rw-r--r--chrome/browser/dom_ui/options/core_options_handler.h100
-rw-r--r--chrome/browser/dom_ui/options/dom_options_util.cc20
-rw-r--r--chrome/browser/dom_ui/options/dom_options_util.h15
-rw-r--r--chrome/browser/dom_ui/options/font_settings_handler.cc188
-rw-r--r--chrome/browser/dom_ui/options/font_settings_handler.h36
-rw-r--r--chrome/browser/dom_ui/options/font_settings_utils.h19
-rw-r--r--chrome/browser/dom_ui/options/font_settings_utils_gtk.cc43
-rw-r--r--chrome/browser/dom_ui/options/font_settings_utils_mac.mm53
-rw-r--r--chrome/browser/dom_ui/options/font_settings_utils_win.cc55
-rw-r--r--chrome/browser/dom_ui/options/import_data_handler.cc169
-rw-r--r--chrome/browser/dom_ui/options/import_data_handler.h44
-rw-r--r--chrome/browser/dom_ui/options/language_options_handler.cc111
-rw-r--r--chrome/browser/dom_ui/options/language_options_handler.h35
-rw-r--r--chrome/browser/dom_ui/options/language_options_handler_common.cc164
-rw-r--r--chrome/browser/dom_ui/options/language_options_handler_common.h58
-rw-r--r--chrome/browser/dom_ui/options/language_options_handler_unittest.cc179
-rw-r--r--chrome/browser/dom_ui/options/options_managed_banner_handler.cc38
-rw-r--r--chrome/browser/dom_ui/options/options_managed_banner_handler.h31
-rw-r--r--chrome/browser/dom_ui/options/options_ui.cc303
-rw-r--r--chrome/browser/dom_ui/options/options_ui.h111
-rw-r--r--chrome/browser/dom_ui/options/options_ui_uitest.cc115
-rw-r--r--chrome/browser/dom_ui/options/password_manager_handler.cc210
-rw-r--r--chrome/browser/dom_ui/options/password_manager_handler.h107
-rw-r--r--chrome/browser/dom_ui/options/personal_options_handler.cc403
-rw-r--r--chrome/browser/dom_ui/options/personal_options_handler.h58
-rw-r--r--chrome/browser/dom_ui/options/search_engine_manager_handler.cc272
-rw-r--r--chrome/browser/dom_ui/options/search_engine_manager_handler.h67
-rw-r--r--chrome/browser/dom_ui/options/stop_syncing_handler.cc46
-rw-r--r--chrome/browser/dom_ui/options/stop_syncing_handler.h24
53 files changed, 60 insertions, 8709 deletions
diff --git a/chrome/browser/dom_ui/options/OWNERS b/chrome/browser/dom_ui/options/OWNERS
deleted file mode 100644
index 67257e6..0000000
--- a/chrome/browser/dom_ui/options/OWNERS
+++ /dev/null
@@ -1,4 +0,0 @@
-csilv@chromium.org
-estade@chromium.org
-jhawkins@chromium.org
-stuartmorgan@chromium.org
diff --git a/chrome/browser/dom_ui/options/about_page_handler.cc b/chrome/browser/dom_ui/options/about_page_handler.cc
deleted file mode 100644
index 703d1f9..0000000
--- a/chrome/browser/dom_ui/options/about_page_handler.cc
+++ /dev/null
@@ -1,419 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/about_page_handler.h"
-
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "base/command_line.h"
-#include "base/i18n/time_formatting.h"
-#include "base/string16.h"
-#include "base/string_number_conversions.h"
-#include "base/time.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/google/google_util.h"
-#include "chrome/browser/platform_util.h"
-#include "chrome/common/chrome_version_info.h"
-#include "chrome/common/url_constants.h"
-#include "googleurl/src/gurl.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"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "webkit/glue/webkit_glue.h"
-
-#if defined(CHROME_V8)
-#include "v8/include/v8.h"
-#endif
-
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/cros/cros_library.h"
-#include "chrome/browser/chromeos/cros/power_library.h"
-#include "chrome/browser/chromeos/cros/update_library.h"
-#include "chrome/browser/chromeos/login/user_manager.h"
-#include "chrome/browser/chromeos/login/wizard_controller.h"
-#endif
-
-namespace {
-
-// These are used as placeholder text around the links in the text in the
-// license.
-const char kBeginLink[] = "BEGIN_LINK";
-const char kEndLink[] = "END_LINK";
-const char kBeginLinkChr[] = "BEGIN_LINK_CHR";
-const char kBeginLinkOss[] = "BEGIN_LINK_OSS";
-const char kEndLinkChr[] = "END_LINK_CHR";
-const char kEndLinkOss[] = "END_LINK_OSS";
-#if defined(OS_CHROMEOS)
-const char kBeginLinkCrosOss[] = "BEGIN_LINK_CROS_OSS";
-const char kEndLinkCrosOss[] = "END_LINK_CROS_OSS";
-#endif
-
-// Returns a substring [start, end) from |text|.
-std::string StringSubRange(const std::string& text, size_t start,
- size_t end) {
- DCHECK(end > start);
- return text.substr(start, end - start);
-}
-
-} // namespace
-
-#if defined(OS_CHROMEOS)
-
-class AboutPageHandler::UpdateObserver
- : public chromeos::UpdateLibrary::Observer {
- public:
- explicit UpdateObserver(AboutPageHandler* handler) : page_handler_(handler) {}
- virtual ~UpdateObserver() {}
-
- private:
- virtual void UpdateStatusChanged(chromeos::UpdateLibrary* object) {
- page_handler_->UpdateStatus(object->status());
- }
-
- AboutPageHandler* page_handler_;
-
- DISALLOW_COPY_AND_ASSIGN(UpdateObserver);
-};
-
-#endif
-
-AboutPageHandler::AboutPageHandler()
-#if defined(OS_CHROMEOS)
- : progress_(-1),
- sticky_(false),
- started_(false)
-#endif
-{}
-
-AboutPageHandler::~AboutPageHandler() {
-#if defined(OS_CHROMEOS)
- if (update_observer_.get()) {
- chromeos::CrosLibrary::Get()->GetUpdateLibrary()->
- RemoveObserver(update_observer_.get());
- }
-#endif
-}
-
-void AboutPageHandler::GetLocalizedValues(DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- static OptionsStringResource resources[] = {
-#if defined (OS_CHROMEOS)
- { "product", IDS_PRODUCT_OS_NAME },
- { "os", IDS_PRODUCT_OS_NAME },
- { "loading", IDS_ABOUT_PAGE_LOADING },
- { "check_now", IDS_ABOUT_PAGE_CHECK_NOW },
- { "update_status", IDS_UPGRADE_CHECK_STARTED },
- { "restart_now", IDS_RELAUNCH_AND_UPDATE },
-#else
- { "product", IDS_PRODUCT_NAME },
- { "check_now", IDS_ABOUT_CHROME_UPDATE_CHECK },
-#endif
- { "browser", IDS_PRODUCT_NAME },
- { "more_info", IDS_ABOUT_PAGE_MORE_INFO },
- { "copyright", IDS_ABOUT_VERSION_COPYRIGHT },
- { "channel", IDS_ABOUT_PAGE_CHANNEL },
- { "release", IDS_ABOUT_PAGE_CHANNEL_RELEASE },
- { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA },
- { "development", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT },
- { "canary", IDS_ABOUT_PAGE_CHANNEL_CANARY },
- { "channel_warning_header", IDS_ABOUT_PAGE_CHANNEL_WARNING_HEADER },
- { "channel_warning_text", IDS_ABOUT_PAGE_CHANNEL_WARNING_TEXT },
- { "user_agent", IDS_ABOUT_VERSION_USER_AGENT },
- { "command_line", IDS_ABOUT_VERSION_COMMAND_LINE },
- };
-
- RegisterStrings(localized_strings, resources, arraysize(resources));
- RegisterTitle(localized_strings, "aboutPage", IDS_ABOUT_TAB_TITLE);
-
- // browser version
-
- chrome::VersionInfo version_info;
- DCHECK(version_info.is_valid());
-
- std::string browser_version = version_info.Version();
- std::string version_modifier = platform_util::GetVersionStringModifier();
- if (!version_modifier.empty())
- browser_version += " " + version_modifier;
-
-#if !defined(GOOGLE_CHROME_BUILD)
- browser_version += " (";
- browser_version += version_info.LastChange();
- browser_version += ")";
-#endif
-
- localized_strings->SetString("browser_version", browser_version);
-
- // license
-
- std::string text = l10n_util::GetStringUTF8(IDS_ABOUT_VERSION_LICENSE);
-
- bool chromium_url_appears_first =
- text.find(kBeginLinkChr) < text.find(kBeginLinkOss);
-
- size_t link1 = text.find(kBeginLink);
- DCHECK(link1 != std::string::npos);
- size_t link1_end = text.find(kEndLink, link1);
- DCHECK(link1_end != std::string::npos);
- size_t link2 = text.find(kBeginLink, link1_end);
- DCHECK(link2 != std::string::npos);
- size_t link2_end = text.find(kEndLink, link2);
- DCHECK(link2_end != std::string::npos);
-
- localized_strings->SetString("license_content_0", text.substr(0, link1));
- localized_strings->SetString("license_content_1",
- StringSubRange(text, link1_end + strlen(kEndLinkOss), link2));
- localized_strings->SetString("license_content_2",
- text.substr(link2_end + strlen(kEndLinkOss)));
-
- // The Chromium link within the main text of the dialog.
- localized_strings->SetString(chromium_url_appears_first ?
- "license_link_content_0" : "license_link_content_1",
- StringSubRange(text,
- text.find(kBeginLinkChr) + strlen(kBeginLinkChr),
- text.find(kEndLinkChr)));
- GURL url = google_util::AppendGoogleLocaleParam(
- GURL(chrome::kChromiumProjectURL));
- localized_strings->SetString(chromium_url_appears_first ?
- "license_link_0" : "license_link_1", url.spec());
-
- // The Open Source link within the main text of the dialog. We need to use
- // the chrome:// variant instead of about:credits; the latter will get
- // rewritten to about:blank.
- localized_strings->SetString(chromium_url_appears_first ?
- "license_link_content_1" : "license_link_content_0",
- StringSubRange(text,
- text.find(kBeginLinkOss) + strlen(kBeginLinkOss),
- text.find(kEndLinkOss)));
- localized_strings->SetString(chromium_url_appears_first ?
- "license_link_1" : "license_link_0", chrome::kChromeUIAboutCreditsURL);
-
-#if defined(OS_CHROMEOS)
- std::string cros_text =
- l10n_util::GetStringUTF8(IDS_ABOUT_CROS_VERSION_LICENSE);
-
- size_t cros_link = cros_text.find(kBeginLinkCrosOss);
- DCHECK(cros_link != std::string::npos);
- size_t cros_link_end = cros_text.find(kEndLinkCrosOss, cros_link);
- DCHECK(cros_link_end != std::string::npos);
-
- localized_strings->SetString("cros_license_content_0",
- cros_text.substr(0, cros_link));
- localized_strings->SetString("cros_license_content_1",
- cros_text.substr(cros_link_end + strlen(kEndLinkCrosOss)));
- localized_strings->SetString("cros_license_link_content_0",
- StringSubRange(cros_text, cros_link + strlen(kBeginLinkCrosOss),
- cros_link_end));
- localized_strings->SetString("cros_license_link_0",
- chrome::kChromeUIAboutOSCreditsURL);
-#endif
-
- // webkit
-
- localized_strings->SetString("webkit_version",
- webkit_glue::GetWebKitVersion());
-
- // javascript
-
-#if defined(CHROME_V8)
- localized_strings->SetString("js_engine", "V8");
- localized_strings->SetString("js_engine_version", v8::V8::GetVersion());
-#else
- localized_strings->SetString("js_engine", "JavaScriptCore");
- localized_strings->SetString("js_engine_version",
- webkit_glue::GetWebKitVersion());
-#endif
-
- // user agent
-
- localized_strings->SetString("user_agent_info",
- webkit_glue::GetUserAgent(GURL()));
-
- // command line
-
-#if defined(OS_WIN)
- localized_strings->SetString("command_line_info",
- WideToUTF16(CommandLine::ForCurrentProcess()->command_line_string()));
-#elif defined(OS_POSIX)
- // TODO(viettrungluu): something horrible might happen if there are non-UTF-8
- // arguments (since |SetString()| requires Unicode).
- std::string command_line = "";
- typedef std::vector<std::string> ArgvList;
- const ArgvList& argv = CommandLine::ForCurrentProcess()->argv();
- for (ArgvList::const_iterator iter = argv.begin(); iter != argv.end(); iter++)
- command_line += " " + *iter;
- localized_strings->SetString("command_line_info", command_line);
-#endif
-}
-
-void AboutPageHandler::RegisterMessages() {
- web_ui_->RegisterMessageCallback("PageReady",
- NewCallback(this, &AboutPageHandler::PageReady));
- web_ui_->RegisterMessageCallback("SetReleaseTrack",
- NewCallback(this, &AboutPageHandler::SetReleaseTrack));
-
-#if defined(OS_CHROMEOS)
- web_ui_->RegisterMessageCallback("CheckNow",
- NewCallback(this, &AboutPageHandler::CheckNow));
- web_ui_->RegisterMessageCallback("RestartNow",
- NewCallback(this, &AboutPageHandler::RestartNow));
-#endif
-}
-
-void AboutPageHandler::PageReady(const ListValue* args) {
-#if defined(OS_CHROMEOS)
- // Version information is loaded from a callback
- loader_.GetVersion(&consumer_,
- NewCallback(this, &AboutPageHandler::OnOSVersion),
- chromeos::VersionLoader::VERSION_FULL);
-
- chromeos::UpdateLibrary* update_library =
- chromeos::CrosLibrary::Get()->GetUpdateLibrary();
-
- // Update the channel information.
- std::string channel = update_library->GetReleaseTrack();
- scoped_ptr<Value> channel_string(Value::CreateStringValue(channel));
- web_ui_->CallJavascriptFunction(L"AboutPage.updateSelectedOptionCallback",
- *channel_string);
-
- update_observer_.reset(new UpdateObserver(this));
- update_library->AddObserver(update_observer_.get());
-
- // Update the WebUI page with the current status. See comments below.
- UpdateStatus(update_library->status());
-
- // Initiate update check. UpdateStatus() below will be called when we
- // get update status via update_observer_. If the update has been
- // already complete, update_observer_ won't receive a notification.
- // This is why we manually update the WebUI page above.
- CheckNow(NULL);
-#endif
-}
-
-void AboutPageHandler::SetReleaseTrack(const ListValue* args) {
-#if defined(OS_CHROMEOS)
- if (!chromeos::UserManager::Get()->current_user_is_owner()) {
- LOG(WARNING) << "Non-owner tried to change release track.";
- return;
- }
- const std::string channel = WideToUTF8(ExtractStringValue(args));
- chromeos::CrosLibrary::Get()->GetUpdateLibrary()->SetReleaseTrack(channel);
-#endif
-}
-
-#if defined(OS_CHROMEOS)
-
-void AboutPageHandler::CheckNow(const ListValue* args) {
- // Make sure that libcros is loaded and OOBE is complete.
- if (chromeos::CrosLibrary::Get()->EnsureLoaded() &&
- (!WizardController::default_controller() ||
- WizardController::IsDeviceRegistered())) {
- chromeos::CrosLibrary::Get()->GetUpdateLibrary()->CheckForUpdate();
- }
-}
-
-void AboutPageHandler::RestartNow(const ListValue* args) {
- chromeos::CrosLibrary::Get()->GetPowerLibrary()->RequestRestart();
-}
-
-void AboutPageHandler::UpdateStatus(
- const chromeos::UpdateLibrary::Status& status) {
- string16 message;
- std::string image = "up-to-date";
- bool enabled = false;
-
- switch (status.status) {
- case chromeos::UPDATE_STATUS_IDLE:
- if (!sticky_) {
- message = l10n_util::GetStringFUTF16(IDS_UPGRADE_ALREADY_UP_TO_DATE,
- l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME));
- enabled = true;
- }
- break;
- case chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE:
- message = l10n_util::GetStringUTF16(IDS_UPGRADE_CHECK_STARTED);
- sticky_ = false;
- break;
- case chromeos::UPDATE_STATUS_UPDATE_AVAILABLE:
- message = l10n_util::GetStringUTF16(IDS_UPDATE_AVAILABLE);
- started_ = true;
- break;
- case chromeos::UPDATE_STATUS_DOWNLOADING:
- {
- int progress = static_cast<int>(status.download_progress * 100.0);
- if (progress != progress_) {
- progress_ = progress;
- message = l10n_util::GetStringFUTF16Int(IDS_UPDATE_DOWNLOADING,
- progress_);
- }
- started_ = true;
- }
- break;
- case chromeos::UPDATE_STATUS_VERIFYING:
- message = l10n_util::GetStringUTF16(IDS_UPDATE_VERIFYING);
- started_ = true;
- break;
- case chromeos::UPDATE_STATUS_FINALIZING:
- message = l10n_util::GetStringUTF16(IDS_UPDATE_FINALIZING);
- started_ = true;
- break;
- case chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT:
- message = l10n_util::GetStringUTF16(IDS_UPDATE_COMPLETED);
- image = "available";
- sticky_ = true;
- break;
- default:
- // case UPDATE_STATUS_ERROR:
- // case UPDATE_STATUS_REPORTING_ERROR_EVENT:
-
- // The error is only displayed if we were able to determine an
- // update was available.
- if (started_) {
- message = l10n_util::GetStringUTF16(IDS_UPDATE_ERROR);
- image = "fail";
- enabled = true;
- sticky_ = true;
- started_ = false;
- }
- break;
- }
- if (message.size()) {
- scoped_ptr<Value> update_message(Value::CreateStringValue(message));
- // "Checking for update..." needs to be shown for a while, so users
- // can read it, hence insert delay for this.
- scoped_ptr<Value> insert_delay(Value::CreateBooleanValue(
- status.status == chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE));
- web_ui_->CallJavascriptFunction(L"AboutPage.updateStatusCallback",
- *update_message, *insert_delay);
-
- scoped_ptr<Value> enabled_value(Value::CreateBooleanValue(enabled));
- web_ui_->CallJavascriptFunction(L"AboutPage.updateEnableCallback",
- *enabled_value);
-
- scoped_ptr<Value> image_string(Value::CreateStringValue(image));
- web_ui_->CallJavascriptFunction(L"AboutPage.setUpdateImage",
- *image_string);
- }
- // We'll change the "Check For Update" button to "Restart" button.
- if (status.status == chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT) {
- web_ui_->CallJavascriptFunction(L"AboutPage.changeToRestartButton");
- }
-}
-
-void AboutPageHandler::OnOSVersion(chromeos::VersionLoader::Handle handle,
- std::string version) {
- if (version.size()) {
- scoped_ptr<Value> version_string(Value::CreateStringValue(version));
- web_ui_->CallJavascriptFunction(L"AboutPage.updateOSVersionCallback",
- *version_string);
- }
-}
-#endif
diff --git a/chrome/browser/dom_ui/options/about_page_handler.h b/chrome/browser/dom_ui/options/about_page_handler.h
index 60fefbc..09b96ff 100644
--- a/chrome/browser/dom_ui/options/about_page_handler.h
+++ b/chrome/browser/dom_ui/options/about_page_handler.h
@@ -1,65 +1,12 @@
-// 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.
#ifndef CHROME_BROWSER_DOM_UI_OPTIONS_ABOUT_PAGE_HANDLER_H_
#define CHROME_BROWSER_DOM_UI_OPTIONS_ABOUT_PAGE_HANDLER_H_
+#pragma once
-#include <string>
-
-#include "chrome/browser/dom_ui/options/options_ui.h"
-
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/cros/update_library.h"
-#include "chrome/browser/chromeos/version_loader.h"
-#endif
-
-// ChromeOS about page UI handler.
-class AboutPageHandler : public OptionsPageUIHandler {
- public:
- AboutPageHandler();
- virtual ~AboutPageHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
- virtual void RegisterMessages();
-
- private:
- // The function is called from JavaScript when the about page is ready.
- void PageReady(const ListValue* args);
-
- // The function is called from JavaScript to set the release track like
- // "beta-channel" and "dev-channel".
- void SetReleaseTrack(const ListValue* args);
-
-#if defined(OS_CHROMEOS)
- // Initiates update check.
- void CheckNow(const ListValue* args);
-
- // Restarts the system.
- void RestartNow(const ListValue* args);
-
- // Callback from chromeos::VersionLoader giving the version.
- void OnOSVersion(chromeos::VersionLoader::Handle handle,
- std::string version);
- void UpdateStatus(const chromeos::UpdateLibrary::Status& status);
-
- // Handles asynchronously loading the version.
- chromeos::VersionLoader loader_;
-
- // Used to request the version.
- CancelableRequestConsumer consumer_;
-
- // Update Observer
- class UpdateObserver;
- scoped_ptr<UpdateObserver> update_observer_;
-
- int progress_;
- bool sticky_;
- bool started_;
-#endif
-
- DISALLOW_COPY_AND_ASSIGN(AboutPageHandler);
-};
+#include "chrome/browser/webui/options/about_page_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_ABOUT_PAGE_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/add_startup_page_handler.cc b/chrome/browser/dom_ui/options/add_startup_page_handler.cc
deleted file mode 100644
index 9ecf5d0..0000000
--- a/chrome/browser/dom_ui/options/add_startup_page_handler.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/add_startup_page_handler.h"
-
-#include "base/string_number_conversions.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/possible_url_model.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/pref_names.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "net/base/net_util.h"
-#include "ui/base/l10n/l10n_util.h"
-
-AddStartupPageHandler::AddStartupPageHandler() {
-}
-
-AddStartupPageHandler::~AddStartupPageHandler() {
- if (url_table_model_.get())
- url_table_model_->SetObserver(NULL);
-}
-
-void AddStartupPageHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
- RegisterTitle(localized_strings, "addStartupPage", IDS_ASI_ADD_TITLE);
- localized_strings->SetString("addStartupPageURLLabel",
- l10n_util::GetStringUTF16(IDS_ASI_URL));
- localized_strings->SetString("addStartupPageAddButton",
- l10n_util::GetStringUTF16(IDS_ASI_ADD));
- localized_strings->SetString("addStartupPageCancelButton",
- l10n_util::GetStringUTF16(IDS_CANCEL));
-}
-
-void AddStartupPageHandler::Initialize() {
- url_table_model_.reset(new PossibleURLModel());
- if (url_table_model_.get()) {
- url_table_model_->SetObserver(this);
- url_table_model_->Reload(web_ui_->GetProfile());
- }
-}
-
-void AddStartupPageHandler::RegisterMessages() {
- web_ui_->RegisterMessageCallback(
- "updateAddStartupFieldWithPage",
- NewCallback(this, &AddStartupPageHandler::UpdateFieldWithRecentPage));
-}
-
-void AddStartupPageHandler::UpdateFieldWithRecentPage(const ListValue* args) {
- int index;
- if (!ExtractIntegerValue(args, &index)) {
- NOTREACHED();
- return;
- }
- std::string languages =
- web_ui_->GetProfile()->GetPrefs()->GetString(prefs::kAcceptLanguages);
- // Because this gets parsed by FixupURL(), it's safe to omit the scheme or
- // trailing slash, and unescape most characters, but we need to not drop any
- // username/password, or unescape anything that changes the meaning.
- string16 url_string = net::FormatUrl(url_table_model_->GetURL(index),
- languages, net::kFormatUrlOmitAll & ~net::kFormatUrlOmitUsernamePassword,
- UnescapeRule::SPACES, NULL, NULL, NULL);
-
- scoped_ptr<Value> url_value(Value::CreateStringValue(url_string));
- web_ui_->CallJavascriptFunction(L"AddStartupPageOverlay.setInputFieldValue",
- *url_value.get());
-}
-
-void AddStartupPageHandler::OnModelChanged() {
- ListValue pages;
- for (int i = 0; i < url_table_model_->RowCount(); ++i) {
- DictionaryValue* dict = new DictionaryValue();
- dict->SetString("title", url_table_model_->GetText(i, IDS_ASI_PAGE_COLUMN));
- dict->SetString("displayURL",
- url_table_model_->GetText(i, IDS_ASI_URL_COLUMN));
- dict->SetString("url", url_table_model_->GetURL(i).spec());
- pages.Append(dict);
- }
-
- web_ui_->CallJavascriptFunction(L"AddStartupPageOverlay.updateRecentPageList",
- pages);
-}
-
-void AddStartupPageHandler::OnItemsChanged(int start, int length) {
- OnModelChanged();
-}
-
-void AddStartupPageHandler::OnItemsAdded(int start, int length) {
- OnModelChanged();
-}
-
-void AddStartupPageHandler::OnItemsRemoved(int start, int length) {
- OnModelChanged();
-}
diff --git a/chrome/browser/dom_ui/options/add_startup_page_handler.h b/chrome/browser/dom_ui/options/add_startup_page_handler.h
index da87a82..e251bcf 100644
--- a/chrome/browser/dom_ui/options/add_startup_page_handler.h
+++ b/chrome/browser/dom_ui/options/add_startup_page_handler.h
@@ -6,38 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_ADD_STARTUP_PAGE_HANDLER_H_
#pragma once
-#include "base/basictypes.h"
-#include "chrome/browser/dom_ui/options/options_ui.h"
-#include "ui/base/models/table_model_observer.h"
-
-class PossibleURLModel;
-
-// Chrome personal options page UI handler.
-class AddStartupPageHandler : public OptionsPageUIHandler,
- public ui::TableModelObserver {
- public:
- AddStartupPageHandler();
- virtual ~AddStartupPageHandler();
-
- // OptionsPageUIHandler implementation.
- virtual void Initialize();
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
- virtual void RegisterMessages();
-
- // ui::TableModelObserver implementation.
- virtual void OnModelChanged();
- virtual void OnItemsChanged(int start, int length);
- virtual void OnItemsAdded(int start, int length);
- virtual void OnItemsRemoved(int start, int length);
-
- private:
- // Request to update the text field with the URL of the recent page at the
- // given index, formatted for user input. Called from WebUI.
- void UpdateFieldWithRecentPage(const ListValue* args);
-
- scoped_ptr<PossibleURLModel> url_table_model_;
-
- DISALLOW_COPY_AND_ASSIGN(AddStartupPageHandler);
-};
+#include "chrome/browser/webui/options/add_startup_page_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_ADD_STARTUP_PAGE_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/advanced_options_handler.cc b/chrome/browser/dom_ui/options/advanced_options_handler.cc
deleted file mode 100644
index 1d9152c..0000000
--- a/chrome/browser/dom_ui/options/advanced_options_handler.cc
+++ /dev/null
@@ -1,659 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/advanced_options_handler.h"
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "base/command_line.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/dom_ui/options/dom_options_util.h"
-#include "chrome/browser/dom_ui/options/options_managed_banner_handler.h"
-#include "chrome/browser/download/download_manager.h"
-#include "chrome/browser/download/download_prefs.h"
-#include "chrome/browser/google/google_util.h"
-#include "chrome/browser/metrics/user_metrics.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/remoting/setup_flow.h"
-#include "chrome/browser/service/service_process_control.h"
-#include "chrome/browser/service/service_process_control_manager.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/browser/tab_contents/tab_contents_view.h"
-#include "chrome/browser/ui/options/options_util.h"
-#include "chrome/browser/ui/options/options_window.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/notification_details.h"
-#include "chrome/common/notification_type.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/url_constants.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "ui/base/l10n/l10n_util.h"
-
-#if !defined(OS_CHROMEOS)
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/dom_ui/options/advanced_options_utils.h"
-#endif
-
-#if defined(OS_WIN)
-#include "chrome/browser/gears_integration.h"
-#include "net/base/ssl_config_service_win.h"
-#endif
-
-AdvancedOptionsHandler::AdvancedOptionsHandler() {
-#if defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)
- cloud_print_proxy_ui_enabled_ = true;
-#elif !defined(OS_CHROMEOS)
- cloud_print_proxy_ui_enabled_ =
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableCloudPrintProxy);
-#endif
-}
-
-AdvancedOptionsHandler::~AdvancedOptionsHandler() {
-}
-
-void AdvancedOptionsHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- static OptionsStringResource resources[] = {
- { "downloadLocationGroupName",
- IDS_OPTIONS_DOWNLOADLOCATION_GROUP_NAME },
- { "downloadLocationChangeButton",
- IDS_OPTIONS_DOWNLOADLOCATION_CHANGE_BUTTON },
- { "downloadLocationBrowseTitle",
- IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE },
- { "downloadLocationBrowseWindowTitle",
- IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_WINDOW_TITLE },
- { "downloadLocationAskForSaveLocation",
- IDS_OPTIONS_DOWNLOADLOCATION_ASKFORSAVELOCATION },
- { "autoOpenFileTypesInfo",
- IDS_OPTIONS_OPEN_FILE_TYPES_AUTOMATICALLY },
- { "autoOpenFileTypesResetToDefault",
- IDS_OPTIONS_AUTOOPENFILETYPES_RESETTODEFAULT },
- { "gearSettingsConfigureGearsButton",
- IDS_OPTIONS_GEARSSETTINGS_CONFIGUREGEARS_BUTTON },
- { "translateEnableTranslate",
- IDS_OPTIONS_TRANSLATE_ENABLE_TRANSLATE },
- { "certificatesManageButton",
- IDS_OPTIONS_CERTIFICATES_MANAGE_BUTTON },
- { "proxiesLabel",
- IDS_OPTIONS_PROXIES_LABEL },
- { "proxiesConfigureButton",
- IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON },
- { "safeBrowsingEnableProtection",
- IDS_OPTIONS_SAFEBROWSING_ENABLEPROTECTION },
- { "sslGroupDescription",
- IDS_OPTIONS_SSL_GROUP_DESCRIPTION },
- { "sslCheckRevocation",
- IDS_OPTIONS_SSL_CHECKREVOCATION },
- { "sslUseSSL3",
- IDS_OPTIONS_SSL_USESSL3 },
- { "sslUseTLS1",
- IDS_OPTIONS_SSL_USETLS1 },
- { "networkDNSPrefetchEnabledDescription",
- IDS_NETWORK_DNS_PREFETCH_ENABLED_DESCRIPTION },
- { "privacyContentSettingsButton",
- IDS_OPTIONS_PRIVACY_CONTENT_SETTINGS_BUTTON },
- { "privacyClearDataButton",
- IDS_OPTIONS_PRIVACY_CLEAR_DATA_BUTTON },
- { "linkDoctorPref",
- IDS_OPTIONS_LINKDOCTOR_PREF },
- { "suggestPref",
- IDS_OPTIONS_SUGGEST_PREF },
- { "tabsToLinksPref",
- IDS_OPTIONS_TABS_TO_LINKS_PREF },
- { "fontSettingsInfo",
- IDS_OPTIONS_FONTSETTINGS_INFO },
- { "defaultZoomLevelLabel",
- IDS_OPTIONS_DEFAULT_ZOOM_LEVEL_LABEL },
- { "defaultFontSizeLabel",
- IDS_OPTIONS_DEFAULT_FONT_SIZE_LABEL },
- { "fontSizeLabelVerySmall",
- IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL },
- { "fontSizeLabelSmall",
- IDS_OPTIONS_FONT_SIZE_LABEL_SMALL },
- { "fontSizeLabelMedium",
- IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM },
- { "fontSizeLabelLarge",
- IDS_OPTIONS_FONT_SIZE_LABEL_LARGE },
- { "fontSizeLabelVeryLarge",
- IDS_OPTIONS_FONT_SIZE_LABEL_VERY_LARGE },
- { "fontSizeLabelCustom",
- IDS_OPTIONS_FONT_SIZE_LABEL_CUSTOM },
- { "fontSettingsCustomizeFontsButton",
- IDS_OPTIONS_FONTSETTINGS_CUSTOMIZE_FONTS_BUTTON },
- { "languageAndSpellCheckSettingsButton",
- IDS_OPTIONS_LANGUAGE_AND_SPELLCHECK_BUTTON },
- { "advancedSectionTitlePrivacy",
- IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY },
- { "advancedSectionTitleContent",
- IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT },
- { "advancedSectionTitleSecurity",
- IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY },
- { "advancedSectionTitleNetwork",
- IDS_OPTIONS_ADVANCED_SECTION_TITLE_NETWORK },
- { "advancedSectionTitleTranslate",
- IDS_OPTIONS_ADVANCED_SECTION_TITLE_TRANSLATE },
- { "translateEnableTranslate",
- IDS_OPTIONS_TRANSLATE_ENABLE_TRANSLATE },
- { "enableLogging",
- IDS_OPTIONS_ENABLE_LOGGING },
- { "improveBrowsingExperience",
- IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE },
- { "disableWebServices",
- IDS_OPTIONS_DISABLE_WEB_SERVICES },
-#if !defined(OS_CHROMEOS)
- { "advancedSectionTitleCloudPrint",
- IDS_OPTIONS_ADVANCED_SECTION_TITLE_CLOUD_PRINT },
- { "cloudPrintProxyDisabledLabel",
- IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_LABEL },
- { "cloudPrintProxyDisabledButton",
- IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_BUTTON },
- { "cloudPrintProxyEnabledButton",
- IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_BUTTON },
- { "cloudPrintProxyEnabledManageButton",
- IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_MANAGE_BUTTON },
- { "cloudPrintProxyEnablingButton",
- IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLING_BUTTON },
-#endif
-#if defined(ENABLE_REMOTING)
- { "advancedSectionTitleRemoting",
- IDS_OPTIONS_ADVANCED_SECTION_TITLE_REMOTING },
- { "remotingSetupButton",
- IDS_OPTIONS_REMOTING_SETUP_BUTTON },
- { "remotingStopButton",
- IDS_OPTIONS_REMOTING_STOP_BUTTON },
-#endif
- };
-
- RegisterStrings(localized_strings, resources, arraysize(resources));
- RegisterTitle(localized_strings, "advancedPage",
- IDS_OPTIONS_ADVANCED_TAB_LABEL);
-
- localized_strings->SetString("privacyLearnMoreURL",
- google_util::AppendGoogleLocaleParam(
- GURL(chrome::kPrivacyLearnMoreURL)).spec());
-}
-
-void AdvancedOptionsHandler::Initialize() {
- DCHECK(web_ui_);
- SetupMetricsReportingCheckbox();
- SetupMetricsReportingSettingVisibility();
- SetupFontSizeLabel();
- SetupDownloadLocationPath();
- SetupPromptForDownload();
- SetupAutoOpenFileTypesDisabledAttribute();
- SetupProxySettingsSection();
-#if defined(OS_WIN)
- SetupSSLConfigSettings();
-#endif
-#if !defined(OS_CHROMEOS)
- if (cloud_print_proxy_ui_enabled_) {
- SetupCloudPrintProxySection();
- RefreshCloudPrintStatusFromService();
- } else {
- RemoveCloudPrintProxySection();
- }
-#endif
-#if defined(ENABLE_REMOTING) && !defined(OS_CHROMEOS)
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableRemoting)) {
- RemoveRemotingSection();
- } else {
- remoting_options_handler_.Init(web_ui_);
- }
-#endif
-
- banner_handler_.reset(
- new OptionsManagedBannerHandler(web_ui_,
- ASCIIToUTF16("AdvancedOptions"),
- OPTIONS_PAGE_ADVANCED));
-}
-
-WebUIMessageHandler* AdvancedOptionsHandler::Attach(WebUI* web_ui) {
- // Call through to superclass.
- WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui);
-
- // Register for preferences that we need to observe manually. These have
- // special behaviors that aren't handled by the standard prefs UI.
- DCHECK(web_ui_);
- PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
-#if !defined(OS_CHROMEOS)
- enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled,
- g_browser_process->local_state(), this);
- cloud_print_proxy_email_.Init(prefs::kCloudPrintEmail, prefs, this);
- cloud_print_proxy_enabled_.Init(prefs::kCloudPrintProxyEnabled, prefs, this);
-#endif
- default_download_location_.Init(prefs::kDownloadDefaultDirectory,
- prefs, this);
- ask_for_save_location_.Init(prefs::kPromptForDownload, prefs, this);
- auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this);
- default_font_size_.Init(prefs::kWebKitDefaultFontSize, prefs, this);
- default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize, prefs,
- this);
- proxy_prefs_.reset(
- PrefSetObserver::CreateProxyPrefSetObserver(prefs, this));
-
- // Return result from the superclass.
- return handler;
-}
-
-void AdvancedOptionsHandler::RegisterMessages() {
- // Setup handlers specific to this panel.
- DCHECK(web_ui_);
- web_ui_->RegisterMessageCallback("selectDownloadLocation",
- NewCallback(this,
- &AdvancedOptionsHandler::HandleSelectDownloadLocation));
- web_ui_->RegisterMessageCallback("promptForDownloadAction",
- NewCallback(this,
- &AdvancedOptionsHandler::HandlePromptForDownload));
- web_ui_->RegisterMessageCallback("autoOpenFileTypesAction",
- NewCallback(this,
- &AdvancedOptionsHandler::HandleAutoOpenButton));
- web_ui_->RegisterMessageCallback("defaultFontSizeAction",
- NewCallback(this, &AdvancedOptionsHandler::HandleDefaultFontSize));
-#if !defined(OS_CHROMEOS)
- web_ui_->RegisterMessageCallback("metricsReportingCheckboxAction",
- NewCallback(this,
- &AdvancedOptionsHandler::HandleMetricsReportingCheckbox));
-#endif
-#if !defined(USE_NSS) && !defined(USE_OPENSSL)
- web_ui_->RegisterMessageCallback("showManageSSLCertificates",
- NewCallback(this,
- &AdvancedOptionsHandler::ShowManageSSLCertificates));
-#endif
-#if !defined(OS_CHROMEOS)
- if (cloud_print_proxy_ui_enabled_) {
- web_ui_->RegisterMessageCallback("showCloudPrintSetupDialog",
- NewCallback(this,
- &AdvancedOptionsHandler::ShowCloudPrintSetupDialog));
- web_ui_->RegisterMessageCallback("disableCloudPrintProxy",
- NewCallback(this,
- &AdvancedOptionsHandler::HandleDisableCloudPrintProxy));
- web_ui_->RegisterMessageCallback("showCloudPrintManagePage",
- NewCallback(this,
- &AdvancedOptionsHandler::ShowCloudPrintManagePage));
- }
- web_ui_->RegisterMessageCallback("showNetworkProxySettings",
- NewCallback(this,
- &AdvancedOptionsHandler::ShowNetworkProxySettings));
-#endif
-#if defined(ENABLE_REMOTING) && !defined(OS_CHROMEOS)
- web_ui_->RegisterMessageCallback("showRemotingSetupDialog",
- NewCallback(this,
- &AdvancedOptionsHandler::ShowRemotingSetupDialog));
- web_ui_->RegisterMessageCallback("disableRemoting",
- NewCallback(this,
- &AdvancedOptionsHandler::DisableRemoting));
-#endif
-#if defined(OS_WIN)
- // Setup Windows specific callbacks.
- web_ui_->RegisterMessageCallback("checkRevocationCheckboxAction",
- NewCallback(this,
- &AdvancedOptionsHandler::HandleCheckRevocationCheckbox));
- web_ui_->RegisterMessageCallback("useSSL3CheckboxAction",
- NewCallback(this,
- &AdvancedOptionsHandler::HandleUseSSL3Checkbox));
- web_ui_->RegisterMessageCallback("useTLS1CheckboxAction",
- NewCallback(this,
- &AdvancedOptionsHandler::HandleUseTLS1Checkbox));
- web_ui_->RegisterMessageCallback("showGearsSettings",
- NewCallback(this,
- &AdvancedOptionsHandler::HandleShowGearsSettings));
-#endif
-}
-
-void AdvancedOptionsHandler::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- if (type == NotificationType::PREF_CHANGED) {
- std::string* pref_name = Details<std::string>(details).ptr();
- if ((*pref_name == prefs::kDownloadDefaultDirectory) ||
- (*pref_name == prefs::kPromptForDownload)) {
- SetupDownloadLocationPath();
- SetupPromptForDownload();
- } else if (*pref_name == prefs::kDownloadExtensionsToOpen) {
- SetupAutoOpenFileTypesDisabledAttribute();
- } else if (proxy_prefs_->IsObserved(*pref_name)) {
- SetupProxySettingsSection();
- } else if ((*pref_name == prefs::kCloudPrintEmail) ||
- (*pref_name == prefs::kCloudPrintProxyEnabled)) {
-#if !defined(OS_CHROMEOS)
- if (cloud_print_proxy_ui_enabled_)
- SetupCloudPrintProxySection();
-#endif
- } else if (*pref_name == prefs::kWebKitDefaultFontSize ||
- *pref_name == prefs::kWebKitDefaultFixedFontSize) {
- SetupFontSizeLabel();
- }
- }
-}
-
-void AdvancedOptionsHandler::HandleSelectDownloadLocation(
- const ListValue* args) {
- PrefService* pref_service = web_ui_->GetProfile()->GetPrefs();
- select_folder_dialog_ = SelectFileDialog::Create(this);
- select_folder_dialog_->SelectFile(
- SelectFileDialog::SELECT_FOLDER,
- l10n_util::GetStringUTF16(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE),
- pref_service->GetFilePath(prefs::kDownloadDefaultDirectory),
- NULL, 0, FILE_PATH_LITERAL(""),
- web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(), NULL);
-}
-
-void AdvancedOptionsHandler::HandlePromptForDownload(
- const ListValue* args) {
- std::string checked_str = WideToUTF8(ExtractStringValue(args));
- ask_for_save_location_.SetValue(checked_str == "true");
-}
-
-void AdvancedOptionsHandler::FileSelected(const FilePath& path, int index,
- void* params) {
- UserMetricsRecordAction(UserMetricsAction("Options_SetDownloadDirectory"));
- default_download_location_.SetValue(path);
- SetupDownloadLocationPath();
-}
-
-void AdvancedOptionsHandler::OnDialogClosed() {
-#if !defined(OS_CHROMEOS)
- if (cloud_print_proxy_ui_enabled_)
- SetupCloudPrintProxySection();
-#endif
-}
-
-void AdvancedOptionsHandler::HandleAutoOpenButton(const ListValue* args) {
- UserMetricsRecordAction(UserMetricsAction("Options_ResetAutoOpenFiles"));
- DownloadManager* manager = web_ui_->GetProfile()->GetDownloadManager();
- if (manager)
- manager->download_prefs()->ResetAutoOpen();
-}
-
-void AdvancedOptionsHandler::HandleMetricsReportingCheckbox(
- const ListValue* args) {
-#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
- std::string checked_str = WideToUTF8(ExtractStringValue(args));
- bool enabled = checked_str == "true";
- UserMetricsRecordAction(
- enabled ?
- UserMetricsAction("Options_MetricsReportingCheckbox_Enable") :
- UserMetricsAction("Options_MetricsReportingCheckbox_Disable"));
- bool is_enabled = OptionsUtil::ResolveMetricsReportingEnabled(enabled);
- enable_metrics_recording_.SetValue(is_enabled);
- SetupMetricsReportingCheckbox();
-#endif
-}
-
-void AdvancedOptionsHandler::HandleDefaultFontSize(const ListValue* args) {
- int font_size;
- if (ExtractIntegerValue(args, &font_size)) {
- if (font_size > 0) {
- default_font_size_.SetValue(font_size);
- default_fixed_font_size_.SetValue(font_size);
- SetupFontSizeLabel();
- }
- }
-}
-
-#if defined(OS_WIN)
-void AdvancedOptionsHandler::HandleCheckRevocationCheckbox(
- const ListValue* args) {
- std::string checked_str = WideToUTF8(ExtractStringValue(args));
- bool enabled = checked_str == "true";
- std::string metric =
- (enabled ? "Options_CheckCertRevocation_Enable"
- : "Options_CheckCertRevocation_Disable");
- UserMetricsRecordAction(UserMetricsAction(metric.c_str()));
- net::SSLConfigServiceWin::SetRevCheckingEnabled(enabled);
-}
-
-void AdvancedOptionsHandler::HandleUseSSL3Checkbox(const ListValue* args) {
- std::string checked_str = WideToUTF8(ExtractStringValue(args));
- bool enabled = checked_str == "true";
- std::string metric =
- (enabled ? "Options_SSL3_Enable" : "Options_SSL3_Disable");
- UserMetricsRecordAction(UserMetricsAction(metric.c_str()));
- net::SSLConfigServiceWin::SetSSL3Enabled(enabled);
-}
-
-void AdvancedOptionsHandler::HandleUseTLS1Checkbox(const ListValue* args) {
- std::string checked_str = WideToUTF8(ExtractStringValue(args));
- bool enabled = checked_str == "true";
- std::string metric =
- (enabled ? "Options_TLS1_Enable" : "Options_TLS1_Disable");
- UserMetricsRecordAction(UserMetricsAction(metric.c_str()));
- net::SSLConfigServiceWin::SetTLS1Enabled(enabled);
-}
-
-void AdvancedOptionsHandler::HandleShowGearsSettings(const ListValue* args) {
- UserMetricsRecordAction(UserMetricsAction("Options_GearsSettings"));
- GearsSettingsPressed(
- web_ui_->tab_contents()->view()->GetTopLevelNativeWindow());
-}
-#endif
-
-#if !defined(OS_CHROMEOS)
-void AdvancedOptionsHandler::ShowNetworkProxySettings(const ListValue* args) {
- UserMetricsRecordAction(UserMetricsAction("Options_ShowProxySettings"));
- AdvancedOptionsUtilities::ShowNetworkProxySettings(web_ui_->tab_contents());
-}
-#endif
-
-#if !defined(USE_NSS) && !defined(USE_OPENSSL)
-void AdvancedOptionsHandler::ShowManageSSLCertificates(const ListValue* args) {
- UserMetricsRecordAction(UserMetricsAction("Options_ManageSSLCertificates"));
- AdvancedOptionsUtilities::ShowManageSSLCertificates(web_ui_->tab_contents());
-}
-#endif
-
-#if !defined(OS_CHROMEOS)
-void AdvancedOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) {
- UserMetricsRecordAction(UserMetricsAction("Options_EnableCloudPrintProxy"));
- CloudPrintSetupFlow::OpenDialog(
- web_ui_->GetProfile(), this,
- web_ui_->tab_contents()->GetMessageBoxRootWindow());
-}
-
-void AdvancedOptionsHandler::HandleDisableCloudPrintProxy(
- const ListValue* args) {
- UserMetricsRecordAction(UserMetricsAction("Options_DisableCloudPrintProxy"));
- web_ui_->GetProfile()->GetCloudPrintProxyService()->DisableForUser();
-}
-
-void AdvancedOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) {
- UserMetricsRecordAction(UserMetricsAction("Options_ManageCloudPrinters"));
- // Open a new tab in the current window for the management page.
- web_ui_->tab_contents()->OpenURL(
- CloudPrintURL(web_ui_->GetProfile()).GetCloudPrintServiceManageURL(),
- GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
-}
-
-void AdvancedOptionsHandler::RefreshCloudPrintStatusFromService() {
- DCHECK(web_ui_);
- if (cloud_print_proxy_ui_enabled_)
- web_ui_->GetProfile()->GetCloudPrintProxyService()->
- RefreshStatusFromService();
-}
-
-void AdvancedOptionsHandler::SetupCloudPrintProxySection() {
- if (NULL == web_ui_->GetProfile()->GetCloudPrintProxyService()) {
- cloud_print_proxy_ui_enabled_ = false;
- RemoveCloudPrintProxySection();
- return;
- }
-
- bool cloud_print_proxy_allowed =
- !cloud_print_proxy_enabled_.IsManaged() ||
- cloud_print_proxy_enabled_.GetValue();
- FundamentalValue allowed(cloud_print_proxy_allowed);
-
- std::string email;
- if (web_ui_->GetProfile()->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) &&
- cloud_print_proxy_allowed) {
- email = web_ui_->GetProfile()->GetPrefs()->GetString(
- prefs::kCloudPrintEmail);
- }
- FundamentalValue disabled(email.empty());
-
- string16 label_str;
- if (email.empty()) {
- label_str = l10n_util::GetStringUTF16(
- IDS_OPTIONS_CLOUD_PRINT_PROXY_DISABLED_LABEL);
- } else {
- label_str = l10n_util::GetStringFUTF16(
- IDS_OPTIONS_CLOUD_PRINT_PROXY_ENABLED_LABEL, UTF8ToUTF16(email));
- }
- StringValue label(label_str);
-
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.SetupCloudPrintProxySection",
- disabled, label, allowed);
-}
-
-void AdvancedOptionsHandler::RemoveCloudPrintProxySection() {
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.RemoveCloudPrintProxySection");
-}
-
-#endif
-
-#if defined(ENABLE_REMOTING) && !defined(OS_CHROMEOS)
-void AdvancedOptionsHandler::RemoveRemotingSection() {
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.RemoveRemotingSection");
-}
-
-void AdvancedOptionsHandler::ShowRemotingSetupDialog(const ListValue* args) {
- remoting::SetupFlow::OpenSetupDialog(web_ui_->GetProfile());
-}
-
-void AdvancedOptionsHandler::DisableRemoting(const ListValue* args) {
- ServiceProcessControl* process_control =
- ServiceProcessControlManager::GetInstance()->GetProcessControl(
- web_ui_->GetProfile());
- if (!process_control || !process_control->is_connected())
- return;
- process_control->DisableRemotingHost();
-}
-#endif
-
-void AdvancedOptionsHandler::SetupMetricsReportingCheckbox() {
-#if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS)
- FundamentalValue checked(enable_metrics_recording_.GetValue());
- FundamentalValue disabled(enable_metrics_recording_.IsManaged());
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.SetMetricsReportingCheckboxState", checked,
- disabled);
-#endif
-}
-
-void AdvancedOptionsHandler::SetupMetricsReportingSettingVisibility() {
-#if defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS)
- // Don't show the reporting setting if we are in the guest mode.
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) {
- FundamentalValue visible(false);
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.SetMetricsReportingSettingVisibility",
- visible);
- }
-#endif
-}
-
-void AdvancedOptionsHandler::SetupFontSizeLabel() {
- // We're only interested in integer values, so convert to int.
- FundamentalValue fixed_font_size(default_fixed_font_size_.GetValue());
- FundamentalValue font_size(default_font_size_.GetValue());
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.SetFontSize", fixed_font_size,
- font_size);
-}
-
-void AdvancedOptionsHandler::SetupDownloadLocationPath() {
- StringValue value(default_download_location_.GetValue().value());
- FundamentalValue disabled(default_download_location_.IsManaged());
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.SetDownloadLocationPath", value, disabled);
-}
-
-void AdvancedOptionsHandler::SetupPromptForDownload() {
- FundamentalValue checked(ask_for_save_location_.GetValue());
- FundamentalValue disabled(default_download_location_.IsManaged());
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.SetPromptForDownload", checked, disabled);
-}
-
-void AdvancedOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() {
- // Set the enabled state for the AutoOpenFileTypesResetToDefault button.
- // We enable the button if the user has any auto-open file types registered.
- DownloadManager* manager = web_ui_->GetProfile()->GetDownloadManager();
- bool disabled = !(manager && manager->download_prefs()->IsAutoOpenUsed());
- FundamentalValue value(disabled);
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.SetAutoOpenFileTypesDisabledAttribute", value);
-}
-
-void AdvancedOptionsHandler::SetupProxySettingsSection() {
- // Disable the button if proxy settings are managed by a sysadmin or
- // overridden by an extension.
- PrefService* pref_service = web_ui_->GetProfile()->GetPrefs();
- const PrefService::Preference* proxy_config =
- pref_service->FindPreference(prefs::kProxy);
- bool is_extension_controlled = (proxy_config &&
- proxy_config->IsExtensionControlled());
-
- FundamentalValue disabled(proxy_prefs_->IsManaged() ||
- is_extension_controlled);
-
- // Get the appropriate info string to describe the button.
- string16 label_str;
- if (is_extension_controlled) {
- label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL);
- } else {
- label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL,
- l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
- }
- StringValue label(label_str);
-
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.SetupProxySettingsSection", disabled, label);
-}
-
-#if defined(OS_WIN)
-void AdvancedOptionsHandler::SetupSSLConfigSettings() {
- bool checkRevocationSetting = false;
- bool useSSL3Setting = false;
- bool useTLS1Setting = false;
- bool disabled = false;
-
- net::SSLConfig config;
- if (net::SSLConfigServiceWin::GetSSLConfigNow(&config)) {
- checkRevocationSetting = config.rev_checking_enabled;
- useSSL3Setting = config.ssl3_enabled;
- useTLS1Setting = config.tls1_enabled;
- } else {
- disabled = true;
- }
- FundamentalValue disabledValue(disabled);
- FundamentalValue checkRevocationValue(checkRevocationSetting);
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.SetCheckRevocationCheckboxState",
- checkRevocationValue, disabledValue);
- FundamentalValue useSSL3Value(useSSL3Setting);
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.SetUseSSL3CheckboxState",
- useSSL3Value, disabledValue);
- FundamentalValue useTLS1Value(useTLS1Setting);
- web_ui_->CallJavascriptFunction(
- L"options.AdvancedOptions.SetUseTLS1CheckboxState",
- useTLS1Value, disabledValue);
-}
-#endif
diff --git a/chrome/browser/dom_ui/options/advanced_options_handler.h b/chrome/browser/dom_ui/options/advanced_options_handler.h
index 22ceebe..4b61de1 100644
--- a/chrome/browser/dom_ui/options/advanced_options_handler.h
+++ b/chrome/browser/dom_ui/options/advanced_options_handler.h
@@ -6,178 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_ADVANCED_OPTIONS_HANDLER_H_
#pragma once
-#include "chrome/browser/dom_ui/options/options_ui.h"
-#include "chrome/browser/prefs/pref_member.h"
-#include "chrome/browser/prefs/pref_set_observer.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h"
-#include "chrome/browser/remoting/remoting_options_handler.h"
-#include "chrome/browser/ui/shell_dialogs.h"
-
-class OptionsManagedBannerHandler;
-
-// Chrome advanced options page UI handler.
-class AdvancedOptionsHandler
- : public OptionsPageUIHandler,
- public SelectFileDialog::Listener,
- public CloudPrintSetupFlow::Delegate {
- public:
- AdvancedOptionsHandler();
- virtual ~AdvancedOptionsHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
- virtual void Initialize();
-
- // WebUIMessageHandler implementation.
- virtual WebUIMessageHandler* Attach(WebUI* web_ui);
- virtual void RegisterMessages();
-
- // NotificationObserver implementation.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- // SelectFileDialog::Listener implementation
- virtual void FileSelected(const FilePath& path, int index, void* params);
-
- // CloudPrintSetupFlow::Delegate implementation.
- virtual void OnDialogClosed();
-
- private:
- // Callback for the "selectDownloadLocation" message. This will prompt
- // the user for a destination folder using platform-specific APIs.
- void HandleSelectDownloadLocation(const ListValue* args);
-
- // Callback for the "promptForDownloadAction" message. This will set
- // the ask for save location pref accordingly.
- void HandlePromptForDownload(const ListValue* args);
-
- // Callback for the "autoOpenFileTypesResetToDefault" message. This will
- // remove all auto-open file-type settings.
- void HandleAutoOpenButton(const ListValue* args);
-
- // Callback for the "metricsReportingCheckboxAction" message. This is called
- // if the user toggles the metrics reporting checkbox.
- void HandleMetricsReportingCheckbox(const ListValue* args);
-
- // Callback for the "defaultFontSizeAction" message. This is called if the
- // user changes the default font size. |args| is an array that contains
- // one item, the font size as a numeric value.
- void HandleDefaultFontSize(const ListValue* args);
-
-#if defined(OS_WIN)
- // Callback for the "Check SSL Revocation" checkbox. This is needed so we
- // can support manual handling on Windows.
- void HandleCheckRevocationCheckbox(const ListValue* args);
-
- // Callback for the "Use SSL3" checkbox. This is needed so we can support
- // manual handling on Windows.
- void HandleUseSSL3Checkbox(const ListValue* args);
-
- // Callback for the "Use TLS1" checkbox. This is needed so we can support
- // manual handling on Windows.
- void HandleUseTLS1Checkbox(const ListValue* args);
-
- // Callback for the "Show Gears Settings" button.
- void HandleShowGearsSettings(const ListValue* args);
-#endif
-
-#if !defined(OS_CHROMEOS)
- // Callback for the "showNetworkProxySettings" message. This will invoke
- // an appropriate dialog for configuring proxy settings.
- void ShowNetworkProxySettings(const ListValue* args);
-#endif
-
-#if !defined(USE_NSS)
- // Callback for the "showManageSSLCertificates" message. This will invoke
- // an appropriate certificate management action based on the platform.
- void ShowManageSSLCertificates(const ListValue* args);
-#endif
-
-#if !defined(OS_CHROMEOS)
- // Callback for the Sign in to Cloud Print button. This will start
- // the authentication process.
- void ShowCloudPrintSetupDialog(const ListValue* args);
-
- // Callback for the Disable Cloud Print button. This will sign out
- // of cloud print.
- void HandleDisableCloudPrintProxy(const ListValue* args);
-
- // Callback for the Cloud Print manage button. This will open a new
- // tab pointed at the management URL.
- void ShowCloudPrintManagePage(const ListValue* args);
-
- // Pings the service to send us it's current notion of the enabled state.
- void RefreshCloudPrintStatusFromService();
-
- // Setup the enabled or disabled state of the cloud print proxy
- // management UI.
- void SetupCloudPrintProxySection();
-
- // Remove cloud print proxy section if cloud print proxy management UI is
- // disabled.
- void RemoveCloudPrintProxySection();
-
-#endif
-
-#if defined(ENABLE_REMOTING) && !defined(OS_CHROMEOS)
- // Removes remoting section. Called if remoting is not enabled.
- void RemoveRemotingSection();
-
- // Callback for Setup Remoting button.
- void ShowRemotingSetupDialog(const ListValue* args);
-
- // Disable Remoting.
- void DisableRemoting(const ListValue* args);
-#endif
-
- // Setup the checked state for the metrics reporting checkbox.
- void SetupMetricsReportingCheckbox();
-
- // Setup the visibility for the metrics reporting setting.
- void SetupMetricsReportingSettingVisibility();
-
- void SetupFontSizeLabel();
-
- // Setup the download path based on user preferences.
- void SetupDownloadLocationPath();
-
- // Setup the pref whether to prompt for download location every time.
- void SetupPromptForDownload();
-
- // Setup the enabled state of the reset button.
- void SetupAutoOpenFileTypesDisabledAttribute();
-
- // Setup the proxy settings section UI.
- void SetupProxySettingsSection();
-
-#if defined(OS_WIN)
- // Setup the checked state for SSL related checkboxes.
- void SetupSSLConfigSettings();
-#endif
-
- scoped_refptr<SelectFileDialog> select_folder_dialog_;
-
-#if !defined(OS_CHROMEOS)
- BooleanPrefMember enable_metrics_recording_;
- StringPrefMember cloud_print_proxy_email_;
- BooleanPrefMember cloud_print_proxy_enabled_;
- bool cloud_print_proxy_ui_enabled_;
-#endif
-
-#if defined(ENABLE_REMOTING) && !defined(OS_CHROMEOS)
- remoting::RemotingOptionsHandler remoting_options_handler_;
-#endif
-
- FilePathPrefMember default_download_location_;
- BooleanPrefMember ask_for_save_location_;
- StringPrefMember auto_open_files_;
- IntegerPrefMember default_font_size_;
- IntegerPrefMember default_fixed_font_size_;
- scoped_ptr<PrefSetObserver> proxy_prefs_;
- scoped_ptr<OptionsManagedBannerHandler> banner_handler_;
-
- DISALLOW_COPY_AND_ASSIGN(AdvancedOptionsHandler);
-};
+#include "chrome/browser/webui/options/advanced_options_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_ADVANCED_OPTIONS_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/advanced_options_utils.h b/chrome/browser/dom_ui/options/advanced_options_utils.h
index a60f89f..7e9507c 100644
--- a/chrome/browser/dom_ui/options/advanced_options_utils.h
+++ b/chrome/browser/dom_ui/options/advanced_options_utils.h
@@ -1,25 +1,12 @@
-// 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.
#ifndef CHROME_BROWSER_DOM_UI_OPTIONS_ADVANCED_OPTIONS_UTILS_H_
#define CHROME_BROWSER_DOM_UI_OPTIONS_ADVANCED_OPTIONS_UTILS_H_
+#pragma once
-#include "base/basictypes.h"
-
-class TabContents;
-
-// Chrome advanced options utility methods.
-class AdvancedOptionsUtilities {
- public:
- // Invoke UI for network proxy settings.
- static void ShowNetworkProxySettings(TabContents*);
-
- // Invoke UI for SSL certificates.
- static void ShowManageSSLCertificates(TabContents*);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(AdvancedOptionsUtilities);
-};
+#include "chrome/browser/webui/options/advanced_options_utils.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_ADVANCED_OPTIONS_UTILS_H_
diff --git a/chrome/browser/dom_ui/options/advanced_options_utils_gtk.cc b/chrome/browser/dom_ui/options/advanced_options_utils_gtk.cc
deleted file mode 100644
index 7b89b50..0000000
--- a/chrome/browser/dom_ui/options/advanced_options_utils_gtk.cc
+++ /dev/null
@@ -1,145 +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.
-
-#if !defined(OS_CHROMEOS)
-
-#include "chrome/browser/dom_ui/options/advanced_options_utils.h"
-
-#include "base/file_util.h"
-#include "base/environment.h"
-#include "base/process_util.h"
-#include "base/string_tokenizer.h"
-#include "base/nix/xdg_util.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_thread.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/common/process_watcher.h"
-#include "ui/base/gtk/gtk_signal.h"
-
-// Command used to configure GNOME proxy settings. The command was renamed
-// in January 2009, so both are used to work on both old and new systems.
-const char* kOldGNOMEProxyConfigCommand[] = {"gnome-network-preferences", NULL};
-const char* kGNOMEProxyConfigCommand[] = {"gnome-network-properties", NULL};
-// KDE3 and KDE4 are only slightly different, but incompatible. Go figure.
-const char* kKDE3ProxyConfigCommand[] = {"kcmshell", "proxy", NULL};
-const char* kKDE4ProxyConfigCommand[] = {"kcmshell4", "proxy", NULL};
-
-// The URL for Linux proxy configuration help when not running under a
-// supported desktop environment.
-const char kLinuxProxyConfigUrl[] = "about:linux-proxy-config";
-
-struct ProxyConfigCommand {
- std::string binary;
- const char** argv;
-};
-
-namespace {
-
-// Search $PATH to find one of the commands. Store the full path to
-// it in the |binary| field and the command array index in in |index|.
-bool SearchPATH(ProxyConfigCommand* commands, size_t ncommands, size_t* index) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- const char* path = getenv("PATH");
- if (!path)
- return false;
- FilePath bin_path;
- CStringTokenizer tk(path, path + strlen(path), ":");
- // Search $PATH looking for the commands in order.
- while (tk.GetNext()) {
- for (size_t i = 0; i < ncommands; i++) {
- bin_path = FilePath(tk.token()).Append(commands[i].argv[0]);
- if (file_util::PathExists(bin_path)) {
- commands[i].binary = bin_path.value();
- if (index)
- *index = i;
- return true;
- }
- }
- }
- // Did not find any of the binaries in $PATH.
- return false;
-}
-
-// Show the proxy config URL in the given tab.
-void ShowLinuxProxyConfigUrl(TabContents* tab_contents) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- scoped_ptr<base::Environment> env(base::Environment::Create());
- const char* name = base::nix::GetDesktopEnvironmentName(env.get());
- if (name)
- LOG(ERROR) << "Could not find " << name << " network settings in $PATH";
- tab_contents->OpenURL(GURL(kLinuxProxyConfigUrl), GURL(),
- NEW_FOREGROUND_TAB, PageTransition::LINK);
-}
-
-// Start the given proxy configuration utility.
-void StartProxyConfigUtil(TabContents* tab_contents,
- const ProxyConfigCommand& command) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- std::vector<std::string> argv;
- argv.push_back(command.binary);
- for (size_t i = 1; command.argv[i]; i++)
- argv.push_back(command.argv[i]);
- base::file_handle_mapping_vector no_files;
- base::ProcessHandle handle;
- if (!base::LaunchApp(argv, no_files, false, &handle)) {
- LOG(ERROR) << "StartProxyConfigUtil failed to start " << command.binary;
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- NewRunnableFunction(&ShowLinuxProxyConfigUrl, tab_contents));
- return;
- }
- ProcessWatcher::EnsureProcessGetsReaped(handle);
-}
-
-// Detect, and if possible, start the appropriate proxy config utility. On
-// failure to do so, show the Linux proxy config URL in a new tab instead.
-void DetectAndStartProxyConfigUtil(TabContents* tab_contents) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
- scoped_ptr<base::Environment> env(base::Environment::Create());
-
- ProxyConfigCommand command;
- bool found_command = false;
- switch (base::nix::GetDesktopEnvironment(env.get())) {
- case base::nix::DESKTOP_ENVIRONMENT_GNOME: {
- size_t index;
- ProxyConfigCommand commands[2];
- commands[0].argv = kGNOMEProxyConfigCommand;
- commands[1].argv = kOldGNOMEProxyConfigCommand;
- found_command = SearchPATH(commands, 2, &index);
- if (found_command)
- command = commands[index];
- break;
- }
-
- case base::nix::DESKTOP_ENVIRONMENT_KDE3:
- command.argv = kKDE3ProxyConfigCommand;
- found_command = SearchPATH(&command, 1, NULL);
- break;
-
- case base::nix::DESKTOP_ENVIRONMENT_KDE4:
- command.argv = kKDE4ProxyConfigCommand;
- found_command = SearchPATH(&command, 1, NULL);
- break;
-
- case base::nix::DESKTOP_ENVIRONMENT_XFCE:
- case base::nix::DESKTOP_ENVIRONMENT_OTHER:
- break;
- }
-
- if (found_command) {
- StartProxyConfigUtil(tab_contents, command);
- } else {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- NewRunnableFunction(&ShowLinuxProxyConfigUrl, tab_contents));
- }
-}
-
-} // anonymous namespace
-
-void AdvancedOptionsUtilities::ShowNetworkProxySettings(
- TabContents* tab_contents) {
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
- NewRunnableFunction(&DetectAndStartProxyConfigUtil, tab_contents));
-}
-
-#endif // !defined(OS_CHROMEOS)
diff --git a/chrome/browser/dom_ui/options/advanced_options_utils_mac.mm b/chrome/browser/dom_ui/options/advanced_options_utils_mac.mm
deleted file mode 100644
index e3bd4f7..0000000
--- a/chrome/browser/dom_ui/options/advanced_options_utils_mac.mm
+++ /dev/null
@@ -1,41 +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.
-
-#import <Cocoa/Cocoa.h>
-
-#include "chrome/browser/dom_ui/options/advanced_options_utils.h"
-
-#include "base/logging.h"
-#include "base/mac/scoped_aedesc.h"
-
-void AdvancedOptionsUtilities::ShowNetworkProxySettings(
- TabContents* tab_contents) {
- NSArray* itemsToOpen = [NSArray arrayWithObject:[NSURL fileURLWithPath:
- @"/System/Library/PreferencePanes/Network.prefPane"]];
-
- const char* proxyPrefCommand = "Proxies";
- base::mac::ScopedAEDesc<> openParams;
- OSStatus status = AECreateDesc('ptru',
- proxyPrefCommand,
- strlen(proxyPrefCommand),
- openParams.OutPointer());
- LOG_IF(ERROR, status != noErr) << "Failed to create open params: " << status;
-
- LSLaunchURLSpec launchSpec = { 0 };
- launchSpec.itemURLs = (CFArrayRef)itemsToOpen;
- launchSpec.passThruParams = openParams;
- launchSpec.launchFlags = kLSLaunchAsync | kLSLaunchDontAddToRecents;
- LSOpenFromURLSpec(&launchSpec, NULL);
-}
-
-void AdvancedOptionsUtilities::ShowManageSSLCertificates(
- TabContents* tab_contents) {
- NSString* const kKeychainBundleId = @"com.apple.keychainaccess";
- [[NSWorkspace sharedWorkspace]
- launchAppWithBundleIdentifier:kKeychainBundleId
- options:0L
- additionalEventParamDescriptor:nil
- launchIdentifier:nil];
-}
-
diff --git a/chrome/browser/dom_ui/options/advanced_options_utils_win.cc b/chrome/browser/dom_ui/options/advanced_options_utils_win.cc
deleted file mode 100644
index 7cf6f454..0000000
--- a/chrome/browser/dom_ui/options/advanced_options_utils_win.cc
+++ /dev/null
@@ -1,67 +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/advanced_options_utils.h"
-
-#include <windows.h>
-#include <cryptuiapi.h>
-#pragma comment(lib, "cryptui.lib")
-#include <shellapi.h>
-
-#include "base/file_util.h"
-#include "base/path_service.h"
-#include "base/threading/thread.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/browser/tab_contents/tab_contents_view.h"
-
-// A helper method that opens the Internet Options control panel dialog with
-// the Connections tab selected.
-class OpenConnectionDialogTask : public Task {
- public:
- OpenConnectionDialogTask() {}
-
- virtual void Run() {
- // Using rundll32 seems better than LaunchConnectionDialog which causes a
- // new dialog to be made for each call. rundll32 uses the same global
- // dialog and it seems to share with the shortcut in control panel.
- FilePath rundll32;
- PathService::Get(base::DIR_SYSTEM, &rundll32);
- rundll32 = rundll32.AppendASCII("rundll32.exe");
-
- FilePath shell32dll;
- PathService::Get(base::DIR_SYSTEM, &shell32dll);
- shell32dll = shell32dll.AppendASCII("shell32.dll");
-
- FilePath inetcpl;
- PathService::Get(base::DIR_SYSTEM, &inetcpl);
- inetcpl = inetcpl.AppendASCII("inetcpl.cpl,,4");
-
- std::wstring args(shell32dll.value());
- args.append(L",Control_RunDLL ");
- args.append(inetcpl.value());
-
- ShellExecute(NULL, L"open", rundll32.value().c_str(), args.c_str(), NULL,
- SW_SHOWNORMAL);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(OpenConnectionDialogTask);
-};
-
-void AdvancedOptionsUtilities::ShowNetworkProxySettings(
- TabContents* tab_contents) {
- base::Thread* thread = g_browser_process->file_thread();
- DCHECK(thread);
- thread->message_loop()->PostTask(FROM_HERE, new OpenConnectionDialogTask);
-}
-
-void AdvancedOptionsUtilities::ShowManageSSLCertificates(
- TabContents* tab_contents) {
- CRYPTUI_CERT_MGR_STRUCT cert_mgr = { 0 };
- cert_mgr.dwSize = sizeof(CRYPTUI_CERT_MGR_STRUCT);
- cert_mgr.hwndParent =
- tab_contents->view()->GetTopLevelNativeWindow();
- ::CryptUIDlgCertMgr(&cert_mgr);
-}
diff --git a/chrome/browser/dom_ui/options/autofill_options_handler.cc b/chrome/browser/dom_ui/options/autofill_options_handler.cc
deleted file mode 100644
index 32810c8..0000000
--- a/chrome/browser/dom_ui/options/autofill_options_handler.cc
+++ /dev/null
@@ -1,395 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/autofill_options_handler.h"
-
-#include <vector>
-
-#include "base/logging.h"
-#include "base/string16.h"
-#include "base/string_number_conversions.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/autofill/autofill_profile.h"
-#include "chrome/browser/autofill/credit_card.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/webui/web_ui_util.h"
-#include "chrome/common/guid.h"
-#include "grit/generated_resources.h"
-#include "grit/webkit_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace {
-
-// Converts a credit card type to the appropriate resource ID of the CC icon.
-int CreditCardTypeToResourceID(const string16& type16) {
- std::string type = UTF16ToUTF8(type16);
- if (type == kAmericanExpressCard)
- return IDR_AUTOFILL_CC_AMEX;
- else if (type == kDinersCard)
- return IDR_AUTOFILL_CC_DINERS;
- else if (type == kDiscoverCard)
- return IDR_AUTOFILL_CC_DISCOVER;
- else if (type == kGenericCard)
- return IDR_AUTOFILL_CC_GENERIC;
- else if (type == kJCBCard)
- return IDR_AUTOFILL_CC_JCB;
- else if (type == kMasterCard)
- return IDR_AUTOFILL_CC_MASTERCARD;
- else if (type == kSoloCard)
- return IDR_AUTOFILL_CC_SOLO;
- else if (type == kVisaCard)
- return IDR_AUTOFILL_CC_VISA;
-
- NOTREACHED();
- return 0;
-}
-
-} // namespace
-
-AutoFillOptionsHandler::AutoFillOptionsHandler()
- : personal_data_(NULL) {
-}
-
-AutoFillOptionsHandler::~AutoFillOptionsHandler() {
- if (personal_data_)
- personal_data_->RemoveObserver(this);
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// OptionsUIHandler implementation:
-void AutoFillOptionsHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- RegisterTitle(localized_strings, "autoFillOptionsPage",
- IDS_AUTOFILL_OPTIONS_TITLE);
- localized_strings->SetString("autoFillAddresses",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_ADDRESSES_GROUP_NAME));
- localized_strings->SetString("autoFillCreditCards",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_CREDITCARDS_GROUP_NAME));
- localized_strings->SetString("autoFillAddAddress",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_ADD_ADDRESS_BUTTON));
- localized_strings->SetString("autoFillAddCreditCard",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_ADD_CREDITCARD_BUTTON));
- localized_strings->SetString("helpButton",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_HELP_LABEL));
- localized_strings->SetString("addAddressTitle",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_ADD_ADDRESS_CAPTION));
- localized_strings->SetString("editAddressTitle",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_EDIT_ADDRESS_CAPTION));
- localized_strings->SetString("addCreditCardTitle",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_ADD_CREDITCARD_CAPTION));
- localized_strings->SetString("editCreditCardTitle",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_EDIT_CREDITCARD_CAPTION));
-
-#if defined(OS_MACOSX)
- localized_strings->SetString("auxiliaryProfilesEnabled",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_USE_MAC_ADDRESS_BOOK));
-#endif // defined(OS_MACOSX)
-
- SetAddressOverlayStrings(localized_strings);
- SetCreditCardOverlayStrings(localized_strings);
-}
-
-void AutoFillOptionsHandler::Initialize() {
- personal_data_ = web_ui_->GetProfile()->GetPersonalDataManager();
- personal_data_->SetObserver(this);
-
- LoadAutoFillData();
-}
-
-void AutoFillOptionsHandler::RegisterMessages() {
- web_ui_->RegisterMessageCallback(
- "removeAddress",
- NewCallback(this, &AutoFillOptionsHandler::RemoveAddress));
- web_ui_->RegisterMessageCallback(
- "removeCreditCard",
- NewCallback(this, &AutoFillOptionsHandler::RemoveCreditCard));
- web_ui_->RegisterMessageCallback(
- "loadAddressEditor",
- NewCallback(this, &AutoFillOptionsHandler::LoadAddressEditor));
- web_ui_->RegisterMessageCallback(
- "loadCreditCardEditor",
- NewCallback(this, &AutoFillOptionsHandler::LoadCreditCardEditor));
- web_ui_->RegisterMessageCallback(
- "setAddress",
- NewCallback(this, &AutoFillOptionsHandler::SetAddress));
- web_ui_->RegisterMessageCallback(
- "setCreditCard",
- NewCallback(this, &AutoFillOptionsHandler::SetCreditCard));
-}
-
-/////////////////////////////////////////////////////////////////////////////
-// PersonalDataManager::Observer implementation:
-void AutoFillOptionsHandler::OnPersonalDataLoaded() {
- LoadAutoFillData();
-}
-
-void AutoFillOptionsHandler::OnPersonalDataChanged() {
- LoadAutoFillData();
-}
-
-void AutoFillOptionsHandler::SetAddressOverlayStrings(
- DictionaryValue* localized_strings) {
- localized_strings->SetString("autoFillEditAddressTitle",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_EDIT_ADDRESS_CAPTION));
- localized_strings->SetString("fullNameLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_FULL_NAME));
- localized_strings->SetString("companyNameLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_COMPANY_NAME));
- localized_strings->SetString("addrLine1Label",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADDRESS_LINE_1));
- localized_strings->SetString("addrLine2Label",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ADDRESS_LINE_2));
- localized_strings->SetString("cityLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_CITY));
- localized_strings->SetString("stateLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_STATE));
- localized_strings->SetString("zipCodeLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_ZIP_CODE));
- localized_strings->SetString("countryLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_COUNTRY));
- localized_strings->SetString("countryLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_COUNTRY));
- localized_strings->SetString("phoneLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_PHONE));
- localized_strings->SetString("faxLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_FAX));
- localized_strings->SetString("emailLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EMAIL));
-}
-
-void AutoFillOptionsHandler::SetCreditCardOverlayStrings(
- DictionaryValue* localized_strings) {
- localized_strings->SetString("autoFillEditCreditCardTitle",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_EDIT_CREDITCARD_CAPTION));
- localized_strings->SetString("nameOnCardLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_NAME_ON_CARD));
- localized_strings->SetString("creditCardNumberLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_CREDIT_CARD_NUMBER));
- localized_strings->SetString("creditCardExpirationDateLabel",
- l10n_util::GetStringUTF16(IDS_AUTOFILL_DIALOG_EXPIRATION_DATE));
-}
-
-void AutoFillOptionsHandler::LoadAutoFillData() {
- if (!personal_data_->IsDataLoaded())
- return;
-
- ListValue addresses;
- for (std::vector<AutoFillProfile*>::const_iterator i =
- personal_data_->web_profiles().begin();
- i != personal_data_->web_profiles().end(); ++i) {
- ListValue* entry = new ListValue();
- entry->Append(new StringValue((*i)->guid()));
- entry->Append(new StringValue((*i)->Label()));
- addresses.Append(entry);
- }
-
- web_ui_->CallJavascriptFunction(L"AutoFillOptions.setAddressList",
- addresses);
-
- ListValue credit_cards;
- for (std::vector<CreditCard*>::const_iterator i =
- personal_data_->credit_cards().begin();
- i != personal_data_->credit_cards().end(); ++i) {
- ListValue* entry = new ListValue();
- entry->Append(new StringValue((*i)->guid()));
- entry->Append(new StringValue((*i)->PreviewSummary()));
- int res = CreditCardTypeToResourceID((*i)->type());
- entry->Append(
- new StringValue(web_ui_util::GetImageDataUrlFromResource(res)));
- credit_cards.Append(entry);
- }
-
- web_ui_->CallJavascriptFunction(L"AutoFillOptions.setCreditCardList",
- credit_cards);
-}
-
-void AutoFillOptionsHandler::RemoveAddress(const ListValue* args) {
- DCHECK(personal_data_->IsDataLoaded());
-
- std::string guid;
- if (!args->GetString(0, &guid)) {
- NOTREACHED();
- return;
- }
-
- personal_data_->RemoveProfile(guid);
-}
-
-void AutoFillOptionsHandler::RemoveCreditCard(const ListValue* args) {
- DCHECK(personal_data_->IsDataLoaded());
-
- std::string guid;
- if (!args->GetString(0, &guid)) {
- NOTREACHED();
- return;
- }
-
- personal_data_->RemoveCreditCard(guid);
-}
-
-void AutoFillOptionsHandler::LoadAddressEditor(const ListValue* args) {
- DCHECK(personal_data_->IsDataLoaded());
-
- std::string guid;
- if (!args->GetString(0, &guid)) {
- NOTREACHED();
- return;
- }
-
- AutoFillProfile* profile = personal_data_->GetProfileByGUID(guid);
- if (!profile) {
- // There is a race where a user can click once on the close button and
- // quickly click again on the list item before the item is removed (since
- // the list is not updated until the model tells the list an item has been
- // removed). This will activate the editor for a profile that has been
- // removed. Do nothing in that case.
- return;
- }
-
- DictionaryValue address;
- address.SetString("guid", profile->guid());
- address.SetString("fullName",
- profile->GetFieldText(AutoFillType(NAME_FULL)));
- address.SetString("companyName",
- profile->GetFieldText(AutoFillType(COMPANY_NAME)));
- address.SetString("addrLine1",
- profile->GetFieldText(AutoFillType(ADDRESS_HOME_LINE1)));
- address.SetString("addrLine2",
- profile->GetFieldText(AutoFillType(ADDRESS_HOME_LINE2)));
- address.SetString("city",
- profile->GetFieldText(AutoFillType(ADDRESS_HOME_CITY)));
- address.SetString("state",
- profile->GetFieldText(AutoFillType(ADDRESS_HOME_STATE)));
- address.SetString("zipCode",
- profile->GetFieldText(AutoFillType(ADDRESS_HOME_ZIP)));
- address.SetString("country",
- profile->GetFieldText(AutoFillType(ADDRESS_HOME_COUNTRY)));
- address.SetString(
- "phone",
- profile->GetFieldText(AutoFillType(PHONE_HOME_WHOLE_NUMBER)));
- address.SetString(
- "fax",
- profile->GetFieldText(AutoFillType(PHONE_FAX_WHOLE_NUMBER)));
- address.SetString("email",
- profile->GetFieldText(AutoFillType(EMAIL_ADDRESS)));
-
- web_ui_->CallJavascriptFunction(L"AutoFillOptions.editAddress", address);
-}
-
-void AutoFillOptionsHandler::LoadCreditCardEditor(const ListValue* args) {
- DCHECK(personal_data_->IsDataLoaded());
-
- std::string guid;
- if (!args->GetString(0, &guid)) {
- NOTREACHED();
- return;
- }
-
- CreditCard* credit_card = personal_data_->GetCreditCardByGUID(guid);
- if (!credit_card) {
- // There is a race where a user can click once on the close button and
- // quickly click again on the list item before the item is removed (since
- // the list is not updated until the model tells the list an item has been
- // removed). This will activate the editor for a profile that has been
- // removed. Do nothing in that case.
- return;
- }
-
- DictionaryValue credit_card_data;
- credit_card_data.SetString("guid", credit_card->guid());
- credit_card_data.SetString(
- "nameOnCard",
- credit_card->GetFieldText(AutoFillType(CREDIT_CARD_NAME)));
- credit_card_data.SetString(
- "creditCardNumber",
- credit_card->GetFieldText(AutoFillType(CREDIT_CARD_NUMBER)));
- credit_card_data.SetString("obfuscatedCardNumber",
- credit_card->ObfuscatedNumber());
- credit_card_data.SetString(
- "expirationMonth",
- credit_card->GetFieldText(AutoFillType(CREDIT_CARD_EXP_MONTH)));
- credit_card_data.SetString(
- "expirationYear",
- credit_card->GetFieldText(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR)));
-
- web_ui_->CallJavascriptFunction(L"AutoFillOptions.editCreditCard",
- credit_card_data);
-}
-
-void AutoFillOptionsHandler::SetAddress(const ListValue* args) {
- if (!personal_data_->IsDataLoaded())
- return;
-
- std::string guid;
- if (!args->GetString(0, &guid)) {
- NOTREACHED();
- return;
- }
-
- AutoFillProfile profile(guid);
-
- string16 value;
- if (args->GetString(1, &value))
- profile.SetInfo(AutoFillType(NAME_FULL), value);
- if (args->GetString(2, &value))
- profile.SetInfo(AutoFillType(COMPANY_NAME), value);
- if (args->GetString(3, &value))
- profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE1), value);
- if (args->GetString(4, &value))
- profile.SetInfo(AutoFillType(ADDRESS_HOME_LINE2), value);
- if (args->GetString(5, &value))
- profile.SetInfo(AutoFillType(ADDRESS_HOME_CITY), value);
- if (args->GetString(6, &value))
- profile.SetInfo(AutoFillType(ADDRESS_HOME_STATE), value);
- if (args->GetString(7, &value))
- profile.SetInfo(AutoFillType(ADDRESS_HOME_ZIP), value);
- if (args->GetString(8, &value))
- profile.SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), value);
- if (args->GetString(9, &value))
- profile.SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), value);
- if (args->GetString(10, &value))
- profile.SetInfo(AutoFillType(PHONE_FAX_WHOLE_NUMBER), value);
- if (args->GetString(11, &value))
- profile.SetInfo(AutoFillType(EMAIL_ADDRESS), value);
-
- if (!guid::IsValidGUID(profile.guid())) {
- profile.set_guid(guid::GenerateGUID());
- personal_data_->AddProfile(profile);
- } else {
- personal_data_->UpdateProfile(profile);
- }
-}
-
-void AutoFillOptionsHandler::SetCreditCard(const ListValue* args) {
- if (!personal_data_->IsDataLoaded())
- return;
-
- std::string guid;
- if (!args->GetString(0, &guid)) {
- NOTREACHED();
- return;
- }
-
- CreditCard credit_card(guid);
-
- string16 value;
- if (args->GetString(1, &value))
- credit_card.SetInfo(AutoFillType(CREDIT_CARD_NAME), value);
- if (args->GetString(2, &value))
- credit_card.SetInfo(AutoFillType(CREDIT_CARD_NUMBER), value);
- if (args->GetString(3, &value))
- credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_MONTH), value);
- if (args->GetString(4, &value))
- credit_card.SetInfo(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR), value);
-
- if (!guid::IsValidGUID(credit_card.guid())) {
- credit_card.set_guid(guid::GenerateGUID());
- personal_data_->AddCreditCard(credit_card);
- } else {
- personal_data_->UpdateCreditCard(credit_card);
- }
-}
diff --git a/chrome/browser/dom_ui/options/autofill_options_handler.h b/chrome/browser/dom_ui/options/autofill_options_handler.h
index 52de3e2..26a7bfd 100644
--- a/chrome/browser/dom_ui/options/autofill_options_handler.h
+++ b/chrome/browser/dom_ui/options/autofill_options_handler.h
@@ -4,75 +4,9 @@
#ifndef CHROME_BROWSER_DOM_UI_OPTIONS_AUTOFILL_OPTIONS_HANDLER_H_
#define CHROME_BROWSER_DOM_UI_OPTIONS_AUTOFILL_OPTIONS_HANDLER_H_
+#pragma once
-#include <string>
-
-#include "chrome/browser/autofill/personal_data_manager.h"
-#include "chrome/browser/dom_ui/options/options_ui.h"
-
-class DictionaryValue;
-class ListValue;
-
-class AutoFillOptionsHandler : public OptionsPageUIHandler,
- public PersonalDataManager::Observer {
- public:
- AutoFillOptionsHandler();
- virtual ~AutoFillOptionsHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
- virtual void Initialize();
- virtual void RegisterMessages();
-
- // PersonalDataManager::Observer implementation.
- virtual void OnPersonalDataLoaded();
- virtual void OnPersonalDataChanged();
-
- private:
- // Loads the strings for the address and credit card overlays.
- void SetAddressOverlayStrings(DictionaryValue* localized_strings);
- void SetCreditCardOverlayStrings(DictionaryValue* localized_strings);
-
- // Loads AutoFill addresses and credit cards using the PersonalDataManager.
- void LoadAutoFillData();
-
- // Removes an address from the PersonalDataManager.
- // |args| - A string, the GUID of the address to remove.
- void RemoveAddress(const ListValue* args);
-
- // Removes a credit card from the PersonalDataManager.
- // |args| - A string, the GUID of the credit card to remove.
- void RemoveCreditCard(const ListValue* args);
-
- // Requests profile data for a specific address. Calls into WebUI with the
- // loaded profile data to open the address editor.
- // |args| - A string, the GUID of the address to load.
- void LoadAddressEditor(const ListValue* args);
-
- // Requests profile data for a specific credit card. Calls into WebUI with the
- // loaded profile data to open the credit card editor.
- // |args| - A string, the GUID of the credit card to load.
- void LoadCreditCardEditor(const ListValue* args);
-
- // Adds or updates an address, depending on the GUID of the profile. If the
- // GUID is empty, a new address is added to the WebDatabase; otherwise, the
- // address with the matching GUID is updated. Called from WebUI.
- // |args| - an array containing the GUID of the address followed by the
- // address data.
- void SetAddress(const ListValue* args);
-
- // Adds or updates a credit card, depending on the GUID of the profile. If the
- // GUID is empty, a new credit card is added to the WebDatabase; otherwise,
- // the credit card with the matching GUID is updated. Called from WebUI.
- // |args| - an array containing the GUID of the credit card followed by the
- // credit card data.
- void SetCreditCard(const ListValue* args);
-
- // The personal data manager, used to load AutoFill profiles and credit cards.
- // Unowned pointer, may not be NULL.
- PersonalDataManager* personal_data_;
-
- DISALLOW_COPY_AND_ASSIGN(AutoFillOptionsHandler);
-};
+#include "chrome/browser/webui/options/autofill_options_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_AUTOFILL_OPTIONS_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/browser_options_handler.cc b/chrome/browser/dom_ui/options/browser_options_handler.cc
deleted file mode 100644
index 10aa148..0000000
--- a/chrome/browser/dom_ui/options/browser_options_handler.cc
+++ /dev/null
@@ -1,415 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/browser_options_handler.h"
-
-#include "base/basictypes.h"
-#include "base/scoped_ptr.h"
-#include "base/singleton.h"
-#include "base/string_number_conversions.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/browser_thread.h"
-#include "chrome/browser/custom_home_pages_table_model.h"
-#include "chrome/browser/dom_ui/options/dom_options_util.h"
-#include "chrome/browser/dom_ui/options/options_managed_banner_handler.h"
-#include "chrome/browser/dom_ui/web_ui_favicon_source.h"
-#include "chrome/browser/instant/instant_confirm_dialog.h"
-#include "chrome/browser/metrics/user_metrics.h"
-#include "chrome/browser/net/url_fixer_upper.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/prefs/session_startup_pref.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/browser/ui/options/options_window.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/installer/util/browser_distribution.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-
-BrowserOptionsHandler::BrowserOptionsHandler()
- : template_url_model_(NULL), startup_custom_pages_table_model_(NULL) {
-#if !defined(OS_MACOSX)
- default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this);
-#endif
-}
-
-BrowserOptionsHandler::~BrowserOptionsHandler() {
- if (default_browser_worker_.get())
- default_browser_worker_->ObserverDestroyed();
- if (template_url_model_)
- template_url_model_->RemoveObserver(this);
-}
-
-void BrowserOptionsHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- static OptionsStringResource resources[] = {
- { "startupGroupName", IDS_OPTIONS_STARTUP_GROUP_NAME, true },
- { "startupShowDefaultAndNewTab",
- IDS_OPTIONS_STARTUP_SHOW_DEFAULT_AND_NEWTAB},
- { "startupShowLastSession", IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION },
- { "startupShowPages", IDS_OPTIONS_STARTUP_SHOW_PAGES },
- { "startupAddButton", IDS_OPTIONS_STARTUP_ADD_BUTTON },
- { "startupUseCurrent", IDS_OPTIONS_STARTUP_USE_CURRENT },
- { "homepageGroupName", IDS_OPTIONS_HOMEPAGE_GROUP_NAME },
- { "homepageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB },
- { "homepageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL },
- { "toolbarGroupName", IDS_OPTIONS_TOOLBAR_GROUP_NAME, true },
- { "toolbarShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON },
- { "defaultSearchGroupName", IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME, true },
- { "defaultSearchManageEngines", IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES },
- { "instantName", IDS_INSTANT_PREF },
- { "instantWarningText", IDS_INSTANT_PREF_WARNING },
- { "instantConfirmTitle", IDS_INSTANT_OPT_IN_TITLE },
- { "instantConfirmMessage", IDS_INSTANT_OPT_IN_MESSAGE },
- { "defaultBrowserGroupName", IDS_OPTIONS_DEFAULTBROWSER_GROUP_NAME, true },
- };
-
- RegisterStrings(localized_strings, resources, arraysize(resources));
- RegisterTitle(localized_strings, "browserPage",
- IDS_OPTIONS_GENERAL_TAB_LABEL);
-
- localized_strings->SetString("instantLearnMoreLink",
- ASCIIToUTF16(browser::InstantLearnMoreURL().spec()));
- localized_strings->SetString("defaultBrowserUnknown",
- l10n_util::GetStringFUTF16(IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN,
- l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
- localized_strings->SetString("defaultBrowserUseAsDefault",
- l10n_util::GetStringFUTF16(IDS_OPTIONS_DEFAULTBROWSER_USEASDEFAULT,
- l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
-}
-
-void BrowserOptionsHandler::RegisterMessages() {
- web_ui_->RegisterMessageCallback(
- "setHomePage",
- NewCallback(this, &BrowserOptionsHandler::SetHomePage));
- web_ui_->RegisterMessageCallback(
- "becomeDefaultBrowser",
- NewCallback(this, &BrowserOptionsHandler::BecomeDefaultBrowser));
- web_ui_->RegisterMessageCallback(
- "setDefaultSearchEngine",
- NewCallback(this, &BrowserOptionsHandler::SetDefaultSearchEngine));
- web_ui_->RegisterMessageCallback(
- "removeStartupPages",
- NewCallback(this, &BrowserOptionsHandler::RemoveStartupPages));
- web_ui_->RegisterMessageCallback(
- "addStartupPage",
- NewCallback(this, &BrowserOptionsHandler::AddStartupPage));
- web_ui_->RegisterMessageCallback(
- "editStartupPage",
- NewCallback(this, &BrowserOptionsHandler::EditStartupPage));
- web_ui_->RegisterMessageCallback(
- "setStartupPagesToCurrentPages",
- NewCallback(this, &BrowserOptionsHandler::SetStartupPagesToCurrentPages));
-}
-
-void BrowserOptionsHandler::Initialize() {
- Profile* profile = web_ui_->GetProfile();
-
- // Create our favicon data source.
- profile->GetChromeURLDataManager()->AddDataSource(
- new WebUIFavIconSource(profile));
-
- homepage_.Init(prefs::kHomePage, profile->GetPrefs(), NULL);
- default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled,
- g_browser_process->local_state(),
- this);
- UpdateDefaultBrowserState();
- UpdateStartupPages();
- UpdateSearchEngines();
- banner_handler_.reset(
- new OptionsManagedBannerHandler(web_ui_,
- ASCIIToUTF16("BrowserOptions"),
- OPTIONS_PAGE_GENERAL));
-}
-
-void BrowserOptionsHandler::SetHomePage(const ListValue* args) {
- std::string url_string;
- std::string do_fixup_string;
- int do_fixup;
- if (args->GetSize() != 2 ||
- !args->GetString(0, &url_string) ||
- !args->GetString(1, &do_fixup_string) ||
- !base::StringToInt(do_fixup_string, &do_fixup)) {
- CHECK(false);
- };
-
- if (do_fixup) {
- GURL fixed_url = URLFixerUpper::FixupURL(url_string, std::string());
- url_string = fixed_url.spec();
- }
- homepage_.SetValueIfNotManaged(url_string);
-}
-
-void BrowserOptionsHandler::UpdateDefaultBrowserState() {
-#if defined(OS_WIN)
- // Check for side-by-side first.
- if (!BrowserDistribution::GetDistribution()->CanSetAsDefault()) {
- SetDefaultBrowserUIString(IDS_OPTIONS_DEFAULTBROWSER_SXS);
- return;
- }
-#endif
-
-#if defined(OS_MACOSX)
- ShellIntegration::DefaultBrowserState state =
- ShellIntegration::IsDefaultBrowser();
- int status_string_id;
- if (state == ShellIntegration::IS_DEFAULT_BROWSER)
- status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT;
- else if (state == ShellIntegration::NOT_DEFAULT_BROWSER)
- status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT;
- else
- status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN;
-
- SetDefaultBrowserUIString(status_string_id);
-#else
- default_browser_worker_->StartCheckDefaultBrowser();
-#endif
-}
-
-void BrowserOptionsHandler::BecomeDefaultBrowser(const ListValue* args) {
- // If the default browser setting is managed then we should not be able to
- // call this function.
- if (default_browser_policy_.IsManaged())
- return;
-
- UserMetricsRecordAction(UserMetricsAction("Options_SetAsDefaultBrowser"));
-#if defined(OS_MACOSX)
- if (ShellIntegration::SetAsDefaultBrowser())
- UpdateDefaultBrowserState();
-#else
- default_browser_worker_->StartSetAsDefaultBrowser();
- // Callback takes care of updating UI.
-#endif
-
- // If the user attempted to make Chrome the default browser, then he/she
- // arguably wants to be notified when that changes.
- PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
- prefs->SetBoolean(prefs::kCheckDefaultBrowser, true);
-}
-
-int BrowserOptionsHandler::StatusStringIdForState(
- ShellIntegration::DefaultBrowserState state) {
- if (state == ShellIntegration::IS_DEFAULT_BROWSER)
- return IDS_OPTIONS_DEFAULTBROWSER_DEFAULT;
- if (state == ShellIntegration::NOT_DEFAULT_BROWSER)
- return IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT;
- return IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN;
-}
-
-void BrowserOptionsHandler::SetDefaultBrowserUIState(
- ShellIntegration::DefaultBrowserUIState state) {
- int status_string_id;
- if (state == ShellIntegration::STATE_IS_DEFAULT)
- status_string_id = IDS_OPTIONS_DEFAULTBROWSER_DEFAULT;
- else if (state == ShellIntegration::STATE_NOT_DEFAULT)
- status_string_id = IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT;
- else if (state == ShellIntegration::STATE_UNKNOWN)
- status_string_id = IDS_OPTIONS_DEFAULTBROWSER_UNKNOWN;
- else
- return; // Still processing.
-
- SetDefaultBrowserUIString(status_string_id);
-}
-
-void BrowserOptionsHandler::SetDefaultBrowserUIString(int status_string_id) {
- scoped_ptr<Value> status_string(Value::CreateStringValue(
- l10n_util::GetStringFUTF16(status_string_id,
- l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))));
-
- scoped_ptr<Value> is_default(Value::CreateBooleanValue(
- status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT));
-
- scoped_ptr<Value> can_be_default(Value::CreateBooleanValue(
- !default_browser_policy_.IsManaged() &&
- (status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT ||
- status_string_id == IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT)));
-
- web_ui_->CallJavascriptFunction(
- L"BrowserOptions.updateDefaultBrowserState",
- *(status_string.get()), *(is_default.get()), *(can_be_default.get()));
-}
-
-void BrowserOptionsHandler::OnTemplateURLModelChanged() {
- if (!template_url_model_ || !template_url_model_->loaded())
- return;
-
- const TemplateURL* default_url =
- template_url_model_->GetDefaultSearchProvider();
-
- int default_index = 0;
- ListValue search_engines;
- std::vector<const TemplateURL*> model_urls =
- template_url_model_->GetTemplateURLs();
- for (size_t i = 0; i < model_urls.size(); ++i) {
- if (!model_urls[i]->ShowInDefaultList())
- continue;
-
- DictionaryValue* entry = new DictionaryValue();
- entry->SetString("name", model_urls[i]->short_name());
- entry->SetInteger("index", i);
- search_engines.Append(entry);
- if (model_urls[i] == default_url)
- default_index = i;
- }
-
- scoped_ptr<Value> default_value(Value::CreateIntegerValue(default_index));
-
- web_ui_->CallJavascriptFunction(L"BrowserOptions.updateSearchEngines",
- search_engines, *(default_value.get()));
-}
-
-void BrowserOptionsHandler::SetDefaultSearchEngine(const ListValue* args) {
- int selected_index = -1;
- if (!ExtractIntegerValue(args, &selected_index)) {
- NOTREACHED();
- return;
- }
-
- std::vector<const TemplateURL*> model_urls =
- template_url_model_->GetTemplateURLs();
- if (selected_index >= 0 &&
- selected_index < static_cast<int>(model_urls.size()))
- template_url_model_->SetDefaultSearchProvider(model_urls[selected_index]);
-
- UserMetricsRecordAction(UserMetricsAction("Options_SearchEngineChanged"));
-}
-
-void BrowserOptionsHandler::UpdateSearchEngines() {
- template_url_model_ = web_ui_->GetProfile()->GetTemplateURLModel();
- if (template_url_model_) {
- template_url_model_->Load();
- template_url_model_->AddObserver(this);
- OnTemplateURLModelChanged();
- }
-}
-
-void BrowserOptionsHandler::UpdateStartupPages() {
- Profile* profile = web_ui_->GetProfile();
- startup_custom_pages_table_model_.reset(
- new CustomHomePagesTableModel(profile));
- startup_custom_pages_table_model_->SetObserver(this);
-
- const SessionStartupPref startup_pref =
- SessionStartupPref::GetStartupPref(profile->GetPrefs());
- startup_custom_pages_table_model_->SetURLs(startup_pref.urls);
-}
-
-void BrowserOptionsHandler::OnModelChanged() {
- ListValue startup_pages;
- int page_count = startup_custom_pages_table_model_->RowCount();
- std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs();
- for (int i = 0; i < page_count; ++i) {
- DictionaryValue* entry = new DictionaryValue();
- entry->SetString("title", startup_custom_pages_table_model_->GetText(i, 0));
- entry->SetString("url", urls[i].spec());
- entry->SetString("tooltip",
- startup_custom_pages_table_model_->GetTooltip(i));
- entry->SetString("modelIndex", base::IntToString(i));
- startup_pages.Append(entry);
- }
-
- web_ui_->CallJavascriptFunction(L"BrowserOptions.updateStartupPages",
- startup_pages);
-}
-
-void BrowserOptionsHandler::OnItemsChanged(int start, int length) {
- OnModelChanged();
-}
-
-void BrowserOptionsHandler::OnItemsAdded(int start, int length) {
- OnModelChanged();
-}
-
-void BrowserOptionsHandler::OnItemsRemoved(int start, int length) {
- OnModelChanged();
-}
-
-void BrowserOptionsHandler::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- UpdateDefaultBrowserState();
-}
-
-void BrowserOptionsHandler::SetStartupPagesToCurrentPages(
- const ListValue* args) {
- startup_custom_pages_table_model_->SetToCurrentlyOpenPages();
- SaveStartupPagesPref();
-}
-
-void BrowserOptionsHandler::RemoveStartupPages(const ListValue* args) {
- for (int i = args->GetSize() - 1; i >= 0; --i) {
- std::string string_value;
- if (!args->GetString(i, &string_value)) {
- CHECK(false);
- }
- int selected_index;
- base::StringToInt(string_value, &selected_index);
- if (selected_index < 0 ||
- selected_index >= startup_custom_pages_table_model_->RowCount()) {
- NOTREACHED();
- return;
- }
- startup_custom_pages_table_model_->Remove(selected_index);
- }
-
- SaveStartupPagesPref();
-}
-
-void BrowserOptionsHandler::AddStartupPage(const ListValue* args) {
- std::string url_string;
- std::string index_string;
- int index;
- if (args->GetSize() != 2 ||
- !args->GetString(0, &url_string) ||
- !args->GetString(1, &index_string) ||
- !base::StringToInt(index_string, &index)) {
- CHECK(false);
- };
-
- if (index == -1)
- index = startup_custom_pages_table_model_->RowCount();
- else
- ++index;
-
- GURL url = URLFixerUpper::FixupURL(url_string, std::string());
-
- startup_custom_pages_table_model_->Add(index, url);
- SaveStartupPagesPref();
-}
-
-void BrowserOptionsHandler::EditStartupPage(const ListValue* args) {
- std::string url_string;
- std::string index_string;
- int index;
- if (args->GetSize() != 2 ||
- !args->GetString(0, &index_string) ||
- !base::StringToInt(index_string, &index) ||
- !args->GetString(1, &url_string)) {
- CHECK(false);
- };
-
- if (index < 0 || index > startup_custom_pages_table_model_->RowCount()) {
- NOTREACHED();
- return;
- }
-
- std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs();
- urls[index] = URLFixerUpper::FixupURL(url_string, std::string());
- startup_custom_pages_table_model_->SetURLs(urls);
-}
-
-void BrowserOptionsHandler::SaveStartupPagesPref() {
- PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
-
- SessionStartupPref pref = SessionStartupPref::GetStartupPref(prefs);
- pref.urls = startup_custom_pages_table_model_->GetURLs();
-
- SessionStartupPref::SetStartupPref(prefs, pref);
-}
diff --git a/chrome/browser/dom_ui/options/browser_options_handler.h b/chrome/browser/dom_ui/options/browser_options_handler.h
index be174dd..cef9920 100644
--- a/chrome/browser/dom_ui/options/browser_options_handler.h
+++ b/chrome/browser/dom_ui/options/browser_options_handler.h
@@ -6,107 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_
#pragma once
-#include "chrome/browser/dom_ui/options/options_ui.h"
-#include "chrome/browser/prefs/pref_member.h"
-#include "chrome/browser/search_engines/template_url_model_observer.h"
-#include "chrome/browser/shell_integration.h"
-#include "ui/base/models/table_model_observer.h"
-
-class CustomHomePagesTableModel;
-class OptionsManagedBannerHandler;
-class StringPrefMember;
-class TemplateURLModel;
-
-// Chrome browser options page UI handler.
-class BrowserOptionsHandler : public OptionsPageUIHandler,
- public ShellIntegration::DefaultBrowserObserver,
- public TemplateURLModelObserver,
- public ui::TableModelObserver {
- public:
- BrowserOptionsHandler();
- virtual ~BrowserOptionsHandler();
-
- virtual void Initialize();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
- virtual void RegisterMessages();
-
- // ShellIntegration::DefaultBrowserObserver implementation.
- virtual void SetDefaultBrowserUIState(
- ShellIntegration::DefaultBrowserUIState state);
-
- // TemplateURLModelObserver implementation.
- virtual void OnTemplateURLModelChanged();
-
- // ui::TableModelObserver implementation.
- virtual void OnModelChanged();
- virtual void OnItemsChanged(int start, int length);
- virtual void OnItemsAdded(int start, int length);
- virtual void OnItemsRemoved(int start, int length);
-
- private:
- // NotificationObserver implementation.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- // Sets the home page to the given string. Called from WebUI.
- void SetHomePage(const ListValue* args);
-
- // Makes this the default browser. Called from WebUI.
- void BecomeDefaultBrowser(const ListValue* args);
-
- // Sets the search engine at the given index to be default. Called from WebUI.
- void SetDefaultSearchEngine(const ListValue* args);
-
- // Removes the startup page at the given indexes. Called from WebUI.
- void RemoveStartupPages(const ListValue* args);
-
- // Adds a startup page with the given URL after the given index.
- // Called from WebUI.
- void AddStartupPage(const ListValue* args);
-
- // Changes the startup page at the given index to the given URL.
- // Called from WebUI.
- void EditStartupPage(const ListValue* args);
-
- // Sets the startup page set to the current pages. Called from WebUI.
- void SetStartupPagesToCurrentPages(const ListValue* args);
-
- // Returns the string ID for the given default browser state.
- int StatusStringIdForState(ShellIntegration::DefaultBrowserState state);
-
- // Gets the current default browser state, and asynchronously reports it to
- // the WebUI page.
- void UpdateDefaultBrowserState();
-
- // Updates the UI with the given state for the default browser.
- void SetDefaultBrowserUIString(int status_string_id);
-
- // Loads the current set of custom startup pages and reports it to the WebUI.
- void UpdateStartupPages();
-
- // Loads the possible default search engine list and reports it to the WebUI.
- void UpdateSearchEngines();
-
- // Writes the current set of startup pages to prefs.
- void SaveStartupPagesPref();
-
- scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_;
-
- StringPrefMember homepage_;
- BooleanPrefMember default_browser_policy_;
-
- TemplateURLModel* template_url_model_; // Weak.
-
- // TODO(stuartmorgan): Once there are no other clients of
- // CustomHomePagesTableModel, consider changing it to something more like
- // TemplateURLModel.
- scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_;
- scoped_ptr<OptionsManagedBannerHandler> banner_handler_;
-
- DISALLOW_COPY_AND_ASSIGN(BrowserOptionsHandler);
-};
+#include "chrome/browser/webui/options/browser_options_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_BROWSER_OPTIONS_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/certificate_manager_handler.cc b/chrome/browser/dom_ui/options/certificate_manager_handler.cc
deleted file mode 100644
index a0cd4ba..0000000
--- a/chrome/browser/dom_ui/options/certificate_manager_handler.cc
+++ /dev/null
@@ -1,938 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/certificate_manager_handler.h"
-
-#include "base/file_util.h" // for FileAccessProvider
-#include "base/safe_strerror_posix.h"
-#include "base/scoped_vector.h"
-#include "base/string_number_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/browser_thread.h" // for FileAccessProvider
-#include "chrome/browser/certificate_manager_model.h"
-#include "chrome/browser/certificate_viewer.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/browser/tab_contents/tab_contents_view.h"
-#include "chrome/browser/ui/crypto_module_password_dialog.h"
-#include "chrome/browser/ui/gtk/certificate_dialogs.h"
-#include "grit/generated_resources.h"
-#include "net/base/crypto_module.h"
-#include "net/base/x509_certificate.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/l10n/l10n_util_collator.h"
-
-namespace {
-
-static const char kKeyId[] = "id";
-static const char kSubNodesId[] = "subnodes";
-static const char kNameId[] = "name";
-static const char kReadOnlyId[] = "readonly";
-static const char kIconId[] = "icon";
-static const char kSecurityDeviceId[] = "device";
-static const char kErrorId[] = "error";
-
-// Enumeration of different callers of SelectFile. (Start counting at 1 so
-// if SelectFile is accidentally called with params=NULL it won't match any.)
-enum {
- EXPORT_PERSONAL_FILE_SELECTED = 1,
- IMPORT_PERSONAL_FILE_SELECTED,
- IMPORT_SERVER_FILE_SELECTED,
- IMPORT_CA_FILE_SELECTED,
-};
-
-// TODO(mattm): These are duplicated from cookies_view_handler.cc
-// Encodes a pointer value into a hex string.
-std::string PointerToHexString(const void* pointer) {
- return base::HexEncode(&pointer, sizeof(pointer));
-}
-
-// Decodes a pointer from a hex string.
-void* HexStringToPointer(const std::string& str) {
- std::vector<uint8> buffer;
- if (!base::HexStringToBytes(str, &buffer) ||
- buffer.size() != sizeof(void*)) {
- return NULL;
- }
-
- return *reinterpret_cast<void**>(&buffer[0]);
-}
-
-std::string OrgNameToId(const std::string& org) {
- return "org-" + org;
-}
-
-std::string CertToId(const net::X509Certificate& cert) {
- return "cert-" + PointerToHexString(&cert);
-}
-
-net::X509Certificate* IdToCert(const std::string& id) {
- if (!StartsWithASCII(id, "cert-", true))
- return NULL;
- return reinterpret_cast<net::X509Certificate*>(
- HexStringToPointer(id.substr(5)));
-}
-
-net::X509Certificate* CallbackArgsToCert(const ListValue* args) {
- std::string node_id;
- if (!args->GetString(0, &node_id)){
- return NULL;
- }
- net::X509Certificate* cert = IdToCert(node_id);
- if (!cert) {
- NOTREACHED();
- return NULL;
- }
- return cert;
-}
-
-bool CallbackArgsToBool(const ListValue* args, int index, bool* result) {
- std::string string_value;
- if (!args->GetString(index, &string_value))
- return false;
-
- *result = string_value[0] == 't';
- return true;
-}
-
-struct DictionaryIdComparator {
- explicit DictionaryIdComparator(icu::Collator* collator)
- : collator_(collator) {
- }
-
- bool operator()(const Value* a,
- const Value* b) const {
- DCHECK(a->GetType() == Value::TYPE_DICTIONARY);
- DCHECK(b->GetType() == Value::TYPE_DICTIONARY);
- const DictionaryValue* a_dict = reinterpret_cast<const DictionaryValue*>(a);
- const DictionaryValue* b_dict = reinterpret_cast<const DictionaryValue*>(b);
- string16 a_str;
- string16 b_str;
- a_dict->GetString(kNameId, &a_str);
- b_dict->GetString(kNameId, &b_str);
- if (collator_ == NULL)
- return a_str < b_str;
- return l10n_util::CompareString16WithCollator(
- collator_, a_str, b_str) == UCOL_LESS;
- }
-
- icu::Collator* collator_;
-};
-
-std::string NetErrorToString(int net_error) {
- switch (net_error) {
- // TODO(mattm): handle more cases.
- case net::ERR_IMPORT_CA_CERT_NOT_CA:
- return l10n_util::GetStringUTF8(IDS_CERT_MANAGER_ERROR_NOT_CA);
- default:
- return l10n_util::GetStringUTF8(IDS_CERT_MANAGER_UNKNOWN_ERROR);
- }
-}
-
-} // namespace
-
-///////////////////////////////////////////////////////////////////////////////
-// FileAccessProvider
-
-// TODO(mattm): Move to some shared location?
-class FileAccessProvider
- : public base::RefCountedThreadSafe<FileAccessProvider>,
- public CancelableRequestProvider {
- public:
- // Reports 0 on success or errno on failure, and the data of the file upon
- // success.
- // TODO(mattm): don't pass std::string by value.. could use RefCountedBytes
- // but it's a vector. Maybe do the derive from CancelableRequest thing
- // described in cancelable_request.h?
- typedef Callback2<int, std::string>::Type ReadCallback;
-
- // Reports 0 on success or errno on failure, and the number of bytes written,
- // on success.
- typedef Callback2<int, int>::Type WriteCallback;
-
- Handle StartRead(const FilePath& path,
- CancelableRequestConsumerBase* consumer,
- ReadCallback* callback);
- Handle StartWrite(const FilePath& path,
- const std::string& data,
- CancelableRequestConsumerBase* consumer,
- WriteCallback* callback);
-
- private:
- void DoRead(scoped_refptr<CancelableRequest<ReadCallback> > request,
- FilePath path);
- void DoWrite(scoped_refptr<CancelableRequest<WriteCallback> > request,
- FilePath path,
- std::string data);
-};
-
-CancelableRequestProvider::Handle FileAccessProvider::StartRead(
- const FilePath& path,
- CancelableRequestConsumerBase* consumer,
- FileAccessProvider::ReadCallback* callback) {
- scoped_refptr<CancelableRequest<ReadCallback> > request(
- new CancelableRequest<ReadCallback>(callback));
- AddRequest(request, consumer);
-
- // Send the parameters and the request to the file thread.
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(this, &FileAccessProvider::DoRead, request, path));
-
- // The handle will have been set by AddRequest.
- return request->handle();
-}
-
-CancelableRequestProvider::Handle FileAccessProvider::StartWrite(
- const FilePath& path,
- const std::string& data,
- CancelableRequestConsumerBase* consumer,
- WriteCallback* callback) {
- scoped_refptr<CancelableRequest<WriteCallback> > request(
- new CancelableRequest<WriteCallback>(callback));
- AddRequest(request, consumer);
-
- // Send the parameters and the request to the file thWrite.
- BrowserThread::PostTask(
- BrowserThread::FILE, FROM_HERE,
- NewRunnableMethod(
- this, &FileAccessProvider::DoWrite, request, path, data));
-
- // The handle will have been set by AddRequest.
- return request->handle();
-}
-
-void FileAccessProvider::DoRead(
- scoped_refptr<CancelableRequest<ReadCallback> > request,
- FilePath path) {
- if (request->canceled())
- return;
-
- std::string data;
- VLOG(1) << "DoRead starting read";
- bool success = file_util::ReadFileToString(path, &data);
- int saved_errno = success ? 0 : errno;
- VLOG(1) << "DoRead done read: " << success << " " << data.size();
- request->ForwardResult(ReadCallback::TupleType(saved_errno, data));
-}
-
-void FileAccessProvider::DoWrite(
- scoped_refptr<CancelableRequest<WriteCallback> > request,
- FilePath path,
- std::string data) {
- VLOG(1) << "DoWrite starting write";
- int bytes_written = file_util::WriteFile(path, data.data(), data.size());
- int saved_errno = bytes_written >= 0 ? 0 : errno;
- VLOG(1) << "DoWrite done write " << bytes_written;
-
- if (request->canceled())
- return;
-
- request->ForwardResult(WriteCallback::TupleType(saved_errno, bytes_written));
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CertificateManagerHandler
-
-CertificateManagerHandler::CertificateManagerHandler()
- : file_access_provider_(new FileAccessProvider) {
- certificate_manager_model_.reset(new CertificateManagerModel(this));
-}
-
-CertificateManagerHandler::~CertificateManagerHandler() {
-}
-
-void CertificateManagerHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- RegisterTitle(localized_strings, "certificateManagerPage",
- IDS_CERTIFICATE_MANAGER_TITLE);
-
- // Tabs.
- localized_strings->SetString("personalCertsTabTitle",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PERSONAL_CERTS_TAB_LABEL));
- localized_strings->SetString("serverCertsTabTitle",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_SERVER_CERTS_TAB_LABEL));
- localized_strings->SetString("caCertsTabTitle",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_CERT_AUTHORITIES_TAB_LABEL));
- localized_strings->SetString("unknownCertsTabTitle",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_UNKNOWN_TAB_LABEL));
-
- // Tab descriptions.
- localized_strings->SetString("personalCertsTabDescription",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_USER_TREE_DESCRIPTION));
- localized_strings->SetString("serverCertsTabDescription",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_SERVER_TREE_DESCRIPTION));
- localized_strings->SetString("caCertsTabDescription",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_AUTHORITIES_TREE_DESCRIPTION));
- localized_strings->SetString("unknownCertsTabDescription",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_UNKNOWN_TREE_DESCRIPTION));
-
- // Tree columns.
- localized_strings->SetString("certNameColumn",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_NAME_COLUMN_LABEL));
- localized_strings->SetString("certDeviceColumn",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_DEVICE_COLUMN_LABEL));
- localized_strings->SetString("certSerialColumn",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_SERIAL_NUMBER_COLUMN_LABEL));
- localized_strings->SetString("certExpiresColumn",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_EXPIRES_COLUMN_LABEL));
-
- // Buttons.
- localized_strings->SetString("view_certificate",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON));
- localized_strings->SetString("import_certificate",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_IMPORT_BUTTON));
- localized_strings->SetString("export_certificate",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_EXPORT_BUTTON));
- localized_strings->SetString("export_all_certificates",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_EXPORT_ALL_BUTTON));
- localized_strings->SetString("edit_certificate",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_EDIT_BUTTON));
- localized_strings->SetString("delete_certificate",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_DELETE_BUTTON));
-
- // Certificate Delete overlay strings.
- localized_strings->SetString("personalCertsTabDeleteConfirm",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_DELETE_USER_FORMAT));
- localized_strings->SetString("personalCertsTabDeleteImpact",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_DELETE_USER_DESCRIPTION));
- localized_strings->SetString("serverCertsTabDeleteConfirm",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_DELETE_SERVER_FORMAT));
- localized_strings->SetString("serverCertsTabDeleteImpact",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_DELETE_SERVER_DESCRIPTION));
- localized_strings->SetString("caCertsTabDeleteConfirm",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_DELETE_CA_FORMAT));
- localized_strings->SetString("caCertsTabDeleteImpact",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_DELETE_CA_DESCRIPTION));
- localized_strings->SetString("unknownCertsTabDeleteConfirm",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_DELETE_UNKNOWN_FORMAT));
- localized_strings->SetString("unknownCertsTabDeleteImpact", "");
-
- // Certificate Restore overlay strings.
- localized_strings->SetString("certificateRestorePasswordDescription",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_RESTORE_PASSWORD_DESC));
- localized_strings->SetString("certificatePasswordLabel",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PASSWORD_LABEL));
-
- // Personal Certificate Export overlay strings.
- localized_strings->SetString("certificateExportPasswordDescription",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_EXPORT_PASSWORD_DESC));
- localized_strings->SetString("certificateExportPasswordHelp",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_EXPORT_PASSWORD_HELP));
- localized_strings->SetString("certificateConfirmPasswordLabel",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_CONFIRM_PASSWORD_LABEL));
-
- // Edit CA Trust & Import CA overlay strings.
- localized_strings->SetString("certificateEditTrustLabel",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_EDIT_TRUST_LABEL));
- localized_strings->SetString("certificateEditCaTrustDescriptionFormat",
- l10n_util::GetStringUTF16(
- IDS_CERT_MANAGER_EDIT_CA_TRUST_DESCRIPTION_FORMAT));
- localized_strings->SetString("certificateImportCaDescriptionFormat",
- l10n_util::GetStringUTF16(
- IDS_CERT_MANAGER_IMPORT_CA_DESCRIPTION_FORMAT));
- localized_strings->SetString("certificateCaTrustSSLLabel",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_EDIT_CA_TRUST_SSL_LABEL));
- localized_strings->SetString("certificateCaTrustEmailLabel",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_EDIT_CA_TRUST_EMAIL_LABEL));
- localized_strings->SetString("certificateCaTrustObjSignLabel",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_EDIT_CA_TRUST_OBJSIGN_LABEL));
- localized_strings->SetString("certificateImportErrorFormat",
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_IMPORT_ERROR_FORMAT));
-}
-
-void CertificateManagerHandler::RegisterMessages() {
- web_ui_->RegisterMessageCallback("viewCertificate",
- NewCallback(this, &CertificateManagerHandler::View));
-
- web_ui_->RegisterMessageCallback("getCaCertificateTrust",
- NewCallback(this, &CertificateManagerHandler::GetCATrust));
- web_ui_->RegisterMessageCallback("editCaCertificateTrust",
- NewCallback(this, &CertificateManagerHandler::EditCATrust));
-
- web_ui_->RegisterMessageCallback("editServerCertificate",
- NewCallback(this, &CertificateManagerHandler::EditServer));
-
- web_ui_->RegisterMessageCallback("cancelImportExportCertificate",
- NewCallback(this, &CertificateManagerHandler::CancelImportExportProcess));
-
- web_ui_->RegisterMessageCallback("exportPersonalCertificate",
- NewCallback(this, &CertificateManagerHandler::ExportPersonal));
- web_ui_->RegisterMessageCallback("exportAllPersonalCertificates",
- NewCallback(this, &CertificateManagerHandler::ExportAllPersonal));
- web_ui_->RegisterMessageCallback("exportPersonalCertificatePasswordSelected",
- NewCallback(this,
- &CertificateManagerHandler::ExportPersonalPasswordSelected));
-
- web_ui_->RegisterMessageCallback("importPersonalCertificate",
- NewCallback(this, &CertificateManagerHandler::StartImportPersonal));
- web_ui_->RegisterMessageCallback("importPersonalCertificatePasswordSelected",
- NewCallback(this,
- &CertificateManagerHandler::ImportPersonalPasswordSelected));
-
- web_ui_->RegisterMessageCallback("importCaCertificate",
- NewCallback(this, &CertificateManagerHandler::ImportCA));
- web_ui_->RegisterMessageCallback("importCaCertificateTrustSelected",
- NewCallback(this, &CertificateManagerHandler::ImportCATrustSelected));
-
- web_ui_->RegisterMessageCallback("importServerCertificate",
- NewCallback(this, &CertificateManagerHandler::ImportServer));
-
- web_ui_->RegisterMessageCallback("exportCertificate",
- NewCallback(this, &CertificateManagerHandler::Export));
-
- web_ui_->RegisterMessageCallback("deleteCertificate",
- NewCallback(this, &CertificateManagerHandler::Delete));
-
- web_ui_->RegisterMessageCallback("populateCertificateManager",
- NewCallback(this, &CertificateManagerHandler::Populate));
-}
-
-void CertificateManagerHandler::CertificatesRefreshed() {
- PopulateTree("personalCertsTab", net::USER_CERT);
- PopulateTree("serverCertsTab", net::SERVER_CERT);
- PopulateTree("caCertsTab", net::CA_CERT);
- PopulateTree("otherCertsTab", net::UNKNOWN_CERT);
- VLOG(1) << "populating finished";
-}
-
-void CertificateManagerHandler::FileSelected(const FilePath& path, int index,
- void* params) {
- switch (reinterpret_cast<intptr_t>(params)) {
- case EXPORT_PERSONAL_FILE_SELECTED:
- ExportPersonalFileSelected(path);
- break;
- case IMPORT_PERSONAL_FILE_SELECTED:
- ImportPersonalFileSelected(path);
- break;
- case IMPORT_SERVER_FILE_SELECTED:
- ImportServerFileSelected(path);
- break;
- case IMPORT_CA_FILE_SELECTED:
- ImportCAFileSelected(path);
- break;
- default:
- NOTREACHED();
- }
-}
-
-void CertificateManagerHandler::FileSelectionCanceled(void* params) {
- switch (reinterpret_cast<intptr_t>(params)) {
- case EXPORT_PERSONAL_FILE_SELECTED:
- case IMPORT_PERSONAL_FILE_SELECTED:
- case IMPORT_SERVER_FILE_SELECTED:
- case IMPORT_CA_FILE_SELECTED:
- ImportExportCleanup();
- break;
- default:
- NOTREACHED();
- }
-}
-
-void CertificateManagerHandler::View(const ListValue* args) {
- net::X509Certificate* cert = CallbackArgsToCert(args);
- if (!cert)
- return;
- ShowCertificateViewer(GetParentWindow(), cert);
-}
-
-void CertificateManagerHandler::GetCATrust(const ListValue* args) {
- net::X509Certificate* cert = CallbackArgsToCert(args);
- if (!cert) {
- web_ui_->CallJavascriptFunction(L"CertificateEditCaTrustOverlay.dismiss");
- return;
- }
-
- int trust = certificate_manager_model_->cert_db().GetCertTrust(
- cert, net::CA_CERT);
- FundamentalValue ssl_value(bool(trust & net::CertDatabase::TRUSTED_SSL));
- FundamentalValue email_value(bool(trust & net::CertDatabase::TRUSTED_EMAIL));
- FundamentalValue obj_sign_value(
- bool(trust & net::CertDatabase::TRUSTED_OBJ_SIGN));
- web_ui_->CallJavascriptFunction(
- L"CertificateEditCaTrustOverlay.populateTrust",
- ssl_value, email_value, obj_sign_value);
-}
-
-void CertificateManagerHandler::EditCATrust(const ListValue* args) {
- net::X509Certificate* cert = CallbackArgsToCert(args);
- bool fail = !cert;
- bool trust_ssl = false;
- bool trust_email = false;
- bool trust_obj_sign = false;
- fail |= !CallbackArgsToBool(args, 1, &trust_ssl);
- fail |= !CallbackArgsToBool(args, 2, &trust_email);
- fail |= !CallbackArgsToBool(args, 3, &trust_obj_sign);
- if (fail) {
- LOG(ERROR) << "EditCATrust args fail";
- web_ui_->CallJavascriptFunction(L"CertificateEditCaTrustOverlay.dismiss");
- return;
- }
-
- bool result = certificate_manager_model_->SetCertTrust(
- cert,
- net::CA_CERT,
- trust_ssl * net::CertDatabase::TRUSTED_SSL +
- trust_email * net::CertDatabase::TRUSTED_EMAIL +
- trust_obj_sign * net::CertDatabase::TRUSTED_OBJ_SIGN);
- web_ui_->CallJavascriptFunction(L"CertificateEditCaTrustOverlay.dismiss");
- if (!result) {
- // TODO(mattm): better error messages?
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_SET_TRUST_ERROR_TITLE),
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_UNKNOWN_ERROR));
- }
-}
-
-void CertificateManagerHandler::EditServer(const ListValue* args) {
- NOTIMPLEMENTED();
-}
-
-void CertificateManagerHandler::ExportPersonal(const ListValue* args) {
- net::X509Certificate* cert = CallbackArgsToCert(args);
- if (!cert)
- return;
-
- selected_cert_list_.push_back(cert);
-
- SelectFileDialog::FileTypeInfo file_type_info;
- file_type_info.extensions.resize(1);
- file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("p12"));
- file_type_info.extension_description_overrides.push_back(
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PKCS12_FILES));
- file_type_info.include_all_files = true;
- select_file_dialog_ = SelectFileDialog::Create(this);
- select_file_dialog_->SelectFile(
- SelectFileDialog::SELECT_SAVEAS_FILE, string16(),
- FilePath(), &file_type_info, 1,
- FILE_PATH_LITERAL("p12"), GetParentWindow(),
- reinterpret_cast<void*>(EXPORT_PERSONAL_FILE_SELECTED));
-}
-
-void CertificateManagerHandler::ExportAllPersonal(const ListValue* args) {
- NOTIMPLEMENTED();
-}
-
-void CertificateManagerHandler::ExportPersonalFileSelected(
- const FilePath& path) {
- file_path_ = path;
- web_ui_->CallJavascriptFunction(
- L"CertificateManager.exportPersonalAskPassword");
-}
-
-void CertificateManagerHandler::ExportPersonalPasswordSelected(
- const ListValue* args) {
- if (!args->GetString(0, &password_)){
- web_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss");
- ImportExportCleanup();
- return;
- }
-
- // Currently, we don't support exporting more than one at a time. If we do,
- // this would need some cleanup to handle unlocking multiple slots.
- DCHECK_EQ(selected_cert_list_.size(), 1U);
-
- // TODO(mattm): do something smarter about non-extractable keys
- browser::UnlockCertSlotIfNecessary(
- selected_cert_list_[0].get(),
- browser::kCryptoModulePasswordCertExport,
- "", // unused.
- NewCallback(this,
- &CertificateManagerHandler::ExportPersonalSlotsUnlocked));
-}
-
-void CertificateManagerHandler::ExportPersonalSlotsUnlocked() {
- std::string output;
- int num_exported = certificate_manager_model_->cert_db().ExportToPKCS12(
- selected_cert_list_,
- password_,
- &output);
- if (!num_exported) {
- web_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss");
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_PKCS12_EXPORT_ERROR_TITLE),
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_UNKNOWN_ERROR));
- ImportExportCleanup();
- return;
- }
- file_access_provider_->StartWrite(
- file_path_,
- output,
- &consumer_,
- NewCallback(this, &CertificateManagerHandler::ExportPersonalFileWritten));
-}
-
-void CertificateManagerHandler::ExportPersonalFileWritten(int write_errno,
- int bytes_written) {
- web_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss");
- ImportExportCleanup();
- if (write_errno) {
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_PKCS12_EXPORT_ERROR_TITLE),
- l10n_util::GetStringFUTF8(IDS_CERT_MANAGER_WRITE_ERROR_FORMAT,
- UTF8ToUTF16(safe_strerror(write_errno))));
- }
-}
-
-void CertificateManagerHandler::StartImportPersonal(const ListValue* args) {
- SelectFileDialog::FileTypeInfo file_type_info;
- file_type_info.extensions.resize(1);
- file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("p12"));
- file_type_info.extension_description_overrides.push_back(
- l10n_util::GetStringUTF16(IDS_CERT_MANAGER_PKCS12_FILES));
- file_type_info.include_all_files = true;
- select_file_dialog_ = SelectFileDialog::Create(this);
- select_file_dialog_->SelectFile(
- SelectFileDialog::SELECT_OPEN_FILE, string16(),
- FilePath(), &file_type_info, 1,
- FILE_PATH_LITERAL("p12"), GetParentWindow(),
- reinterpret_cast<void*>(IMPORT_PERSONAL_FILE_SELECTED));
-}
-
-void CertificateManagerHandler::ImportPersonalFileSelected(
- const FilePath& path) {
- file_path_ = path;
- web_ui_->CallJavascriptFunction(
- L"CertificateManager.importPersonalAskPassword");
-}
-
-void CertificateManagerHandler::ImportPersonalPasswordSelected(
- const ListValue* args) {
- if (!args->GetString(0, &password_)){
- web_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss");
- ImportExportCleanup();
- return;
- }
- file_access_provider_->StartRead(
- file_path_,
- &consumer_,
- NewCallback(this, &CertificateManagerHandler::ImportPersonalFileRead));
-}
-
-void CertificateManagerHandler::ImportPersonalFileRead(
- int read_errno, std::string data) {
- if (read_errno) {
- ImportExportCleanup();
- web_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss");
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_PKCS12_IMPORT_ERROR_TITLE),
- l10n_util::GetStringFUTF8(IDS_CERT_MANAGER_READ_ERROR_FORMAT,
- UTF8ToUTF16(safe_strerror(read_errno))));
- return;
- }
-
- file_data_ = data;
-
- // TODO(mattm): allow user to choose a slot to import to.
- module_ = certificate_manager_model_->cert_db().GetDefaultModule();
-
- browser::UnlockSlotIfNecessary(
- module_.get(),
- browser::kCryptoModulePasswordCertImport,
- "", // unused.
- NewCallback(this,
- &CertificateManagerHandler::ImportPersonalSlotUnlocked));
-}
-
-void CertificateManagerHandler::ImportPersonalSlotUnlocked() {
- int result = certificate_manager_model_->ImportFromPKCS12(
- module_, file_data_, password_);
- ImportExportCleanup();
- web_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss");
- switch (result) {
- case net::OK:
- break;
- case net::ERR_PKCS12_IMPORT_BAD_PASSWORD:
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_PKCS12_IMPORT_ERROR_TITLE),
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_BAD_PASSWORD));
- // TODO(mattm): if the error was a bad password, we should reshow the
- // password dialog after the user dismisses the error dialog.
- break;
- default:
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_PKCS12_IMPORT_ERROR_TITLE),
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_UNKNOWN_ERROR));
- break;
- }
-}
-
-void CertificateManagerHandler::CancelImportExportProcess(
- const ListValue* args) {
- ImportExportCleanup();
-}
-
-void CertificateManagerHandler::ImportExportCleanup() {
- file_path_.clear();
- password_.clear();
- file_data_.clear();
- selected_cert_list_.clear();
- select_file_dialog_ = NULL;
- module_ = NULL;
-}
-
-void CertificateManagerHandler::ImportServer(const ListValue* args) {
- select_file_dialog_ = SelectFileDialog::Create(this);
- ShowCertSelectFileDialog(
- select_file_dialog_.get(),
- SelectFileDialog::SELECT_OPEN_FILE,
- FilePath(),
- GetParentWindow(),
- reinterpret_cast<void*>(IMPORT_SERVER_FILE_SELECTED));
-}
-
-void CertificateManagerHandler::ImportServerFileSelected(const FilePath& path) {
- file_path_ = path;
- file_access_provider_->StartRead(
- file_path_,
- &consumer_,
- NewCallback(this, &CertificateManagerHandler::ImportServerFileRead));
-}
-
-void CertificateManagerHandler::ImportServerFileRead(int read_errno,
- std::string data) {
- if (read_errno) {
- ImportExportCleanup();
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_SERVER_IMPORT_ERROR_TITLE),
- l10n_util::GetStringFUTF8(IDS_CERT_MANAGER_READ_ERROR_FORMAT,
- UTF8ToUTF16(safe_strerror(read_errno))));
- return;
- }
-
- selected_cert_list_ = net::X509Certificate::CreateCertificateListFromBytes(
- data.data(), data.size(), net::X509Certificate::FORMAT_AUTO);
- if (selected_cert_list_.empty()) {
- ImportExportCleanup();
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_SERVER_IMPORT_ERROR_TITLE),
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_CERT_PARSE_ERROR));
- return;
- }
-
- net::CertDatabase::ImportCertFailureList not_imported;
- bool result = certificate_manager_model_->ImportServerCert(
- selected_cert_list_,
- &not_imported);
- if (!result) {
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_SERVER_IMPORT_ERROR_TITLE),
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_UNKNOWN_ERROR));
- } else if (!not_imported.empty()) {
- ShowImportErrors(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_SERVER_IMPORT_ERROR_TITLE),
- not_imported);
- }
- ImportExportCleanup();
-}
-
-void CertificateManagerHandler::ImportCA(const ListValue* args) {
- select_file_dialog_ = SelectFileDialog::Create(this);
- ShowCertSelectFileDialog(select_file_dialog_.get(),
- SelectFileDialog::SELECT_OPEN_FILE,
- FilePath(),
- GetParentWindow(),
- reinterpret_cast<void*>(IMPORT_CA_FILE_SELECTED));
-}
-
-void CertificateManagerHandler::ImportCAFileSelected(const FilePath& path) {
- file_path_ = path;
- file_access_provider_->StartRead(
- file_path_,
- &consumer_,
- NewCallback(this, &CertificateManagerHandler::ImportCAFileRead));
-}
-
-void CertificateManagerHandler::ImportCAFileRead(int read_errno,
- std::string data) {
- if (read_errno) {
- ImportExportCleanup();
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_CA_IMPORT_ERROR_TITLE),
- l10n_util::GetStringFUTF8(IDS_CERT_MANAGER_READ_ERROR_FORMAT,
- UTF8ToUTF16(safe_strerror(read_errno))));
- return;
- }
-
- selected_cert_list_ = net::X509Certificate::CreateCertificateListFromBytes(
- data.data(), data.size(), net::X509Certificate::FORMAT_AUTO);
- if (selected_cert_list_.empty()) {
- ImportExportCleanup();
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_CA_IMPORT_ERROR_TITLE),
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_CERT_PARSE_ERROR));
- return;
- }
-
- scoped_refptr<net::X509Certificate> root_cert =
- certificate_manager_model_->cert_db().FindRootInList(selected_cert_list_);
-
- // TODO(mattm): check here if root_cert is not a CA cert and show error.
-
- StringValue cert_name(root_cert->subject().GetDisplayName());
- web_ui_->CallJavascriptFunction(L"CertificateEditCaTrustOverlay.showImport",
- cert_name);
-}
-
-void CertificateManagerHandler::ImportCATrustSelected(const ListValue* args) {
- bool fail = false;
- bool trust_ssl = false;
- bool trust_email = false;
- bool trust_obj_sign = false;
- fail |= !CallbackArgsToBool(args, 0, &trust_ssl);
- fail |= !CallbackArgsToBool(args, 1, &trust_email);
- fail |= !CallbackArgsToBool(args, 2, &trust_obj_sign);
- if (fail) {
- LOG(ERROR) << "ImportCATrustSelected args fail";
- ImportExportCleanup();
- web_ui_->CallJavascriptFunction(L"CertificateEditCaTrustOverlay.dismiss");
- return;
- }
-
- net::CertDatabase::ImportCertFailureList not_imported;
- bool result = certificate_manager_model_->ImportCACerts(
- selected_cert_list_,
- trust_ssl * net::CertDatabase::TRUSTED_SSL +
- trust_email * net::CertDatabase::TRUSTED_EMAIL +
- trust_obj_sign * net::CertDatabase::TRUSTED_OBJ_SIGN,
- &not_imported);
- web_ui_->CallJavascriptFunction(L"CertificateEditCaTrustOverlay.dismiss");
- if (!result) {
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_CA_IMPORT_ERROR_TITLE),
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_UNKNOWN_ERROR));
- } else if (!not_imported.empty()) {
- ShowImportErrors(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_CA_IMPORT_ERROR_TITLE),
- not_imported);
- }
- ImportExportCleanup();
-}
-
-void CertificateManagerHandler::Export(const ListValue* args) {
- net::X509Certificate* cert = CallbackArgsToCert(args);
- if (!cert)
- return;
- ShowCertExportDialog(GetParentWindow(), cert->os_cert_handle());
-}
-
-void CertificateManagerHandler::Delete(const ListValue* args) {
- net::X509Certificate* cert = CallbackArgsToCert(args);
- if (!cert)
- return;
- bool result = certificate_manager_model_->Delete(cert);
- if (!result) {
- // TODO(mattm): better error messages?
- ShowError(
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_DELETE_CERT_ERROR_TITLE),
- l10n_util::GetStringUTF8(IDS_CERT_MANAGER_UNKNOWN_ERROR));
- }
-}
-
-void CertificateManagerHandler::Populate(const ListValue* args) {
- certificate_manager_model_->Refresh();
-}
-
-void CertificateManagerHandler::PopulateTree(const std::string& tab_name,
- net::CertType type) {
- const std::string tree_name = tab_name + "-tree";
-
- scoped_ptr<icu::Collator> collator;
- UErrorCode error = U_ZERO_ERROR;
- collator.reset(
- icu::Collator::createInstance(
- icu::Locale(g_browser_process->GetApplicationLocale().c_str()),
- error));
- if (U_FAILURE(error))
- collator.reset(NULL);
- DictionaryIdComparator comparator(collator.get());
- CertificateManagerModel::OrgGroupingMap map;
-
- certificate_manager_model_->FilterAndBuildOrgGroupingMap(type, &map);
-
- {
- ListValue* nodes = new ListValue;
- for (CertificateManagerModel::OrgGroupingMap::iterator i = map.begin();
- i != map.end(); ++i) {
- // Populate first level (org name).
- DictionaryValue* dict = new DictionaryValue;
- dict->SetString(kKeyId, OrgNameToId(i->first));
- dict->SetString(kNameId, i->first);
-
- // Populate second level (certs).
- ListValue* subnodes = new ListValue;
- for (net::CertificateList::const_iterator org_cert_it = i->second.begin();
- org_cert_it != i->second.end(); ++org_cert_it) {
- DictionaryValue* cert_dict = new DictionaryValue;
- net::X509Certificate* cert = org_cert_it->get();
- cert_dict->SetString(kKeyId, CertToId(*cert));
- cert_dict->SetString(kNameId, certificate_manager_model_->GetColumnText(
- *cert, CertificateManagerModel::COL_SUBJECT_NAME));
- cert_dict->SetBoolean(
- kReadOnlyId,
- certificate_manager_model_->cert_db().IsReadOnly(cert));
- // TODO(mattm): Other columns.
- cert_dict->SetString(kIconId, "none");
- subnodes->Append(cert_dict);
- }
- std::sort(subnodes->begin(), subnodes->end(), comparator);
-
- dict->Set(kSubNodesId, subnodes);
- nodes->Append(dict);
- }
- std::sort(nodes->begin(), nodes->end(), comparator);
-
- ListValue args;
- args.Append(Value::CreateStringValue(tree_name));
- args.Append(nodes);
- web_ui_->CallJavascriptFunction(L"CertificateManager.onPopulateTree", args);
- }
-}
-
-void CertificateManagerHandler::ShowError(const std::string& title,
- const std::string& error) const {
- ScopedVector<const Value> args;
- args.push_back(Value::CreateStringValue(title));
- args.push_back(Value::CreateStringValue(error));
- args.push_back(Value::CreateStringValue(l10n_util::GetStringUTF8(IDS_OK)));
- args.push_back(Value::CreateNullValue()); // cancelTitle
- args.push_back(Value::CreateNullValue()); // okCallback
- args.push_back(Value::CreateNullValue()); // cancelCallback
- web_ui_->CallJavascriptFunction(L"AlertOverlay.show", args.get());
-}
-
-void CertificateManagerHandler::ShowImportErrors(
- const std::string& title,
- const net::CertDatabase::ImportCertFailureList& not_imported) const {
- std::string error;
- if (selected_cert_list_.size() == 1)
- error = l10n_util::GetStringUTF8(
- IDS_CERT_MANAGER_IMPORT_SINGLE_NOT_IMPORTED);
- else if (not_imported.size() == selected_cert_list_.size())
- error = l10n_util::GetStringUTF8(IDS_CERT_MANAGER_IMPORT_ALL_NOT_IMPORTED);
- else
- error = l10n_util::GetStringUTF8(IDS_CERT_MANAGER_IMPORT_SOME_NOT_IMPORTED);
-
- ListValue cert_error_list;
- for (size_t i = 0; i < not_imported.size(); ++i) {
- const net::CertDatabase::ImportCertFailure& failure = not_imported[i];
- DictionaryValue* dict = new DictionaryValue;
- dict->SetString(kNameId, failure.certificate->subject().GetDisplayName());
- dict->SetString(kErrorId, NetErrorToString(failure.net_error));
- cert_error_list.Append(dict);
- }
-
- StringValue title_value(title);
- StringValue error_value(error);
- web_ui_->CallJavascriptFunction(L"CertificateImportErrorOverlay.show",
- title_value,
- error_value,
- cert_error_list);
-}
-
-gfx::NativeWindow CertificateManagerHandler::GetParentWindow() const {
- return web_ui_->tab_contents()->view()->GetTopLevelNativeWindow();
-}
diff --git a/chrome/browser/dom_ui/options/certificate_manager_handler.h b/chrome/browser/dom_ui/options/certificate_manager_handler.h
index 24a6169..1500337 100644
--- a/chrome/browser/dom_ui/options/certificate_manager_handler.h
+++ b/chrome/browser/dom_ui/options/certificate_manager_handler.h
@@ -6,156 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_CERTIFICATE_MANAGER_HANDLER_H_
#pragma once
-#include <string>
-
-#include "base/scoped_ptr.h"
-#include "chrome/browser/cancelable_request.h"
-#include "chrome/browser/certificate_manager_model.h"
-#include "chrome/browser/dom_ui/options/options_ui.h"
-#include "chrome/browser/ui/shell_dialogs.h"
-#include "net/base/cert_database.h"
-#include "ui/gfx/native_widget_types.h"
-
-class FileAccessProvider;
-
-class CertificateManagerHandler : public OptionsPageUIHandler,
- public CertificateManagerModel::Observer,
- public SelectFileDialog::Listener {
- public:
- CertificateManagerHandler();
- virtual ~CertificateManagerHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
- virtual void RegisterMessages();
-
- // CertificateManagerModel::Observer implementation.
- virtual void CertificatesRefreshed();
-
- // SelectFileDialog::Listener implementation.
- virtual void FileSelected(const FilePath& path, int index, void* params);
- virtual void FileSelectionCanceled(void* params);
-
- private:
- // View certificate.
- void View(const ListValue* args);
-
- // Edit server certificate trust values.
- void EditServer(const ListValue* args);
-
- // Edit certificate authority trust values. The sequence goes like:
- // 1. user clicks edit button -> CertificateEditCaTrustOverlay.show ->
- // GetCATrust -> CertificateEditCaTrustOverlay.populateTrust
- // 2. user clicks ok -> EditCATrust -> CertificateEditCaTrustOverlay.dismiss
- void GetCATrust(const ListValue* args);
- void EditCATrust(const ListValue* args);
-
- // Cleanup state stored during import or export process.
- void CancelImportExportProcess(const ListValue* args);
- void ImportExportCleanup();
-
- // Export to PKCS #12 file. The sequence goes like:
- // 1a. user click on export button -> ExportPersonal -> launches file
- // selector
- // 1b. user click on export all button -> ExportAllPersonal -> launches file
- // selector
- // 2. user selects file -> ExportPersonalFileSelected -> launches password
- // dialog
- // 3. user enters password -> ExportPersonalPasswordSelected -> unlock slots
- // 4. slots unlocked -> ExportPersonalSlotsUnlocked -> exports to memory
- // buffer -> starts async write operation
- // 5. write finishes (or fails) -> ExportPersonalFileWritten
- void ExportPersonal(const ListValue* args);
- void ExportAllPersonal(const ListValue* args);
- void ExportPersonalFileSelected(const FilePath& path);
- void ExportPersonalPasswordSelected(const ListValue* args);
- void ExportPersonalSlotsUnlocked();
- void ExportPersonalFileWritten(int write_errno, int bytes_written);
-
- // Import from PKCS #12 file. The sequence goes like:
- // 1. user click on import button -> StartImportPersonal -> launches file
- // selector
- // 2. user selects file -> ImportPersonalFileSelected -> launches password
- // dialog
- // 3. user enters password -> ImportPersonalPasswordSelected -> starts async
- // read operation
- // 4. read operation completes -> ImportPersonalFileRead -> unlock slot
- // 5. slot unlocked -> ImportPersonalSlotUnlocked attempts to
- // import with previously entered password
- // 6a. if import succeeds -> ImportExportCleanup
- // 6b. if import fails -> show error, ImportExportCleanup
- // TODO(mattm): allow retrying with different password
- void StartImportPersonal(const ListValue* args);
- void ImportPersonalFileSelected(const FilePath& path);
- void ImportPersonalPasswordSelected(const ListValue* args);
- void ImportPersonalFileRead(int read_errno, std::string data);
- void ImportPersonalSlotUnlocked();
-
- // Import Server certificates from file. Sequence goes like:
- // 1. user clicks on import button -> ImportServer -> launches file selector
- // 2. user selects file -> ImportServerFileSelected -> starts async read
- // 3. read completes -> ImportServerFileRead -> parse certs -> attempt import
- // 4a. if import succeeds -> ImportExportCleanup
- // 4b. if import fails -> show error, ImportExportCleanup
- void ImportServer(const ListValue* args);
- void ImportServerFileSelected(const FilePath& path);
- void ImportServerFileRead(int read_errno, std::string data);
-
- // Import Certificate Authorities from file. Sequence goes like:
- // 1. user clicks on import button -> ImportCA -> launches file selector
- // 2. user selects file -> ImportCAFileSelected -> starts async read
- // 3. read completes -> ImportCAFileRead -> parse certs ->
- // CertificateEditCaTrustOverlay.showImport
- // 4. user clicks ok -> ImportCATrustSelected -> attempt import
- // 5a. if import succeeds -> ImportExportCleanup
- // 5b. if import fails -> show error, ImportExportCleanup
- void ImportCA(const ListValue* args);
- void ImportCAFileSelected(const FilePath& path);
- void ImportCAFileRead(int read_errno, std::string data);
- void ImportCATrustSelected(const ListValue* args);
-
- // Export a certificate.
- void Export(const ListValue* args);
-
- // Delete certificate and private key (if any).
- void Delete(const ListValue* args);
-
- // Populate the trees in all the tabs.
- void Populate(const ListValue* args);
-
- // Populate the given tab's tree.
- void PopulateTree(const std::string& tab_name, net::CertType type);
-
- // Display a WebUI error message box.
- void ShowError(const std::string& title, const std::string& error) const;
-
- // Display a WebUI error message box for import failures.
- // Depends on |selected_cert_list_| being set to the imports that we
- // attempted to import.
- void ShowImportErrors(
- const std::string& title,
- const net::CertDatabase::ImportCertFailureList& not_imported) const;
-
- gfx::NativeWindow GetParentWindow() const;
-
- // The Certificates Manager model
- scoped_ptr<CertificateManagerModel> certificate_manager_model_;
-
- // For multi-step import or export processes, we need to store the path,
- // password, etc the user chose while we wait for them to enter a password,
- // wait for file to be read, etc.
- FilePath file_path_;
- string16 password_;
- std::string file_data_;
- net::CertificateList selected_cert_list_;
- scoped_refptr<SelectFileDialog> select_file_dialog_;
- scoped_refptr<net::CryptoModule> module_;
-
- // Used in reading and writing certificate files.
- CancelableRequestConsumer consumer_;
- scoped_refptr<FileAccessProvider> file_access_provider_;
-
- DISALLOW_COPY_AND_ASSIGN(CertificateManagerHandler);
-};
+#include "chrome/browser/webui/options/certificate_manager_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_CERTIFICATE_MANAGER_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/clear_browser_data_handler.cc b/chrome/browser/dom_ui/options/clear_browser_data_handler.cc
deleted file mode 100644
index 08afd5d..0000000
--- a/chrome/browser/dom_ui/options/clear_browser_data_handler.cc
+++ /dev/null
@@ -1,169 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/clear_browser_data_handler.h"
-
-#include "base/basictypes.h"
-#include "base/string16.h"
-#include "base/values.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/notification_details.h"
-#include "chrome/common/pref_names.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "ui/base/l10n/l10n_util.h"
-
-ClearBrowserDataHandler::ClearBrowserDataHandler() : remover_(NULL) {
-}
-
-ClearBrowserDataHandler::~ClearBrowserDataHandler() {
- if (remover_) {
- remover_->RemoveObserver(this);
- }
-}
-
-void ClearBrowserDataHandler::Initialize() {
- clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled,
- g_browser_process->local_state(),
- this);
- UpdateClearPluginLSOData();
-}
-
-void ClearBrowserDataHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
- RegisterTitle(localized_strings, "clearBrowserDataOverlay",
- IDS_CLEAR_BROWSING_DATA_TITLE);
-
- localized_strings->SetString("clearBrowserDataLabel",
- l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_LABEL));
- localized_strings->SetString("deleteBrowsingHistoryCheckbox",
- l10n_util::GetStringUTF16(IDS_DEL_BROWSING_HISTORY_CHKBOX));
- localized_strings->SetString("deleteDownloadHistoryCheckbox",
- l10n_util::GetStringUTF16(IDS_DEL_DOWNLOAD_HISTORY_CHKBOX));
- localized_strings->SetString("deleteCacheCheckbox",
- l10n_util::GetStringUTF16(IDS_DEL_CACHE_CHKBOX));
- localized_strings->SetString("deleteCookiesCheckbox",
- l10n_util::GetStringUTF16(IDS_DEL_COOKIES_CHKBOX));
- localized_strings->SetString("deletePasswordsCheckbox",
- l10n_util::GetStringUTF16(IDS_DEL_PASSWORDS_CHKBOX));
- localized_strings->SetString("deleteFormDataCheckbox",
- l10n_util::GetStringUTF16(IDS_DEL_FORM_DATA_CHKBOX));
- localized_strings->SetString("clearBrowserDataCommit",
- l10n_util::GetStringUTF16(IDS_CLEAR_BROWSING_DATA_COMMIT));
- localized_strings->SetString("flashStorageSettings",
- l10n_util::GetStringUTF16(IDS_FLASH_STORAGE_SETTINGS));
- localized_strings->SetString("flash_storage_url",
- l10n_util::GetStringUTF16(IDS_FLASH_STORAGE_URL));
- localized_strings->SetString("clearDataDeleting",
- l10n_util::GetStringUTF16(IDS_CLEAR_DATA_DELETING));
-
- ListValue* time_list = new ListValue;
- for (int i = 0; i < 5; i++) {
- string16 label_string;
- switch (i) {
- case 0:
- label_string = l10n_util::GetStringUTF16(IDS_CLEAR_DATA_HOUR);
- break;
- case 1:
- label_string = l10n_util::GetStringUTF16(IDS_CLEAR_DATA_DAY);
- break;
- case 2:
- label_string = l10n_util::GetStringUTF16(IDS_CLEAR_DATA_WEEK);
- break;
- case 3:
- label_string = l10n_util::GetStringUTF16(IDS_CLEAR_DATA_4WEEKS);
- break;
- case 4:
- label_string = l10n_util::GetStringUTF16(IDS_CLEAR_DATA_EVERYTHING);
- break;
- }
- ListValue* option = new ListValue();
- option->Append(Value::CreateIntegerValue(i));
- option->Append(Value::CreateStringValue(label_string));
- time_list->Append(option);
- }
- localized_strings->Set("clearBrowserDataTimeList", time_list);
-}
-
-void ClearBrowserDataHandler::RegisterMessages() {
- // Setup handlers specific to this panel.
- DCHECK(web_ui_);
- web_ui_->RegisterMessageCallback("performClearBrowserData",
- NewCallback(this, &ClearBrowserDataHandler::HandleClearBrowserData));
-}
-
-void ClearBrowserDataHandler::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- switch (type.value) {
- case NotificationType::PREF_CHANGED: {
- const std::string& pref_name = *Details<std::string>(details).ptr();
- if (pref_name == prefs::kClearPluginLSODataEnabled)
- UpdateClearPluginLSOData();
- else
- OptionsPageUIHandler::Observe(type, source, details);
- break;
- }
-
- default:
- OptionsPageUIHandler::Observe(type, source, details);
- }
-}
-
-void ClearBrowserDataHandler::HandleClearBrowserData(const ListValue* value) {
- Profile* profile = web_ui_->GetProfile();
- PrefService* prefs = profile->GetPrefs();
-
- int remove_mask = 0;
- if (prefs->GetBoolean(prefs::kDeleteBrowsingHistory))
- remove_mask |= BrowsingDataRemover::REMOVE_HISTORY;
- if (prefs->GetBoolean(prefs::kDeleteDownloadHistory))
- remove_mask |= BrowsingDataRemover::REMOVE_DOWNLOADS;
- if (prefs->GetBoolean(prefs::kDeleteCache))
- remove_mask |= BrowsingDataRemover::REMOVE_CACHE;
- if (prefs->GetBoolean(prefs::kDeleteCookies)) {
- remove_mask |= BrowsingDataRemover::REMOVE_COOKIES;
- if (clear_plugin_lso_data_enabled_.GetValue())
- remove_mask |= BrowsingDataRemover::REMOVE_LSO_DATA;
- }
- if (prefs->GetBoolean(prefs::kDeletePasswords))
- remove_mask |= BrowsingDataRemover::REMOVE_PASSWORDS;
- if (prefs->GetBoolean(prefs::kDeleteFormData))
- remove_mask |= BrowsingDataRemover::REMOVE_FORM_DATA;
-
- int period_selected = prefs->GetInteger(prefs::kDeleteTimePeriod);
-
- FundamentalValue state(true);
- web_ui_->CallJavascriptFunction(L"ClearBrowserDataOverlay.setClearingState",
- state);
-
- // BrowsingDataRemover deletes itself when done.
- remover_ = new BrowsingDataRemover(profile,
- static_cast<BrowsingDataRemover::TimePeriod>(period_selected),
- base::Time());
- remover_->AddObserver(this);
- remover_->Remove(remove_mask);
-}
-
-void ClearBrowserDataHandler::UpdateClearPluginLSOData() {
- int label_id = clear_plugin_lso_data_enabled_.GetValue() ?
- IDS_DEL_COOKIES_FLASH_CHKBOX :
- IDS_DEL_COOKIES_CHKBOX;
- scoped_ptr<Value> label(
- Value::CreateStringValue(l10n_util::GetStringUTF16(label_id)));
- web_ui_->CallJavascriptFunction(
- L"ClearBrowserDataOverlay.setClearLocalDataLabel", *label);
-}
-
-void ClearBrowserDataHandler::OnBrowsingDataRemoverDone() {
- // No need to remove ourselves as an observer as BrowsingDataRemover deletes
- // itself after we return.
- remover_ = NULL;
- DCHECK(web_ui_);
- web_ui_->CallJavascriptFunction(L"ClearBrowserDataOverlay.doneClearing");
-}
diff --git a/chrome/browser/dom_ui/options/clear_browser_data_handler.h b/chrome/browser/dom_ui/options/clear_browser_data_handler.h
index e475eb0..873993f 100644
--- a/chrome/browser/dom_ui/options/clear_browser_data_handler.h
+++ b/chrome/browser/dom_ui/options/clear_browser_data_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.
@@ -6,49 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_CLEAR_BROWSER_DATA_HANDLER_H_
#pragma once
-#include "chrome/browser/dom_ui/options/options_ui.h"
-#include "chrome/browser/browsing_data_remover.h"
-#include "chrome/browser/plugin_data_remover_helper.h"
-
-// Clear browser data handler page UI handler.
-class ClearBrowserDataHandler : public OptionsPageUIHandler,
- public BrowsingDataRemover::Observer {
- public:
- ClearBrowserDataHandler();
- virtual ~ClearBrowserDataHandler();
-
- // OptionsUIHandler implementation.
- virtual void Initialize();
-
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
-
- // WebUIMessageHandler implementation.
- virtual void RegisterMessages();
-
- // NotificationObserver implementation.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- private:
- // Javascript callback to start clearing data.
- void HandleClearBrowserData(const ListValue* value);
-
- // Updates the UI to reflect whether clearing LSO data is supported.
- void UpdateClearPluginLSOData();
-
- // Callback from BrowsingDataRemover. Closes the dialog.
- virtual void OnBrowsingDataRemoverDone();
-
- // If non-null it means removal is in progress. BrowsingDataRemover takes care
- // of deleting itself when done.
- BrowsingDataRemover* remover_;
-
- // Used for asynchronously updating the preference stating whether clearing
- // LSO data is supported.
- PluginDataRemoverHelper clear_plugin_lso_data_enabled_;
-
- DISALLOW_COPY_AND_ASSIGN(ClearBrowserDataHandler);
-};
+#include "chrome/browser/webui/options/clear_browser_data_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_CLEAR_BROWSER_DATA_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/content_settings_handler.cc b/chrome/browser/dom_ui/options/content_settings_handler.cc
deleted file mode 100644
index 4a7a649..0000000
--- a/chrome/browser/dom_ui/options/content_settings_handler.cc
+++ /dev/null
@@ -1,728 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/content_settings_handler.h"
-
-#include "base/callback.h"
-#include "base/command_line.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/content_settings/content_settings_details.h"
-#include "chrome/browser/content_settings/host_content_settings_map.h"
-#include "chrome/browser/geolocation/geolocation_content_settings_map.h"
-#include "chrome/browser/notifications/desktop_notification_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/content_settings_helper.h"
-#include "chrome/common/notification_service.h"
-#include "chrome/common/notification_source.h"
-#include "chrome/common/notification_type.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/url_constants.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace {
-
-const char* kDisplayPattern = "displayPattern";
-const char* kSetting = "setting";
-const char* kOrigin = "origin";
-const char* kEmbeddingOrigin = "embeddingOrigin";
-
-ContentSettingsType ContentSettingsTypeFromGroupName(const std::string& name) {
- if (name == "cookies")
- return CONTENT_SETTINGS_TYPE_COOKIES;
- if (name == "images")
- return CONTENT_SETTINGS_TYPE_IMAGES;
- if (name == "javascript")
- return CONTENT_SETTINGS_TYPE_JAVASCRIPT;
- if (name == "plugins")
- return CONTENT_SETTINGS_TYPE_PLUGINS;
- if (name == "popups")
- return CONTENT_SETTINGS_TYPE_POPUPS;
- if (name == "location")
- return CONTENT_SETTINGS_TYPE_GEOLOCATION;
- if (name == "notifications")
- return CONTENT_SETTINGS_TYPE_NOTIFICATIONS;
-
- NOTREACHED() << name << " is not a recognized content settings type.";
- return CONTENT_SETTINGS_TYPE_DEFAULT;
-}
-
-std::string ContentSettingToString(ContentSetting setting) {
- switch (setting) {
- case CONTENT_SETTING_ALLOW:
- return "allow";
- case CONTENT_SETTING_ASK:
- return "ask";
- case CONTENT_SETTING_BLOCK:
- return "block";
- case CONTENT_SETTING_SESSION_ONLY:
- return "session";
- case CONTENT_SETTING_DEFAULT:
- return "default";
- case CONTENT_SETTING_NUM_SETTINGS:
- NOTREACHED();
- }
-
- return "";
-}
-
-ContentSetting ContentSettingFromString(const std::string& name) {
- if (name == "allow")
- return CONTENT_SETTING_ALLOW;
- if (name == "ask")
- return CONTENT_SETTING_ASK;
- if (name == "block")
- return CONTENT_SETTING_BLOCK;
- if (name == "session")
- return CONTENT_SETTING_SESSION_ONLY;
-
- NOTREACHED() << name << " is not a recognized content setting.";
- return CONTENT_SETTING_DEFAULT;
-}
-
-std::string GeolocationExceptionToString(const GURL& origin,
- const GURL& embedding_origin) {
- if (origin == embedding_origin)
- return content_settings_helper::OriginToString(origin);
-
- // TODO(estade): the page needs to use CSS to indent the string.
- std::string indent(" ");
- if (embedding_origin.is_empty()) {
- // NOTE: As long as the user cannot add/edit entries from the exceptions
- // dialog, it's impossible to actually have a non-default setting for some
- // origin "embedded on any other site", so this row will never appear. If
- // we add the ability to add/edit exceptions, we'll need to decide when to
- // display this and how "removing" it will function.
- return indent +
- l10n_util::GetStringUTF8(IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ANY_OTHER);
- }
-
- return indent + l10n_util::GetStringFUTF8(
- IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST,
- UTF8ToUTF16(content_settings_helper::OriginToString(embedding_origin)));
-}
-
-// Create a DictionaryValue* that will act as a data source for a single row
-// in a HostContentSettingsMap-controlled exceptions table (e.g., cookies).
-// Ownership of the pointer is passed to the caller.
-DictionaryValue* GetExceptionForPage(
- const ContentSettingsPattern pattern,
- ContentSetting setting) {
- DictionaryValue* exception = new DictionaryValue();
- exception->Set(
- kDisplayPattern,
- new StringValue(pattern.AsString()));
- exception->Set(
- kSetting,
- new StringValue(ContentSettingToString(setting)));
- return exception;
-}
-
-// Create a DictionaryValue* that will act as a data source for a single row
-// in the Geolocation exceptions table. Ownership of the pointer is passed to
-// the caller.
-DictionaryValue* GetGeolocationExceptionForPage(const GURL& origin,
- const GURL& embedding_origin,
- ContentSetting setting) {
- DictionaryValue* exception = new DictionaryValue();
- exception->Set(
- kDisplayPattern,
- new StringValue(GeolocationExceptionToString(origin, embedding_origin)));
- exception->Set(
- kSetting,
- new StringValue(ContentSettingToString(setting)));
- exception->Set(
- kOrigin,
- new StringValue(origin.spec()));
- exception->Set(
- kEmbeddingOrigin,
- new StringValue(embedding_origin.spec()));
- return exception;
-}
-
-// Create a DictionaryValue* that will act as a data source for a single row
-// in the desktop notifications exceptions table. Ownership of the pointer is
-// passed to the caller.
-DictionaryValue* GetNotificationExceptionForPage(
- const GURL& url,
- ContentSetting setting) {
- DictionaryValue* exception = new DictionaryValue();
- exception->Set(
- kDisplayPattern,
- new StringValue(content_settings_helper::OriginToString(url)));
- exception->Set(
- kSetting,
- new StringValue(ContentSettingToString(setting)));
- exception->Set(
- kOrigin,
- new StringValue(url.spec()));
- return exception;
-}
-
-} // namespace
-
-ContentSettingsHandler::ContentSettingsHandler() {
-}
-
-ContentSettingsHandler::~ContentSettingsHandler() {
-}
-
-void ContentSettingsHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- static OptionsStringResource resources[] = {
- { "content_exceptions", IDS_COOKIES_EXCEPTIONS_BUTTON },
- { "allowException", IDS_EXCEPTIONS_ALLOW_BUTTON },
- { "blockException", IDS_EXCEPTIONS_BLOCK_BUTTON },
- { "sessionException", IDS_EXCEPTIONS_SESSION_ONLY_BUTTON },
- { "askException", IDS_EXCEPTIONS_ASK_BUTTON },
- { "addExceptionRow", IDS_EXCEPTIONS_ADD_BUTTON },
- { "removeExceptionRow", IDS_EXCEPTIONS_REMOVE_BUTTON },
- { "editExceptionRow", IDS_EXCEPTIONS_EDIT_BUTTON },
- { "otr_exceptions_explanation", IDS_EXCEPTIONS_OTR_LABEL },
- { "examplePattern", IDS_EXCEPTIONS_PATTERN_EXAMPLE },
- { "addNewExceptionInstructions", IDS_EXCEPTIONS_ADD_NEW_INSTRUCTIONS },
- { "manage_exceptions", IDS_EXCEPTIONS_MANAGE },
- // Cookies filter.
- { "cookies_tab_label", IDS_COOKIES_TAB_LABEL },
- { "cookies_header", IDS_COOKIES_HEADER },
- { "cookies_allow", IDS_COOKIES_ALLOW_RADIO },
- { "cookies_ask", IDS_COOKIES_ASK_EVERY_TIME_RADIO },
- { "cookies_block", IDS_COOKIES_BLOCK_RADIO },
- { "cookies_block_3rd_party", IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX },
- { "cookies_show_cookies", IDS_COOKIES_SHOW_COOKIES_BUTTON },
- { "flash_storage_settings", IDS_FLASH_STORAGE_SETTINGS },
- { "flash_storage_url", IDS_FLASH_STORAGE_URL },
- // Image filter.
- { "images_tab_label", IDS_IMAGES_TAB_LABEL },
- { "images_header", IDS_IMAGES_HEADER },
- { "images_allow", IDS_IMAGES_LOAD_RADIO },
- { "images_block", IDS_IMAGES_NOLOAD_RADIO },
- // JavaScript filter.
- { "javascript_tab_label", IDS_JAVASCRIPT_TAB_LABEL },
- { "javascript_header", IDS_JAVASCRIPT_HEADER },
- { "javascript_allow", IDS_JS_ALLOW_RADIO },
- { "javascript_block", IDS_JS_DONOTALLOW_RADIO },
- // Plug-ins filter.
- { "plugins_tab_label", IDS_PLUGIN_TAB_LABEL },
- { "plugins_header", IDS_PLUGIN_HEADER },
- { "plugins_ask", IDS_PLUGIN_ASK_RADIO },
- { "plugins_allow", IDS_PLUGIN_LOAD_RADIO },
- { "plugins_block", IDS_PLUGIN_NOLOAD_RADIO },
- { "disable_individual_plugins", IDS_PLUGIN_SELECTIVE_DISABLE },
- // Pop-ups filter.
- { "popups_tab_label", IDS_POPUP_TAB_LABEL },
- { "popups_header", IDS_POPUP_HEADER },
- { "popups_allow", IDS_POPUP_ALLOW_RADIO },
- { "popups_block", IDS_POPUP_BLOCK_RADIO },
- // Location filter.
- { "location_tab_label", IDS_GEOLOCATION_TAB_LABEL },
- { "location_header", IDS_GEOLOCATION_HEADER },
- { "location_allow", IDS_GEOLOCATION_ALLOW_RADIO },
- { "location_ask", IDS_GEOLOCATION_ASK_RADIO },
- { "location_block", IDS_GEOLOCATION_BLOCK_RADIO },
- // Notifications filter.
- { "notifications_tab_label", IDS_NOTIFICATIONS_TAB_LABEL },
- { "notifications_header", IDS_NOTIFICATIONS_HEADER },
- { "notifications_allow", IDS_NOTIFICATIONS_ALLOW_RADIO },
- { "notifications_ask", IDS_NOTIFICATIONS_ASK_RADIO },
- { "notifications_block", IDS_NOTIFICATIONS_BLOCK_RADIO },
- };
-
- RegisterStrings(localized_strings, resources, arraysize(resources));
- RegisterTitle(localized_strings, "contentSettingsPage",
- IDS_CONTENT_SETTINGS_TITLE);
- localized_strings->SetBoolean("enable_click_to_play",
- CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableClickToPlay));
-}
-
-void ContentSettingsHandler::Initialize() {
- const HostContentSettingsMap* settings_map = GetContentSettingsMap();
- scoped_ptr<Value> block_3rd_party(Value::CreateBooleanValue(
- settings_map->BlockThirdPartyCookies()));
- web_ui_->CallJavascriptFunction(
- L"ContentSettings.setBlockThirdPartyCookies", *block_3rd_party.get());
-
- clear_plugin_lso_data_enabled_.Init(prefs::kClearPluginLSODataEnabled,
- g_browser_process->local_state(),
- this);
- UpdateClearPluginLSOData();
-
- notification_registrar_.Add(
- this, NotificationType::OTR_PROFILE_CREATED,
- NotificationService::AllSources());
- notification_registrar_.Add(
- this, NotificationType::PROFILE_DESTROYED,
- NotificationService::AllSources());
-
- UpdateAllExceptionsViewsFromModel();
- notification_registrar_.Add(
- this, NotificationType::CONTENT_SETTINGS_CHANGED,
- NotificationService::AllSources());
- notification_registrar_.Add(
- this, NotificationType::DESKTOP_NOTIFICATION_DEFAULT_CHANGED,
- NotificationService::AllSources());
- notification_registrar_.Add(
- this, NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED,
- NotificationService::AllSources());
-
- PrefService* prefs = web_ui_->GetProfile()->GetPrefs();
- pref_change_registrar_.Init(prefs);
- pref_change_registrar_.Add(prefs::kGeolocationDefaultContentSetting, this);
- pref_change_registrar_.Add(prefs::kGeolocationContentSettings, this);
-}
-
-void ContentSettingsHandler::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- switch (type.value) {
- case NotificationType::PROFILE_DESTROYED: {
- Profile* profile = static_cast<Source<Profile> >(source).ptr();
- if (profile->IsOffTheRecord()) {
- web_ui_->CallJavascriptFunction(
- L"ContentSettingsExceptionsArea.OTRProfileDestroyed");
- }
- break;
- }
-
- case NotificationType::OTR_PROFILE_CREATED: {
- UpdateAllOTRExceptionsViewsFromModel();
- break;
- }
-
- case NotificationType::CONTENT_SETTINGS_CHANGED: {
- const ContentSettingsDetails* settings_details =
- Details<const ContentSettingsDetails>(details).ptr();
-
- // TODO(estade): we pretend update_all() is always true.
- if (settings_details->update_all_types())
- UpdateAllExceptionsViewsFromModel();
- else
- UpdateExceptionsViewFromModel(settings_details->type());
- break;
- }
-
- case NotificationType::PREF_CHANGED: {
- const std::string& pref_name = *Details<std::string>(details).ptr();
- if (pref_name == prefs::kGeolocationDefaultContentSetting)
- UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION);
- else if (pref_name == prefs::kGeolocationContentSettings)
- UpdateGeolocationExceptionsView();
- else if (pref_name == prefs::kClearPluginLSODataEnabled)
- UpdateClearPluginLSOData();
- break;
- }
-
- case NotificationType::DESKTOP_NOTIFICATION_DEFAULT_CHANGED: {
- UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
- break;
- }
-
- case NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED: {
- UpdateNotificationExceptionsView();
- break;
- }
-
- default:
- OptionsPageUIHandler::Observe(type, source, details);
- }
-}
-
-void ContentSettingsHandler::UpdateClearPluginLSOData() {
- int label_id = clear_plugin_lso_data_enabled_.GetValue() ?
- IDS_COOKIES_LSO_CLEAR_WHEN_CLOSE_CHKBOX :
- IDS_COOKIES_CLEAR_WHEN_CLOSE_CHKBOX;
- scoped_ptr<Value> label(
- Value::CreateStringValue(l10n_util::GetStringUTF16(label_id)));
- web_ui_->CallJavascriptFunction(
- L"ContentSettings.setClearLocalDataOnShutdownLabel", *label);
-}
-
-void ContentSettingsHandler::UpdateSettingDefaultFromModel(
- ContentSettingsType type) {
- DictionaryValue filter_settings;
- filter_settings.SetString(ContentSettingsTypeToGroupName(type) + ".value",
- GetSettingDefaultFromModel(type));
- filter_settings.SetBoolean(ContentSettingsTypeToGroupName(type) + ".managed",
- GetDefaultSettingManagedFromModel(type));
-
- web_ui_->CallJavascriptFunction(
- L"ContentSettings.setContentFilterSettingsValue", filter_settings);
-}
-
-std::string ContentSettingsHandler::GetSettingDefaultFromModel(
- ContentSettingsType type) {
- ContentSetting default_setting;
- if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
- default_setting = web_ui_->GetProfile()->
- GetGeolocationContentSettingsMap()->GetDefaultContentSetting();
- } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
- default_setting = web_ui_->GetProfile()->
- GetDesktopNotificationService()->GetDefaultContentSetting();
- } else {
- default_setting = GetContentSettingsMap()->GetDefaultContentSetting(type);
- }
-
- return ContentSettingToString(default_setting);
-}
-
-bool ContentSettingsHandler::GetDefaultSettingManagedFromModel(
- ContentSettingsType type) {
- if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
- return web_ui_->GetProfile()->
- GetGeolocationContentSettingsMap()->IsDefaultContentSettingManaged();
- } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
- return web_ui_->GetProfile()->
- GetDesktopNotificationService()->IsDefaultContentSettingManaged();
- } else {
- return GetContentSettingsMap()->IsDefaultContentSettingManaged(type);
- }
-}
-
-void ContentSettingsHandler::UpdateAllExceptionsViewsFromModel() {
- for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1;
- type < CONTENT_SETTINGS_NUM_TYPES; ++type) {
- UpdateExceptionsViewFromModel(static_cast<ContentSettingsType>(type));
- }
-}
-
-void ContentSettingsHandler::UpdateAllOTRExceptionsViewsFromModel() {
- for (int type = CONTENT_SETTINGS_TYPE_DEFAULT + 1;
- type < CONTENT_SETTINGS_NUM_TYPES; ++type) {
- if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION ||
- type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
- continue;
- }
-
- UpdateExceptionsViewFromOTRHostContentSettingsMap(
- static_cast<ContentSettingsType>(type));
- }
-}
-
-void ContentSettingsHandler::UpdateExceptionsViewFromModel(
- ContentSettingsType type) {
- if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
- UpdateGeolocationExceptionsView();
- else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS)
- UpdateNotificationExceptionsView();
- else
- UpdateExceptionsViewFromHostContentSettingsMap(type);
-}
-
-void ContentSettingsHandler::UpdateGeolocationExceptionsView() {
- GeolocationContentSettingsMap* map =
- web_ui_->GetProfile()->GetGeolocationContentSettingsMap();
- GeolocationContentSettingsMap::AllOriginsSettings all_settings =
- map->GetAllOriginsSettings();
- GeolocationContentSettingsMap::AllOriginsSettings::const_iterator i;
-
- ListValue exceptions;
- for (i = all_settings.begin(); i != all_settings.end(); ++i) {
- const GURL& origin = i->first;
- const GeolocationContentSettingsMap::OneOriginSettings& one_settings =
- i->second;
-
- GeolocationContentSettingsMap::OneOriginSettings::const_iterator parent =
- one_settings.find(origin);
-
- // Add the "parent" entry for the non-embedded setting.
- ContentSetting parent_setting =
- parent == one_settings.end() ? CONTENT_SETTING_DEFAULT : parent->second;
- exceptions.Append(
- GetGeolocationExceptionForPage(origin, origin, parent_setting));
-
- // Add the "children" for any embedded settings.
- GeolocationContentSettingsMap::OneOriginSettings::const_iterator j;
- for (j = one_settings.begin(); j != one_settings.end(); ++j) {
- // Skip the non-embedded setting which we already added above.
- if (j == parent)
- continue;
-
- exceptions.Append(
- GetGeolocationExceptionForPage(origin, j->first, j->second));
- }
- }
-
- StringValue type_string(
- ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_GEOLOCATION));
- web_ui_->CallJavascriptFunction(
- L"ContentSettings.setExceptions", type_string, exceptions);
-
- // This is mainly here to keep this function ideologically parallel to
- // UpdateExceptionsViewFromHostContentSettingsMap().
- UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_GEOLOCATION);
-}
-
-void ContentSettingsHandler::UpdateNotificationExceptionsView() {
- DesktopNotificationService* service =
- web_ui_->GetProfile()->GetDesktopNotificationService();
-
- std::vector<GURL> allowed(service->GetAllowedOrigins());
- std::vector<GURL> blocked(service->GetBlockedOrigins());
-
- ListValue exceptions;
- for (size_t i = 0; i < allowed.size(); ++i) {
- exceptions.Append(
- GetNotificationExceptionForPage(allowed[i], CONTENT_SETTING_ALLOW));
- }
- for (size_t i = 0; i < blocked.size(); ++i) {
- exceptions.Append(
- GetNotificationExceptionForPage(blocked[i], CONTENT_SETTING_BLOCK));
- }
-
- StringValue type_string(
- ContentSettingsTypeToGroupName(CONTENT_SETTINGS_TYPE_NOTIFICATIONS));
- web_ui_->CallJavascriptFunction(
- L"ContentSettings.setExceptions", type_string, exceptions);
-
- // This is mainly here to keep this function ideologically parallel to
- // UpdateExceptionsViewFromHostContentSettingsMap().
- UpdateSettingDefaultFromModel(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
-}
-
-void ContentSettingsHandler::UpdateExceptionsViewFromHostContentSettingsMap(
- ContentSettingsType type) {
- HostContentSettingsMap::SettingsForOneType entries;
- GetContentSettingsMap()->GetSettingsForOneType(type, "", &entries);
-
- ListValue exceptions;
- for (size_t i = 0; i < entries.size(); ++i) {
- exceptions.Append(GetExceptionForPage(entries[i].first, entries[i].second));
- }
-
- StringValue type_string(ContentSettingsTypeToGroupName(type));
- web_ui_->CallJavascriptFunction(
- L"ContentSettings.setExceptions", type_string, exceptions);
-
- UpdateExceptionsViewFromOTRHostContentSettingsMap(type);
-
- // The default may also have changed (we won't get a separate notification).
- // If it hasn't changed, this call will be harmless.
- UpdateSettingDefaultFromModel(type);
-}
-
-void ContentSettingsHandler::UpdateExceptionsViewFromOTRHostContentSettingsMap(
- ContentSettingsType type) {
- const HostContentSettingsMap* otr_settings_map = GetOTRContentSettingsMap();
- if (!otr_settings_map)
- return;
-
- HostContentSettingsMap::SettingsForOneType otr_entries;
- otr_settings_map->GetSettingsForOneType(type, "", &otr_entries);
-
- ListValue otr_exceptions;
- for (size_t i = 0; i < otr_entries.size(); ++i) {
- otr_exceptions.Append(GetExceptionForPage(otr_entries[i].first,
- otr_entries[i].second));
- }
-
- StringValue type_string(ContentSettingsTypeToGroupName(type));
- web_ui_->CallJavascriptFunction(
- L"ContentSettings.setOTRExceptions", type_string, otr_exceptions);
-}
-
-void ContentSettingsHandler::RegisterMessages() {
- web_ui_->RegisterMessageCallback("setContentFilter",
- NewCallback(this,
- &ContentSettingsHandler::SetContentFilter));
- web_ui_->RegisterMessageCallback("setAllowThirdPartyCookies",
- NewCallback(this,
- &ContentSettingsHandler::SetAllowThirdPartyCookies));
- web_ui_->RegisterMessageCallback("removeException",
- NewCallback(this,
- &ContentSettingsHandler::RemoveException));
- web_ui_->RegisterMessageCallback("setException",
- NewCallback(this,
- &ContentSettingsHandler::SetException));
- web_ui_->RegisterMessageCallback("checkExceptionPatternValidity",
- NewCallback(this,
- &ContentSettingsHandler::CheckExceptionPatternValidity));
-}
-
-void ContentSettingsHandler::SetContentFilter(const ListValue* args) {
- DCHECK_EQ(2U, args->GetSize());
- std::string group, setting;
- if (!(args->GetString(0, &group) &&
- args->GetString(1, &setting))) {
- NOTREACHED();
- return;
- }
-
- ContentSetting default_setting = ContentSettingFromString(setting);
- ContentSettingsType content_type = ContentSettingsTypeFromGroupName(group);
- if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
- web_ui_->GetProfile()->GetGeolocationContentSettingsMap()->
- SetDefaultContentSetting(default_setting);
- } else if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
- web_ui_->GetProfile()->GetDesktopNotificationService()->
- SetDefaultContentSetting(default_setting);
- } else {
- GetContentSettingsMap()->
- SetDefaultContentSetting(content_type, default_setting);
- }
-}
-
-void ContentSettingsHandler::SetAllowThirdPartyCookies(const ListValue* args) {
- std::wstring allow = ExtractStringValue(args);
-
- GetContentSettingsMap()->SetBlockThirdPartyCookies(allow == L"true");
-}
-
-void ContentSettingsHandler::RemoveException(const ListValue* args) {
- size_t arg_i = 0;
- std::string type_string;
- CHECK(args->GetString(arg_i++, &type_string));
-
- ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string);
- if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
- std::string origin;
- std::string embedding_origin;
- bool rv = args->GetString(arg_i++, &origin);
- DCHECK(rv);
- rv = args->GetString(arg_i++, &embedding_origin);
- DCHECK(rv);
-
- web_ui_->GetProfile()->GetGeolocationContentSettingsMap()->
- SetContentSetting(GURL(origin),
- GURL(embedding_origin),
- CONTENT_SETTING_DEFAULT);
- } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
- std::string origin;
- std::string setting;
- bool rv = args->GetString(arg_i++, &origin);
- DCHECK(rv);
- rv = args->GetString(arg_i++, &setting);
- DCHECK(rv);
- ContentSetting content_setting = ContentSettingFromString(setting);
- if (content_setting == CONTENT_SETTING_ALLOW) {
- web_ui_->GetProfile()->GetDesktopNotificationService()->
- ResetAllowedOrigin(GURL(origin));
- } else {
- DCHECK_EQ(content_setting, CONTENT_SETTING_BLOCK);
- web_ui_->GetProfile()->GetDesktopNotificationService()->
- ResetBlockedOrigin(GURL(origin));
- }
- } else {
- std::string mode;
- bool rv = args->GetString(arg_i++, &mode);
- DCHECK(rv);
-
- std::string pattern;
- rv = args->GetString(arg_i++, &pattern);
- DCHECK(rv);
-
- HostContentSettingsMap* settings_map =
- mode == "normal" ? GetContentSettingsMap() :
- GetOTRContentSettingsMap();
- // The settings map could be null if the mode was OTR but the OTR profile
- // got destroyed before we received this message.
- if (settings_map) {
- settings_map->SetContentSetting(
- ContentSettingsPattern(pattern),
- ContentSettingsTypeFromGroupName(type_string),
- "",
- CONTENT_SETTING_DEFAULT);
- }
- }
-}
-
-void ContentSettingsHandler::SetException(const ListValue* args) {
- size_t arg_i = 0;
- std::string type_string;
- CHECK(args->GetString(arg_i++, &type_string));
- std::string mode;
- CHECK(args->GetString(arg_i++, &mode));
- std::string pattern;
- CHECK(args->GetString(arg_i++, &pattern));
- std::string setting;
- CHECK(args->GetString(arg_i++, &setting));
-
- ContentSettingsType type = ContentSettingsTypeFromGroupName(type_string);
- if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION ||
- type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
- NOTREACHED();
- return;
- }
-
- HostContentSettingsMap* settings_map =
- mode == "normal" ? GetContentSettingsMap() :
- GetOTRContentSettingsMap();
-
- // The settings map could be null if the mode was OTR but the OTR profile
- // got destroyed before we received this message.
- if (!settings_map)
- return;
-
- settings_map->SetContentSetting(ContentSettingsPattern(pattern),
- type,
- "",
- ContentSettingFromString(setting));
-}
-
-void ContentSettingsHandler::CheckExceptionPatternValidity(
- const ListValue* args) {
- size_t arg_i = 0;
- Value* type;
- CHECK(args->Get(arg_i++, &type));
- std::string mode_string;
- CHECK(args->GetString(arg_i++, &mode_string));
- std::string pattern_string;
- CHECK(args->GetString(arg_i++, &pattern_string));
-
- ContentSettingsPattern pattern(pattern_string);
-
- scoped_ptr<Value> mode_value(Value::CreateStringValue(mode_string));
- scoped_ptr<Value> pattern_value(Value::CreateStringValue(pattern_string));
- scoped_ptr<Value> valid_value(Value::CreateBooleanValue(pattern.IsValid()));
-
- web_ui_->CallJavascriptFunction(
- L"ContentSettings.patternValidityCheckComplete", *type,
- *mode_value.get(),
- *pattern_value.get(),
- *valid_value.get());
-}
-
-// static
-std::string ContentSettingsHandler::ContentSettingsTypeToGroupName(
- ContentSettingsType type) {
- switch (type) {
- case CONTENT_SETTINGS_TYPE_COOKIES:
- return "cookies";
- case CONTENT_SETTINGS_TYPE_IMAGES:
- return "images";
- case CONTENT_SETTINGS_TYPE_JAVASCRIPT:
- return "javascript";
- case CONTENT_SETTINGS_TYPE_PLUGINS:
- return "plugins";
- case CONTENT_SETTINGS_TYPE_POPUPS:
- return "popups";
- case CONTENT_SETTINGS_TYPE_GEOLOCATION:
- return "location";
- case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
- return "notifications";
-
- default:
- NOTREACHED();
- return "";
- }
-}
-
-HostContentSettingsMap* ContentSettingsHandler::GetContentSettingsMap() {
- return web_ui_->GetProfile()->GetHostContentSettingsMap();
-}
-
-HostContentSettingsMap*
- ContentSettingsHandler::GetOTRContentSettingsMap() {
- Profile* profile = web_ui_->GetProfile();
- if (profile->HasOffTheRecordProfile())
- return profile->GetOffTheRecordProfile()->GetHostContentSettingsMap();
- return NULL;
-}
diff --git a/chrome/browser/dom_ui/options/content_settings_handler.h b/chrome/browser/dom_ui/options/content_settings_handler.h
index adc16db..85e67b4 100644
--- a/chrome/browser/dom_ui/options/content_settings_handler.h
+++ b/chrome/browser/dom_ui/options/content_settings_handler.h
@@ -6,107 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_CONTENT_SETTINGS_HANDLER_H_
#pragma once
-#include "chrome/browser/dom_ui/options/options_ui.h"
-#include "chrome/browser/plugin_data_remover_helper.h"
-#include "chrome/browser/prefs/pref_change_registrar.h"
-#include "chrome/common/content_settings_types.h"
-#include "chrome/common/notification_observer.h"
-#include "chrome/common/notification_registrar.h"
-
-class HostContentSettingsMap;
-
-class ContentSettingsHandler : public OptionsPageUIHandler {
- public:
- ContentSettingsHandler();
- virtual ~ContentSettingsHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
-
- virtual void Initialize();
-
- virtual void RegisterMessages();
-
- // NotificationObserver implementation.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- // Gets a string identifier for the group name, for use in HTML.
- static std::string ContentSettingsTypeToGroupName(ContentSettingsType type);
-
- private:
- // Functions that call into the page -----------------------------------------
-
- // Updates the page with the default settings (allow, ask, block, etc.)
- void UpdateSettingDefaultFromModel(ContentSettingsType type);
- // Updates the state of the "Clear plugin LSO data on exit" checkbox.
- void UpdateClearPluginLSOData();
-
- // Clobbers and rebuilds the specific content setting type exceptions table.
- void UpdateExceptionsViewFromModel(ContentSettingsType type);
- // Clobbers and rebuilds all the exceptions tables in the page (both normal
- // and OTR tables).
- void UpdateAllExceptionsViewsFromModel();
- // As above, but only OTR tables.
- void UpdateAllOTRExceptionsViewsFromModel();
- // Clobbers and rebuilds just the geolocation exception table.
- void UpdateGeolocationExceptionsView();
- // Clobbers and rebuilds just the desktop notification exception table.
- void UpdateNotificationExceptionsView();
- // Clobbers and rebuilds an exception table that's managed by the host content
- // settings map.
- void UpdateExceptionsViewFromHostContentSettingsMap(ContentSettingsType type);
- // As above, but acts on the OTR table for the content setting type.
- void UpdateExceptionsViewFromOTRHostContentSettingsMap(
- ContentSettingsType type);
-
- // Callbacks used by the page ------------------------------------------------
-
- // Sets the default value for a specific content type. |args| includes the
- // content type and a string describing the new default the user has
- // chosen.
- void SetContentFilter(const ListValue* args);
-
- // Removes the given row from the table. The first entry in |args| is the
- // content type, and the rest of the arguments depend on the content type
- // to be removed.
- void RemoveException(const ListValue* args);
-
- // Changes the value of an exception. Called after the user is done editing an
- // exception.
- void SetException(const ListValue* args);
-
- // Called to decide whether a given pattern is valid, or if it should be
- // rejected. Called while the user is editing an exception pattern.
- void CheckExceptionPatternValidity(const ListValue* args);
-
- // Sets the global 3rd party cookies pref.
- void SetAllowThirdPartyCookies(const ListValue* args);
-
- // Utility functions ---------------------------------------------------------
-
- // Gets the HostContentSettingsMap for the normal profile.
- HostContentSettingsMap* GetContentSettingsMap();
-
- // Gets the HostContentSettingsMap for the incognito profile, or NULL if there
- // is no active incognito session.
- HostContentSettingsMap* GetOTRContentSettingsMap();
-
- // Gets the default setting in string form.
- std::string GetSettingDefaultFromModel(ContentSettingsType type);
-
- // Returns true if the default setting for the given content settings type
- // |type| is managed.
- bool GetDefaultSettingManagedFromModel(ContentSettingsType type);
-
- // Member variables ---------------------------------------------------------
-
- NotificationRegistrar notification_registrar_;
- PrefChangeRegistrar pref_change_registrar_;
- PluginDataRemoverHelper clear_plugin_lso_data_enabled_;
-
- DISALLOW_COPY_AND_ASSIGN(ContentSettingsHandler);
-};
+#include "chrome/browser/webui/options/content_settings_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_CONTENT_SETTINGS_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/cookies_view_handler.cc b/chrome/browser/dom_ui/options/cookies_view_handler.cc
deleted file mode 100644
index edde6b6..0000000
--- a/chrome/browser/dom_ui/options/cookies_view_handler.cc
+++ /dev/null
@@ -1,413 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/cookies_view_handler.h"
-
-#include "base/i18n/time_formatting.h"
-#include "base/string_number_conversions.h"
-#include "base/string_split.h"
-#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/browsing_data_appcache_helper.h"
-#include "chrome/browser/browsing_data_database_helper.h"
-#include "chrome/browser/browsing_data_indexed_db_helper.h"
-#include "chrome/browser/browsing_data_local_storage_helper.h"
-#include "chrome/browser/profiles/profile.h"
-#include "grit/generated_resources.h"
-#include "net/base/cookie_monster.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace {
-
-static const char kKeyId[] = "id";
-static const char kKeyTitle[] = "title";
-static const char kKeyIcon[] = "icon";
-static const char kKeyType[] = "type";
-static const char kKeyHasChildren[] = "hasChildren";
-
-static const char kKeyName[] = "name";
-static const char kKeyContent[] = "content";
-static const char kKeyDomain[] = "domain";
-static const char kKeyPath[] = "path";
-static const char kKeySendFor[] = "sendfor";
-static const char kKeyAccessibleToScript[] = "accessibleToScript";
-static const char kKeyDesc[] = "desc";
-static const char kKeySize[] = "size";
-static const char kKeyOrigin[] = "origin";
-static const char kKeyManifest[] = "manifest";
-
-static const char kKeyAccessed[] = "accessed";
-static const char kKeyCreated[] = "created";
-static const char kKeyExpires[] = "expires";
-static const char kKeyModified[] = "modified";
-
-// Encodes a pointer value into a hex string.
-std::string PointerToHexString(const void* pointer) {
- return base::HexEncode(&pointer, sizeof(pointer));
-}
-
-// Decodes a pointer from a hex string.
-void* HexStringToPointer(const std::string& str) {
- std::vector<uint8> buffer;
- if (!base::HexStringToBytes(str, &buffer) ||
- buffer.size() != sizeof(void*)) {
- return NULL;
- }
-
- return *reinterpret_cast<void**>(&buffer[0]);
-}
-
-// Populate given |dict| with cookie tree node properties.
-void GetCookieTreeNodeDictionary(const CookieTreeNode& node,
- DictionaryValue* dict) {
- // Use node's address as an id for WebUI to look it up.
- dict->SetString(kKeyId, PointerToHexString(&node));
- dict->SetString(kKeyTitle, node.GetTitle());
- dict->SetBoolean(kKeyHasChildren, !!node.GetChildCount());
-
- switch (node.GetDetailedInfo().node_type) {
- case CookieTreeNode::DetailedInfo::TYPE_ORIGIN: {
- dict->SetString(kKeyType, "origin");
-#if defined(OS_MACOSX)
- dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER");
-#endif
- break;
- }
- case CookieTreeNode::DetailedInfo::TYPE_COOKIE: {
- dict->SetString(kKeyType, "cookie");
- dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_ICON");
-
- const net::CookieMonster::CanonicalCookie& cookie =
- *node.GetDetailedInfo().cookie;
-
- dict->SetString(kKeyName, cookie.Name());
- dict->SetString(kKeyContent, cookie.Value());
- dict->SetString(kKeyDomain, cookie.Domain());
- dict->SetString(kKeyPath, cookie.Path());
- dict->SetString(kKeySendFor, cookie.IsSecure() ?
- l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_SENDFOR_SECURE) :
- l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_SENDFOR_ANY));
- std::string accessible = cookie.IsHttpOnly() ?
- l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_ACCESSIBLE_TO_SCRIPT_NO) :
- l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_ACCESSIBLE_TO_SCRIPT_YES);
- dict->SetString(kKeyAccessibleToScript, accessible);
- dict->SetString(kKeyCreated, UTF16ToUTF8(
- base::TimeFormatFriendlyDateAndTime(cookie.CreationDate())));
- dict->SetString(kKeyExpires, cookie.DoesExpire() ? UTF16ToUTF8(
- base::TimeFormatFriendlyDateAndTime(cookie.ExpiryDate())) :
- l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_EXPIRES_SESSION));
-
- break;
- }
- case CookieTreeNode::DetailedInfo::TYPE_DATABASE: {
- dict->SetString(kKeyType, "database");
- dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON");
-
- const BrowsingDataDatabaseHelper::DatabaseInfo& database_info =
- *node.GetDetailedInfo().database_info;
-
- dict->SetString(kKeyName, database_info.database_name.empty() ?
- l10n_util::GetStringUTF8(IDS_COOKIES_WEB_DATABASE_UNNAMED_NAME) :
- database_info.database_name);
- dict->SetString(kKeyDesc, database_info.description);
- dict->SetString(kKeySize,
- FormatBytes(database_info.size,
- GetByteDisplayUnits(database_info.size),
- true));
- dict->SetString(kKeyModified, UTF16ToUTF8(
- base::TimeFormatFriendlyDateAndTime(database_info.last_modified)));
-
- break;
- }
- case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE: {
- dict->SetString(kKeyType, "local_storage");
- dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON");
-
- const BrowsingDataLocalStorageHelper::LocalStorageInfo&
- local_storage_info = *node.GetDetailedInfo().local_storage_info;
-
- dict->SetString(kKeyOrigin, local_storage_info.origin);
- dict->SetString(kKeySize,
- FormatBytes(local_storage_info.size,
- GetByteDisplayUnits(local_storage_info.size),
- true));
- dict->SetString(kKeyModified, UTF16ToUTF8(
- base::TimeFormatFriendlyDateAndTime(
- local_storage_info.last_modified)));
-
- break;
- }
- case CookieTreeNode::DetailedInfo::TYPE_APPCACHE: {
- dict->SetString(kKeyType, "app_cache");
- dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON");
-
- const appcache::AppCacheInfo& appcache_info =
- *node.GetDetailedInfo().appcache_info;
-
- dict->SetString(kKeyManifest, appcache_info.manifest_url.spec());
- dict->SetString(kKeySize,
- FormatBytes(appcache_info.size,
- GetByteDisplayUnits(appcache_info.size),
- true));
- dict->SetString(kKeyCreated, UTF16ToUTF8(
- base::TimeFormatFriendlyDateAndTime(appcache_info.creation_time)));
- dict->SetString(kKeyAccessed, UTF16ToUTF8(
- base::TimeFormatFriendlyDateAndTime(appcache_info.last_access_time)));
-
- break;
- }
- case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB: {
- dict->SetString(kKeyType, "indexed_db");
- dict->SetString(kKeyIcon, "chrome://theme/IDR_COOKIE_STORAGE_ICON");
-
- const BrowsingDataIndexedDBHelper::IndexedDBInfo& indexed_db_info =
- *node.GetDetailedInfo().indexed_db_info;
-
- dict->SetString(kKeyOrigin, indexed_db_info.origin);
- dict->SetString(kKeySize,
- FormatBytes(indexed_db_info.size,
- GetByteDisplayUnits(indexed_db_info.size),
- true));
- dict->SetString(kKeyModified, UTF16ToUTF8(
- base::TimeFormatFriendlyDateAndTime(indexed_db_info.last_modified)));
-
- break;
- }
- default:
-#if defined(OS_MACOSX)
- dict->SetString(kKeyIcon, "chrome://theme/IDR_BOOKMARK_BAR_FOLDER");
-#endif
- break;
- }
-}
-
-// Append the children nodes of |parent| in specified range to |nodes| list.
-void GetChildNodeList(CookieTreeNode* parent, int start, int count,
- ListValue* nodes) {
- for (int i = 0; i < count; ++i) {
- DictionaryValue* dict = new DictionaryValue;
- CookieTreeNode* child = parent->GetChild(start + i);
- GetCookieTreeNodeDictionary(*child, dict);
- nodes->Append(dict);
- }
-}
-
-// TODO(xiyuan): Remove this function when strings are updated.
-// Remove "&" in button label for WebUI.
-string16 CleanButtonLabel(const string16& text) {
- string16 out(text);
- ReplaceFirstSubstringAfterOffset(&out, 0, ASCIIToUTF16("&"), string16());
- return out;
-}
-
-} // namespace
-
-CookiesViewHandler::CookiesViewHandler() : batch_update_(false) {
-}
-
-CookiesViewHandler::~CookiesViewHandler() {
-}
-
-void CookiesViewHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- RegisterTitle(localized_strings, "cookiesViewPage",
- IDS_COOKIES_WEBSITE_PERMISSIONS_WINDOW_TITLE);
-
- localized_strings->SetString("label_cookie_search",
- l10n_util::GetStringUTF16(IDS_COOKIES_SEARCH_LABEL));
-
- localized_strings->SetString("label_cookie_name",
- l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_NAME_LABEL));
- localized_strings->SetString("label_cookie_content",
- l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_CONTENT_LABEL));
- localized_strings->SetString("label_cookie_domain",
- l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_DOMAIN_LABEL));
- localized_strings->SetString("label_cookie_path",
- l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_PATH_LABEL));
- localized_strings->SetString("label_cookie_send_for",
- l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_SENDFOR_LABEL));
- localized_strings->SetString("label_cookie_accessible_to_script",
- l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_ACCESSIBLE_TO_SCRIPT_LABEL));
- localized_strings->SetString("label_cookie_created",
- l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_CREATED_LABEL));
- localized_strings->SetString("label_cookie_expires",
- l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_EXPIRES_LABEL));
- localized_strings->SetString("label_webdb_desc",
- l10n_util::GetStringUTF16(IDS_COOKIES_WEB_DATABASE_DESCRIPTION_LABEL));
- localized_strings->SetString("label_local_storage_size",
- l10n_util::GetStringUTF16(IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL));
- localized_strings->SetString("label_local_storage_last_modified",
- l10n_util::GetStringUTF16(IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL));
- localized_strings->SetString("label_local_storage_origin",
- l10n_util::GetStringUTF16(IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL));
- localized_strings->SetString("label_indexed_db_size",
- l10n_util::GetStringUTF16(IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL));
- localized_strings->SetString("label_indexed_db_last_modified",
- l10n_util::GetStringUTF16(IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL));
- localized_strings->SetString("label_indexed_db_origin",
- l10n_util::GetStringUTF16(IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL));
- localized_strings->SetString("label_app_cache_manifest",
- l10n_util::GetStringUTF16(IDS_COOKIES_APPLICATION_CACHE_MANIFEST_LABEL));
- localized_strings->SetString("label_cookie_last_accessed",
- l10n_util::GetStringUTF16(IDS_COOKIES_LAST_ACCESSED_LABEL));
-
- localized_strings->SetString("no_cookie",
- l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_NONESELECTED));
- localized_strings->SetString("unnamed",
- l10n_util::GetStringUTF16(IDS_COOKIES_WEB_DATABASE_UNNAMED_NAME));
-
- localized_strings->SetString("label_cookie_clear_search", CleanButtonLabel(
- l10n_util::GetStringUTF16(IDS_COOKIES_CLEAR_SEARCH_LABEL)));
- localized_strings->SetString("remove_cookie", CleanButtonLabel(
- l10n_util::GetStringUTF16(IDS_COOKIES_REMOVE_LABEL)));
- localized_strings->SetString("remove_all_cookie", CleanButtonLabel(
- l10n_util::GetStringUTF16(IDS_COOKIES_REMOVE_ALL_LABEL)));
-}
-
-void CookiesViewHandler::RegisterMessages() {
- web_ui_->RegisterMessageCallback("updateCookieSearchResults",
- NewCallback(this, &CookiesViewHandler::UpdateSearchResults));
- web_ui_->RegisterMessageCallback("removeAllCookies",
- NewCallback(this, &CookiesViewHandler::RemoveAll));
- web_ui_->RegisterMessageCallback("removeCookie",
- NewCallback(this, &CookiesViewHandler::Remove));
- web_ui_->RegisterMessageCallback("loadCookie",
- NewCallback(this, &CookiesViewHandler::LoadChildren));
-}
-
-void CookiesViewHandler::TreeNodesAdded(ui::TreeModel* model,
- ui::TreeModelNode* parent,
- int start,
- int count) {
- // Skip if there is a batch update in progress.
- if (batch_update_)
- return;
-
- ListValue* children = new ListValue;
- GetChildNodeList(cookies_tree_model_->AsNode(parent), start, count, children);
-
- ListValue args;
- args.Append(parent == cookies_tree_model_->GetRoot() ?
- Value::CreateNullValue() :
- Value::CreateStringValue(PointerToHexString(parent)));
- args.Append(Value::CreateIntegerValue(start));
- args.Append(children);
- web_ui_->CallJavascriptFunction(L"CookiesView.onTreeItemAdded", args);
-}
-
-void CookiesViewHandler::TreeNodesRemoved(ui::TreeModel* model,
- ui::TreeModelNode* parent,
- int start,
- int count) {
- // Skip if there is a batch update in progress.
- if (batch_update_)
- return;
-
- ListValue args;
- args.Append(parent == cookies_tree_model_->GetRoot() ?
- Value::CreateNullValue() :
- Value::CreateStringValue(PointerToHexString(parent)));
- args.Append(Value::CreateIntegerValue(start));
- args.Append(Value::CreateIntegerValue(count));
- web_ui_->CallJavascriptFunction(L"CookiesView.onTreeItemRemoved", args);
-}
-
-void CookiesViewHandler::TreeModelBeginBatch(CookiesTreeModel* model) {
- DCHECK(!batch_update_); // There should be no nested batch begin.
- batch_update_ = true;
-}
-
-void CookiesViewHandler::TreeModelEndBatch(CookiesTreeModel* model) {
- DCHECK(batch_update_);
- batch_update_ = false;
-
- SendChildren(cookies_tree_model_->GetRoot());
-}
-
-void CookiesViewHandler::UpdateSearchResults(const ListValue* args) {
- std::string query;
- if (!args->GetString(0, &query)){
- return;
- }
-
- if (!cookies_tree_model_.get()) {
- Profile* profile = web_ui_->GetProfile();
- cookies_tree_model_.reset(new CookiesTreeModel(
- profile->GetRequestContext()->GetCookieStore()->GetCookieMonster(),
- new BrowsingDataDatabaseHelper(profile),
- new BrowsingDataLocalStorageHelper(profile),
- NULL,
- new BrowsingDataAppCacheHelper(profile),
- BrowsingDataIndexedDBHelper::Create(profile)));
- cookies_tree_model_->AddCookiesTreeObserver(this);
- }
-
- cookies_tree_model_->UpdateSearchResults(UTF8ToWide(query));
-}
-
-void CookiesViewHandler::RemoveAll(const ListValue* args) {
- cookies_tree_model_->DeleteAllStoredObjects();
-}
-
-void CookiesViewHandler::Remove(const ListValue* args) {
- std::string node_path;
- if (!args->GetString(0, &node_path)){
- return;
- }
-
- CookieTreeNode* node = GetTreeNodeFromPath(node_path);
- if (node)
- cookies_tree_model_->DeleteCookieNode(node);
-}
-
-void CookiesViewHandler::LoadChildren(const ListValue* args) {
- std::string node_path;
- if (!args->GetString(0, &node_path)){
- return;
- }
-
- CookieTreeNode* node = GetTreeNodeFromPath(node_path);
- if (node)
- SendChildren(node);
-}
-
-CookieTreeNode* CookiesViewHandler::GetTreeNodeFromPath(
- const std::string& path) {
- std::vector<std::string> node_ids;
- base::SplitString(path, ',', &node_ids);
-
- CookieTreeNode* child = NULL;
- CookieTreeNode* parent = cookies_tree_model_->GetRoot();
- int child_index = -1;
-
- // Validate the tree path and get the node pointer.
- for (size_t i = 0; i < node_ids.size(); ++i) {
- child = reinterpret_cast<CookieTreeNode*>(
- HexStringToPointer(node_ids[i]));
-
- child_index = parent->IndexOfChild(child);
- if (child_index == -1)
- break;
-
- parent = child;
- }
-
- return child_index >= 0 ? child : NULL;
-}
-
-void CookiesViewHandler::SendChildren(CookieTreeNode* parent) {
- ListValue* children = new ListValue;
- GetChildNodeList(parent, 0, parent->GetChildCount(), children);
-
- ListValue args;
- args.Append(parent == cookies_tree_model_->GetRoot() ?
- Value::CreateNullValue() :
- Value::CreateStringValue(PointerToHexString(parent)));
- args.Append(children);
-
- web_ui_->CallJavascriptFunction(L"CookiesView.loadChildren", args);
-}
diff --git a/chrome/browser/dom_ui/options/cookies_view_handler.h b/chrome/browser/dom_ui/options/cookies_view_handler.h
index 12e52be..73810a3c 100644
--- a/chrome/browser/dom_ui/options/cookies_view_handler.h
+++ b/chrome/browser/dom_ui/options/cookies_view_handler.h
@@ -6,61 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_COOKIES_VIEW_HANDLER_H_
#pragma once
-#include "base/scoped_ptr.h"
-#include "chrome/browser/cookies_tree_model.h"
-#include "chrome/browser/dom_ui/options/options_ui.h"
-
-class CookiesViewHandler : public OptionsPageUIHandler,
- public CookiesTreeModel::Observer {
- public:
- CookiesViewHandler();
- virtual ~CookiesViewHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
- virtual void RegisterMessages();
-
- // ui::TreeModel::Observer implementation.
- virtual void TreeNodesAdded(ui::TreeModel* model,
- ui::TreeModelNode* parent,
- int start,
- int count);
- virtual void TreeNodesRemoved(ui::TreeModel* model,
- ui::TreeModelNode* parent,
- int start,
- int count);
- virtual void TreeNodeChanged(ui::TreeModel* model, ui::TreeModelNode* node) {}
- virtual void TreeModelBeginBatch(CookiesTreeModel* model);
- virtual void TreeModelEndBatch(CookiesTreeModel* model);
-
- private:
- // Updates search filter for cookies tree model.
- void UpdateSearchResults(const ListValue* args);
-
- // Remove all sites data.
- void RemoveAll(const ListValue* args);
-
- // Remove selected sites data.
- void Remove(const ListValue* args);
-
- // Get the tree node using the tree path info in |args| and call
- // SendChildren to pass back children nodes data to WebUI.
- void LoadChildren(const ListValue* args);
-
- // Gets tree node from given path. Return NULL if path is not valid.
- CookieTreeNode* GetTreeNodeFromPath(const std::string& path);
-
- // Get children nodes data and pass it to 'CookiesView.loadChildren' to
- // update the WebUI.
- void SendChildren(CookieTreeNode* parent);
-
- // The Cookies Tree model
- scoped_ptr<CookiesTreeModel> cookies_tree_model_;
-
- // Flag to indicate whether there is a batch update in progress.
- bool batch_update_;
-
- DISALLOW_COPY_AND_ASSIGN(CookiesViewHandler);
-};
+#include "chrome/browser/webui/options/cookies_view_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_COOKIES_VIEW_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/core_options_handler.cc b/chrome/browser/dom_ui/options/core_options_handler.cc
deleted file mode 100644
index 5a20e8b..0000000
--- a/chrome/browser/dom_ui/options/core_options_handler.cc
+++ /dev/null
@@ -1,373 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/core_options_handler.h"
-
-#include "base/json/json_reader.h"
-#include "base/scoped_ptr.h"
-#include "base/string16.h"
-#include "base/string_number_conversions.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/google/google_util.h"
-#include "chrome/browser/metrics/user_metrics.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/notification_details.h"
-#include "chrome/common/notification_type.h"
-#include "chrome/common/url_constants.h"
-#include "googleurl/src/gurl.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"
-#include "ui/base/l10n/l10n_util.h"
-
-CoreOptionsHandler::CoreOptionsHandler() {}
-
-CoreOptionsHandler::~CoreOptionsHandler() {}
-
-void CoreOptionsHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
- // Main
- localized_strings->SetString("title",
- l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE));
-
- // Managed prefs
- localized_strings->SetString("managedPrefsBannerText",
- l10n_util::GetStringUTF16(IDS_OPTIONS_MANAGED_PREFS));
-
- // Search
- localized_strings->SetString("searchPageTitle",
- l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_TITLE));
- localized_strings->SetString("searchPageNoMatches",
- l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_NO_MATCHES));
- localized_strings->SetString("searchPageHelpLabel",
- l10n_util::GetStringUTF16(IDS_OPTIONS_SEARCH_PAGE_HELP_LABEL));
- localized_strings->SetString("searchPageHelpTitle",
- l10n_util::GetStringFUTF16(IDS_OPTIONS_SEARCH_PAGE_HELP_TITLE,
- l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
- localized_strings->SetString("searchPageHelpURL",
- google_util::AppendGoogleLocaleParam(
- GURL(chrome::kChromeHelpURL)).spec());
-
- // Common
- localized_strings->SetString("ok",
- l10n_util::GetStringUTF16(IDS_OK));
- localized_strings->SetString("cancel",
- l10n_util::GetStringUTF16(IDS_CANCEL));
- localized_strings->SetString("delete",
- l10n_util::GetStringUTF16(IDS_DELETE));
- localized_strings->SetString("edit",
- l10n_util::GetStringUTF16(IDS_EDIT));
- localized_strings->SetString("learnMore",
- l10n_util::GetStringUTF16(IDS_LEARN_MORE));
- localized_strings->SetString("abort",
- l10n_util::GetStringUTF16(IDS_ABORT));
- localized_strings->SetString("close",
- l10n_util::GetStringUTF16(IDS_CLOSE));
- localized_strings->SetString("done",
- l10n_util::GetStringUTF16(IDS_DONE));
- localized_strings->SetString("yesButtonLabel",
- l10n_util::GetStringUTF16(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL));
- localized_strings->SetString("noButtonLabel",
- l10n_util::GetStringUTF16(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL));
-}
-
-void CoreOptionsHandler::Uninitialize() {
- std::string last_pref;
- for (PreferenceCallbackMap::const_iterator iter = pref_callback_map_.begin();
- iter != pref_callback_map_.end();
- ++iter) {
- if (last_pref != iter->first) {
- StopObservingPref(iter->first);
- last_pref = iter->first;
- }
- }
-}
-
-WebUIMessageHandler* CoreOptionsHandler::Attach(WebUI* web_ui) {
- WebUIMessageHandler* result = WebUIMessageHandler::Attach(web_ui);
- DCHECK(web_ui_);
- registrar_.Init(web_ui_->GetProfile()->GetPrefs());
- return result;
-}
-
-void CoreOptionsHandler::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- if (type == NotificationType::PREF_CHANGED)
- NotifyPrefChanged(Details<std::string>(details).ptr());
-}
-
-void CoreOptionsHandler::RegisterMessages() {
- web_ui_->RegisterMessageCallback("coreOptionsInitialize",
- NewCallback(this, &CoreOptionsHandler::HandleInitialize));
- web_ui_->RegisterMessageCallback("fetchPrefs",
- NewCallback(this, &CoreOptionsHandler::HandleFetchPrefs));
- web_ui_->RegisterMessageCallback("observePrefs",
- NewCallback(this, &CoreOptionsHandler::HandleObservePrefs));
- web_ui_->RegisterMessageCallback("setBooleanPref",
- NewCallback(this, &CoreOptionsHandler::HandleSetBooleanPref));
- web_ui_->RegisterMessageCallback("setIntegerPref",
- NewCallback(this, &CoreOptionsHandler::HandleSetIntegerPref));
- web_ui_->RegisterMessageCallback("setDoublePref",
- NewCallback(this, &CoreOptionsHandler::HandleSetDoublePref));
- web_ui_->RegisterMessageCallback("setStringPref",
- NewCallback(this, &CoreOptionsHandler::HandleSetStringPref));
- web_ui_->RegisterMessageCallback("setListPref",
- NewCallback(this, &CoreOptionsHandler::HandleSetListPref));
- web_ui_->RegisterMessageCallback("clearPref",
- NewCallback(this, &CoreOptionsHandler::HandleClearPref));
- web_ui_->RegisterMessageCallback("coreOptionsUserMetricsAction",
- NewCallback(this, &CoreOptionsHandler::HandleUserMetricsAction));
-}
-
-void CoreOptionsHandler::HandleInitialize(const ListValue* args) {
- static_cast<OptionsUI*>(web_ui_)->InitializeHandlers();
-}
-
-Value* CoreOptionsHandler::FetchPref(const std::string& pref_name) {
- PrefService* pref_service = web_ui_->GetProfile()->GetPrefs();
-
- const PrefService::Preference* pref =
- pref_service->FindPreference(pref_name.c_str());
-
- Value* return_value;
- if (pref) {
- DictionaryValue* dict = new DictionaryValue;
- dict->Set("value", pref->GetValue()->DeepCopy());
- dict->SetBoolean("managed", pref->IsManaged());
- return_value = dict;
- } else {
- return_value = Value::CreateNullValue();
- }
- return return_value;
-}
-
-void CoreOptionsHandler::ObservePref(const std::string& pref_name) {
- registrar_.Add(pref_name.c_str(), this);
-}
-
-void CoreOptionsHandler::SetPref(const std::string& pref_name,
- const Value* value,
- const std::string& metric) {
- PrefService* pref_service = web_ui_->GetProfile()->GetPrefs();
-
- switch (value->GetType()) {
- case Value::TYPE_BOOLEAN:
- case Value::TYPE_INTEGER:
- case Value::TYPE_DOUBLE:
- case Value::TYPE_STRING:
- pref_service->Set(pref_name.c_str(), *value);
- break;
-
- default:
- NOTREACHED();
- return;
- }
-
- pref_service->ScheduleSavePersistentPrefs();
- ProcessUserMetric(value, metric);
-}
-
-void CoreOptionsHandler::ClearPref(const std::string& pref_name,
- const std::string& metric) {
- PrefService* pref_service = web_ui_->GetProfile()->GetPrefs();
- pref_service->ClearPref(pref_name.c_str());
- pref_service->ScheduleSavePersistentPrefs();
-
- if (!metric.empty())
- UserMetricsRecordAction(UserMetricsAction(metric.c_str()));
-}
-
-void CoreOptionsHandler::ProcessUserMetric(const Value* value,
- const std::string& metric) {
- if (metric.empty())
- return;
-
- std::string metric_string = metric;
- if (value->IsType(Value::TYPE_BOOLEAN)) {
- bool bool_value;
- CHECK(value->GetAsBoolean(&bool_value));
- metric_string += bool_value ? "_Enable" : "_Disable";
- }
-
- UserMetricsRecordAction(UserMetricsAction(metric_string.c_str()));
-}
-
-void CoreOptionsHandler::StopObservingPref(const std::string& path) {
- registrar_.Remove(path.c_str(), this);
-}
-
-void CoreOptionsHandler::HandleFetchPrefs(const ListValue* args) {
- // First param is name of callback function, so, there needs to be at least
- // one more element for the actual preference identifier.
- DCHECK_GE(static_cast<int>(args->GetSize()), 2);
-
- // Get callback JS function name.
- Value* callback;
- if (!args->Get(0, &callback) || !callback->IsType(Value::TYPE_STRING))
- return;
-
- string16 callback_function;
- if (!callback->GetAsString(&callback_function))
- return;
-
- // Get the list of name for prefs to build the response dictionary.
- DictionaryValue result_value;
- Value* list_member;
-
- for (size_t i = 1; i < args->GetSize(); i++) {
- if (!args->Get(i, &list_member))
- break;
-
- if (!list_member->IsType(Value::TYPE_STRING))
- continue;
-
- std::string pref_name;
- if (!list_member->GetAsString(&pref_name))
- continue;
-
- result_value.Set(pref_name.c_str(), FetchPref(pref_name));
- }
- web_ui_->CallJavascriptFunction(UTF16ToWideHack(callback_function).c_str(),
- result_value);
-}
-
-void CoreOptionsHandler::HandleObservePrefs(const ListValue* args) {
- // First param is name is JS callback function name, the rest are pref
- // identifiers that we are observing.
- DCHECK_GE(static_cast<int>(args->GetSize()), 2);
-
- // Get preference change callback function name.
- string16 callback_func_name;
- if (!args->GetString(0, &callback_func_name))
- return;
-
- // Get all other parameters - pref identifiers.
- for (size_t i = 1; i < args->GetSize(); i++) {
- Value* list_member;
- if (!args->Get(i, &list_member))
- break;
-
- // Just ignore bad pref identifiers for now.
- std::string pref_name;
- if (!list_member->IsType(Value::TYPE_STRING) ||
- !list_member->GetAsString(&pref_name))
- continue;
-
- if (pref_callback_map_.find(pref_name) == pref_callback_map_.end())
- ObservePref(pref_name);
-
- pref_callback_map_.insert(
- PreferenceCallbackMap::value_type(pref_name,
- UTF16ToWideHack(callback_func_name)));
- }
-}
-
-void CoreOptionsHandler::HandleSetBooleanPref(const ListValue* args) {
- HandleSetPref(args, Value::TYPE_BOOLEAN);
-}
-
-void CoreOptionsHandler::HandleSetIntegerPref(const ListValue* args) {
- HandleSetPref(args, Value::TYPE_INTEGER);
-}
-
-void CoreOptionsHandler::HandleSetDoublePref(const ListValue* args) {
- HandleSetPref(args, Value::TYPE_DOUBLE);
-}
-
-void CoreOptionsHandler::HandleSetStringPref(const ListValue* args) {
- HandleSetPref(args, Value::TYPE_STRING);
-}
-
-void CoreOptionsHandler::HandleSetListPref(const ListValue* args) {
- HandleSetPref(args, Value::TYPE_LIST);
-}
-
-void CoreOptionsHandler::HandleSetPref(const ListValue* args,
- Value::ValueType type) {
- DCHECK_GT(static_cast<int>(args->GetSize()), 1);
-
- std::string pref_name;
- if (!args->GetString(0, &pref_name))
- return;
-
- Value* value;
- if (!args->Get(1, &value))
- return;
-
- scoped_ptr<Value> temp_value;
-
- // In JS all numbers are doubles.
- if (type == Value::TYPE_INTEGER) {
- double double_value;
- CHECK(value->GetAsDouble(&double_value));
- temp_value.reset(Value::CreateIntegerValue(static_cast<int>(double_value)));
- value = temp_value.get();
-
- // In case we have a List pref we got a JSON string.
- } else if (type == Value::TYPE_LIST) {
- std::string json_string;
- CHECK(value->GetAsString(&json_string));
- temp_value.reset(
- base::JSONReader().JsonToValue(json_string,
- false, // no check_root
- false)); // no trailing comma
- value = temp_value.get();
- }
-
- CHECK_EQ(type, value->GetType());
-
- std::string metric;
- if (args->GetSize() > 2)
- args->GetString(2, &metric);
-
- SetPref(pref_name, value, metric);
-}
-
-void CoreOptionsHandler::HandleClearPref(const ListValue* args) {
- DCHECK_GT(static_cast<int>(args->GetSize()), 0);
-
- std::string pref_name;
- if (!args->GetString(0, &pref_name))
- return;
-
- std::string metric;
- if (args->GetSize() > 1)
- args->GetString(1, &metric);
-
- ClearPref(pref_name, metric);
-}
-
-void CoreOptionsHandler::HandleUserMetricsAction(const ListValue* args) {
- std::string metric = WideToUTF8(ExtractStringValue(args));
- if (!metric.empty())
- UserMetricsRecordAction(UserMetricsAction(metric.c_str()));
-}
-
-void CoreOptionsHandler::NotifyPrefChanged(const std::string* pref_name) {
- PrefService* pref_service = web_ui_->GetProfile()->GetPrefs();
- const PrefService::Preference* pref =
- pref_service->FindPreference(pref_name->c_str());
- if (pref) {
- for (PreferenceCallbackMap::const_iterator iter =
- pref_callback_map_.find(*pref_name);
- iter != pref_callback_map_.end(); ++iter) {
- const std::wstring& callback_function = iter->second;
- ListValue result_value;
- result_value.Append(Value::CreateStringValue(pref_name->c_str()));
-
- DictionaryValue* dict = new DictionaryValue;
- dict->Set("value", pref->GetValue()->DeepCopy());
- dict->SetBoolean("managed", pref->IsManaged());
- result_value.Append(dict);
-
- web_ui_->CallJavascriptFunction(callback_function, result_value);
- }
- }
-}
diff --git a/chrome/browser/dom_ui/options/core_options_handler.h b/chrome/browser/dom_ui/options/core_options_handler.h
index cc6c2c1..535aa25 100644
--- a/chrome/browser/dom_ui/options/core_options_handler.h
+++ b/chrome/browser/dom_ui/options/core_options_handler.h
@@ -6,103 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_CORE_OPTIONS_HANDLER_H_
#pragma once
-#include <map>
-#include <string>
-
-#include "base/values.h"
-#include "chrome/browser/dom_ui/options/options_ui.h"
-#include "chrome/browser/prefs/pref_change_registrar.h"
-
-// Core options UI handler.
-// Handles resource and JS calls common to all options sub-pages.
-class CoreOptionsHandler : public OptionsPageUIHandler {
- public:
- CoreOptionsHandler();
- virtual ~CoreOptionsHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
- virtual void Uninitialize();
-
- // NotificationObserver implementation.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- // WebUIMessageHandler implementation.
- virtual void RegisterMessages();
- virtual WebUIMessageHandler* Attach(WebUI* web_ui);
-
- protected:
- // Fetches a pref value of given |pref_name|.
- // Note that caller owns the returned Value.
- virtual Value* FetchPref(const std::string& pref_name);
-
- // Observes a pref of given |pref_name|.
- virtual void ObservePref(const std::string& pref_name);
-
- // Sets a pref |value| to given |pref_name|.
- virtual void SetPref(const std::string& pref_name,
- const Value* value,
- const std::string& metric);
-
- // Clears pref value for given |pref_name|.
- void ClearPref(const std::string& pref_name, const std::string& metric);
-
- // Stops observing given preference identified by |path|.
- virtual void StopObservingPref(const std::string& path);
-
- // Records a user metric action for the given value.
- void ProcessUserMetric(const Value* value,
- const std::string& metric);
-
- typedef std::multimap<std::string, std::wstring> PreferenceCallbackMap;
- PreferenceCallbackMap pref_callback_map_;
- private:
- // Callback for the "coreOptionsInitialize" message. This message will
- // trigger the Initialize() method of all other handlers so that final
- // setup can be performed before the page is shown.
- void HandleInitialize(const ListValue* args);
-
- // Callback for the "fetchPrefs" message. This message accepts the list of
- // preference names passed as the |args| parameter (ListValue). It passes
- // results dictionary of preference values by calling prefsFetched() JS method
- // on the page.
- void HandleFetchPrefs(const ListValue* args);
-
- // Callback for the "observePrefs" message. This message initiates
- // notification observing for given array of preference names.
- void HandleObservePrefs(const ListValue* args);
-
- // Callbacks for the "set<type>Pref" message. This message saves the new
- // preference value. |args| is an array of parameters as follows:
- // item 0 - name of the preference.
- // item 1 - the value of the preference in string form.
- // item 2 - name of the metric identifier (optional).
- void HandleSetBooleanPref(const ListValue* args);
- void HandleSetIntegerPref(const ListValue* args);
- void HandleSetDoublePref(const ListValue* args);
- void HandleSetStringPref(const ListValue* args);
- void HandleSetListPref(const ListValue* args);
-
- void HandleSetPref(const ListValue* args, Value::ValueType type);
-
- // Callback for the "clearPref" message. This message clears a preference
- // value. |args| is an array of parameters as follows:
- // item 0 - name of the preference.
- // item 1 - name of the metric identifier (optional).
- void HandleClearPref(const ListValue* args);
-
- // Callback for the "coreOptionsUserMetricsAction" message. This records
- // an action that should be tracked if metrics recording is enabled. |args|
- // is an array that contains a single item, the name of the metric identifier.
- void HandleUserMetricsAction(const ListValue* args);
-
- void NotifyPrefChanged(const std::string* pref_name);
-
- PrefChangeRegistrar registrar_;
-
- DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler);
-};
+#include "chrome/browser/webui/options/core_options_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_CORE_OPTIONS_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/dom_options_util.cc b/chrome/browser/dom_ui/options/dom_options_util.cc
deleted file mode 100644
index 2eb8ec3..0000000
--- a/chrome/browser/dom_ui/options/dom_options_util.cc
+++ /dev/null
@@ -1,20 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/dom_options_util.h"
-
-#include "base/string_util.h"
-
-namespace dom_options_util {
-
-// TODO(estade): update all strings that have a trailing colon once we get rid
-// of the native dialogs.
-string16 StripColon(const string16& str) {
- const string16::value_type kColon[] = { ':', 0 };
- string16 result;
- TrimString(str, kColon, &result);
- return result;
-}
-
-} // namespace dom_options_util
diff --git a/chrome/browser/dom_ui/options/dom_options_util.h b/chrome/browser/dom_ui/options/dom_options_util.h
index 9cbac39..beeebdb 100644
--- a/chrome/browser/dom_ui/options/dom_options_util.h
+++ b/chrome/browser/dom_ui/options/dom_options_util.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.
@@ -6,16 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_DOM_OPTIONS_UTIL_H_
#pragma once
-#include "base/string16.h"
-
-namespace dom_options_util {
-
-// Strips the trailing colon from a string. Used to remove the colon from
-// section titles on platforms that append it.
-// TODO(jhawkins): Remove this once the platform-specific options dialogs are
-// removed.
-string16 StripColon(const string16& str);
-
-} // namespace options_util
+#include "chrome/browser/webui/options/dom_options_util.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_DOM_OPTIONS_UTIL_H_
diff --git a/chrome/browser/dom_ui/options/font_settings_handler.cc b/chrome/browser/dom_ui/options/font_settings_handler.cc
deleted file mode 100644
index 6942acd..0000000
--- a/chrome/browser/dom_ui/options/font_settings_handler.cc
+++ /dev/null
@@ -1,188 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/font_settings_handler.h"
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/string_number_conversions.h"
-#include "base/string_util.h"
-#include "base/values.h"
-#include "chrome/browser/character_encoding.h"
-#include "chrome/browser/dom_ui/options/dom_options_util.h"
-#include "chrome/browser/dom_ui/options/font_settings_utils.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/notification_details.h"
-#include "chrome/common/notification_type.h"
-#include "chrome/common/pref_names.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-
-FontSettingsHandler::FontSettingsHandler() {
-}
-
-FontSettingsHandler::~FontSettingsHandler() {
-}
-
-void FontSettingsHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- RegisterTitle(localized_strings, "fontSettingsPage",
- IDS_FONT_LANGUAGE_SETTING_FONT_TAB_TITLE);
- localized_strings->SetString("fontSettingsStandard",
- dom_options_util::StripColon(
- l10n_util::GetStringUTF16(
- IDS_FONT_LANGUAGE_SETTING_FONT_SELECTOR_STANDARD_LABEL)));
- localized_strings->SetString("fontSettingsFixedWidth",
- dom_options_util::StripColon(
- l10n_util::GetStringUTF16(
- IDS_FONT_LANGUAGE_SETTING_FONT_SELECTOR_FIXED_WIDTH_LABEL)));
- localized_strings->SetString("fontSettingsMinimumSize",
- l10n_util::GetStringUTF16(
- IDS_FONT_LANGUAGE_SETTING_MINIMUM_FONT_SIZE_TITLE));
- localized_strings->SetString("fontSettingsEncoding",
- l10n_util::GetStringUTF16(
- IDS_FONT_LANGUAGE_SETTING_FONT_SUB_DIALOG_ENCODING_TITLE));
- localized_strings->SetString("fontSettingsSizeLabel",
- l10n_util::GetStringUTF16(
- IDS_FONT_LANGUAGE_SETTING_FONT_SIZE_SELECTOR_LABEL));
- localized_strings->SetString("fontSettingsSizeTiny",
- l10n_util::GetStringUTF16(
- IDS_FONT_LANGUAGE_SETTING_FONT_SIZE_TINY));
- localized_strings->SetString("fontSettingsSizeHuge",
- l10n_util::GetStringUTF16(
- IDS_FONT_LANGUAGE_SETTING_FONT_SIZE_HUGE));
- localized_strings->SetString("fontSettingsEncodingLabel",
- l10n_util::GetStringUTF16(
- IDS_FONT_LANGUAGE_SETTING_FONT_DEFAULT_ENCODING_SELECTOR_LABEL));
- localized_strings->SetString("fontSettingsLoremIpsum",
- l10n_util::GetStringUTF16(
- IDS_FONT_LANGUAGE_SETTING_LOREM_IPSUM));
-
- // Fonts
- ListValue* font_list = FontSettingsUtilities::GetFontsList();
- if (font_list) localized_strings->Set("fontSettingsFontList", font_list);
-
- // Font sizes
- int font_sizes[] = { 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 24, 26,
- 28, 30, 32, 34, 36, 40, 44, 48, 56, 64, 72 };
- int count = arraysize(font_sizes);
- ListValue* font_size_list = new ListValue;
- for (int i = 0; i < count; i++) {
- ListValue* option = new ListValue();
- option->Append(Value::CreateIntegerValue(font_sizes[i]));
- option->Append(Value::CreateStringValue(base::IntToString(font_sizes[i])));
- font_size_list->Append(option);
- }
- localized_strings->Set("fontSettingsFontSizeList", font_size_list);
-
- // Miniumum font size
- int minimum_font_sizes[] = { 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22,
- 24 };
- count = arraysize(minimum_font_sizes);
- ListValue* minimum_font_size_list = new ListValue;
- ListValue* default_option = new ListValue();
- default_option->Append(Value::CreateIntegerValue(0));
- default_option->Append(Value::CreateStringValue(
- l10n_util::GetStringUTF16(
- IDS_FONT_LANGUAGE_SETTING_NO_MINIMUM_FONT_SIZE_LABEL)));
- minimum_font_size_list->Append(default_option);
- for (int i = 0; i < count; i++) {
- ListValue* option = new ListValue();
- option->Append(Value::CreateIntegerValue(minimum_font_sizes[i]));
- option->Append(
- Value::CreateStringValue(base::IntToString(minimum_font_sizes[i])));
- minimum_font_size_list->Append(option);
- }
- localized_strings->Set("fontSettingsMinimumFontSizeList",
- minimum_font_size_list);
-
- // Encodings
- count = CharacterEncoding::GetSupportCanonicalEncodingCount();
- ListValue* encoding_list = new ListValue;
- for (int i = 0; i < count; ++i) {
- int cmd_id = CharacterEncoding::GetEncodingCommandIdByIndex(i);
- std::string encoding =
- CharacterEncoding::GetCanonicalEncodingNameByCommandId(cmd_id);
- string16 name =
- CharacterEncoding::GetCanonicalEncodingDisplayNameByCommandId(cmd_id);
-
- ListValue* option = new ListValue();
- option->Append(Value::CreateStringValue(encoding));
- option->Append(Value::CreateStringValue(name));
- encoding_list->Append(option);
- }
- localized_strings->Set("fontSettingsEncodingList", encoding_list);
-}
-
-void FontSettingsHandler::Initialize() {
- SetupSerifFontSample();
- SetupMinimumFontSample();
- SetupFixedFontSample();
-}
-
-WebUIMessageHandler* FontSettingsHandler::Attach(WebUI* web_ui) {
- // Call through to superclass.
- WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui);
-
- // Perform validation for saved fonts.
- DCHECK(web_ui_);
- PrefService* pref_service = web_ui_->GetProfile()->GetPrefs();
- FontSettingsUtilities::ValidateSavedFonts(pref_service);
-
- // Register for preferences that we need to observe manually.
- serif_font_.Init(prefs::kWebKitSerifFontFamily, pref_service, this);
- fixed_font_.Init(prefs::kWebKitFixedFontFamily, pref_service, this);
- default_font_size_.Init(prefs::kWebKitDefaultFontSize, pref_service, this);
- default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize,
- pref_service, this);
- minimum_font_size_.Init(prefs::kWebKitMinimumFontSize, pref_service, this);
-
- // Return result from the superclass.
- return handler;
-}
-
-void FontSettingsHandler::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- if (type == NotificationType::PREF_CHANGED) {
- std::string* pref_name = Details<std::string>(details).ptr();
- if (*pref_name == prefs::kWebKitSerifFontFamily ||
- *pref_name == prefs::kWebKitDefaultFontSize) {
- SetupSerifFontSample();
- } else if (*pref_name == prefs::kWebKitFixedFontFamily ||
- *pref_name == prefs::kWebKitDefaultFixedFontSize) {
- SetupFixedFontSample();
- } else if (*pref_name == prefs::kWebKitMinimumFontSize) {
- SetupMinimumFontSample();
- }
- }
-}
-
-void FontSettingsHandler::SetupSerifFontSample() {
- DCHECK(web_ui_);
- StringValue font_value(serif_font_.GetValue());
- FundamentalValue size_value(default_font_size_.GetValue());
- web_ui_->CallJavascriptFunction(
- L"FontSettings.setupSerifFontSample", font_value, size_value);
-}
-
-void FontSettingsHandler::SetupFixedFontSample() {
- DCHECK(web_ui_);
- StringValue font_value(fixed_font_.GetValue());
- FundamentalValue size_value(default_fixed_font_size_.GetValue());
- web_ui_->CallJavascriptFunction(
- L"FontSettings.setupFixedFontSample", font_value, size_value);
-}
-
-void FontSettingsHandler::SetupMinimumFontSample() {
- DCHECK(web_ui_);
- FundamentalValue size_value(minimum_font_size_.GetValue());
- web_ui_->CallJavascriptFunction(
- L"FontSettings.setupMinimumFontSample", size_value);
-}
diff --git a/chrome/browser/dom_ui/options/font_settings_handler.h b/chrome/browser/dom_ui/options/font_settings_handler.h
index ad7a907..dd9196b 100644
--- a/chrome/browser/dom_ui/options/font_settings_handler.h
+++ b/chrome/browser/dom_ui/options/font_settings_handler.h
@@ -6,39 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_FONT_SETTINGS_HANDLER_H_
#pragma once
-#include "chrome/browser/dom_ui/options/options_ui.h"
-#include "chrome/browser/prefs/pref_member.h"
-
-// Font settings overlay page UI handler.
-class FontSettingsHandler : public OptionsPageUIHandler {
- public:
- FontSettingsHandler();
- virtual ~FontSettingsHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
- virtual void Initialize();
-
- // WebUIMessageHandler implementation.
- virtual WebUIMessageHandler* Attach(WebUI* web_ui);
-
- // NotificationObserver implementation.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- private:
- void SetupSerifFontSample();
- void SetupFixedFontSample();
- void SetupMinimumFontSample();
-
- StringPrefMember serif_font_;
- StringPrefMember fixed_font_;
- IntegerPrefMember default_font_size_;
- IntegerPrefMember default_fixed_font_size_;
- IntegerPrefMember minimum_font_size_;
-
- DISALLOW_COPY_AND_ASSIGN(FontSettingsHandler);
-};
+#include "chrome/browser/webui/options/font_settings_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_FONT_SETTINGS_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/font_settings_utils.h b/chrome/browser/dom_ui/options/font_settings_utils.h
index 5ac232c..012c2a5 100644
--- a/chrome/browser/dom_ui/options/font_settings_utils.h
+++ b/chrome/browser/dom_ui/options/font_settings_utils.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.
@@ -6,20 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_FONT_SETTINGS_UTILS_H_
#pragma once
-#include "base/basictypes.h"
-
-class ListValue;
-class PrefService;
-
-// Chrome advanced options utility methods.
-class FontSettingsUtilities {
- public:
- static ListValue* GetFontsList();
-
- static void ValidateSavedFonts(PrefService* prefs);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(FontSettingsUtilities);
-};
+#include "chrome/browser/webui/options/font_settings_utils.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_FONT_SETTINGS_UTILS_H_
diff --git a/chrome/browser/dom_ui/options/font_settings_utils_gtk.cc b/chrome/browser/dom_ui/options/font_settings_utils_gtk.cc
deleted file mode 100644
index d1aaefb5..0000000
--- a/chrome/browser/dom_ui/options/font_settings_utils_gtk.cc
+++ /dev/null
@@ -1,43 +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/font_settings_utils.h"
-
-#include <set>
-#include <string>
-
-#include <pango/pango.h>
-#include <pango/pangocairo.h>
-
-#include "base/values.h"
-
-ListValue* FontSettingsUtilities::GetFontsList() {
- ListValue* font_list = new ListValue;
-
- PangoFontMap* font_map = ::pango_cairo_font_map_get_default();
- PangoFontFamily** families = NULL;
- int num_families = 0;
- ::pango_font_map_list_families(font_map, &families, &num_families);
-
- std::set<std::string> sorted_families;
- for (int i = 0; i < num_families; i++) {
- sorted_families.insert(::pango_font_family_get_name(families[i]));
- }
- g_free(families);
-
- for (std::set<std::string>::const_iterator iter = sorted_families.begin();
- iter != sorted_families.end(); ++iter) {
- ListValue* font_item = new ListValue();
- font_item->Append(Value::CreateStringValue(*iter));
- font_item->Append(Value::CreateStringValue(*iter)); // localized name.
- // TODO(yusukes): Support localized family names.
- font_list->Append(font_item);
- }
-
- return font_list;
-}
-
-void FontSettingsUtilities::ValidateSavedFonts(PrefService* prefs) {
- // nothing to do for GTK.
-}
diff --git a/chrome/browser/dom_ui/options/font_settings_utils_mac.mm b/chrome/browser/dom_ui/options/font_settings_utils_mac.mm
deleted file mode 100644
index bfdff36..0000000
--- a/chrome/browser/dom_ui/options/font_settings_utils_mac.mm
+++ /dev/null
@@ -1,53 +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/font_settings_utils.h"
-
-#import <Cocoa/Cocoa.h>
-
-#include "base/sys_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/common/pref_names.h"
-
-static void ValidateFontFamily(PrefService* prefs,
- const char* family_pref_name) {
- // The native font settings dialog saved fonts by the font name, rather
- // than the family name. This worked for the old dialog since
- // -[NSFont fontWithName:size] accepted a font or family name, but the
- // behavior was technically wrong. Since we really need the family name for
- // the dom-ui options window, we will fix the saved preference if necessary.
- NSString *family_name =
- base::SysUTF8ToNSString(prefs->GetString(family_pref_name));
- NSFont *font = [NSFont fontWithName:family_name
- size:[NSFont systemFontSize]];
- if (font &&
- [[font familyName] caseInsensitiveCompare:family_name] != NSOrderedSame) {
- std::string new_family_name = base::SysNSStringToUTF8([font familyName]);
- prefs->SetString(family_pref_name, new_family_name);
- }
-}
-
-ListValue* FontSettingsUtilities::GetFontsList() {
- ListValue* font_list = new ListValue;
- NSFontManager* fontManager = [NSFontManager sharedFontManager];
- NSArray* fonts = [fontManager availableFontFamilies];
- for (NSString* family_name in fonts) {
- NSString* localized_family_name =
- [fontManager localizedNameForFamily:family_name face:nil];
- ListValue* font_item = new ListValue();
- string16 family = base::SysNSStringToUTF16(family_name);
- font_item->Append(Value::CreateStringValue(family));
- string16 loc_family = base::SysNSStringToUTF16(localized_family_name);
- font_item->Append(Value::CreateStringValue(loc_family));
- font_list->Append(font_item);
- }
- return font_list;
-}
-
-void FontSettingsUtilities::ValidateSavedFonts(PrefService* prefs) {
- ValidateFontFamily(prefs, prefs::kWebKitSerifFontFamily);
- ValidateFontFamily(prefs, prefs::kWebKitSansSerifFontFamily);
- ValidateFontFamily(prefs, prefs::kWebKitFixedFontFamily);
-}
diff --git a/chrome/browser/dom_ui/options/font_settings_utils_win.cc b/chrome/browser/dom_ui/options/font_settings_utils_win.cc
deleted file mode 100644
index 9a7c9bb..0000000
--- a/chrome/browser/dom_ui/options/font_settings_utils_win.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/font_settings_utils.h"
-
-#include <set>
-#include <string>
-#include <windows.h>
-
-#include "base/values.h"
-
-static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXW *logical_font,
- NEWTEXTMETRICEXW *physical_font,
- DWORD font_type,
- LPARAM lparam) {
- std::set<std::wstring>* font_names =
- reinterpret_cast<std::set<std::wstring>*>(lparam);
- if (font_names) {
- const LOGFONTW& lf = logical_font->elfLogFont;
- if (lf.lfFaceName[0] && lf.lfFaceName[0] != '@') {
- std::wstring face_name(lf.lfFaceName);
- font_names->insert(face_name);
- }
- }
- return 1;
-}
-
-ListValue* FontSettingsUtilities::GetFontsList() {
- std::set<std::wstring> font_names;
-
- LOGFONTW logfont;
- memset(&logfont, 0, sizeof(logfont));
- logfont.lfCharSet = DEFAULT_CHARSET;
-
- HDC hdc = ::GetDC(NULL);
- ::EnumFontFamiliesExW(hdc, &logfont, (FONTENUMPROCW)&EnumFontFamExProc,
- (LPARAM)&font_names, 0);
- ::ReleaseDC(NULL, hdc);
-
- ListValue* font_list = new ListValue;
- std::set<std::wstring>::iterator iter;
- for (iter = font_names.begin(); iter != font_names.end(); iter++) {
- ListValue* font_item = new ListValue();
- font_item->Append(Value::CreateStringValue(*iter));
- font_item->Append(Value::CreateStringValue(*iter));
- font_list->Append(font_item);
- }
- return font_list;
-}
-
-void FontSettingsUtilities::ValidateSavedFonts(PrefService* prefs) {
- // nothing to do for Windows.
-}
-
diff --git a/chrome/browser/dom_ui/options/import_data_handler.cc b/chrome/browser/dom_ui/options/import_data_handler.cc
deleted file mode 100644
index 3931d09..0000000
--- a/chrome/browser/dom_ui/options/import_data_handler.cc
+++ /dev/null
@@ -1,169 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/import_data_handler.h"
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "base/scoped_ptr.h"
-#include "base/string16.h"
-#include "base/string_number_conversions.h"
-#include "base/string_util.h"
-#include "base/threading/thread_restrictions.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/profiles/profile.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "chrome/browser/importer/importer_data_types.h"
-#include "ui/base/l10n/l10n_util.h"
-
-ImportDataHandler::ImportDataHandler() : importer_host_(NULL) {
-}
-
-ImportDataHandler::~ImportDataHandler() {
- if (importer_list_)
- importer_list_->SetObserver(NULL);
-
- if (importer_host_)
- importer_host_->SetObserver(NULL);
-}
-
-void ImportDataHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
- RegisterTitle(localized_strings, "importDataOverlay",
- IDS_IMPORT_SETTINGS_TITLE);
- localized_strings->SetString("importFromLabel",
- l10n_util::GetStringUTF16(IDS_IMPORT_FROM_LABEL));
- localized_strings->SetString("importLoading",
- l10n_util::GetStringUTF16(IDS_IMPORT_LOADING_PROFILES));
- localized_strings->SetString("importDescription",
- l10n_util::GetStringUTF16(IDS_IMPORT_ITEMS_LABEL));
- localized_strings->SetString("importHistory",
- l10n_util::GetStringUTF16(IDS_IMPORT_HISTORY_CHKBOX));
- localized_strings->SetString("importFavorites",
- l10n_util::GetStringUTF16(IDS_IMPORT_FAVORITES_CHKBOX));
- localized_strings->SetString("importSearch",
- l10n_util::GetStringUTF16(IDS_IMPORT_SEARCH_ENGINES_CHKBOX));
- localized_strings->SetString("importPasswords",
- l10n_util::GetStringUTF16(IDS_IMPORT_PASSWORDS_CHKBOX));
- localized_strings->SetString("importCommit",
- l10n_util::GetStringUTF16(IDS_IMPORT_COMMIT));
- localized_strings->SetString("noProfileFound",
- l10n_util::GetStringUTF16(IDS_IMPORT_NO_PROFILE_FOUND));
-}
-
-void ImportDataHandler::Initialize() {
- importer_list_ = new ImporterList;
- importer_list_->DetectSourceProfiles(this);
-}
-
-void ImportDataHandler::RegisterMessages() {
- web_ui_->RegisterMessageCallback(
- "importData", NewCallback(this, &ImportDataHandler::ImportData));
-}
-
-void ImportDataHandler::ImportData(const ListValue* args) {
- std::string string_value;
-
- int browser_index;
- if (!args->GetString(0, &string_value) ||
- !base::StringToInt(string_value, &browser_index)) {
- NOTREACHED();
- return;
- }
-
- uint16 selected_items = importer::NONE;
- if (args->GetString(1, &string_value) && string_value == "true") {
- selected_items |= importer::HISTORY;
- }
- if (args->GetString(2, &string_value) && string_value == "true") {
- selected_items |= importer::FAVORITES;
- }
- if (args->GetString(3, &string_value) && string_value == "true") {
- selected_items |= importer::PASSWORDS;
- }
- if (args->GetString(4, &string_value) && string_value == "true") {
- selected_items |= importer::SEARCH_ENGINES;
- }
-
- const ProfileInfo& source_profile =
- importer_list_->GetSourceProfileInfoAt(browser_index);
- uint16 supported_items = source_profile.services_supported;
-
- uint16 import_services = (selected_items & supported_items);
- if (import_services) {
- FundamentalValue state(true);
- web_ui_->CallJavascriptFunction(
- L"ImportDataOverlay.setImportingState", state);
-
- // TODO(csilv): Out-of-process import has only been qualified on MacOS X,
- // so we will only use it on that platform since it is required. Remove this
- // conditional logic once oop import is qualified for Linux/Windows.
- // http://crbug.com/22142
-#if defined(OS_MACOSX)
- importer_host_ = new ExternalProcessImporterHost;
-#else
- importer_host_ = new ImporterHost;
-#endif
- importer_host_->SetObserver(this);
- Profile* profile = web_ui_->GetProfile();
- importer_host_->StartImportSettings(source_profile, profile,
- import_services,
- new ProfileWriter(profile), false);
- } else {
- LOG(WARNING) << "There were no settings to import from '"
- << source_profile.description << "'.";
- }
-}
-
-void ImportDataHandler::ImportStarted() {
-}
-
-void ImportDataHandler::ImportItemStarted(importer::ImportItem item) {
- // TODO(csilv): show progress detail in the web view.
-}
-
-void ImportDataHandler::ImportItemEnded(importer::ImportItem item) {
- // TODO(csilv): show progress detail in the web view.
-}
-
-void ImportDataHandler::ImportEnded() {
- importer_host_->SetObserver(NULL);
- importer_host_ = NULL;
-
- web_ui_->CallJavascriptFunction(L"ImportDataOverlay.dismiss");
-}
-
-void ImportDataHandler::SourceProfilesLoaded() {
- ListValue browser_profiles;
- int profiles_count = importer_list_->GetAvailableProfileCount();
- for (int i = 0; i < profiles_count; i++) {
- const importer::ProfileInfo& source_profile =
- importer_list_->GetSourceProfileInfoAt(i);
- string16 browser_name = WideToUTF16Hack(source_profile.description);
- uint16 browser_services = source_profile.services_supported;
-
- DictionaryValue* browser_profile = new DictionaryValue();
- browser_profile->SetString("name", browser_name);
- browser_profile->SetInteger("index", i);
- browser_profile->SetBoolean("history",
- (browser_services & importer::HISTORY) != 0);
- browser_profile->SetBoolean("favorites",
- (browser_services & importer::FAVORITES) != 0);
- browser_profile->SetBoolean("passwords",
- (browser_services & importer::PASSWORDS) != 0);
- browser_profile->SetBoolean("search",
- (browser_services & importer::SEARCH_ENGINES) != 0);
-
- browser_profiles.Append(browser_profile);
- }
-
- web_ui_->CallJavascriptFunction(
- L"options.ImportDataOverlay.updateSupportedBrowsers",
- browser_profiles);
-}
diff --git a/chrome/browser/dom_ui/options/import_data_handler.h b/chrome/browser/dom_ui/options/import_data_handler.h
index bc50ad1..e2e5eee 100644
--- a/chrome/browser/dom_ui/options/import_data_handler.h
+++ b/chrome/browser/dom_ui/options/import_data_handler.h
@@ -1,48 +1,12 @@
-// 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.
#ifndef CHROME_BROWSER_DOM_UI_OPTIONS_IMPORT_DATA_HANDLER_H_
#define CHROME_BROWSER_DOM_UI_OPTIONS_IMPORT_DATA_HANDLER_H_
+#pragma once
-#include "base/ref_counted.h"
-#include "chrome/browser/dom_ui/options/options_ui.h"
-#include "chrome/browser/importer/importer.h"
-
-// Chrome personal stuff import data overlay UI handler.
-class ImportDataHandler : public OptionsPageUIHandler,
- public ImporterHost::Observer,
- public ImporterList::Observer {
- public:
- ImportDataHandler();
- virtual ~ImportDataHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
- virtual void Initialize();
-
- // WebUIMessageHandler implementation.
- virtual void RegisterMessages();
-
- private:
- void ImportData(const ListValue* args);
-
- // ImporterHost::Observer implementation.
- virtual void ImportStarted();
- virtual void ImportItemStarted(importer::ImportItem item);
- virtual void ImportItemEnded(importer::ImportItem item);
- virtual void ImportEnded();
-
- // ImporterList::Observer implementation.
- virtual void SourceProfilesLoaded();
-
- scoped_refptr<ImporterList> importer_list_;
-
- // If non-null it means importing is in progress. ImporterHost takes care
- // of deleting itself when import is complete.
- ImporterHost* importer_host_; // weak
-
- DISALLOW_COPY_AND_ASSIGN(ImportDataHandler);
-};
+#include "chrome/browser/webui/options/import_data_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_IMPORT_DATA_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/language_options_handler.cc b/chrome/browser/dom_ui/options/language_options_handler.cc
deleted file mode 100644
index f3119d5..0000000
--- a/chrome/browser/dom_ui/options/language_options_handler.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/language_options_handler.h"
-
-#include <map>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/command_line.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/metrics/user_metrics.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-
-LanguageOptionsHandler::LanguageOptionsHandler() {
-}
-
-LanguageOptionsHandler::~LanguageOptionsHandler() {
-}
-
-void LanguageOptionsHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- LanguageOptionsHandlerCommon::GetLocalizedValues(localized_strings);
-
- localized_strings->SetString("restart_button",
- l10n_util::GetStringUTF16(
- IDS_OPTIONS_SETTINGS_LANGUAGES_RELAUNCH_BUTTON));
- localized_strings->Set("languageList", GetLanguageList());
-}
-
-void LanguageOptionsHandler::RegisterMessages() {
- LanguageOptionsHandlerCommon::RegisterMessages();
-
- web_ui_->RegisterMessageCallback("uiLanguageRestart",
- NewCallback(this, &LanguageOptionsHandler::RestartCallback));
-}
-
-ListValue* LanguageOptionsHandler::GetLanguageList() {
- // Collect the language codes from the supported accept-languages.
- const std::string app_locale = g_browser_process->GetApplicationLocale();
- std::vector<std::string> language_codes;
- l10n_util::GetAcceptLanguagesForLocale(app_locale, &language_codes);
-
- // Map of display name -> {language code, native_display_name}.
- // In theory, we should be able to create a map that is sorted by
- // display names using ICU comparator, but doing it is hard, thus we'll
- // use an auxiliary vector to achieve the same result.
- typedef std::pair<std::string, string16> LanguagePair;
- typedef std::map<string16, LanguagePair> LanguageMap;
- LanguageMap language_map;
- // The auxiliary vector mentioned above.
- std::vector<string16> display_names;
-
- // Build the list of display names, and build the language map.
- for (size_t i = 0; i < language_codes.size(); ++i) {
- const string16 display_name =
- l10n_util::GetDisplayNameForLocale(language_codes[i], app_locale, true);
- const string16 native_display_name =
- l10n_util::GetDisplayNameForLocale(language_codes[i], language_codes[i],
- true);
- display_names.push_back(display_name);
- language_map[display_name] =
- std::make_pair(language_codes[i], native_display_name);
- }
- DCHECK_EQ(display_names.size(), language_map.size());
-
- // Sort display names using locale specific sorter.
- l10n_util::SortStrings16(app_locale, &display_names);
-
- // Build the language list from the language map.
- ListValue* language_list = new ListValue();
- for (size_t i = 0; i < display_names.size(); ++i) {
- const LanguagePair& pair = language_map[display_names[i]];
- DictionaryValue* dictionary = new DictionaryValue();
- dictionary->SetString("code", pair.first);
- dictionary->SetString("displayName", display_names[i]);
- dictionary->SetString("nativeDisplayName", pair.second);
- language_list->Append(dictionary);
- }
-
- return language_list;
-}
-
-string16 LanguageOptionsHandler::GetProductName() {
- return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
-}
-
-void LanguageOptionsHandler::SetApplicationLocale(std::string language_code) {
- PrefService* pref_service = g_browser_process->local_state();
- pref_service->SetString(prefs::kApplicationLocale, language_code);
-}
-
-void LanguageOptionsHandler::RestartCallback(const ListValue* args) {
- UserMetrics::RecordAction(UserMetricsAction("LanguageOptions_Restart"));
-
- // Set the flag to restore state after the restart.
- PrefService* pref_service = g_browser_process->local_state();
- pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true);
- BrowserList::CloseAllBrowsersAndExit();
-}
diff --git a/chrome/browser/dom_ui/options/language_options_handler.h b/chrome/browser/dom_ui/options/language_options_handler.h
index 1f1181c..e2448eb 100644
--- a/chrome/browser/dom_ui/options/language_options_handler.h
+++ b/chrome/browser/dom_ui/options/language_options_handler.h
@@ -6,38 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_H_
#pragma once
-#include "chrome/browser/dom_ui/options/language_options_handler_common.h"
-
-// Language options UI page handler for non-Chrome OS platforms. For Chrome OS,
-// see chromeos::CrosLanguageOptionsHandler.
-class LanguageOptionsHandler : public LanguageOptionsHandlerCommon {
- public:
- LanguageOptionsHandler();
- virtual ~LanguageOptionsHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
-
- // WebUIMessageHandler implementation.
- virtual void RegisterMessages();
-
- // The following static method is public for ease of testing.
-
- // Gets the list of languages from the given input descriptors.
- // The return value will look like:
- // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'},
- // ...]
- static ListValue* GetLanguageList();
-
- private:
- // LanguageOptionsHandlerCommon implementation.
- virtual string16 GetProductName();
- virtual void SetApplicationLocale(std::string language_code);
-
- // Called when the restart button is clicked.
- void RestartCallback(const ListValue* args);
-
- DISALLOW_COPY_AND_ASSIGN(LanguageOptionsHandler);
-};
+#include "chrome/browser/webui/options/language_options_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/language_options_handler_common.cc b/chrome/browser/dom_ui/options/language_options_handler_common.cc
deleted file mode 100644
index e2e4403..0000000
--- a/chrome/browser/dom_ui/options/language_options_handler_common.cc
+++ /dev/null
@@ -1,164 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/language_options_handler_common.h"
-
-#include <map>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/command_line.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/metrics/user_metrics.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/spellcheck_common.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-
-LanguageOptionsHandlerCommon::LanguageOptionsHandlerCommon() {
-}
-
-LanguageOptionsHandlerCommon::~LanguageOptionsHandlerCommon() {
-}
-
-void LanguageOptionsHandlerCommon::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
- string16 product_name = GetProductName();
- RegisterTitle(localized_strings, "languagePage",
- IDS_OPTIONS_SETTINGS_LANGUAGES_DIALOG_TITLE);
- localized_strings->SetString("add_button",
- l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_BUTTON));
- localized_strings->SetString("languages",
- l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_LANGUAGES));
- localized_strings->SetString("please_add_another_language",
- l10n_util::GetStringUTF16(
- IDS_OPTIONS_SETTINGS_LANGUAGES_PLEASE_ADD_ANOTHER_LANGUAGE));
- localized_strings->SetString("remove_button",
- l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_REMOVE_BUTTON));
- localized_strings->SetString("add_language_instructions",
- l10n_util::GetStringUTF16(
- IDS_OPTIONS_SETTINGS_LANGUAGES_ADD_LANGUAGE_INSTRUCTIONS));
- localized_strings->SetString("cannot_be_displayed_in_this_language",
- l10n_util::GetStringFUTF16(
- IDS_OPTIONS_SETTINGS_LANGUAGES_CANNOT_BE_DISPLAYED_IN_THIS_LANGUAGE,
- product_name));
- localized_strings->SetString("is_displayed_in_this_language",
- l10n_util::GetStringFUTF16(
- IDS_OPTIONS_SETTINGS_LANGUAGES_IS_DISPLAYED_IN_THIS_LANGUAGE,
- product_name));
- localized_strings->SetString("display_in_this_language",
- l10n_util::GetStringFUTF16(
- IDS_OPTIONS_SETTINGS_LANGUAGES_DISPLAY_IN_THIS_LANGUAGE,
- product_name));
- localized_strings->SetString("this_language_is_currently_in_use",
- l10n_util::GetStringFUTF16(
- IDS_OPTIONS_SETTINGS_LANGUAGES_THIS_LANGUAGE_IS_CURRENTLY_IN_USE,
- product_name));
- localized_strings->SetString("use_this_for_spell_checking",
- l10n_util::GetStringUTF16(
- IDS_OPTIONS_SETTINGS_USE_THIS_FOR_SPELL_CHECKING));
- localized_strings->SetString("cannot_be_used_for_spell_checking",
- l10n_util::GetStringUTF16(
- IDS_OPTIONS_SETTINGS_CANNOT_BE_USED_FOR_SPELL_CHECKING));
- localized_strings->SetString("is_used_for_spell_checking",
- l10n_util::GetStringUTF16(
- IDS_OPTIONS_SETTINGS_IS_USED_FOR_SPELL_CHECKING));
- localized_strings->SetString("restart_required",
- l10n_util::GetStringUTF16(IDS_OPTIONS_RELAUNCH_REQUIRED));
- localized_strings->SetString("enable_spell_check",
- l10n_util::GetStringUTF16(IDS_OPTIONS_ENABLE_SPELLCHECK));
- localized_strings->SetString("enable_auto_spell_correction",
- l10n_util::GetStringUTF16(IDS_OPTIONS_ENABLE_AUTO_SPELL_CORRECTION));
- localized_strings->SetString("add_language_title",
- l10n_util::GetStringUTF16(IDS_OPTIONS_LANGUAGES_ADD_TITLE));
- localized_strings->SetString("add_language_select_label",
- l10n_util::GetStringUTF16(IDS_OPTIONS_LANGUAGES_ADD_SELECT_LABEL));
- localized_strings->SetString("restart_button",
- l10n_util::GetStringUTF16(
- IDS_OPTIONS_SETTINGS_LANGUAGES_RELAUNCH_BUTTON));
-
- // The following are resources, rather than local strings.
- localized_strings->SetString("currentUiLanguageCode",
- g_browser_process->GetApplicationLocale());
- localized_strings->Set("spellCheckLanguageCodeSet",
- GetSpellCheckLanguageCodeSet());
- localized_strings->Set("uiLanguageCodeSet", GetUILanguageCodeSet());
-
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- bool experimental_spell_check_features =
- command_line.HasSwitch(switches::kExperimentalSpellcheckerFeatures);
- localized_strings->SetBoolean("experimentalSpellCheckFeatures",
- experimental_spell_check_features);
-}
-
-void LanguageOptionsHandlerCommon::RegisterMessages() {
- DCHECK(web_ui_);
- web_ui_->RegisterMessageCallback("languageOptionsOpen",
- NewCallback(
- this,
- &LanguageOptionsHandlerCommon::LanguageOptionsOpenCallback));
- web_ui_->RegisterMessageCallback("spellCheckLanguageChange",
- NewCallback(
- this,
- &LanguageOptionsHandlerCommon::SpellCheckLanguageChangeCallback));
- web_ui_->RegisterMessageCallback("uiLanguageChange",
- NewCallback(
- this,
- &LanguageOptionsHandlerCommon::UiLanguageChangeCallback));
-}
-
-DictionaryValue* LanguageOptionsHandlerCommon::GetUILanguageCodeSet() {
- DictionaryValue* dictionary = new DictionaryValue();
- const std::vector<std::string>& available_locales =
- l10n_util::GetAvailableLocales();
- for (size_t i = 0; i < available_locales.size(); ++i) {
- dictionary->SetBoolean(available_locales[i], true);
- }
- return dictionary;
-}
-
-DictionaryValue* LanguageOptionsHandlerCommon::GetSpellCheckLanguageCodeSet() {
- DictionaryValue* dictionary = new DictionaryValue();
- std::vector<std::string> spell_check_languages;
- SpellCheckCommon::SpellCheckLanguages(&spell_check_languages);
- for (size_t i = 0; i < spell_check_languages.size(); ++i) {
- dictionary->SetBoolean(spell_check_languages[i], true);
- }
- return dictionary;
-}
-
-void LanguageOptionsHandlerCommon::LanguageOptionsOpenCallback(
- const ListValue* args) {
- UserMetrics::RecordAction(UserMetricsAction("LanguageOptions_Open"));
-}
-
-void LanguageOptionsHandlerCommon::UiLanguageChangeCallback(
- const ListValue* args) {
- const std::string language_code = WideToASCII(ExtractStringValue(args));
- CHECK(!language_code.empty());
- const std::string action = StringPrintf(
- "LanguageOptions_UiLanguageChange_%s", language_code.c_str());
- UserMetrics::RecordComputedAction(action);
- SetApplicationLocale(language_code);
- web_ui_->CallJavascriptFunction(
- L"options.LanguageOptions.uiLanguageSaved");
-}
-
-void LanguageOptionsHandlerCommon::SpellCheckLanguageChangeCallback(
- const ListValue* args) {
- const std::string language_code = WideToASCII(ExtractStringValue(args));
- CHECK(!language_code.empty());
- const std::string action = StringPrintf(
- "LanguageOptions_SpellCheckLanguageChange_%s", language_code.c_str());
- UserMetrics::RecordComputedAction(action);
-}
diff --git a/chrome/browser/dom_ui/options/language_options_handler_common.h b/chrome/browser/dom_ui/options/language_options_handler_common.h
index 9871ce4..05c0ce7 100644
--- a/chrome/browser/dom_ui/options/language_options_handler_common.h
+++ b/chrome/browser/dom_ui/options/language_options_handler_common.h
@@ -6,61 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_COMMON_H_
#pragma once
-#include "chrome/browser/dom_ui/options/options_ui.h"
-
-class DictionaryValue;
-class ListValue;
-
-// The base class for language options page UI handlers. This class has code
-// common to the Chrome OS and non-Chrome OS implementation of the handler.
-class LanguageOptionsHandlerCommon : public OptionsPageUIHandler {
- public:
- LanguageOptionsHandlerCommon();
- virtual ~LanguageOptionsHandlerCommon();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
-
- // DOMMessageHandler implementation.
- virtual void RegisterMessages();
-
- // The following static methods are public for ease of testing.
-
- // Gets the set of language codes that can be used as UI language.
- // The return value will look like:
- // {'en-US': true, 'fi': true, 'fr': true, ...}
- //
- // Note that true in values does not mean anything. We just use the
- // dictionary as a set.
- static DictionaryValue* GetUILanguageCodeSet();
-
- // Gets the set of language codes that can be used for spellchecking.
- // The return value will look like:
- // {'en-US': true, 'fi': true, 'fr': true, ...}
- //
- // Note that true in values does not mean anything. We just use the
- // dictionary as a set.
- static DictionaryValue* GetSpellCheckLanguageCodeSet();
-
- private:
- // Returns the name of the product (ex. "Chrome" or "Chrome OS").
- virtual string16 GetProductName() = 0;
-
- // Sets the application locale.
- virtual void SetApplicationLocale(std::string language_code) = 0;
-
- // Called when the language options is opened.
- void LanguageOptionsOpenCallback(const ListValue* args);
-
- // Called when the UI language is changed.
- // |args| will contain the language code as string (ex. "fr").
- void UiLanguageChangeCallback(const ListValue* args);
-
- // Called when the spell check language is changed.
- // |args| will contain the language code as string (ex. "fr").
- void SpellCheckLanguageChangeCallback(const ListValue* args);
-
- DISALLOW_COPY_AND_ASSIGN(LanguageOptionsHandlerCommon);
-};
+#include "chrome/browser/webui/options/language_options_handler_common.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_LANGUAGE_OPTIONS_HANDLER_COMMON_H_
diff --git a/chrome/browser/dom_ui/options/language_options_handler_unittest.cc b/chrome/browser/dom_ui/options/language_options_handler_unittest.cc
deleted file mode 100644
index 3b616c4..0000000
--- a/chrome/browser/dom_ui/options/language_options_handler_unittest.cc
+++ /dev/null
@@ -1,179 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/language_options_handler.h"
-
-#include <string>
-
-#include "base/scoped_ptr.h"
-#include "base/values.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/cros/cros_library.h"
-#include "chrome/browser/chromeos/cros/input_method_library.h"
-#include "chrome/browser/chromeos/webui/cros_language_options_handler.h"
-#endif // defined(OS_CHROMEOS)
-
-#if defined(OS_CHROMEOS)
-static chromeos::InputMethodDescriptors CreateInputMethodDescriptors() {
- chromeos::InputMethodDescriptors descriptors;
- descriptors.push_back(
- chromeos::InputMethodDescriptor("xkb:us::eng", "USA", "us", "eng"));
- descriptors.push_back(
- chromeos::InputMethodDescriptor("xkb:fr::fra", "France", "fr", "fra"));
- descriptors.push_back(
- chromeos::InputMethodDescriptor("xkb:be::fra", "Belgium", "be", "fr"));
- descriptors.push_back(
- chromeos::InputMethodDescriptor("mozc", "Mozc (US keyboard layout)", "us",
- "ja"));
- return descriptors;
-}
-
-TEST(LanguageOptionsHandlerTest, GetInputMethodList) {
- // Use the stub libcros. The object will take care of the cleanup.
- chromeos::ScopedStubCrosEnabler stub_cros_enabler;
-
- // Reset the library implementation so it will be initialized
- // again. Otherwise, non-stub implementation can be reused, if it's
- // already initialized elsewhere, which results in a crash.
- chromeos::CrosLibrary::Get()->GetTestApi()->SetInputMethodLibrary(NULL,
- false);
-
- chromeos::InputMethodDescriptors descriptors = CreateInputMethodDescriptors();
- scoped_ptr<ListValue> list(
- chromeos::CrosLanguageOptionsHandler::GetInputMethodList(descriptors));
- ASSERT_EQ(4U, list->GetSize());
-
- DictionaryValue* entry = NULL;
- DictionaryValue *language_code_set = NULL;
- std::string input_method_id;
- std::string display_name;
- std::string language_code;
-
- // As shown below, the list should be input method ids should appear in
- // the same order of the descriptors.
- ASSERT_TRUE(list->GetDictionary(0, &entry));
- ASSERT_TRUE(entry->GetString("id", &input_method_id));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
- EXPECT_EQ("xkb:us::eng", input_method_id);
- // Commented out as it depends on translation in generated_resources.grd
- // (i.e. makes the test fragile).
- // EXPECT_EQ("English (USA) keyboard layout", display_name);
- ASSERT_TRUE(language_code_set->HasKey("en-US"));
- ASSERT_TRUE(language_code_set->HasKey("id")); // From kExtraLanguages.
- ASSERT_TRUE(language_code_set->HasKey("fil")); // From kExtraLanguages.
-
- ASSERT_TRUE(list->GetDictionary(1, &entry));
- ASSERT_TRUE(entry->GetString("id", &input_method_id));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
- EXPECT_EQ("xkb:fr::fra", input_method_id);
- // Commented out. See above.
- // EXPECT_EQ("French keyboard layout", display_name);
- ASSERT_TRUE(language_code_set->HasKey("fr"));
-
- ASSERT_TRUE(list->GetDictionary(2, &entry));
- ASSERT_TRUE(entry->GetString("id", &input_method_id));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
- EXPECT_EQ("xkb:be::fra", input_method_id);
- // Commented out. See above.
- // EXPECT_EQ("Belgian keyboard layout", display_name);
- ASSERT_TRUE(language_code_set->HasKey("fr"));
-
- ASSERT_TRUE(list->GetDictionary(3, &entry));
- ASSERT_TRUE(entry->GetString("id", &input_method_id));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetDictionary("languageCodeSet", &language_code_set));
- EXPECT_EQ("mozc", input_method_id);
- // Commented out. See above.
- // EXPECT_EQ("Japanese input method (for US keyboard)", display_name);
- ASSERT_TRUE(language_code_set->HasKey("ja"));
-}
-
-TEST(LanguageOptionsHandlerTest, GetLanguageList) {
- chromeos::InputMethodDescriptors descriptors = CreateInputMethodDescriptors();
- scoped_ptr<ListValue> list(
- chromeos::CrosLanguageOptionsHandler::GetLanguageList(descriptors));
- ASSERT_EQ(6U, list->GetSize());
-
- DictionaryValue* entry = NULL;
- std::string language_code;
- std::string display_name;
- std::string native_display_name;
-
- // As shown below, the list should be sorted by the display names,
- // and these names should not have duplicates.
- ASSERT_TRUE(list->GetDictionary(0, &entry));
- ASSERT_TRUE(entry->GetString("code", &language_code));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
- EXPECT_EQ("en-US", language_code);
- EXPECT_EQ("English (United States)", display_name);
- EXPECT_EQ("English (United States)", native_display_name);
-
- // This comes from kExtraLanguages.
- ASSERT_TRUE(list->GetDictionary(1, &entry));
- ASSERT_TRUE(entry->GetString("code", &language_code));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
- EXPECT_EQ("fil", language_code);
- EXPECT_EQ("Filipino", display_name);
- EXPECT_EQ("Filipino", native_display_name);
-
- ASSERT_TRUE(list->GetDictionary(2, &entry));
- ASSERT_TRUE(entry->GetString("code", &language_code));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
- EXPECT_EQ("fr", language_code);
- EXPECT_EQ("French", display_name);
- EXPECT_EQ("fran\u00E7ais", native_display_name);
-
- // This comes from kExtraLanguages.
- ASSERT_TRUE(list->GetDictionary(3, &entry));
- ASSERT_TRUE(entry->GetString("code", &language_code));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
- EXPECT_EQ("id", language_code);
- EXPECT_EQ("Indonesian", display_name);
- EXPECT_EQ("Bahasa Indonesia", native_display_name);
-
- ASSERT_TRUE(list->GetDictionary(4, &entry));
- ASSERT_TRUE(entry->GetString("code", &language_code));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
- EXPECT_EQ("ja", language_code);
- EXPECT_EQ("Japanese", display_name);
- EXPECT_EQ("\u65E5\u672C\u8A9E", native_display_name);
-
- // This comes from kExtraLanguages.
- ASSERT_TRUE(list->GetDictionary(5, &entry));
- ASSERT_TRUE(entry->GetString("code", &language_code));
- ASSERT_TRUE(entry->GetString("displayName", &display_name));
- ASSERT_TRUE(entry->GetString("nativeDisplayName", &native_display_name));
- EXPECT_EQ("es-419", language_code);
- EXPECT_EQ("Spanish (Latin America and the Caribbean)", display_name);
- EXPECT_EQ("espa\u00F1ol (Latinoam\u00E9rica y el Caribe)",
- native_display_name);
-}
-#endif // defined(OS_CHROMEOS)
-
-#if !defined(OS_MACOSX)
-TEST(LanguageOptionsHandlerTest, GetUILanguageCodeSet) {
- scoped_ptr<DictionaryValue> dictionary(
- LanguageOptionsHandler::GetUILanguageCodeSet());
- EXPECT_TRUE(dictionary->HasKey("en-US"));
- // Note that we don't test a false case, as such an expectation will
- // fail when we add support for the language.
- // EXPECT_FALSE(dictionary->HasKey("no"));
-}
-#endif // !defined(OS_MACOSX)
-
-TEST(LanguageOptionsHandlerTest, GetSpellCheckLanguageCodeSet) {
- scoped_ptr<DictionaryValue> dictionary(
- LanguageOptionsHandler::GetSpellCheckLanguageCodeSet());
- EXPECT_TRUE(dictionary->HasKey("en-US"));
-}
diff --git a/chrome/browser/dom_ui/options/options_managed_banner_handler.cc b/chrome/browser/dom_ui/options/options_managed_banner_handler.cc
deleted file mode 100644
index 81d2ccc..0000000
--- a/chrome/browser/dom_ui/options/options_managed_banner_handler.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/options_managed_banner_handler.h"
-
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/webui/web_ui.h"
-
-OptionsManagedBannerHandler::OptionsManagedBannerHandler(
- WebUI* web_ui, const string16& page_name, OptionsPage page)
- : policy::ManagedPrefsBannerBase(web_ui->GetProfile()->GetPrefs(), page),
- web_ui_(web_ui), page_name_(page_name), page_(page) {
- // Initialize the visibility state of the banner.
- SetupBannerVisibilty();
-}
-
-OptionsManagedBannerHandler::~OptionsManagedBannerHandler() {}
-
-void OptionsManagedBannerHandler::OnUpdateVisibility() {
- // A preference that may be managed has changed. Update our visibility
- // state.
- SetupBannerVisibilty();
-}
-
-void OptionsManagedBannerHandler::SetupBannerVisibilty() {
- // Construct the banner visibility script name.
- string16 script = ASCIIToUTF16("options.") + page_name_ +
- ASCIIToUTF16(".getInstance().setManagedBannerVisibility");
-
- // Get the visiblity value from the base class.
- FundamentalValue visibility(DetermineVisibility());
-
- // Set the managed state in the javascript handler.
- web_ui_->CallJavascriptFunction(UTF16ToWideHack(script), visibility);
-}
diff --git a/chrome/browser/dom_ui/options/options_managed_banner_handler.h b/chrome/browser/dom_ui/options/options_managed_banner_handler.h
index 49047df..c7422ca 100644
--- a/chrome/browser/dom_ui/options/options_managed_banner_handler.h
+++ b/chrome/browser/dom_ui/options/options_managed_banner_handler.h
@@ -6,34 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_OPTIONS_MANAGED_BANNER_HANDLER_H_
#pragma once
-#include "base/string16.h"
-#include "chrome/browser/policy/managed_prefs_banner_base.h"
-#include "chrome/browser/ui/options/options_window.h"
-
-class WebUI;
-
-// Managed options banner handler.
-// Controls the display of a banner if an options panel contains options
-// that are under administator control.
-class OptionsManagedBannerHandler : public policy::ManagedPrefsBannerBase {
- public:
- OptionsManagedBannerHandler(WebUI* web_ui, const string16& page_name,
- OptionsPage page);
- virtual ~OptionsManagedBannerHandler();
-
- protected:
- // ManagedPrefsBannerBase implementation.
- virtual void OnUpdateVisibility();
-
- private:
- // Set the managed options banner to be visible or invisible.
- void SetupBannerVisibilty();
-
- WebUI* web_ui_; // weak reference to the WebUI.
- string16 page_name_; // current options page name.
- OptionsPage page_; // current options page value.
-
- DISALLOW_COPY_AND_ASSIGN(OptionsManagedBannerHandler);
-};
+#include "chrome/browser/webui/options/options_managed_banner_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_OPTIONS_MANAGED_BANNER_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/options_ui.cc b/chrome/browser/dom_ui/options/options_ui.cc
deleted file mode 100644
index 06eafff..0000000
--- a/chrome/browser/dom_ui/options/options_ui.cc
+++ /dev/null
@@ -1,303 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/options_ui.h"
-
-#include <algorithm>
-#include <vector>
-
-#include "base/callback.h"
-#include "base/command_line.h"
-#include "base/message_loop.h"
-#include "base/singleton.h"
-#include "base/string_piece.h"
-#include "base/string_util.h"
-#include "base/threading/thread.h"
-#include "base/time.h"
-#include "base/values.h"
-#include "chrome/browser/browser_about_handler.h"
-#include "chrome/browser/browser_thread.h"
-#include "chrome/browser/dom_ui/options/about_page_handler.h"
-#include "chrome/browser/dom_ui/options/add_startup_page_handler.h"
-#include "chrome/browser/dom_ui/options/advanced_options_handler.h"
-#include "chrome/browser/dom_ui/options/autofill_options_handler.h"
-#include "chrome/browser/dom_ui/options/browser_options_handler.h"
-#include "chrome/browser/dom_ui/options/clear_browser_data_handler.h"
-#include "chrome/browser/dom_ui/options/content_settings_handler.h"
-#include "chrome/browser/dom_ui/options/cookies_view_handler.h"
-#include "chrome/browser/dom_ui/options/core_options_handler.h"
-#include "chrome/browser/dom_ui/options/dom_options_util.h"
-#include "chrome/browser/dom_ui/options/font_settings_handler.h"
-#include "chrome/browser/dom_ui/options/import_data_handler.h"
-#include "chrome/browser/dom_ui/options/language_options_handler.h"
-#include "chrome/browser/dom_ui/options/password_manager_handler.h"
-#include "chrome/browser/dom_ui/options/personal_options_handler.h"
-#include "chrome/browser/dom_ui/options/search_engine_manager_handler.h"
-#include "chrome/browser/dom_ui/options/stop_syncing_handler.h"
-#include "chrome/browser/dom_ui/web_ui_theme_source.h"
-#include "chrome/browser/metrics/user_metrics.h"
-#include "chrome/browser/renderer_host/render_view_host.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
-#include "chrome/browser/tab_contents/tab_contents_delegate.h"
-#include "chrome/common/jstemplate_builder.h"
-#include "chrome/common/notification_type.h"
-#include "chrome/common/time_format.h"
-#include "chrome/common/url_constants.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"
-#include "net/base/escape.h"
-#include "ui/base/resource/resource_bundle.h"
-
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/webui/accounts_options_handler.h"
-#include "chrome/browser/chromeos/webui/core_chromeos_options_handler.h"
-#include "chrome/browser/chromeos/webui/cros_language_options_handler.h"
-#include "chrome/browser/chromeos/webui/internet_options_handler.h"
-#include "chrome/browser/chromeos/webui/language_chewing_options_handler.h"
-#include "chrome/browser/chromeos/webui/language_customize_modifier_keys_handler.h"
-#include "chrome/browser/chromeos/webui/language_hangul_options_handler.h"
-#include "chrome/browser/chromeos/webui/language_mozc_options_handler.h"
-#include "chrome/browser/chromeos/webui/language_pinyin_options_handler.h"
-#include "chrome/browser/chromeos/webui/proxy_handler.h"
-#include "chrome/browser/chromeos/webui/stats_options_handler.h"
-#include "chrome/browser/chromeos/webui/system_options_handler.h"
-#endif
-
-#if defined(USE_NSS)
-#include "chrome/browser/dom_ui/options/certificate_manager_handler.h"
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// OptionsUIHTMLSource
-//
-////////////////////////////////////////////////////////////////////////////////
-
-OptionsUIHTMLSource::OptionsUIHTMLSource(DictionaryValue* localized_strings)
- : DataSource(chrome::kChromeUISettingsHost, MessageLoop::current()) {
- DCHECK(localized_strings);
- localized_strings_.reset(localized_strings);
-}
-
-OptionsUIHTMLSource::~OptionsUIHTMLSource() {}
-
-void OptionsUIHTMLSource::StartDataRequest(const std::string& path,
- bool is_off_the_record,
- int request_id) {
- SetFontAndTextDirection(localized_strings_.get());
-
- static const base::StringPiece options_html(
- ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_OPTIONS_HTML));
- const std::string full_html = jstemplate_builder::GetI18nTemplateHtml(
- options_html, localized_strings_.get());
-
- scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
- html_bytes->data.resize(full_html.size());
- std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin());
-
- SendResponse(request_id, html_bytes);
-}
-
-std::string OptionsUIHTMLSource::GetMimeType(const std::string&) const {
- return "text/html";
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// OptionsPageUIHandler
-//
-////////////////////////////////////////////////////////////////////////////////
-
-OptionsPageUIHandler::OptionsPageUIHandler() {
-}
-
-OptionsPageUIHandler::~OptionsPageUIHandler() {
-}
-
-bool OptionsPageUIHandler::IsEnabled() {
- return true;
-}
-
-void OptionsPageUIHandler::UserMetricsRecordAction(
- const UserMetricsAction& action) {
- UserMetrics::RecordAction(action, web_ui_->GetProfile());
-}
-
-// static
-void OptionsPageUIHandler::RegisterStrings(
- DictionaryValue* localized_strings,
- const OptionsStringResource* resources,
- size_t length) {
- for (size_t i = 0; i < length; ++i) {
- const string16& value = l10n_util::GetStringUTF16(resources[i].id);
- localized_strings->SetString(
- resources[i].name,
- resources[i].strip_colon ? dom_options_util::StripColon(value) : value);
- }
-}
-
-void OptionsPageUIHandler::RegisterTitle(DictionaryValue* localized_strings,
- const std::string& variable_name,
- int title_id) {
- localized_strings->SetString(variable_name,
- l10n_util::GetStringUTF16(title_id));
- localized_strings->SetString(variable_name + "TabTitle",
- l10n_util::GetStringFUTF16(IDS_OPTIONS_TAB_TITLE,
- l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE),
- l10n_util::GetStringUTF16(title_id)));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// OptionsUI
-//
-////////////////////////////////////////////////////////////////////////////////
-
-OptionsUI::OptionsUI(TabContents* contents)
- : WebUI(contents), initialized_handlers_(false) {
- DictionaryValue* localized_strings = new DictionaryValue();
-
-#if defined(OS_CHROMEOS)
- AddOptionsPageUIHandler(localized_strings,
- new chromeos::CoreChromeOSOptionsHandler());
-#else
- AddOptionsPageUIHandler(localized_strings, new CoreOptionsHandler());
-#endif
-
- AddOptionsPageUIHandler(localized_strings, new AddStartupPageHandler());
- AddOptionsPageUIHandler(localized_strings, new AdvancedOptionsHandler());
- AddOptionsPageUIHandler(localized_strings, new AutoFillOptionsHandler());
- AddOptionsPageUIHandler(localized_strings, new BrowserOptionsHandler());
- AddOptionsPageUIHandler(localized_strings, new ClearBrowserDataHandler());
- AddOptionsPageUIHandler(localized_strings, new ContentSettingsHandler());
- AddOptionsPageUIHandler(localized_strings, new CookiesViewHandler());
- AddOptionsPageUIHandler(localized_strings, new FontSettingsHandler());
-#if defined(OS_CHROMEOS)
- AddOptionsPageUIHandler(localized_strings,
- new chromeos::CrosLanguageOptionsHandler());
-#else
- AddOptionsPageUIHandler(localized_strings, new LanguageOptionsHandler());
-#endif
- AddOptionsPageUIHandler(localized_strings, new PasswordManagerHandler());
- AddOptionsPageUIHandler(localized_strings, new PersonalOptionsHandler());
- AddOptionsPageUIHandler(localized_strings, new SearchEngineManagerHandler());
- AddOptionsPageUIHandler(localized_strings, new ImportDataHandler());
- AddOptionsPageUIHandler(localized_strings, new StopSyncingHandler());
-#if defined(OS_CHROMEOS)
- AddOptionsPageUIHandler(localized_strings, new AboutPageHandler());
- AddOptionsPageUIHandler(localized_strings,
- new chromeos::AccountsOptionsHandler());
- AddOptionsPageUIHandler(localized_strings, new InternetOptionsHandler());
- AddOptionsPageUIHandler(localized_strings,
- new chromeos::LanguageChewingOptionsHandler());
- AddOptionsPageUIHandler(localized_strings,
- new chromeos::LanguageCustomizeModifierKeysHandler());
- AddOptionsPageUIHandler(localized_strings,
- new chromeos::LanguageHangulOptionsHandler());
- AddOptionsPageUIHandler(localized_strings,
- new chromeos::LanguageMozcOptionsHandler());
- AddOptionsPageUIHandler(localized_strings,
- new chromeos::LanguagePinyinOptionsHandler());
- AddOptionsPageUIHandler(localized_strings, new chromeos::ProxyHandler());
- AddOptionsPageUIHandler(localized_strings,
- new chromeos::StatsOptionsHandler());
- AddOptionsPageUIHandler(localized_strings, new SystemOptionsHandler());
-#endif
-#if defined(USE_NSS)
- AddOptionsPageUIHandler(localized_strings, new CertificateManagerHandler());
-#endif
-
- // |localized_strings| ownership is taken over by this constructor.
- OptionsUIHTMLSource* html_source =
- new OptionsUIHTMLSource(localized_strings);
-
- // Set up the chrome://settings/ source.
- contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
-
- // Set up the chrome://theme/ source.
- WebUIThemeSource* theme = new WebUIThemeSource(contents->profile());
- contents->profile()->GetChromeURLDataManager()->AddDataSource(theme);
-
- // Initialize the chrome://about/ source in case the user clicks the credits
- // link.
- InitializeAboutDataSource(contents->profile());
-}
-
-OptionsUI::~OptionsUI() {
- // Uninitialize all registered handlers. The base class owns them and it will
- // eventually delete them. Skip over the generic handler.
- for (std::vector<WebUIMessageHandler*>::iterator iter = handlers_.begin() + 1;
- iter != handlers_.end();
- ++iter) {
- static_cast<OptionsPageUIHandler*>(*iter)->Uninitialize();
- }
-}
-
-// Override.
-void OptionsUI::RenderViewCreated(RenderViewHost* render_view_host) {
- std::string command_line_string;
-
-#if defined(OS_WIN)
- std::wstring wstr = CommandLine::ForCurrentProcess()->command_line_string();
- command_line_string = WideToASCII(wstr);
-#else
- command_line_string = CommandLine::ForCurrentProcess()->command_line_string();
-#endif
-
- render_view_host->SetWebUIProperty("commandLineString", command_line_string);
- WebUI::RenderViewCreated(render_view_host);
-}
-
-void OptionsUI::DidBecomeActiveForReusedRenderView() {
- // When the renderer is re-used (e.g., for back/forward navigation within
- // options), the handlers are torn down and rebuilt, so are no longer
- // initialized, but the web page's DOM may remain intact, in which case onload
- // won't fire to initilize the handlers. To make sure initialization always
- // happens, call reinitializeCore (which is a no-op unless the DOM was already
- // initialized).
- CallJavascriptFunction(L"OptionsPage.reinitializeCore");
-
- WebUI::DidBecomeActiveForReusedRenderView();
-}
-
-// static
-RefCountedMemory* OptionsUI::GetFaviconResourceBytes() {
- return ResourceBundle::GetSharedInstance().
- LoadDataResourceBytes(IDR_SETTINGS_FAVICON);
-}
-
-void OptionsUI::InitializeHandlers() {
- DCHECK(!GetProfile()->IsOffTheRecord() || Profile::IsGuestSession());
-
- // The reinitialize call from DidBecomeActiveForReusedRenderView end up being
- // delivered after a new web page DOM has been brought up in an existing
- // renderer (due to IPC delays), causing this method to be called twice. If
- // that happens, ignore the second call.
- if (initialized_handlers_)
- return;
- initialized_handlers_ = true;
-
- std::vector<WebUIMessageHandler*>::iterator iter;
- // Skip over the generic handler.
- for (iter = handlers_.begin() + 1; iter != handlers_.end(); ++iter) {
- (static_cast<OptionsPageUIHandler*>(*iter))->Initialize();
- }
-}
-
-void OptionsUI::AddOptionsPageUIHandler(DictionaryValue* localized_strings,
- OptionsPageUIHandler* handler_raw) {
- scoped_ptr<OptionsPageUIHandler> handler(handler_raw);
- DCHECK(handler.get());
- // Add only if handler's service is enabled.
- if (handler->IsEnabled()) {
- handler->GetLocalizedValues(localized_strings);
- // Add handler to the list and also pass the ownership.
- AddMessageHandler(handler.release()->Attach(this));
- }
-}
diff --git a/chrome/browser/dom_ui/options/options_ui.h b/chrome/browser/dom_ui/options/options_ui.h
index 84928d7..c1a04eb 100644
--- a/chrome/browser/dom_ui/options/options_ui.h
+++ b/chrome/browser/dom_ui/options/options_ui.h
@@ -6,114 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_OPTIONS_UI_H_
#pragma once
-#include <string>
-
-#include "base/scoped_ptr.h"
-#include "chrome/browser/webui/chrome_url_data_manager.h"
-#include "chrome/browser/webui/web_ui.h"
-#include "chrome/common/notification_observer.h"
-#include "chrome/common/notification_registrar.h"
-#include "chrome/common/notification_type.h"
-
-class GURL;
-class PrefService;
-struct UserMetricsAction;
-
-class OptionsUIHTMLSource : public ChromeURLDataManager::DataSource {
- public:
- // The constructor takes over ownership of |localized_strings|.
- explicit OptionsUIHTMLSource(DictionaryValue* localized_strings);
- virtual ~OptionsUIHTMLSource();
-
- // Called when the network layer has requested a resource underneath
- // the path we registered.
- virtual void StartDataRequest(const std::string& path,
- bool is_off_the_record,
- int request_id);
- virtual std::string GetMimeType(const std::string&) const;
-
- private:
- // Localized strings collection.
- scoped_ptr<DictionaryValue> localized_strings_;
-
- DISALLOW_COPY_AND_ASSIGN(OptionsUIHTMLSource);
-};
-
-// The base class handler of Javascript messages of options pages.
-class OptionsPageUIHandler : public WebUIMessageHandler,
- public NotificationObserver {
- public:
- OptionsPageUIHandler();
- virtual ~OptionsPageUIHandler();
-
- // Is this handler enabled?
- virtual bool IsEnabled();
-
- // Collects localized strings for options page.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings) = 0;
-
- // Initialize the page. Called once the DOM is available for manipulation.
- // This will be called only once.
- virtual void Initialize() {}
-
- // Uninitializes the page. Called just before the object is destructed.
- virtual void Uninitialize() {}
-
- // WebUIMessageHandler implementation.
- virtual void RegisterMessages() {}
-
- // NotificationObserver implementation.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {}
-
- void UserMetricsRecordAction(const UserMetricsAction& action);
-
- protected:
- struct OptionsStringResource {
- // The name of the resource in templateData.
- const char* name;
- // The .grd ID for the resource (IDS_*).
- int id;
- // True if the trailing colon should be stripped on platforms that
- // don't want trailing colons.
- bool strip_colon;
- };
- // A helper for simplifying the process of registering strings in WebUI.
- static void RegisterStrings(DictionaryValue* localized_strings,
- const OptionsStringResource* resources,
- size_t length);
-
- // Registers string resources for a page's header and tab title.
- static void RegisterTitle(DictionaryValue* localized_strings,
- const std::string& variable_name,
- int title_id);
-
- NotificationRegistrar registrar_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(OptionsPageUIHandler);
-};
-
-class OptionsUI : public WebUI {
- public:
- explicit OptionsUI(TabContents* contents);
- virtual ~OptionsUI();
-
- static RefCountedMemory* GetFaviconResourceBytes();
- virtual void RenderViewCreated(RenderViewHost* render_view_host);
- virtual void DidBecomeActiveForReusedRenderView();
-
- void InitializeHandlers();
-
- private:
- // Adds OptionsPageUiHandler to the handlers list if handler is enabled.
- void AddOptionsPageUIHandler(DictionaryValue* localized_strings,
- OptionsPageUIHandler* handler);
-
- bool initialized_handlers_;
-
- DISALLOW_COPY_AND_ASSIGN(OptionsUI);
-};
+#include "chrome/browser/webui/options/options_ui.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_OPTIONS_UI_H_
diff --git a/chrome/browser/dom_ui/options/options_ui_uitest.cc b/chrome/browser/dom_ui/options/options_ui_uitest.cc
deleted file mode 100644
index d6061aa..0000000
--- a/chrome/browser/dom_ui/options/options_ui_uitest.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-// 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.
-
-#include "base/command_line.h"
-#include "base/string16.h"
-#include "base/test/test_timeouts.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/app/chrome_command_ids.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/test/automation/browser_proxy.h"
-#include "chrome/test/automation/tab_proxy.h"
-#include "chrome/test/automation/window_proxy.h"
-#include "chrome/test/ui/ui_test.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace {
-
-class OptionsUITest : public UITest {
- public:
- OptionsUITest() {
- dom_automation_enabled_ = true;
- }
-
- void AssertIsOptionsPage(TabProxy* tab) {
- std::wstring title;
- ASSERT_TRUE(tab->GetTabTitle(&title));
- string16 expected_title = l10n_util::GetStringUTF16(IDS_SETTINGS_TITLE);
- // The only guarantee we can make about the title of a settings tab is that
- // it should contain IDS_SETTINGS_TITLE somewhere.
- ASSERT_FALSE(WideToUTF16Hack(title).find(expected_title) == string16::npos);
- }
-};
-
-TEST_F(OptionsUITest, LoadOptionsByURL) {
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- ASSERT_TRUE(browser.get());
-
- scoped_refptr<TabProxy> tab = browser->GetActiveTab();
- ASSERT_TRUE(tab.get());
-
- // Go to the options tab via URL.
- NavigateToURL(GURL(chrome::kChromeUISettingsURL));
- AssertIsOptionsPage(tab);
-}
-
-// Flaky, and takes very long to fail. http://crbug.com/64619.
-TEST_F(OptionsUITest, DISABLED_CommandOpensOptionsTab) {
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- ASSERT_TRUE(browser.get());
-
- int tab_count = -1;
- ASSERT_TRUE(browser->GetTabCount(&tab_count));
- ASSERT_EQ(1, tab_count);
-
- // Bring up the options tab via command.
- ASSERT_TRUE(browser->RunCommand(IDC_OPTIONS));
- ASSERT_TRUE(browser->GetTabCount(&tab_count));
- ASSERT_EQ(2, tab_count);
-
- scoped_refptr<TabProxy> tab = browser->GetActiveTab();
- ASSERT_TRUE(tab.get());
- AssertIsOptionsPage(tab);
-}
-
-// Flaky, and takes very long to fail. http://crbug.com/48521
-TEST_F(OptionsUITest, DISABLED_CommandAgainGoesBackToOptionsTab) {
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- ASSERT_TRUE(browser.get());
-
- int tab_count = -1;
- ASSERT_TRUE(browser->GetTabCount(&tab_count));
- ASSERT_EQ(1, tab_count);
-
- // Bring up the options tab via command.
- ASSERT_TRUE(browser->RunCommand(IDC_OPTIONS));
- ASSERT_TRUE(browser->GetTabCount(&tab_count));
- ASSERT_EQ(2, tab_count);
-
- scoped_refptr<TabProxy> tab = browser->GetActiveTab();
- ASSERT_TRUE(tab.get());
- AssertIsOptionsPage(tab);
-
- // Switch to first tab and run command again.
- ASSERT_TRUE(browser->ActivateTab(0));
- ASSERT_TRUE(browser->WaitForTabToBecomeActive(
- 0, TestTimeouts::action_max_timeout_ms()));
- ASSERT_TRUE(browser->RunCommand(IDC_OPTIONS));
-
- // Ensure the options ui tab is active.
- ASSERT_TRUE(browser->WaitForTabToBecomeActive(
- 1, TestTimeouts::action_max_timeout_ms()));
- ASSERT_TRUE(browser->GetTabCount(&tab_count));
- ASSERT_EQ(2, tab_count);
-}
-
-// Flaky, and takes very long to fail. http://crbug.com/48521
-TEST_F(OptionsUITest, DISABLED_TwoCommandsOneTab) {
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- ASSERT_TRUE(browser.get());
-
- int tab_count = -1;
- ASSERT_TRUE(browser->GetTabCount(&tab_count));
- ASSERT_EQ(1, tab_count);
-
- ASSERT_TRUE(browser->RunCommand(IDC_OPTIONS));
- ASSERT_TRUE(browser->RunCommand(IDC_OPTIONS));
- ASSERT_TRUE(browser->GetTabCount(&tab_count));
- ASSERT_EQ(2, tab_count);
-}
-
-} // namespace
diff --git a/chrome/browser/dom_ui/options/password_manager_handler.cc b/chrome/browser/dom_ui/options/password_manager_handler.cc
deleted file mode 100644
index f14643f..0000000
--- a/chrome/browser/dom_ui/options/password_manager_handler.cc
+++ /dev/null
@@ -1,210 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/password_manager_handler.h"
-
-#include "base/callback.h"
-#include "base/stl_util-inl.h"
-#include "base/string_number_conversions.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/url_constants.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "net/base/net_util.h"
-#include "ui/base/l10n/l10n_util.h"
-
-PasswordManagerHandler::PasswordManagerHandler()
- : ALLOW_THIS_IN_INITIALIZER_LIST(populater_(this)),
- ALLOW_THIS_IN_INITIALIZER_LIST(exception_populater_(this)) {
-}
-
-PasswordManagerHandler::~PasswordManagerHandler() {
-}
-
-void PasswordManagerHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- RegisterTitle(localized_strings, "passwordsPage",
- IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE);
- localized_strings->SetString("savedPasswordsTitle",
- l10n_util::GetStringUTF16(IDS_PASSWORDS_SHOW_PASSWORDS_TAB_TITLE));
- localized_strings->SetString("passwordExceptionsTitle",
- l10n_util::GetStringUTF16(IDS_PASSWORDS_EXCEPTIONS_TAB_TITLE));
- localized_strings->SetString("passwordShowButton",
- l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON));
- localized_strings->SetString("passwordHideButton",
- l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON));
- localized_strings->SetString("passwordsSiteColumn",
- l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN));
- localized_strings->SetString("passwordsUsernameColumn",
- l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_USERNAME_COLUMN));
- localized_strings->SetString("passwordsRemoveButton",
- l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_REMOVE_BUTTON));
- localized_strings->SetString("passwordsRemoveAllButton",
- l10n_util::GetStringUTF16(IDS_PASSWORDS_PAGE_VIEW_REMOVE_ALL_BUTTON));
- localized_strings->SetString("passwordsRemoveAllTitle",
- l10n_util::GetStringUTF16(
- IDS_PASSWORDS_PAGE_VIEW_CAPTION_DELETE_ALL_PASSWORDS));
- localized_strings->SetString("passwordsRemoveAllWarning",
- l10n_util::GetStringUTF16(
- IDS_PASSWORDS_PAGE_VIEW_TEXT_DELETE_ALL_PASSWORDS));
-}
-
-void PasswordManagerHandler::Initialize() {
- // We should not cache web_ui_->GetProfile(). See crosbug.com/6304.
-}
-
-void PasswordManagerHandler::RegisterMessages() {
- DCHECK(web_ui_);
-
- web_ui_->RegisterMessageCallback("updatePasswordLists",
- NewCallback(this, &PasswordManagerHandler::UpdatePasswordLists));
- web_ui_->RegisterMessageCallback("removeSavedPassword",
- NewCallback(this, &PasswordManagerHandler::RemoveSavedPassword));
- web_ui_->RegisterMessageCallback("removePasswordException",
- NewCallback(this, &PasswordManagerHandler::RemovePasswordException));
- web_ui_->RegisterMessageCallback("removeAllSavedPasswords",
- NewCallback(this, &PasswordManagerHandler::RemoveAllSavedPasswords));
- web_ui_->RegisterMessageCallback("removeAllPasswordExceptions", NewCallback(
- this, &PasswordManagerHandler::RemoveAllPasswordExceptions));
-}
-
-PasswordStore* PasswordManagerHandler::GetPasswordStore() {
- return web_ui_->GetProfile()->GetPasswordStore(Profile::EXPLICIT_ACCESS);
-}
-
-void PasswordManagerHandler::UpdatePasswordLists(const ListValue* args) {
- languages_ =
- web_ui_->GetProfile()->GetPrefs()->GetString(prefs::kAcceptLanguages);
- populater_.Populate();
- exception_populater_.Populate();
-}
-
-void PasswordManagerHandler::RemoveSavedPassword(const ListValue* args) {
- std::string string_value = WideToUTF8(ExtractStringValue(args));
- int index;
- base::StringToInt(string_value, &index);
-
- GetPasswordStore()->RemoveLogin(*password_list_[index]);
- delete password_list_[index];
- password_list_.erase(password_list_.begin() + index);
- SetPasswordList();
-}
-
-void PasswordManagerHandler::RemovePasswordException(
- const ListValue* args) {
- std::string string_value = WideToUTF8(ExtractStringValue(args));
- int index;
- base::StringToInt(string_value, &index);
-
- GetPasswordStore()->RemoveLogin(*password_exception_list_[index]);
- delete password_exception_list_[index];
- password_exception_list_.erase(password_exception_list_.begin() + index);
- SetPasswordExceptionList();
-}
-
-void PasswordManagerHandler::RemoveAllSavedPasswords(
- const ListValue* args) {
- PasswordStore* store = GetPasswordStore();
- for (size_t i = 0; i < password_list_.size(); ++i)
- store->RemoveLogin(*password_list_[i]);
- STLDeleteElements(&password_list_);
- SetPasswordList();
-}
-
-void PasswordManagerHandler::RemoveAllPasswordExceptions(
- const ListValue* args) {
- PasswordStore* store = GetPasswordStore();
- for (size_t i = 0; i < password_exception_list_.size(); ++i)
- store->RemoveLogin(*password_exception_list_[i]);
- STLDeleteElements(&password_exception_list_);
- SetPasswordExceptionList();
-}
-
-void PasswordManagerHandler::SetPasswordList() {
- ListValue entries;
- for (size_t i = 0; i < password_list_.size(); ++i) {
- ListValue* entry = new ListValue();
- entry->Append(new StringValue(net::FormatUrl(password_list_[i]->origin,
- languages_)));
- entry->Append(new StringValue(password_list_[i]->username_value));
- entry->Append(new StringValue(password_list_[i]->password_value));
- entries.Append(entry);
- }
-
- web_ui_->CallJavascriptFunction(
- L"PasswordManager.setSavedPasswordsList", entries);
-}
-
-void PasswordManagerHandler::SetPasswordExceptionList() {
- ListValue entries;
- for (size_t i = 0; i < password_exception_list_.size(); ++i) {
- entries.Append(new StringValue(
- net::FormatUrl(password_exception_list_[i]->origin, languages_)));
- }
-
- web_ui_->CallJavascriptFunction(
- L"PasswordManager.setPasswordExceptionsList", entries);
-}
-
-PasswordManagerHandler::ListPopulater::ListPopulater(
- PasswordManagerHandler* page) : page_(page),
- pending_login_query_(0) {
-}
-
-PasswordManagerHandler::ListPopulater::~ListPopulater() {
- PasswordStore* store = page_->GetPasswordStore();
- if (store)
- store->CancelLoginsQuery(pending_login_query_);
-}
-
-PasswordManagerHandler::PasswordListPopulater::PasswordListPopulater(
- PasswordManagerHandler* page) : ListPopulater(page) {
-}
-
-void PasswordManagerHandler::PasswordListPopulater::Populate() {
- DCHECK(!pending_login_query_);
- PasswordStore* store = page_->GetPasswordStore();
- if (store != NULL)
- pending_login_query_ = store->GetAutofillableLogins(this);
- else
- LOG(ERROR) << "No password store! Cannot display passwords.";
-}
-
-void PasswordManagerHandler::PasswordListPopulater::
- OnPasswordStoreRequestDone(int handle,
- const std::vector<webkit_glue::PasswordForm*>& result) {
- DCHECK_EQ(pending_login_query_, handle);
- pending_login_query_ = 0;
- page_->password_list_ = result;
- page_->SetPasswordList();
-}
-
-PasswordManagerHandler::PasswordExceptionListPopulater::
- PasswordExceptionListPopulater(PasswordManagerHandler* page)
- : ListPopulater(page) {
-}
-
-void PasswordManagerHandler::PasswordExceptionListPopulater::Populate() {
- DCHECK(!pending_login_query_);
- PasswordStore* store = page_->GetPasswordStore();
- if (store != NULL)
- pending_login_query_ = store->GetBlacklistLogins(this);
- else
- LOG(ERROR) << "No password store! Cannot display exceptions.";
-}
-
-void PasswordManagerHandler::PasswordExceptionListPopulater::
- OnPasswordStoreRequestDone(int handle,
- const std::vector<webkit_glue::PasswordForm*>& result) {
- DCHECK_EQ(pending_login_query_, handle);
- pending_login_query_ = 0;
- page_->password_exception_list_ = result;
- page_->SetPasswordExceptionList();
-}
diff --git a/chrome/browser/dom_ui/options/password_manager_handler.h b/chrome/browser/dom_ui/options/password_manager_handler.h
index af94e6b..787b853 100644
--- a/chrome/browser/dom_ui/options/password_manager_handler.h
+++ b/chrome/browser/dom_ui/options/password_manager_handler.h
@@ -4,110 +4,9 @@
#ifndef CHROME_BROWSER_DOM_UI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_
#define CHROME_BROWSER_DOM_UI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_
+#pragma once
-#include <string>
-#include <vector>
-
-#include "chrome/browser/dom_ui/options/options_ui.h"
-#include "chrome/browser/password_manager/password_store.h"
-
-class PasswordManagerHandler : public OptionsPageUIHandler {
- public:
- PasswordManagerHandler();
- virtual ~PasswordManagerHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
-
- virtual void Initialize();
-
- virtual void RegisterMessages();
-
- private:
- // The password store associated with the currently active profile.
- PasswordStore* GetPasswordStore();
-
- // Called when the JS PasswordManager object is initialized.
- void UpdatePasswordLists(const ListValue* args);
-
- // Remove an entry.
- // @param value the entry index to be removed.
- void RemoveSavedPassword(const ListValue* args);
-
- // Remove an password exception.
- // @param value the entry index to be removed.
- void RemovePasswordException(const ListValue* args);
-
- // Remove all saved passwords
- void RemoveAllSavedPasswords(const ListValue* args);
-
- // Remove All password exceptions
- void RemoveAllPasswordExceptions(const ListValue* args);
-
- // Get password value for the selected entry.
- // @param value the selected entry index.
- void ShowSelectedPassword(const ListValue* args);
-
- // Sets the password and exception list contents to the given data.
- // We take ownership of the PasswordForms in the vector.
- void SetPasswordList();
- void SetPasswordExceptionList();
-
- // A short class to mediate requests to the password store.
- class ListPopulater : public PasswordStoreConsumer {
- public:
- explicit ListPopulater(PasswordManagerHandler* page);
- virtual ~ListPopulater();
-
- // Send a query to the password store to populate a list.
- virtual void Populate() = 0;
-
- // Send the password store's reply back to the handler.
- virtual void OnPasswordStoreRequestDone(
- int handle, const std::vector<webkit_glue::PasswordForm*>& result) = 0;
-
- protected:
- PasswordManagerHandler* page_;
- int pending_login_query_;
- };
-
- // A short class to mediate requests to the password store for passwordlist.
- class PasswordListPopulater : public ListPopulater {
- public:
- explicit PasswordListPopulater(PasswordManagerHandler* page);
-
- // Send a query to the password store to populate a password list.
- virtual void Populate();
-
- // Send the password store's reply back to the handler.
- virtual void OnPasswordStoreRequestDone(
- int handle, const std::vector<webkit_glue::PasswordForm*>& result);
- };
-
- // A short class to mediate requests to the password store for exceptions.
- class PasswordExceptionListPopulater : public ListPopulater {
- public:
- explicit PasswordExceptionListPopulater(PasswordManagerHandler* page);
-
- // Send a query to the password store to populate a passwordException list.
- virtual void Populate();
-
- // Send the password store's reply back to the handler.
- virtual void OnPasswordStoreRequestDone(
- int handle, const std::vector<webkit_glue::PasswordForm*>& result);
- };
-
- // Password store consumer for populating the password list and exceptions.
- PasswordListPopulater populater_;
- PasswordExceptionListPopulater exception_populater_;
-
- std::vector<webkit_glue::PasswordForm*> password_list_;
- std::vector<webkit_glue::PasswordForm*> password_exception_list_;
-
- // User's pref
- std::string languages_;
-
- DISALLOW_COPY_AND_ASSIGN(PasswordManagerHandler);
-};
+#include "chrome/browser/webui/options/password_manager_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_PASSWORD_MANAGER_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/personal_options_handler.cc b/chrome/browser/dom_ui/options/personal_options_handler.cc
deleted file mode 100644
index 64968f2..0000000
--- a/chrome/browser/dom_ui/options/personal_options_handler.cc
+++ /dev/null
@@ -1,403 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/personal_options_handler.h"
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "base/path_service.h"
-#include "base/stl_util-inl.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "build/build_config.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/dom_ui/options/dom_options_util.h"
-#include "chrome/browser/dom_ui/options/options_managed_banner_handler.h"
-#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"
-#include "chrome/browser/ui/options/options_window.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/net/gaia/google_service_auth_error.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"
-#include "ui/base/l10n/l10n_util.h"
-
-#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/login/user_manager.h"
-#include "chrome/browser/webui/web_ui_util.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#endif // defined(OS_CHROMEOS)
-#if defined(TOOLKIT_GTK)
-#include "chrome/browser/ui/gtk/gtk_theme_provider.h"
-#endif // defined(TOOLKIT_GTK)
-
-PersonalOptionsHandler::PersonalOptionsHandler() {
-}
-
-PersonalOptionsHandler::~PersonalOptionsHandler() {
- ProfileSyncService* sync_service =
- web_ui_->GetProfile()->GetProfileSyncService();
- if (sync_service)
- sync_service->RemoveObserver(this);
-}
-
-void PersonalOptionsHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- RegisterTitle(localized_strings, "personalPage",
- IDS_OPTIONS_CONTENT_TAB_LABEL);
-
- localized_strings->SetString("syncSection",
- dom_options_util::StripColon(
- l10n_util::GetStringUTF16(IDS_SYNC_OPTIONS_GROUP_NAME)));
- localized_strings->SetString("customizeSync",
- l10n_util::GetStringUTF16(IDS_SYNC_CUSTOMIZE_BUTTON_LABEL));
- localized_strings->SetString("privacyDashboardLink",
- l10n_util::GetStringUTF16(IDS_SYNC_PRIVACY_DASHBOARD_LINK_LABEL));
-
- localized_strings->SetString("passwords",
- dom_options_util::StripColon(
- l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_GROUP_NAME)));
- localized_strings->SetString("passwordsAskToSave",
- l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_ASKTOSAVE));
- localized_strings->SetString("passwordsNeverSave",
- l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_NEVERSAVE));
- localized_strings->SetString("manage_passwords",
- l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS));
-
- localized_strings->SetString("autofill",
- dom_options_util::StripColon(
- l10n_util::GetStringUTF16(IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME)));
- localized_strings->SetString("autoFillEnabled",
- l10n_util::GetStringUTF16(IDS_OPTIONS_AUTOFILL_ENABLE));
- localized_strings->SetString("manageAutofillSettings",
- l10n_util::GetStringUTF16(IDS_OPTIONS_MANAGE_AUTOFILL_SETTINGS));
-
- localized_strings->SetString("browsingData",
- dom_options_util::StripColon(
- l10n_util::GetStringUTF16(IDS_OPTIONS_BROWSING_DATA_GROUP_NAME)));
- localized_strings->SetString("importData",
- l10n_util::GetStringUTF16(IDS_OPTIONS_IMPORT_DATA_BUTTON));
-
- localized_strings->SetString("themesGallery",
- l10n_util::GetStringUTF16(IDS_THEMES_GALLERY_BUTTON));
- localized_strings->SetString("themesGalleryURL",
- l10n_util::GetStringUTF16(IDS_THEMES_GALLERY_URL));
-
-#if defined(TOOLKIT_GTK)
- localized_strings->SetString("appearance",
- dom_options_util::StripColon(
- l10n_util::GetStringUTF16(IDS_APPEARANCE_GROUP_NAME)));
- localized_strings->SetString("themesGTKButton",
- l10n_util::GetStringUTF16(IDS_THEMES_GTK_BUTTON));
- localized_strings->SetString("themesSetClassic",
- l10n_util::GetStringUTF16(IDS_THEMES_SET_CLASSIC));
- localized_strings->SetString("showWindowDecorations",
- l10n_util::GetStringUTF16(IDS_SHOW_WINDOW_DECORATIONS_RADIO));
- localized_strings->SetString("hideWindowDecorations",
- l10n_util::GetStringUTF16(IDS_HIDE_WINDOW_DECORATIONS_RADIO));
-#else
- localized_strings->SetString("themes",
- dom_options_util::StripColon(
- l10n_util::GetStringUTF16(IDS_THEMES_GROUP_NAME)));
- localized_strings->SetString("themesReset",
- l10n_util::GetStringUTF16(IDS_THEMES_RESET_BUTTON));
-#endif
-
- // Sync select control.
- ListValue* sync_select_list = new ListValue;
- ListValue* datatypes = new ListValue;
- datatypes->Append(Value::CreateBooleanValue(false));
- datatypes->Append(
- Value::CreateStringValue(
- l10n_util::GetStringUTF8(IDS_SYNC_OPTIONS_SELECT_DATATYPES)));
- sync_select_list->Append(datatypes);
- ListValue* everything = new ListValue;
- everything->Append(Value::CreateBooleanValue(true));
- everything->Append(
- Value::CreateStringValue(
- 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));
-
-#if defined(OS_CHROMEOS)
- localized_strings->SetString("account",
- l10n_util::GetStringUTF16(IDS_OPTIONS_PERSONAL_ACCOUNT_GROUP_NAME));
- localized_strings->SetString("enableScreenlock",
- l10n_util::GetStringUTF16(IDS_OPTIONS_ENABLE_SCREENLOCKER_CHECKBOX));
-#endif
-}
-
-void PersonalOptionsHandler::RegisterMessages() {
- DCHECK(web_ui_);
- web_ui_->RegisterMessageCallback(
- "showSyncActionDialog",
- NewCallback(this, &PersonalOptionsHandler::ShowSyncActionDialog));
- web_ui_->RegisterMessageCallback(
- "showSyncLoginDialog",
- NewCallback(this, &PersonalOptionsHandler::ShowSyncLoginDialog));
- web_ui_->RegisterMessageCallback(
- "showCustomizeSyncDialog",
- NewCallback(this, &PersonalOptionsHandler::ShowCustomizeSyncDialog));
- web_ui_->RegisterMessageCallback(
- "themesReset",
- NewCallback(this, &PersonalOptionsHandler::ThemesReset));
-#if defined(TOOLKIT_GTK)
- web_ui_->RegisterMessageCallback(
- "themesSetGTK",
- NewCallback(this, &PersonalOptionsHandler::ThemesSetGTK));
-#endif
- web_ui_->RegisterMessageCallback("updatePreferredDataTypes",
- NewCallback(this, &PersonalOptionsHandler::OnPreferredDataTypesUpdated));
-#if defined(OS_CHROMEOS)
- web_ui_->RegisterMessageCallback(
- "loadAccountPicture",
- NewCallback(this, &PersonalOptionsHandler::LoadAccountPicture));
-#endif
-}
-
-void PersonalOptionsHandler::Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details) {
- if (type == NotificationType::BROWSER_THEME_CHANGED)
- ObserveThemeChanged();
- else
- OptionsPageUIHandler::Observe(type, source, details);
-}
-
-void PersonalOptionsHandler::OnStateChanged() {
- string16 status_label;
- string16 link_label;
- ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService();
- DCHECK(service);
- bool managed = service->IsManaged();
- bool sync_setup_completed = service->HasSyncSetupCompleted();
- bool status_has_error = sync_ui_util::GetStatusLabels(service,
- &status_label, &link_label) == sync_ui_util::SYNC_ERROR;
-
- string16 start_stop_button_label;
- bool is_start_stop_button_visible = false;
- bool is_start_stop_button_enabled = false;
- if (sync_setup_completed) {
- start_stop_button_label =
- l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL);
-#if defined(OS_CHROMEOS)
- is_start_stop_button_visible = false;
-#else
- is_start_stop_button_visible = true;
-#endif // defined(OS_CHROMEOS)
- is_start_stop_button_enabled = !managed;
- } else if (service->SetupInProgress()) {
- start_stop_button_label =
- l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS);
- is_start_stop_button_visible = true;
- is_start_stop_button_enabled = false;
- } else {
- start_stop_button_label =
- l10n_util::GetStringUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL);
- is_start_stop_button_visible = true;
- is_start_stop_button_enabled = !managed;
- }
-
- scoped_ptr<Value> completed(Value::CreateBooleanValue(sync_setup_completed));
- web_ui_->CallJavascriptFunction(L"PersonalOptions.setSyncSetupCompleted",
- *completed);
-
- scoped_ptr<Value> label(Value::CreateStringValue(status_label));
- web_ui_->CallJavascriptFunction(L"PersonalOptions.setSyncStatus",
- *label);
-
- scoped_ptr<Value> enabled(
- Value::CreateBooleanValue(is_start_stop_button_enabled));
- web_ui_->CallJavascriptFunction(L"PersonalOptions.setStartStopButtonEnabled",
- *enabled);
-
- scoped_ptr<Value> visible(
- Value::CreateBooleanValue(is_start_stop_button_visible));
- web_ui_->CallJavascriptFunction(L"PersonalOptions.setStartStopButtonVisible",
- *visible);
-
- label.reset(Value::CreateStringValue(start_stop_button_label));
- web_ui_->CallJavascriptFunction(L"PersonalOptions.setStartStopButtonLabel",
- *label);
-
- label.reset(Value::CreateStringValue(link_label));
- web_ui_->CallJavascriptFunction(L"PersonalOptions.setSyncActionLinkLabel",
- *label);
-
- enabled.reset(Value::CreateBooleanValue(!managed));
- web_ui_->CallJavascriptFunction(L"PersonalOptions.setSyncActionLinkEnabled",
- *enabled);
-
- visible.reset(Value::CreateBooleanValue(status_has_error));
- web_ui_->CallJavascriptFunction(
- L"PersonalOptions.setSyncStatusErrorVisible", *visible);
-}
-
-void PersonalOptionsHandler::OnLoginSuccess() {
- OnStateChanged();
-}
-
-void PersonalOptionsHandler::OnLoginFailure(
- const GoogleServiceAuthError& error) {
- OnStateChanged();
-}
-
-void PersonalOptionsHandler::ObserveThemeChanged() {
- Profile* profile = web_ui_->GetProfile();
-#if defined(TOOLKIT_GTK)
- GtkThemeProvider* provider = GtkThemeProvider::GetFrom(profile);
- bool is_gtk_theme = provider->UseGtkTheme();
- FundamentalValue gtk_enabled(!is_gtk_theme);
- web_ui_->CallJavascriptFunction(
- L"options.PersonalOptions.setGtkThemeButtonEnabled", gtk_enabled);
-#else
- BrowserThemeProvider* provider =
- reinterpret_cast<BrowserThemeProvider*>(profile->GetThemeProvider());
- bool is_gtk_theme = false;
-#endif
-
- bool is_classic_theme = !is_gtk_theme && provider->UsingDefaultTheme();
- FundamentalValue enabled(!is_classic_theme);
- web_ui_->CallJavascriptFunction(
- L"options.PersonalOptions.setThemesResetButtonEnabled", enabled);
-}
-
-void PersonalOptionsHandler::Initialize() {
- banner_handler_.reset(
- new OptionsManagedBannerHandler(web_ui_,
- ASCIIToUTF16("PersonalOptions"),
- OPTIONS_PAGE_CONTENT));
-
- // Listen for theme installation.
- registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
- NotificationService::AllSources());
- ObserveThemeChanged();
-
- ProfileSyncService* sync_service =
- web_ui_->GetProfile()->GetProfileSyncService();
- if (sync_service) {
- sync_service->AddObserver(this);
- OnStateChanged();
-
- DictionaryValue args;
- SyncSetupFlow::GetArgsForConfigure(sync_service, &args);
-
- web_ui_->CallJavascriptFunction(
- L"PersonalOptions.setRegisteredDataTypes", args);
- } else {
- web_ui_->CallJavascriptFunction(L"options.PersonalOptions.hideSyncSection");
- }
-}
-
-void PersonalOptionsHandler::ShowSyncActionDialog(const ListValue* args) {
- ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService();
- DCHECK(service);
-#if defined(OS_CHROMEOS)
- // ProfileSyncService calls ProfileSyncService::ShowLoginDialog()
- // for these errors, which currently does not work on ChromeOS.
- // TODO(stevenjb + jhawkins): This code path should go away for R11 when
- // we switch to DOM based sync setup UI.
- const GoogleServiceAuthError& error = service->GetAuthError();
- if (error.state() == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS ||
- error.state() == GoogleServiceAuthError::CAPTCHA_REQUIRED ||
- error.state() == GoogleServiceAuthError::ACCOUNT_DELETED ||
- error.state() == GoogleServiceAuthError::ACCOUNT_DISABLED ||
- error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE) {
- ShowSyncLoginDialog(args);
- }
-#endif
- service->ShowErrorUI(NULL);
-}
-
-void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) {
-#if defined(OS_CHROMEOS)
- std::string email = chromeos::UserManager::Get()->logged_in_user().email();
- string16 message = l10n_util::GetStringFUTF16(
- IDS_SYNC_LOGIN_INTRODUCTION,
- l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
- web_ui_->GetProfile()->GetBrowserSignin()->RequestSignin(
- web_ui_->tab_contents(), UTF8ToUTF16(email), message, this);
-#else
- ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService();
- DCHECK(service);
- service->ShowLoginDialog(NULL);
- ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS);
-#endif
-}
-
-void PersonalOptionsHandler::ShowCustomizeSyncDialog(const ListValue* args) {
- ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService();
- DCHECK(service);
- service->ShowConfigure(NULL);
-}
-
-void PersonalOptionsHandler::ThemesReset(const ListValue* args) {
- UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset"));
- web_ui_->GetProfile()->ClearTheme();
-}
-
-#if defined(TOOLKIT_GTK)
-void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) {
- UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet"));
- web_ui_->GetProfile()->SetNativeTheme();
-}
-#endif
-
-void PersonalOptionsHandler::OnPreferredDataTypesUpdated(
- const ListValue* args) {
- NotificationService::current()->Notify(
- NotificationType::SYNC_DATA_TYPES_UPDATED,
- Source<Profile>(web_ui_->GetProfile()),
- NotificationService::NoDetails());
-}
-
-#if defined(OS_CHROMEOS)
-void PersonalOptionsHandler::LoadAccountPicture(const ListValue* args) {
- const SkBitmap& account_picture =
- chromeos::UserManager::Get()->logged_in_user().image();
-
- if (!account_picture.isNull()) {
- StringValue data_url(web_ui_util::GetImageDataUrl(account_picture));
- web_ui_->CallJavascriptFunction(L"PersonalOptions.setAccountPicture",
- data_url);
- }
-}
-#endif
diff --git a/chrome/browser/dom_ui/options/personal_options_handler.h b/chrome/browser/dom_ui/options/personal_options_handler.h
index 0340f79..92e9e29 100644
--- a/chrome/browser/dom_ui/options/personal_options_handler.h
+++ b/chrome/browser/dom_ui/options/personal_options_handler.h
@@ -6,61 +6,7 @@
#define CHROME_BROWSER_DOM_UI_OPTIONS_PERSONAL_OPTIONS_HANDLER_H_
#pragma once
-#include "base/basictypes.h"
-#include "chrome/browser/browser_signin.h"
-#include "chrome/browser/dom_ui/options/options_ui.h"
-#include "chrome/browser/sync/profile_sync_service.h"
-
-class OptionsManagedBannerHandler;
-
-// Chrome personal options page UI handler.
-class PersonalOptionsHandler : public OptionsPageUIHandler,
- public ProfileSyncServiceObserver,
- public BrowserSignin::SigninDelegate {
- public:
- PersonalOptionsHandler();
- virtual ~PersonalOptionsHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
- virtual void Initialize();
-
- // WebUIMessageHandler implementation.
- virtual void RegisterMessages();
-
- // NotificationObserver implementation.
- virtual void Observe(NotificationType type,
- const NotificationSource& source,
- const NotificationDetails& details);
-
- // ProfileSyncServiceObserver implementation.
- virtual void OnStateChanged();
-
- // BrowserSignin::SigninDelegate implementation.
- virtual void OnLoginSuccess();
- virtual void OnLoginFailure(const GoogleServiceAuthError& error);
-
- private:
- void ObserveThemeChanged();
- void ShowSyncActionDialog(const ListValue* args);
- void ShowSyncLoginDialog(const ListValue* args);
- void ShowCustomizeSyncDialog(const ListValue* args);
- void ThemesReset(const ListValue* args);
-#if defined(TOOLKIT_GTK)
- 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);
-
-#if defined(OS_CHROMEOS)
- void LoadAccountPicture(const ListValue* args);
-#endif
-
- scoped_ptr<OptionsManagedBannerHandler> banner_handler_;
-
- DISALLOW_COPY_AND_ASSIGN(PersonalOptionsHandler);
-};
+#include "chrome/browser/webui/options/personal_options_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_PERSONAL_OPTIONS_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/search_engine_manager_handler.cc b/chrome/browser/dom_ui/options/search_engine_manager_handler.cc
deleted file mode 100644
index 607ce46..0000000
--- a/chrome/browser/dom_ui/options/search_engine_manager_handler.cc
+++ /dev/null
@@ -1,272 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/search_engine_manager_handler.h"
-
-#include "base/callback.h"
-#include "base/string_number_conversions.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/search_engines/keyword_editor_controller.h"
-#include "chrome/browser/search_engines/template_url.h"
-#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/browser/search_engines/template_url_table_model.h"
-#include "chrome/common/url_constants.h"
-#include "grit/generated_resources.h"
-#include "grit/locale_settings.h"
-#include "ui/base/l10n/l10n_util.h"
-
-namespace {
-
-enum EngineInfoIndexes {
- ENGINE_NAME,
- ENGINE_KEYWORD,
- ENGINE_URL,
-};
-
-}; // namespace
-
-SearchEngineManagerHandler::SearchEngineManagerHandler() {
-}
-
-SearchEngineManagerHandler::~SearchEngineManagerHandler() {
- if (list_controller_.get() && list_controller_->table_model())
- list_controller_->table_model()->SetObserver(NULL);
-}
-
-void SearchEngineManagerHandler::Initialize() {
- list_controller_.reset(new KeywordEditorController(web_ui_->GetProfile()));
- if (list_controller_.get()) {
- list_controller_->table_model()->SetObserver(this);
- OnModelChanged();
- }
-}
-
-void SearchEngineManagerHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
-
- RegisterTitle(localized_strings, "searchEngineManagerPage",
- IDS_SEARCH_ENGINES_EDITOR_WINDOW_TITLE);
- localized_strings->SetString("defaultSearchEngineListTitle",
- l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR));
- localized_strings->SetString("otherSearchEngineListTitle",
- l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR));
- localized_strings->SetString("searchEngineTableNameHeader",
- l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN));
- localized_strings->SetString("searchEngineTableKeywordHeader",
- l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN));
- localized_strings->SetString("searchEngineTableURLHeader",
- l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_EDIT_BUTTON));
- localized_strings->SetString("makeDefaultSearchEngineButton",
- l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_MAKE_DEFAULT_BUTTON));
- localized_strings->SetString("searchEngineTableNamePlaceholder",
- l10n_util::GetStringUTF16(IDS_SEARCH_ENGINE_ADD_NEW_NAME_PLACEHOLDER));
- localized_strings->SetString("searchEngineTableKeywordPlaceholder",
- l10n_util::GetStringUTF16(IDS_SEARCH_ENGINE_ADD_NEW_KEYWORD_PLACEHOLDER));
- localized_strings->SetString("searchEngineTableURLPlaceholder",
- l10n_util::GetStringUTF16(IDS_SEARCH_ENGINE_ADD_NEW_URL_PLACEHOLDER));
- localized_strings->SetString("editSearchEngineInvalidTitleToolTip",
- l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_INVALID_TITLE_TT));
- localized_strings->SetString("editSearchEngineInvalidKeywordToolTip",
- l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_INVALID_KEYWORD_TT));
- localized_strings->SetString("editSearchEngineInvalidURLToolTip",
- l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_INVALID_URL_TT));
-}
-
-void SearchEngineManagerHandler::RegisterMessages() {
- web_ui_->RegisterMessageCallback(
- "managerSetDefaultSearchEngine",
- NewCallback(this, &SearchEngineManagerHandler::SetDefaultSearchEngine));
- web_ui_->RegisterMessageCallback(
- "removeSearchEngine",
- NewCallback(this, &SearchEngineManagerHandler::RemoveSearchEngine));
- web_ui_->RegisterMessageCallback(
- "editSearchEngine",
- NewCallback(this, &SearchEngineManagerHandler::EditSearchEngine));
- web_ui_->RegisterMessageCallback(
- "checkSearchEngineInfoValidity",
- NewCallback(this,
- &SearchEngineManagerHandler::CheckSearchEngineInfoValidity));
- web_ui_->RegisterMessageCallback(
- "searchEngineEditCancelled",
- NewCallback(this, &SearchEngineManagerHandler::EditCancelled));
- web_ui_->RegisterMessageCallback(
- "searchEngineEditCompleted",
- NewCallback(this, &SearchEngineManagerHandler::EditCompleted));
-}
-
-void SearchEngineManagerHandler::OnModelChanged() {
- if (!list_controller_->loaded())
- return;
-
- // Find the default engine.
- const TemplateURL* default_engine =
- list_controller_->url_model()->GetDefaultSearchProvider();
- int default_index = list_controller_->table_model()->IndexOfTemplateURL(
- default_engine);
-
- // Build the first list (default search engine options).
- ListValue defaults_list;
- int last_default_engine_index =
- list_controller_->table_model()->last_search_engine_index();
- for (int i = 0; i < last_default_engine_index; ++i) {
- defaults_list.Append(CreateDictionaryForEngine(i, i == default_index));
- }
-
- // Build the second list (other search templates).
- ListValue others_list;
- if (last_default_engine_index < 0)
- last_default_engine_index = 0;
- int engine_count = list_controller_->table_model()->RowCount();
- for (int i = last_default_engine_index; i < engine_count; ++i) {
- others_list.Append(CreateDictionaryForEngine(i, i == default_index));
- }
-
- web_ui_->CallJavascriptFunction(L"SearchEngineManager.updateSearchEngineList",
- defaults_list, others_list);
-}
-
-void SearchEngineManagerHandler::OnItemsChanged(int start, int length) {
- OnModelChanged();
-}
-
-void SearchEngineManagerHandler::OnItemsAdded(int start, int length) {
- OnModelChanged();
-}
-
-void SearchEngineManagerHandler::OnItemsRemoved(int start, int length) {
- OnModelChanged();
-}
-
-DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForEngine(
- int index, bool is_default) {
- TemplateURLTableModel* table_model = list_controller_->table_model();
-
- DictionaryValue* dict = new DictionaryValue();
- dict->SetString("name", table_model->GetText(
- index, IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN));
- dict->SetString("keyword", table_model->GetText(
- index, IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN));
- const TemplateURL* template_url = list_controller_->GetTemplateURL(index);
- dict->SetString("url", template_url->url()->DisplayURL());
- dict->SetBoolean("urlLocked", template_url->prepopulate_id() > 0);
- GURL icon_url = template_url->GetFavIconURL();
- if (icon_url.is_valid())
- dict->SetString("iconURL", icon_url.spec());
- dict->SetString("modelIndex", base::IntToString(index));
-
- if (list_controller_->CanRemove(template_url))
- dict->SetString("canBeRemoved", "1");
- if (list_controller_->CanMakeDefault(template_url))
- dict->SetString("canBeDefault", "1");
- if (is_default)
- dict->SetString("default", "1");
-
- return dict;
-}
-
-void SearchEngineManagerHandler::SetDefaultSearchEngine(const ListValue* args) {
- int index;
- if (!ExtractIntegerValue(args, &index)) {
- NOTREACHED();
- return;
- }
- if (index < 0 || index >= list_controller_->table_model()->RowCount())
- return;
-
- list_controller_->MakeDefaultTemplateURL(index);
-}
-
-void SearchEngineManagerHandler::RemoveSearchEngine(const ListValue* args) {
- int index;
- if (!ExtractIntegerValue(args, &index)) {
- NOTREACHED();
- return;
- }
- if (index < 0 || index >= list_controller_->table_model()->RowCount())
- return;
-
- if (list_controller_->CanRemove(list_controller_->GetTemplateURL(index)))
- list_controller_->RemoveTemplateURL(index);
-}
-
-void SearchEngineManagerHandler::EditSearchEngine(const ListValue* args) {
- int index;
- if (!ExtractIntegerValue(args, &index)) {
- NOTREACHED();
- return;
- }
- // Allow -1, which means we are adding a new engine.
- if (index < -1 || index >= list_controller_->table_model()->RowCount())
- return;
-
- const TemplateURL* edit_url = NULL;
- if (index != -1)
- edit_url = list_controller_->GetTemplateURL(index);
- edit_controller_.reset(
- new EditSearchEngineController(edit_url, this, web_ui_->GetProfile()));
-}
-
-void SearchEngineManagerHandler::OnEditedKeyword(
- const TemplateURL* template_url,
- const string16& title,
- const string16& keyword,
- const std::string& url) {
- if (template_url) {
- list_controller_->ModifyTemplateURL(template_url, title, keyword, url);
- } else {
- list_controller_->AddTemplateURL(title, keyword, url);
- }
- edit_controller_.reset();
-}
-
-void SearchEngineManagerHandler::CheckSearchEngineInfoValidity(
- const ListValue* args)
-{
- if (!edit_controller_.get())
- return;
- string16 name;
- string16 keyword;
- std::string url;
- std::string modelIndex;
- if (!args->GetString(ENGINE_NAME, &name) ||
- !args->GetString(ENGINE_KEYWORD, &keyword) ||
- !args->GetString(ENGINE_URL, &url) ||
- !args->GetString(3, &modelIndex)) {
- NOTREACHED();
- return;
- }
-
- DictionaryValue validity;
- validity.SetBoolean("name", edit_controller_->IsTitleValid(name));
- validity.SetBoolean("keyword", edit_controller_->IsKeywordValid(keyword));
- validity.SetBoolean("url", edit_controller_->IsURLValid(url));
- StringValue indexValue(modelIndex);
- web_ui_->CallJavascriptFunction(
- L"SearchEngineManager.validityCheckCallback", validity, indexValue);
-}
-
-void SearchEngineManagerHandler::EditCancelled(const ListValue* args) {
- if (!edit_controller_.get())
- return;
- edit_controller_->CleanUpCancelledAdd();
- edit_controller_.reset();
-}
-
-void SearchEngineManagerHandler::EditCompleted(const ListValue* args) {
- if (!edit_controller_.get())
- return;
- string16 name;
- string16 keyword;
- std::string url;
- if (!args->GetString(ENGINE_NAME, &name) ||
- !args->GetString(ENGINE_KEYWORD, &keyword) ||
- !args->GetString(ENGINE_URL, &url)) {
- NOTREACHED();
- return;
- }
- edit_controller_->AcceptAddOrEdit(name, keyword, url);
-}
diff --git a/chrome/browser/dom_ui/options/search_engine_manager_handler.h b/chrome/browser/dom_ui/options/search_engine_manager_handler.h
index 1a87cc6..f391f51 100644
--- a/chrome/browser/dom_ui/options/search_engine_manager_handler.h
+++ b/chrome/browser/dom_ui/options/search_engine_manager_handler.h
@@ -4,70 +4,9 @@
#ifndef CHROME_BROWSER_DOM_UI_OPTIONS_SEARCH_ENGINE_MANAGER_HANDLER_H_
#define CHROME_BROWSER_DOM_UI_OPTIONS_SEARCH_ENGINE_MANAGER_HANDLER_H_
+#pragma once
-#include "chrome/browser/dom_ui/options/options_ui.h"
-#include "chrome/browser/search_engines/edit_search_engine_controller.h"
-#include "ui/base/models/table_model_observer.h"
-
-class KeywordEditorController;
-
-class SearchEngineManagerHandler : public OptionsPageUIHandler,
- public ui::TableModelObserver,
- public EditSearchEngineControllerDelegate {
- public:
- SearchEngineManagerHandler();
- virtual ~SearchEngineManagerHandler();
-
- virtual void Initialize();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
-
- // ui::TableModelObserver implementation.
- virtual void OnModelChanged();
- virtual void OnItemsChanged(int start, int length);
- virtual void OnItemsAdded(int start, int length);
- virtual void OnItemsRemoved(int start, int length);
-
- // EditSearchEngineControllerDelegate implementation.
- virtual void OnEditedKeyword(const TemplateURL* template_url,
- const string16& title,
- const string16& keyword,
- const std::string& url);
-
- virtual void RegisterMessages();
-
- private:
- scoped_ptr<KeywordEditorController> list_controller_;
- scoped_ptr<EditSearchEngineController> edit_controller_;
-
- // Removes the search engine at the given index. Called from WebUI.
- void RemoveSearchEngine(const ListValue* args);
-
- // Sets the search engine at the given index to be default. Called from WebUI.
- void SetDefaultSearchEngine(const ListValue* args);
-
- // Starts an edit session for the search engine at the given index. If the
- // index is -1, starts editing a new search engine instead of an existing one.
- // Called from WebUI.
- void EditSearchEngine(const ListValue* args);
-
- // Validates the given search engine values, and reports the results back
- // to WebUI. Called from WebUI.
- void CheckSearchEngineInfoValidity(const ListValue* args);
-
- // Called when an edit is cancelled.
- // Called from WebUI.
- void EditCancelled(const ListValue* args);
-
- // Called when an edit is finished and should be saved.
- // Called from WebUI.
- void EditCompleted(const ListValue* args);
-
- // Returns a dictionary to pass to WebUI representing the given search engine.
- DictionaryValue* CreateDictionaryForEngine(int index, bool is_default);
-
- DISALLOW_COPY_AND_ASSIGN(SearchEngineManagerHandler);
-};
+#include "chrome/browser/webui/options/search_engine_manager_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_SEARCH_ENGINE_MANAGER_HANDLER_H_
diff --git a/chrome/browser/dom_ui/options/stop_syncing_handler.cc b/chrome/browser/dom_ui/options/stop_syncing_handler.cc
deleted file mode 100644
index 9c0c579..0000000
--- a/chrome/browser/dom_ui/options/stop_syncing_handler.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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.
-
-#include "chrome/browser/dom_ui/options/stop_syncing_handler.h"
-
-#include "base/basictypes.h"
-#include "base/values.h"
-#include "base/callback.h"
-#include "grit/chromium_strings.h"
-#include "grit/generated_resources.h"
-#include "chrome/browser/sync/profile_sync_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/profile_manager.h"
-#include "ui/base/l10n/l10n_util.h"
-
-StopSyncingHandler::StopSyncingHandler() {
-}
-
-StopSyncingHandler::~StopSyncingHandler() {
-}
-
-void StopSyncingHandler::GetLocalizedValues(
- DictionaryValue* localized_strings) {
- DCHECK(localized_strings);
- localized_strings->SetString("stop_syncing_explanation",
- l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL));
- localized_strings->SetString("stop_syncing_title",
- l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_DIALOG_TITLE));
- localized_strings->SetString("stop_syncing_confirm",
- l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL));
-}
-
-void StopSyncingHandler::RegisterMessages() {
- DCHECK(web_ui_);
- web_ui_->RegisterMessageCallback("stopSyncing",
- NewCallback(this, &StopSyncingHandler::StopSyncing));
-}
-
-void StopSyncingHandler::StopSyncing(const ListValue* args){
- ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService();
- if (service != NULL && ProfileSyncService::IsSyncEnabled()) {
- service->DisableForUser();
- ProfileSyncService::SyncEvent(ProfileSyncService::STOP_FROM_OPTIONS);
- }
-}
diff --git a/chrome/browser/dom_ui/options/stop_syncing_handler.h b/chrome/browser/dom_ui/options/stop_syncing_handler.h
index f586556..cd69363 100644
--- a/chrome/browser/dom_ui/options/stop_syncing_handler.h
+++ b/chrome/browser/dom_ui/options/stop_syncing_handler.h
@@ -1,28 +1,12 @@
-// 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.
#ifndef CHROME_BROWSER_DOM_UI_OPTIONS_STOP_SYNCING_HANDLER_H_
#define CHROME_BROWSER_DOM_UI_OPTIONS_STOP_SYNCING_HANDLER_H_
+#pragma once
-#include "chrome/browser/dom_ui/options/options_ui.h"
-
-// Chrome personal stuff stop syncing overlay UI handler.
-class StopSyncingHandler : public OptionsPageUIHandler {
- public:
- StopSyncingHandler();
- virtual ~StopSyncingHandler();
-
- // OptionsUIHandler implementation.
- virtual void GetLocalizedValues(DictionaryValue* localized_strings);
-
- // WebUIMessageHandler implementation.
- virtual void RegisterMessages();
-
- private:
- void StopSyncing(const ListValue* args);
-
- DISALLOW_COPY_AND_ASSIGN(StopSyncingHandler);
-};
+#include "chrome/browser/webui/options/stop_syncing_handler.h"
+// TODO(tfarina): remove this file once all includes have been updated.
#endif // CHROME_BROWSER_DOM_UI_OPTIONS_STOP_SYNCING_HANDLER_H_