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..257f941583dabe2aeb663174586ddb719f945da1 |
--- /dev/null |
+++ b/chrome/browser/ui/webui/settings/content_settings_handler.cc |
@@ -0,0 +1,74 @@ |
+// 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( |
+ "fetchContentSettingsData", |
+ base::Bind(&ContentSettingsHandler::HandleFetchData, |
+ base::Unretained(this))); |
+ web_ui()->RegisterMessageCallback( |
+ "toggleChanged", |
+ base::Bind(&ContentSettingsHandler::HandleToggleChange, |
+ base::Unretained(this))); |
+} |
+ |
+void ContentSettingsHandler::HandleFetchData( |
+ const base::ListValue* args) { |
+ CHECK_EQ(1U, args->GetSize()); |
+ int content_settings_type = -1; |
+ CHECK(args->GetInteger(0, &content_settings_type)); |
+ |
+ base::ListValue allowedList; |
+ base::ListValue blockedList; |
+ |
+ // Return dummy data. |
+ switch (content_settings_type) { |
+ default: { |
+ scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
+ entry->SetString("url", "http://foo.com"); |
+ allowedList.Append(entry.release()); |
+ |
+ scoped_ptr<base::DictionaryValue> entry2(new base::DictionaryValue()); |
+ entry2->SetString("url", "http://bar.com"); |
+ blockedList.Append(entry2.release()); |
+ break; |
+ } |
+ case CONTENT_SETTINGS_TYPE_GEOLOCATION: { |
+ scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
+ entry->SetString("url", "http://foo.com"); |
+ allowedList.Append(entry.release()); |
+ break; |
+ } |
+ } |
+ |
+ web_ui()->CallJavascriptFunction( |
+ "Settings.receiveData", allowedList, blockedList, |
+ 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. |
+} |
+ |
+} // namespace settings |