Index: third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp |
diff --git a/third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp b/third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp |
index 2c1fe8191064b80ef3d77d6117bb376b97d99649..93e5c20c9dad3406d10710f9f56e476a1f11926f 100644 |
--- a/third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp |
+++ b/third_party/WebKit/Source/core/loader/WorkerFetchContext.cpp |
@@ -93,6 +93,10 @@ ResourceFetcher* WorkerFetchContext::GetResourceFetcher() { |
return resource_fetcher_; |
} |
+KURL WorkerFetchContext::FirstPartyForCookies() const { |
+ return web_context_->FirstPartyForCookies(); |
+} |
+ |
ContentSettingsClient* WorkerFetchContext::GetContentSettingsClient() const { |
// TODO(horo): Implement this. |
return nullptr; |
@@ -191,6 +195,28 @@ void WorkerFetchContext::AddResourceTiming(const ResourceTimingInfo& info) { |
->AddResourceTiming(info); |
} |
+void WorkerFetchContext::PopulateResourceRequest( |
+ const KURL& url, |
+ Resource::Type type, |
+ const ClientHintsPreferences& hints_preferences, |
+ const FetchParameters::ResourceWidth& resource_width, |
+ const ResourceLoaderOptions& options, |
+ SecurityViolationReportingPolicy reporting_policy, |
+ ResourceRequest& out_request) { |
+ SetFirstPartyCookieAndRequestorOrigin(out_request); |
+} |
+ |
+void WorkerFetchContext::SetFirstPartyCookieAndRequestorOrigin( |
+ ResourceRequest& out_request) { |
+ if (out_request.FirstPartyForCookies().IsNull()) |
+ out_request.SetFirstPartyForCookies(FirstPartyForCookies()); |
+ // TODO(mkwst): It would be cleaner to adjust blink::ResourceRequest to |
+ // initialize itself with a `nullptr` initiator so that this can be a simple |
+ // `isNull()` check. https://crbug.com/625969 |
+ if (out_request.RequestorOrigin()->IsUnique()) |
+ out_request.SetRequestorOrigin(GetSecurityOrigin()); |
+} |
+ |
DEFINE_TRACE(WorkerFetchContext) { |
visitor->Trace(worker_global_scope_); |
visitor->Trace(resource_fetcher_); |