Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: extensions/browser/api/web_request/web_request_api.cc

Issue 2700553002: Introduce WebRequestResourceType. (Closed)
Patch Set: Address comments from Devlin. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/web_request/web_request_api.cc
diff --git a/extensions/browser/api/web_request/web_request_api.cc b/extensions/browser/api/web_request/web_request_api.cc
index ebe0c124f60d94d265035f5025fc78b9bed2f52f..9cfc02b4c2707f74b836652e7a928e10f100aded 100644
--- a/extensions/browser/api/web_request/web_request_api.cc
+++ b/extensions/browser/api/web_request/web_request_api.cc
@@ -29,6 +29,7 @@
#include "content/public/browser/user_metrics.h"
#include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/common/child_process_host.h"
+#include "content/public/common/resource_type.h"
#include "extensions/browser/api/activity_log/web_request_constants.h"
#include "extensions/browser/api/declarative/rules_registry_service.h"
#include "extensions/browser/api/declarative_webrequest/request_stage.h"
@@ -1380,7 +1381,7 @@ void ExtensionWebRequestEventRouter::GetMatchingListenersImpl(
const GURL& url,
int render_process_host_id,
int routing_id,
- content::ResourceType resource_type,
+ WebRequestResourceType resource_type,
bool is_async_request,
bool is_request_from_extension,
int* extra_info_spec,
@@ -1452,7 +1453,7 @@ void ExtensionWebRequestEventRouter::GetMatchingListenersImpl(
continue;
}
- const std::vector<content::ResourceType>& types = listener->filter.types;
+ const std::vector<WebRequestResourceType>& types = listener->filter.types;
if (!types.empty() &&
std::find(types.begin(), types.end(), resource_type) == types.end()) {
continue;
@@ -1486,7 +1487,7 @@ void ExtensionWebRequestEventRouter::GetMatchingListenersImpl(
// http://crbug.com/105656
bool synchronous_xhr_from_extension =
!is_async_request && is_request_from_extension &&
- resource_type == content::RESOURCE_TYPE_XHR;
+ resource_type == WebRequestResourceType::XHR;
// Only send webRequest events for URLs the extension has access to.
if (blocking_listener && synchronous_xhr_from_extension)
@@ -1512,7 +1513,7 @@ ExtensionWebRequestEventRouter::GetMatchingListeners(
const GURL& url = request->url();
int render_process_host_id = content::ChildProcessHost::kInvalidUniqueID;
int routing_id = MSG_ROUTING_NONE;
- content::ResourceType resource_type = content::RESOURCE_TYPE_LAST_TYPE;
+ auto resource_type = WebRequestResourceType::OTHER;
// We are conservative here and assume requests are asynchronous in case
// we don't have an info object. We don't want to risk a deadlock.
bool is_async_request = false;
@@ -1523,7 +1524,7 @@ ExtensionWebRequestEventRouter::GetMatchingListeners(
if (info) {
is_async_request = info->IsAsync();
if (helpers::IsRelevantResourceType(info->GetResourceType()))
- resource_type = info->GetResourceType();
+ resource_type = ToWebRequestResourceType(info->GetResourceType());
Devlin 2017/02/16 16:08:26 here, too, looks like this type should be able to
pkalinnikov 2017/02/16 19:27:33 Yes, I have already done it in the follow-up CL (n
render_process_host_id = info->GetChildID();
routing_id = info->GetRouteID();
}

Powered by Google App Engine
This is Rietveld 408576698