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> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
16 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/memory/ptr_util.h" | 19 #include "base/memory/ptr_util.h" |
20 #include "base/metrics/histogram_macros.h" | 20 #include "base/metrics/histogram_macros.h" |
21 #include "base/metrics/user_metrics.h" | 21 #include "base/metrics/user_metrics.h" |
| 22 #include "base/stl_util.h" |
22 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
23 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
24 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
25 #include "base/time/time.h" | 26 #include "base/time/time.h" |
26 #include "base/values.h" | 27 #include "base/values.h" |
27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
28 #include "content/public/browser/resource_request_info.h" | 29 #include "content/public/browser/resource_request_info.h" |
29 #include "content/public/common/browser_side_navigation_policy.h" | 30 #include "content/public/common/browser_side_navigation_policy.h" |
30 #include "content/public/common/child_process_host.h" | 31 #include "content/public/common/child_process_host.h" |
31 #include "content/public/common/resource_type.h" | 32 #include "content/public/common/resource_type.h" |
(...skipping 1449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 // Check if the tab id and window id match, if they were set in the | 1482 // Check if the tab id and window id match, if they were set in the |
1482 // listener params. | 1483 // listener params. |
1483 if ((listener->filter.tab_id != -1 && | 1484 if ((listener->filter.tab_id != -1 && |
1484 frame_data.tab_id != listener->filter.tab_id) || | 1485 frame_data.tab_id != listener->filter.tab_id) || |
1485 (listener->filter.window_id != -1 && | 1486 (listener->filter.window_id != -1 && |
1486 frame_data.window_id != listener->filter.window_id)) { | 1487 frame_data.window_id != listener->filter.window_id)) { |
1487 continue; | 1488 continue; |
1488 } | 1489 } |
1489 | 1490 |
1490 const std::vector<WebRequestResourceType>& types = listener->filter.types; | 1491 const std::vector<WebRequestResourceType>& types = listener->filter.types; |
1491 if (!types.empty() && | 1492 if (!types.empty() && !base::ContainsValue(types, resource_type)) { |
1492 std::find(types.begin(), types.end(), resource_type) == types.end()) { | |
1493 continue; | 1493 continue; |
1494 } | 1494 } |
1495 | 1495 |
1496 if (!is_web_view_guest) { | 1496 if (!is_web_view_guest) { |
1497 PermissionsData::AccessType access = | 1497 PermissionsData::AccessType access = |
1498 WebRequestPermissions::CanExtensionAccessURL( | 1498 WebRequestPermissions::CanExtensionAccessURL( |
1499 extension_info_map, listener->id.extension_id, url, | 1499 extension_info_map, listener->id.extension_id, url, |
1500 frame_data.tab_id, crosses_incognito, | 1500 frame_data.tab_id, crosses_incognito, |
1501 WebRequestPermissions::REQUIRE_HOST_PERMISSION, | 1501 WebRequestPermissions::REQUIRE_HOST_PERMISSION, |
1502 request->initiator()); | 1502 request->initiator()); |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2447 // Since EventListeners are segmented by browser_context, check that | 2447 // Since EventListeners are segmented by browser_context, check that |
2448 // last, as it is exceedingly unlikely to be different. | 2448 // last, as it is exceedingly unlikely to be different. |
2449 return extension_id == that.extension_id && | 2449 return extension_id == that.extension_id && |
2450 sub_event_name == that.sub_event_name && | 2450 sub_event_name == that.sub_event_name && |
2451 web_view_instance_id == that.web_view_instance_id && | 2451 web_view_instance_id == that.web_view_instance_id && |
2452 embedder_process_id == that.embedder_process_id && | 2452 embedder_process_id == that.embedder_process_id && |
2453 browser_context == that.browser_context; | 2453 browser_context == that.browser_context; |
2454 } | 2454 } |
2455 | 2455 |
2456 } // namespace extensions | 2456 } // namespace extensions |
OLD | NEW |