Index: content/browser/frame_host/render_frame_host_impl.cc |
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc |
index 55e731cda2a209abf59122cee740afa2cf320f40..f0397dfb883eb9b0dfa289fc3e2c5e4daa8c4269 100644 |
--- a/content/browser/frame_host/render_frame_host_impl.cc |
+++ b/content/browser/frame_host/render_frame_host_impl.cc |
@@ -484,6 +484,8 @@ RenderFrameHostImpl::~RenderFrameHostImpl() { |
// RenderFrameHost during cleanup. |
ClearAllWebUI(); |
+ SetLastCommittedSiteUrl(GURL()); |
+ |
GetProcess()->RemoveRoute(routing_id_); |
g_routing_id_frame_map.Get().erase( |
RenderFrameHostID(GetProcess()->GetID(), routing_id_)); |
@@ -1455,6 +1457,15 @@ void RenderFrameHostImpl::OnDidCommitProvisionalLoad(const IPC::Message& msg) { |
TakeNavigationHandleForCommit(validated_params); |
DCHECK(navigation_handle); |
+ // Update the site url if the navigation was successful and the page is not an |
+ // interstitial. |
+ if (validated_params.url_is_unreachable || |
+ delegate_->GetAsInterstitialPage()) { |
+ SetLastCommittedSiteUrl(GURL()); |
+ } else { |
+ SetLastCommittedSiteUrl(validated_params.url); |
+ } |
+ |
// PlzNavigate sends searchable form data in the BeginNavigation message |
// while non-PlzNavigate sends it in the DidCommitProvisionalLoad message. |
// Update |navigation_handle| if necessary. |
@@ -3926,6 +3937,32 @@ void RenderFrameHostImpl::BeforeUnloadTimeout() { |
SimulateBeforeUnloadAck(); |
} |
+void RenderFrameHostImpl::SetLastCommittedSiteUrl(const GURL& url) { |
+ GURL site_url = |
+ url.is_empty() ? GURL() |
+ : SiteInstance::GetSiteForURL(frame_tree_node_->navigator() |
+ ->GetController() |
+ ->GetBrowserContext(), |
+ url); |
+ |
+ if (last_committed_site_url_ == site_url) |
+ return; |
+ |
+ if (!last_committed_site_url_.is_empty()) { |
+ RenderProcessHostImpl::RemoveFrameWithSite( |
+ frame_tree_node_->navigator()->GetController()->GetBrowserContext(), |
+ GetProcess(), last_committed_site_url_); |
+ } |
+ |
+ last_committed_site_url_ = site_url; |
+ |
+ if (!last_committed_site_url_.is_empty()) { |
+ RenderProcessHostImpl::AddFrameWithSite( |
+ frame_tree_node_->navigator()->GetController()->GetBrowserContext(), |
+ GetProcess(), last_committed_site_url_); |
+ } |
+} |
+ |
#if defined(OS_ANDROID) |
class RenderFrameHostImpl::JavaInterfaceProvider |