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

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

Issue 2405483002: Make the request initiator Optional (Closed)
Patch Set: Introduce NullableOrigin to use for request initiator Created 4 years, 2 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 f3437802e4c54618a9d751d33adb8f3f6e4e5689..979df227b6632effb5d4cc229f7183b072afac0f 100644
--- a/content/browser/service_worker/foreign_fetch_request_handler.cc
+++ b/content/browser/service_worker/foreign_fetch_request_handler.cc
@@ -92,8 +92,10 @@ void ForeignFetchRequestHandler::InitializeHandler(
if (ServiceWorkerUtils::IsMainResourceType(resource_type))
return;
- if (request->initiator().IsSameOriginWith(url::Origin(request->url())))
+ if (request->initiator() &&
+ request->initiator()->IsSameOriginWith(url::Origin(request->url()))) {
return;
+ }
if (!context_wrapper->OriginHasForeignFetchRegistrations(
request->url().GetOrigin())) {
@@ -218,7 +220,9 @@ void ForeignFetchRequestHandler::DidFindRegistration(
}
}
- const url::Origin& request_origin = job->request()->initiator();
+ const url::Origin& request_origin = job->request()->initiator()
+ ? url::Origin()
+ : *job->request()->initiator();
bool origin_matches = active_version->foreign_fetch_origins().empty();
for (const url::Origin& origin : active_version->foreign_fetch_origins()) {
if (request_origin.IsSameOriginWith(origin))

Powered by Google App Engine
This is Rietveld 408576698