OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/webui/settings/content_settings_handler.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "components/content_settings/core/common/content_settings_types.h" |
| 9 #include "content/public/browser/web_ui.h" |
| 10 |
| 11 namespace settings { |
| 12 |
| 13 ContentSettingsHandler::ContentSettingsHandler() { |
| 14 } |
| 15 |
| 16 ContentSettingsHandler::~ContentSettingsHandler() { |
| 17 } |
| 18 |
| 19 void ContentSettingsHandler::RegisterMessages() { |
| 20 web_ui()->RegisterMessageCallback( |
| 21 "fetchContentSettingsData", |
| 22 base::Bind(&ContentSettingsHandler::HandleFetchData, |
| 23 base::Unretained(this))); |
| 24 web_ui()->RegisterMessageCallback( |
| 25 "toggleChanged", |
| 26 base::Bind(&ContentSettingsHandler::HandleToggleChange, |
| 27 base::Unretained(this))); |
| 28 } |
| 29 |
| 30 void ContentSettingsHandler::HandleFetchData( |
| 31 const base::ListValue* args) { |
| 32 CHECK_EQ(1U, args->GetSize()); |
| 33 int content_settings_type = -1; |
| 34 CHECK(args->GetInteger(0, &content_settings_type)); |
| 35 |
| 36 base::ListValue allowedList; |
| 37 base::ListValue blockedList; |
| 38 |
| 39 // Return dummy data. |
| 40 switch (content_settings_type) { |
| 41 default: { |
| 42 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
| 43 entry->SetString("url", "http://foo.com"); |
| 44 allowedList.Append(entry.release()); |
| 45 |
| 46 scoped_ptr<base::DictionaryValue> entry2(new base::DictionaryValue()); |
| 47 entry2->SetString("url", "http://bar.com"); |
| 48 blockedList.Append(entry2.release()); |
| 49 break; |
| 50 } |
| 51 case CONTENT_SETTINGS_TYPE_GEOLOCATION: { |
| 52 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
| 53 entry->SetString("url", "http://foo.com"); |
| 54 allowedList.Append(entry.release()); |
| 55 break; |
| 56 } |
| 57 } |
| 58 |
| 59 web_ui()->CallJavascriptFunction( |
| 60 "Settings.receiveData", allowedList, blockedList, |
| 61 base::FundamentalValue(true)); |
| 62 } |
| 63 |
| 64 void ContentSettingsHandler::HandleToggleChange(const base::ListValue* args) { |
| 65 CHECK_EQ(2U, args->GetSize()); |
| 66 int content_settings_type = -1; |
| 67 CHECK(args->GetInteger(0, &content_settings_type)); |
| 68 bool enabled = false; |
| 69 CHECK(args->GetBoolean(1, &enabled)); |
| 70 |
| 71 // TODO(finnur): Implement. |
| 72 } |
| 73 |
| 74 } // namespace settings |
OLD | NEW |