| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 for (std::vector<std::string>::iterator protocol = protocols.begin(); | 122 for (std::vector<std::string>::iterator protocol = protocols.begin(); |
| 123 protocol != protocols.end(); protocol++) { | 123 protocol != protocols.end(); protocol++) { |
| 124 std::unique_ptr<base::DictionaryValue> handler_value( | 124 std::unique_ptr<base::DictionaryValue> handler_value( |
| 125 new base::DictionaryValue()); | 125 new base::DictionaryValue()); |
| 126 GetHandlersForProtocol(*protocol, handler_value.get()); | 126 GetHandlersForProtocol(*protocol, handler_value.get()); |
| 127 handlers.Append(std::move(handler_value)); | 127 handlers.Append(std::move(handler_value)); |
| 128 } | 128 } |
| 129 | 129 |
| 130 std::unique_ptr<base::ListValue> ignored_handlers(new base::ListValue()); | 130 std::unique_ptr<base::ListValue> ignored_handlers(new base::ListValue()); |
| 131 GetIgnoredHandlers(ignored_handlers.get()); | 131 GetIgnoredHandlers(ignored_handlers.get()); |
| 132 CallJavascriptFunction("cr.webUIListenerCallback", | 132 FireWebUIListener("setProtocolHandlers", handlers); |
| 133 base::Value("setProtocolHandlers"), handlers); | 133 FireWebUIListener("setIgnoredProtocolHandlers", *ignored_handlers); |
| 134 CallJavascriptFunction("cr.webUIListenerCallback", | |
| 135 base::Value("setIgnoredProtocolHandlers"), | |
| 136 *ignored_handlers); | |
| 137 } | 134 } |
| 138 | 135 |
| 139 void ProtocolHandlersHandler::HandleObserveProtocolHandlers( | 136 void ProtocolHandlersHandler::HandleObserveProtocolHandlers( |
| 140 const base::ListValue* args) { | 137 const base::ListValue* args) { |
| 141 AllowJavascript(); | 138 AllowJavascript(); |
| 142 SendHandlersEnabledValue(); | 139 SendHandlersEnabledValue(); |
| 143 UpdateHandlerList(); | 140 UpdateHandlerList(); |
| 144 } | 141 } |
| 145 | 142 |
| 146 void ProtocolHandlersHandler::HandleObserveProtocolHandlersEnabledState( | 143 void ProtocolHandlersHandler::HandleObserveProtocolHandlersEnabledState( |
| 147 const base::ListValue* args) { | 144 const base::ListValue* args) { |
| 148 AllowJavascript(); | 145 AllowJavascript(); |
| 149 SendHandlersEnabledValue(); | 146 SendHandlersEnabledValue(); |
| 150 } | 147 } |
| 151 | 148 |
| 152 void ProtocolHandlersHandler::SendHandlersEnabledValue() { | 149 void ProtocolHandlersHandler::SendHandlersEnabledValue() { |
| 153 CallJavascriptFunction("cr.webUIListenerCallback", | 150 FireWebUIListener("setHandlersEnabled", |
| 154 base::Value("setHandlersEnabled"), | 151 base::Value(GetProtocolHandlerRegistry()->enabled())); |
| 155 base::Value(GetProtocolHandlerRegistry()->enabled())); | |
| 156 } | 152 } |
| 157 | 153 |
| 158 void ProtocolHandlersHandler::HandleRemoveHandler(const base::ListValue* args) { | 154 void ProtocolHandlersHandler::HandleRemoveHandler(const base::ListValue* args) { |
| 159 const base::ListValue* list; | 155 const base::ListValue* list; |
| 160 if (!args->GetList(0, &list)) { | 156 if (!args->GetList(0, &list)) { |
| 161 NOTREACHED(); | 157 NOTREACHED(); |
| 162 return; | 158 return; |
| 163 } | 159 } |
| 164 | 160 |
| 165 ProtocolHandler handler(ParseHandlerFromArgs(list)); | 161 ProtocolHandler handler(ParseHandlerFromArgs(list)); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 void ProtocolHandlersHandler::Observe( | 218 void ProtocolHandlersHandler::Observe( |
| 223 int type, | 219 int type, |
| 224 const content::NotificationSource& source, | 220 const content::NotificationSource& source, |
| 225 const content::NotificationDetails& details) { | 221 const content::NotificationDetails& details) { |
| 226 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type); | 222 DCHECK_EQ(chrome::NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, type); |
| 227 SendHandlersEnabledValue(); | 223 SendHandlersEnabledValue(); |
| 228 UpdateHandlerList(); | 224 UpdateHandlerList(); |
| 229 } | 225 } |
| 230 | 226 |
| 231 } // namespace settings | 227 } // namespace settings |
| OLD | NEW |