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

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

Issue 1311543005: Show hosted app requests to extensions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 0aaa4fad49fdd99661c424b454038001ed5c9ec3..5ae6cfb77e99184394a00ea546af2f7f88c0869e 100644
--- a/extensions/browser/api/web_request/web_request_api.cc
+++ b/extensions/browser/api/web_request/web_request_api.cc
@@ -147,7 +147,8 @@ bool IsWebRequestEvent(const std::string& event_name) {
// Returns whether |request| has been triggered by an extension in
// |extension_info_map|.
bool IsRequestFromExtension(const net::URLRequest* request,
- const InfoMap* extension_info_map) {
+ const InfoMap* extension_info_map,
+ void* browser_context_id) {
// |extension_info_map| is NULL for system-level requests.
if (!extension_info_map)
return false;
@@ -159,7 +160,25 @@ bool IsRequestFromExtension(const net::URLRequest* request,
if (!info)
return false;
- return extension_info_map->process_map().Contains(info->GetChildID());
+ const std::set<std::string> extension_ids =
+ extension_info_map->process_map().GetExtensionsInProcess(
+ info->GetChildID());
+ if (extension_ids.empty())
+ return false;
+
+ content::BrowserContext* browser_context =
+ reinterpret_cast<content::BrowserContext*>(browser_context_id);
+ if (browser_context) {
robwu 2015/09/05 17:29:10 I'm not sure whether it is safe to use |browser_co
not at google - send to devlin 2015/09/08 16:09:20 It's not valid to use the BrowserContext on the IO
robwu 2015/09/08 17:19:48 Yes, of course.
+ // Hosted apps are like normal web pages (crbug.com/526413).
+ const ExtensionSet& enabled_extensions =
+ ExtensionRegistry::Get(browser_context)->enabled_extensions();
+ for (const std::string& extension_id : extension_ids) {
+ const Extension* extension = enabled_extensions.GetByID(extension_id);
+ if (extension && !extension->is_hosted_app())
+ return true;
+ }
+ }
+ return false;
}
void ExtractRequestRoutingInfo(const net::URLRequest* request,
@@ -1587,7 +1606,7 @@ ExtensionWebRequestEventRouter::GetMatchingListeners(
&routing_id, &resource_type);
bool is_request_from_extension =
- IsRequestFromExtension(request, extension_info_map);
+ IsRequestFromExtension(request, extension_info_map, browser_context);
const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
// We are conservative here and assume requests are asynchronous in case

Powered by Google App Engine
This is Rietveld 408576698