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

Unified Diff: content/browser/tab_contents/tab_contents.cc

Issue 6319001: Support window.opener after a process swap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unload; chrome dependency in RenderWidget. Created 9 years, 8 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/tab_contents/tab_contents.cc
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 4119f0f22b2fbe09950f2b64a65705a2eda15241..2f0a6469204fa9ea20ccd70e4be655c0cf94838e 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -111,14 +111,17 @@
// - After RDH receives a response and determines that it is safe and not a
// download, it pauses the response to first run the old page's onunload
// handler. It does this by asynchronously calling the OnCrossSiteResponse
-// method of TabContents on the UI thread, which sends a ClosePage message
+// method of TabContents on the UI thread, which sends a SwapOut message
// to the current RVH.
-// - Once the onunload handler is finished, a ClosePage_ACK message is sent to
+// - Once the onunload handler is finished, a SwapOut_ACK message is sent to
// the ResourceDispatcherHost, who unpauses the response. Data is then sent
// to the pending RVH.
// - The pending renderer sends a FrameNavigate message that invokes the
// DidNavigate method. This replaces the current RVH with the
// pending RVH and goes back to the NORMAL RendererState.
+// - The previous renderer is kept swapped out in RenderViewHostManager in case
+// the user goes back. The process only stays live if another tab is using
+// it, but if so, the existing frame relationships will be maintained.
namespace {
@@ -259,6 +262,8 @@ TabContents::TabContents(Profile* profile,
pref_change_registrar_.Add(kPrefsToObserve[i], this);
}
+ registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSING,
+ NotificationService::AllSources());
registrar_.Add(this, NotificationType::RENDER_WIDGET_HOST_DESTROYED,
NotificationService::AllSources());
#if defined(OS_LINUX)
@@ -1702,7 +1707,9 @@ void TabContents::DidNavigate(RenderViewHost* rvh,
void TabContents::UpdateState(RenderViewHost* rvh,
int32 page_id,
const std::string& state) {
- DCHECK(rvh == render_view_host());
+ // Ensure that this state update comes from either the active RVH or one of
+ // the swapped out RVHs. We don't expect to hear from any other RVHs.
+ DCHECK(rvh == render_view_host() || render_manager_.IsSwappedOut(rvh));
// We must be prepared to handle state updates for any page, these occur
// when the user is scrolling and entering form data, as well as when we're
@@ -1711,7 +1718,7 @@ void TabContents::UpdateState(RenderViewHost* rvh,
// NavigationEntry and update it when it is notified via the delegate.
int entry_index = controller_.GetEntryIndexWithPageID(
- GetSiteInstance(), page_id);
+ rvh->site_instance(), page_id);
if (entry_index < 0)
return;
NavigationEntry* entry = controller_.GetEntryAtIndex(entry_index);
@@ -1873,6 +1880,7 @@ void TabContents::ProcessExternalHostMessage(const std::string& message,
}
void TabContents::RunJavaScriptMessage(
+ const RenderViewHost* rvh,
const std::wstring& message,
const std::wstring& default_prompt,
const GURL& frame_url,
@@ -1886,6 +1894,7 @@ void TabContents::RunJavaScriptMessage(
// shown over the previous page, we don't want the hidden page dialogs to
// interfere with the interstitial.
bool suppress_this_message =
+ rvh->is_swapped_out() ||
suppress_javascript_messages_ ||
showing_interstitial_page() ||
(delegate() && delegate()->ShouldSuppressDialogs());
@@ -1915,11 +1924,14 @@ void TabContents::RunJavaScriptMessage(
}
}
-void TabContents::RunBeforeUnloadConfirm(const std::wstring& message,
+void TabContents::RunBeforeUnloadConfirm(const RenderViewHost* rvh,
+ const std::wstring& message,
IPC::Message* reply_msg) {
if (delegate())
delegate()->WillRunBeforeUnloadConfirm();
- if (delegate() && delegate()->ShouldSuppressDialogs()) {
+ bool suppress_this_message = rvh->is_swapped_out() ||
+ (delegate() && delegate()->ShouldSuppressDialogs());
+ if (suppress_this_message) {
render_view_host()->JavaScriptMessageBoxClosed(reply_msg, true,
std::wstring());
return;
@@ -1983,6 +1995,10 @@ void TabContents::OnCrossSiteResponse(int new_render_process_host_id,
void TabContents::RendererUnresponsive(RenderViewHost* rvh,
bool is_during_unload) {
+ // Don't show hung renderer dialog for a swapped out RVH.
+ if (rvh != render_view_host())
+ return;
+
if (is_during_unload) {
// Hang occurred while firing the beforeunload/unload handler.
// Pretend the handler fired so tab closing continues as if it had.
@@ -2148,6 +2164,11 @@ void TabContents::Observe(NotificationType type,
}
break;
}
+ case NotificationType::RENDERER_PROCESS_CLOSING:
+ render_manager_.RendererProcessClosing(
+ Source<RenderProcessHost>(source).ptr());
+ break;
+
case NotificationType::RENDER_WIDGET_HOST_DESTROYED:
view_->RenderWidgetHostDestroyed(Source<RenderWidgetHost>(source).ptr());
break;

Powered by Google App Engine
This is Rietveld 408576698