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 "fetchToggleState", | |
22 base::Bind(&ContentSettingsHandler::HandleFetchToggleState, | |
23 base::Unretained(this))); | |
24 web_ui()->RegisterMessageCallback( | |
25 "fetchContentSettingsData", | |
26 base::Bind(&ContentSettingsHandler::HandleFetchData, | |
27 base::Unretained(this))); | |
28 web_ui()->RegisterMessageCallback( | |
29 "toggleChanged", | |
30 base::Bind(&ContentSettingsHandler::HandleToggleChange, | |
31 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
| |
32 } | |
33 | |
34 void ContentSettingsHandler::HandleFetchToggleState( | |
35 const base::ListValue* args) { | |
36 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.
| |
37 int content_settings_type = -1; | |
38 CHECK(args->GetInteger(0, &content_settings_type)); | |
39 | |
40 web_ui()->CallJavascriptFunction( | |
41 "Settings.receiveToggleState", base::FundamentalValue(true)); | |
42 } | |
43 | |
44 void ContentSettingsHandler::HandleFetchData( | |
45 const base::ListValue* args) { | |
46 CHECK_EQ(2U, args->GetSize()); | |
47 int content_settings_type = -1; | |
48 CHECK(args->GetInteger(0, &content_settings_type)); | |
49 bool allowedList = false; | |
50 CHECK(args->GetBoolean(1, &allowedList)); | |
51 | |
52 base::ListValue siteList; | |
53 | |
54 // Uncomment the following for testing. | |
55 /* | |
56 switch (content_settings_type) { | |
57 case CONTENT_SETTINGS_TYPE_GEOLOCATION: { | |
58 if (allowedList) { | |
59 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | |
60 entry->SetString("url", "http://foo.com"); | |
61 siteList.Append(entry.release()); | |
62 } | |
63 break; | |
64 } | |
65 default: { | |
66 if (allowedList) { | |
67 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | |
68 entry->SetString("url", "http://foo.com"); | |
69 siteList.Append(entry.release()); | |
70 | |
71 scoped_ptr<base::DictionaryValue> entry2(new base::DictionaryValue()); | |
72 entry2->SetString("url", "http://bar.com"); | |
73 siteList.Append(entry2.release()); | |
74 } | |
75 | |
76 if (!allowedList) { | |
77 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | |
78 entry->SetString("url", "http://bar.com"); | |
79 siteList.Append(entry.release()); | |
80 } | |
81 break; | |
82 } | |
83 } | |
84 */ | |
Dan Beam
2015/10/05 16:52:58
remove
Finnur
2015/10/06 16:31:09
Ditto.
| |
85 | |
86 web_ui()->CallJavascriptFunction( | |
87 allowedList | |
88 ? "Settings.receiveAllowedData" | |
89 : "Settings.receiveBlockedData", | |
90 siteList, base::FundamentalValue(true)); | |
91 } | |
92 | |
93 void ContentSettingsHandler::HandleToggleChange(const base::ListValue* args) { | |
94 CHECK_EQ(2U, args->GetSize()); | |
95 int content_settings_type = -1; | |
96 CHECK(args->GetInteger(0, &content_settings_type)); | |
97 bool enabled = false; | |
98 CHECK(args->GetBoolean(1, &enabled)); | |
99 | |
100 // TODO(finnur): Implement. | |
101 NOTIMPLEMENTED(); | |
102 } | |
103 | |
104 } // namespace settings | |
OLD | NEW |