Commit 081f4cc4 authored by Alex Turner's avatar Alex Turner Committed by Commit Bot

Change ComputeTopFrameOrigin to use GetLastCommittedOrigin

ComputeTopFrameOrigin currently uses current_origin(), which has a
prominent warning about possible incorrect behavior. The function's use
is likely causing incorrect Network Isolation Keys to be used. We thus
use the replacement suggested by the warning.

Bug: 1014077
Change-Id: Iaecbb0ab028c626dce037462bb22053b5114bc52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1860106Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarShivani Sharma <shivanisha@chromium.org>
Commit-Queue: Alex Turner <alexmt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706911}
parent d87d1cda
...@@ -2239,9 +2239,16 @@ void RenderFrameHostImpl::SetLastCommittedOriginForTesting( ...@@ -2239,9 +2239,16 @@ void RenderFrameHostImpl::SetLastCommittedOriginForTesting(
const url::Origin& RenderFrameHostImpl::ComputeTopFrameOrigin( const url::Origin& RenderFrameHostImpl::ComputeTopFrameOrigin(
const url::Origin& frame_origin) const { const url::Origin& frame_origin) const {
return frame_tree_node_->IsMainFrame() if (frame_tree_node_->IsMainFrame()) {
? frame_origin return frame_origin;
: frame_tree_->root()->current_origin(); }
DCHECK(parent_);
RenderFrameHostImpl* host = parent_;
while (host->parent_) {
host = host->parent_;
}
return host->GetLastCommittedOrigin();
} }
GURL RenderFrameHostImpl::ComputeSiteForCookiesForNavigation( GURL RenderFrameHostImpl::ComputeSiteForCookiesForNavigation(
......
...@@ -475,6 +475,8 @@ class CONTENT_EXPORT RenderFrameHostImpl ...@@ -475,6 +475,8 @@ class CONTENT_EXPORT RenderFrameHostImpl
// Return the http status code of the last committed navigation. // Return the http status code of the last committed navigation.
int last_http_status_code() { return last_http_status_code_; } int last_http_status_code() { return last_http_status_code_; }
// Returns |frame_origin| if this frame is the top (i.e. root) frame in the
// frame tree. Otherwise, it returns the top frame's origin.
const url::Origin& ComputeTopFrameOrigin( const url::Origin& ComputeTopFrameOrigin(
const url::Origin& frame_origin) const; const url::Origin& frame_origin) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment