| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "extensions/browser/api/web_request/web_request_api.h" | 5 #include "extensions/browser/api/web_request/web_request_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 listener.filter = filter; | 1114 listener.filter = filter; |
| 1115 listener.extra_info_spec = extra_info_spec; | 1115 listener.extra_info_spec = extra_info_spec; |
| 1116 listener.ipc_sender = ipc_sender; | 1116 listener.ipc_sender = ipc_sender; |
| 1117 listener.embedder_process_id = embedder_process_id; | 1117 listener.embedder_process_id = embedder_process_id; |
| 1118 listener.web_view_instance_id = web_view_instance_id; | 1118 listener.web_view_instance_id = web_view_instance_id; |
| 1119 if (listener.web_view_instance_id) { | 1119 if (listener.web_view_instance_id) { |
| 1120 content::RecordAction( | 1120 content::RecordAction( |
| 1121 base::UserMetricsAction("WebView.WebRequest.AddListener")); | 1121 base::UserMetricsAction("WebView.WebRequest.AddListener")); |
| 1122 } | 1122 } |
| 1123 | 1123 |
| 1124 if (ContainsKey(listeners_[browser_context][event_name], listener)) { | 1124 if (base::ContainsKey(listeners_[browser_context][event_name], listener)) { |
| 1125 // This is likely an abuse of the API by a malicious extension. | 1125 // This is likely an abuse of the API by a malicious extension. |
| 1126 return false; | 1126 return false; |
| 1127 } | 1127 } |
| 1128 listeners_[browser_context][event_name].insert(listener); | 1128 listeners_[browser_context][event_name].insert(listener); |
| 1129 return true; | 1129 return true; |
| 1130 } | 1130 } |
| 1131 | 1131 |
| 1132 int ExtensionWebRequestEventRouter::GetListenerCountForTesting( | 1132 int ExtensionWebRequestEventRouter::GetListenerCountForTesting( |
| 1133 void* browser_context, | 1133 void* browser_context, |
| 1134 const std::string& event_name) { | 1134 const std::string& event_name) { |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 if (num_handlers_blocking == 0) { | 1636 if (num_handlers_blocking == 0) { |
| 1637 blocked_request.request->LogUnblocked(); | 1637 blocked_request.request->LogUnblocked(); |
| 1638 ExecuteDeltas(browser_context, request_id, true); | 1638 ExecuteDeltas(browser_context, request_id, true); |
| 1639 } else { | 1639 } else { |
| 1640 // Update the URLRequest to make sure it's tagged with an extension that's | 1640 // Update the URLRequest to make sure it's tagged with an extension that's |
| 1641 // still blocking it. This may end up being the same extension as before. | 1641 // still blocking it. This may end up being the same extension as before. |
| 1642 std::set<EventListener>& listeners = | 1642 std::set<EventListener>& listeners = |
| 1643 listeners_[browser_context][event_name]; | 1643 listeners_[browser_context][event_name]; |
| 1644 | 1644 |
| 1645 for (const auto& listener : listeners) { | 1645 for (const auto& listener : listeners) { |
| 1646 if (!ContainsKey(listener.blocked_requests, request_id)) | 1646 if (!base::ContainsKey(listener.blocked_requests, request_id)) |
| 1647 continue; | 1647 continue; |
| 1648 std::string delegate_info = | 1648 std::string delegate_info = |
| 1649 l10n_util::GetStringFUTF8(IDS_LOAD_STATE_PARAMETER_EXTENSION, | 1649 l10n_util::GetStringFUTF8(IDS_LOAD_STATE_PARAMETER_EXTENSION, |
| 1650 base::UTF8ToUTF16(listener.extension_name)); | 1650 base::UTF8ToUTF16(listener.extension_name)); |
| 1651 blocked_request.request->LogAndReportBlockedBy(delegate_info.c_str()); | 1651 blocked_request.request->LogAndReportBlockedBy(delegate_info.c_str()); |
| 1652 break; | 1652 break; |
| 1653 } | 1653 } |
| 1654 } | 1654 } |
| 1655 } | 1655 } |
| 1656 | 1656 |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2239 RunWithValidation()->Execute(); | 2239 RunWithValidation()->Execute(); |
| 2240 } | 2240 } |
| 2241 | 2241 |
| 2242 ExtensionFunction::ResponseAction | 2242 ExtensionFunction::ResponseAction |
| 2243 WebRequestHandlerBehaviorChangedFunction::Run() { | 2243 WebRequestHandlerBehaviorChangedFunction::Run() { |
| 2244 helpers::ClearCacheOnNavigation(); | 2244 helpers::ClearCacheOnNavigation(); |
| 2245 return RespondNow(NoArguments()); | 2245 return RespondNow(NoArguments()); |
| 2246 } | 2246 } |
| 2247 | 2247 |
| 2248 } // namespace extensions | 2248 } // namespace extensions |
| OLD | NEW |