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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 2080653002: SameSite: Correctly set requests' initiator for new tabs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minimal. Created 4 years, 6 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/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index eedba7ad380c84503cd9450d07de2f7c55a35b61..c983655cd9b24d21da1be01c08483f7c3be35553 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -3932,9 +3932,16 @@ void RenderFrameImpl::willSendRequest(
request.setFirstPartyForCookies(request.url());
else
request.setFirstPartyForCookies(frame->document().firstPartyForCookies());
+ }
- // If we need to set the first party, then we need to set the request's
- // initiator as well; it will not be updated during redirects.
+ // Set the requestor origin to the same origin as the frame's document if it
+ // hasn't yet been set.
+ //
+ // 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.
+ if (request.requestorOrigin().isUnique() &&
+ !frame->document().getSecurityOrigin().isUnique()) {
request.setRequestorOrigin(frame->document().getSecurityOrigin());
}
@@ -5474,6 +5481,9 @@ void RenderFrameImpl::NavigateInternal(
WebURLRequest request =
CreateURLRequestForNavigation(common_params, std::move(stream_params),
frame_->isViewSourceModeEnabled());
+ request.setFrameType(IsTopLevelNavigation(frame_)
+ ? blink::WebURLRequest::FrameTypeTopLevel
+ : blink::WebURLRequest::FrameTypeNested);
if (IsBrowserSideNavigationEnabled() && common_params.post_data)
request.setHTTPBody(GetWebHTTPBodyForRequestBody(common_params.post_data));
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_browsertest.cc ('k') | third_party/WebKit/Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698