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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 950223006: Fix RenderFrameHostChanged WebContentsObserver methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes based on Charlie's review. Created 5 years, 10 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/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 8dad3e7904accddb5d06e94501e0e4fc02ede46d..e4d419835e472498ba0156e98042035a81746d48 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1269,6 +1269,13 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
RenderViewCreated(GetRenderViewHost());
GetRenderManager()->current_frame_host()->SetRenderFrameCreated(true);
}
+
+ // Ensure that observers are notified of the creation of this WebContents's
+ // main RenderFrameHost. It must be done here for main frames, since the
+ // NotifySwappedFromRenderManager expects view_ to already be created and that
+ // happens after RenderFrameHostManager::Init.
+ NotifySwappedFromRenderManager(
+ nullptr, GetRenderManager()->current_frame_host(), true);
}
void WebContentsImpl::OnWebContentsDestroyed(WebContentsImpl* web_contents) {
@@ -4181,7 +4188,7 @@ void WebContentsImpl::NotifySwappedFromRenderManager(RenderFrameHost* old_host,
RenderFrameHost* new_host,
bool is_main_frame) {
if (is_main_frame) {
- NotifyViewSwapped(old_host ? old_host->GetRenderViewHost() : NULL,
+ NotifyViewSwapped(old_host ? old_host->GetRenderViewHost() : nullptr,
new_host->GetRenderViewHost());
// Make sure the visible RVH reflects the new delegate's preferences.
@@ -4194,6 +4201,12 @@ void WebContentsImpl::NotifySwappedFromRenderManager(RenderFrameHost* old_host,
NotifyFrameSwapped(old_host, new_host);
}
+void WebContentsImpl::NotifyMainFrameSwappedFromRenderManager(
+ RenderViewHost* old_host,
+ RenderViewHost* new_host) {
+ NotifyViewSwapped(old_host, new_host);
+}
+
int WebContentsImpl::CreateOpenerRenderViewsForRenderManager(
SiteInstance* instance) {
if (!opener_)
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/public/test/web_contents_observer_sanity_checker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698