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

Unified Diff: content/browser/service_worker/foreign_fetch_request_handler.cc

Issue 1656933003: Add origins argument to registerForeignFetchScopes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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: content/browser/service_worker/foreign_fetch_request_handler.cc
diff --git a/content/browser/service_worker/foreign_fetch_request_handler.cc b/content/browser/service_worker/foreign_fetch_request_handler.cc
index aa085bd53a0ecb317da16981dddb42845b58d7b9..6479e95cecc0d425942764136eaef4ee76754b59 100644
--- a/content/browser/service_worker/foreign_fetch_request_handler.cc
+++ b/content/browser/service_worker/foreign_fetch_request_handler.cc
@@ -180,7 +180,14 @@ void ForeignFetchRequestHandler::DidFindRegistration(
}
}
- if (!scope_matches) {
+ const url::Origin& request_origin = job->request()->initiator();
+ bool origin_matches = active_version->foreign_fetch_origins().empty();
+ for (const GURL& origin : active_version->foreign_fetch_origins()) {
+ if (request_origin.IsSameOriginWith(url::Origin(origin)))
+ origin_matches = true;
+ }
+
+ if (!scope_matches || !origin_matches) {
job->FallbackToNetwork();
return;
}

Powered by Google App Engine
This is Rietveld 408576698