Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5948)

Unified Diff: chrome/browser/ui/webui/settings/content_settings_handler.cc

Issue 1372053002: Flesh out the location-page class to make it more general. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split list into two Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/settings/content_settings_handler.cc
diff --git a/chrome/browser/ui/webui/settings/content_settings_handler.cc b/chrome/browser/ui/webui/settings/content_settings_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e16535c40c1a6baa4da09341a90c874a0d02b907
--- /dev/null
+++ b/chrome/browser/ui/webui/settings/content_settings_handler.cc
@@ -0,0 +1,104 @@
+// Copyright (c) 2015 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/ui/webui/settings/content_settings_handler.h"
+
+#include "base/bind.h"
+#include "components/content_settings/core/common/content_settings_types.h"
+#include "content/public/browser/web_ui.h"
+
+namespace settings {
+
+ContentSettingsHandler::ContentSettingsHandler() {
+}
+
+ContentSettingsHandler::~ContentSettingsHandler() {
+}
+
+void ContentSettingsHandler::RegisterMessages() {
+ web_ui()->RegisterMessageCallback(
+ "fetchToggleState",
+ base::Bind(&ContentSettingsHandler::HandleFetchToggleState,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "fetchContentSettingsData",
+ base::Bind(&ContentSettingsHandler::HandleFetchData,
+ base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
+ "toggleChanged",
+ base::Bind(&ContentSettingsHandler::HandleToggleChange,
+ base::Unretained(this)));
Dan Beam 2015/10/05 16:52:58 why are any of these needed? why can't we use pre
Finnur 2015/10/06 16:31:09 We can. I just threw this up to mock the data to g
+}
+
+void ContentSettingsHandler::HandleFetchToggleState(
+ const base::ListValue* args) {
+ CHECK_EQ(1U, args->GetSize());
Dan Beam 2015/10/05 16:52:58 change to DCHECKs
Finnur 2015/10/06 16:31:09 This is going away soon.
+ int content_settings_type = -1;
+ CHECK(args->GetInteger(0, &content_settings_type));
+
+ web_ui()->CallJavascriptFunction(
+ "Settings.receiveToggleState", base::FundamentalValue(true));
+}
+
+void ContentSettingsHandler::HandleFetchData(
+ const base::ListValue* args) {
+ CHECK_EQ(2U, args->GetSize());
+ int content_settings_type = -1;
+ CHECK(args->GetInteger(0, &content_settings_type));
+ bool allowedList = false;
+ CHECK(args->GetBoolean(1, &allowedList));
+
+ base::ListValue siteList;
+
+ // Uncomment the following for testing.
+/*
+ switch (content_settings_type) {
+ case CONTENT_SETTINGS_TYPE_GEOLOCATION: {
+ if (allowedList) {
+ scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
+ entry->SetString("url", "http://foo.com");
+ siteList.Append(entry.release());
+ }
+ break;
+ }
+ default: {
+ if (allowedList) {
+ scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
+ entry->SetString("url", "http://foo.com");
+ siteList.Append(entry.release());
+
+ scoped_ptr<base::DictionaryValue> entry2(new base::DictionaryValue());
+ entry2->SetString("url", "http://bar.com");
+ siteList.Append(entry2.release());
+ }
+
+ if (!allowedList) {
+ scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
+ entry->SetString("url", "http://bar.com");
+ siteList.Append(entry.release());
+ }
+ break;
+ }
+ }
+*/
Dan Beam 2015/10/05 16:52:58 remove
Finnur 2015/10/06 16:31:09 Ditto.
+
+ web_ui()->CallJavascriptFunction(
+ allowedList
+ ? "Settings.receiveAllowedData"
+ : "Settings.receiveBlockedData",
+ siteList, base::FundamentalValue(true));
+}
+
+void ContentSettingsHandler::HandleToggleChange(const base::ListValue* args) {
+ CHECK_EQ(2U, args->GetSize());
+ int content_settings_type = -1;
+ CHECK(args->GetInteger(0, &content_settings_type));
+ bool enabled = false;
+ CHECK(args->GetBoolean(1, &enabled));
+
+ // TODO(finnur): Implement.
+ NOTIMPLEMENTED();
+}
+
+} // namespace settings

Powered by Google App Engine
This is Rietveld 408576698