OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/settings/protocol_handlers_handler.h" | 5 #include "chrome/browser/ui/webui/settings/protocol_handlers_handler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 protocol != protocols.end(); protocol++) { | 121 protocol != protocols.end(); protocol++) { |
122 std::unique_ptr<base::DictionaryValue> handler_value( | 122 std::unique_ptr<base::DictionaryValue> handler_value( |
123 new base::DictionaryValue()); | 123 new base::DictionaryValue()); |
124 GetHandlersForProtocol(*protocol, handler_value.get()); | 124 GetHandlersForProtocol(*protocol, handler_value.get()); |
125 handlers.Append(std::move(handler_value)); | 125 handlers.Append(std::move(handler_value)); |
126 } | 126 } |
127 | 127 |
128 std::unique_ptr<base::ListValue> ignored_handlers(new base::ListValue()); | 128 std::unique_ptr<base::ListValue> ignored_handlers(new base::ListValue()); |
129 GetIgnoredHandlers(ignored_handlers.get()); | 129 GetIgnoredHandlers(ignored_handlers.get()); |
130 CallJavascriptFunction("cr.webUIListenerCallback", | 130 CallJavascriptFunction("cr.webUIListenerCallback", |
131 base::StringValue("setProtocolHandlers"), | 131 base::Value("setProtocolHandlers"), handlers); |
132 handlers); | |
133 CallJavascriptFunction("cr.webUIListenerCallback", | 132 CallJavascriptFunction("cr.webUIListenerCallback", |
134 base::StringValue("setIgnoredProtocolHandlers"), | 133 base::Value("setIgnoredProtocolHandlers"), |
135 *ignored_handlers); | 134 *ignored_handlers); |
136 } | 135 } |
137 | 136 |
138 void ProtocolHandlersHandler::HandleObserveProtocolHandlers( | 137 void ProtocolHandlersHandler::HandleObserveProtocolHandlers( |
139 const base::ListValue* args) { | 138 const base::ListValue* args) { |
140 AllowJavascript(); | 139 AllowJavascript(); |
141 SendHandlersEnabledValue(); | 140 SendHandlersEnabledValue(); |
142 UpdateHandlerList(); | 141 UpdateHandlerList(); |
143 } | 142 } |
144 | 143 |
145 void ProtocolHandlersHandler::HandleObserveProtocolHandlersEnabledState( | 144 void ProtocolHandlersHandler::HandleObserveProtocolHandlersEnabledState( |
146 const base::ListValue* args) { | 145 const base::ListValue* args) { |
147 AllowJavascript(); | 146 AllowJavascript(); |
148 SendHandlersEnabledValue(); | 147 SendHandlersEnabledValue(); |
149 } | 148 } |
150 | 149 |
151 void ProtocolHandlersHandler::SendHandlersEnabledValue() { | 150 void ProtocolHandlersHandler::SendHandlersEnabledValue() { |
152 CallJavascriptFunction("cr.webUIListenerCallback", | 151 CallJavascriptFunction("cr.webUIListenerCallback", |
153 base::StringValue("setHandlersEnabled"), | 152 base::Value("setHandlersEnabled"), |
154 base::Value(GetProtocolHandlerRegistry()->enabled())); | 153 base::Value(GetProtocolHandlerRegistry()->enabled())); |
155 } | 154 } |
156 | 155 |
157 void ProtocolHandlersHandler::HandleRemoveHandler(const base::ListValue* args) { | 156 void ProtocolHandlersHandler::HandleRemoveHandler(const base::ListValue* args) { |
158 const base::ListValue* list; | 157 const base::ListValue* list; |
159 if (!args->GetList(0, &list)) { | 158 if (!args->GetList(0, &list)) { |
160 NOTREACHED(); | 159 NOTREACHED(); |
161 return; | 160 return; |
162 } | 161 } |
163 | 162 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 void ProtocolHandlersHandler::Observe( | 220 void ProtocolHandlersHandler::Observe( |
222 int type, | 221 int type, |
223 const content::NotificationSource& source, | 222 const content::NotificationSource& source, |
224 const content::NotificationDetails& details) { | 223 const content::NotificationDetails& details) { |
225 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type); | 224 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type); |
226 SendHandlersEnabledValue(); | 225 SendHandlersEnabledValue(); |
227 UpdateHandlerList(); | 226 UpdateHandlerList(); |
228 } | 227 } |
229 | 228 |
230 } // namespace settings | 229 } // namespace settings |
OLD | NEW |