summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoshia@google.com <joshia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-12 23:03:08 +0000
committerjoshia@google.com <joshia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-12 23:03:08 +0000
commit0a23f974cde41d8375a77d7af3fe32b8435fa4e4 (patch)
treee52e91a1fd5df20bfc056a5af53ea574f5ec969e
parent41949fc0cedfa009608d11d430f126ac47741f45 (diff)
downloadchromium_src-0a23f974cde41d8375a77d7af3fe32b8435fa4e4.zip
chromium_src-0a23f974cde41d8375a77d7af3fe32b8435fa4e4.tar.gz
chromium_src-0a23f974cde41d8375a77d7af3fe32b8435fa4e4.tar.bz2
On exit do not terminate renderers hosted in external tabs
When a browser window is closed, we just terminate all existing renderers for fast shutdown. If we have any renderers hosted externally using automation they are also killed during this process. The fix is to prevent fast termination if any of the tabs are hosted by automation. Review URL: http://codereview.chromium.org/17453 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7901 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/external_tab_container.h2
-rw-r--r--chrome/browser/render_process_host.cc2
-rw-r--r--chrome/browser/render_view_host.cc7
-rw-r--r--chrome/browser/render_view_host.h3
-rw-r--r--chrome/browser/render_view_host_delegate.h3
-rw-r--r--chrome/browser/tab_contents_delegate.h3
-rw-r--r--chrome/browser/web_contents.cc4
-rw-r--r--chrome/browser/web_contents.h2
8 files changed, 24 insertions, 2 deletions
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index 17be9b2..bd9ab4c 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -77,7 +77,7 @@ class ExternalTabContainer : public TabContentsDelegate,
virtual void ToolbarSizeChanged(TabContents* source, bool is_animating);
virtual void ForwardMessageToExternalHost(const std::string& receiver,
const std::string& message);
-
+ virtual bool IsExternalTabContainer() const { return true; };
// Notification service callback.
virtual void Observe(NotificationType type,
diff --git a/chrome/browser/render_process_host.cc b/chrome/browser/render_process_host.cc
index f3a2e88..4adaff1 100644
--- a/chrome/browser/render_process_host.cc
+++ b/chrome/browser/render_process_host.cc
@@ -546,7 +546,7 @@ bool RenderProcessHost::FastShutdownIfPossible() {
if (!widget || !widget->IsRenderView())
continue;
RenderViewHost* rvh = static_cast<RenderViewHost*>(widget);
- if (rvh->HasUnloadListener()) {
+ if (!rvh->CanTerminate()) {
// NOTE: It's possible that an onunload listener may be installed
// while we're shutting down, so there's a small race here. Given that
// the window is small, it's unlikely that the web page has much
diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc
index e20f489..0d43757 100644
--- a/chrome/browser/render_view_host.cc
+++ b/chrome/browser/render_view_host.cc
@@ -608,6 +608,13 @@ void RenderViewHost::LoadStateChanged(const GURL& url,
delegate_->LoadStateChanged(url, load_state);
}
+bool RenderViewHost::CanTerminate() const {
+ if (!delegate_->CanTerminate())
+ return false;
+
+ return has_unload_listener_;
+}
+
///////////////////////////////////////////////////////////////////////////////
// RenderViewHost, IPC message handlers:
diff --git a/chrome/browser/render_view_host.h b/chrome/browser/render_view_host.h
index a3c8683..0dec873 100644
--- a/chrome/browser/render_view_host.h
+++ b/chrome/browser/render_view_host.h
@@ -371,6 +371,9 @@ class RenderViewHost : public RenderWidgetHost {
// Does the associated view have an onunload or onbeforeunload handler?
bool HasUnloadListener() { return has_unload_listener_; }
+ // If the associated view can be terminated without any side effects
+ bool CanTerminate() const;
+
// Clears the has_unload_listener_ bit since the unload handler has fired
// and we're necessarily leaving the page.
void UnloadListenerHasFired() { has_unload_listener_ = false; }
diff --git a/chrome/browser/render_view_host_delegate.h b/chrome/browser/render_view_host_delegate.h
index 35e8770..91cc531 100644
--- a/chrome/browser/render_view_host_delegate.h
+++ b/chrome/browser/render_view_host_delegate.h
@@ -377,6 +377,9 @@ class RenderViewHostDelegate {
// page. This is used to avoid uninitiated user downloads (aka carpet
// bombing), see DownloadRequestManager for details.
virtual void OnEnterOrSpace() { }
+
+ // If this view can be terminated without any side effects
+ virtual bool CanTerminate() const { return true; }
};
#endif // CHROME_BROWSER_RENDER_VIEW_HOST_DELEGATE_H__
diff --git a/chrome/browser/tab_contents_delegate.h b/chrome/browser/tab_contents_delegate.h
index c845dec..58cf471 100644
--- a/chrome/browser/tab_contents_delegate.h
+++ b/chrome/browser/tab_contents_delegate.h
@@ -142,6 +142,9 @@ class TabContentsDelegate : public PageNavigator {
// Send IPC to external host. Default implementation is do nothing.
virtual void ForwardMessageToExternalHost(const std::string& receiver,
const std::string& message) {};
+
+ // If the delegate is hosting tabs externally.
+ virtual bool IsExternalTabContainer() const { return false; }
};
#endif // CHROME_BROWSER_TAB_CONTENTS_DELEGATE_H_
diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc
index c40ec7d..3b5b66e 100644
--- a/chrome/browser/web_contents.cc
+++ b/chrome/browser/web_contents.cc
@@ -1341,6 +1341,10 @@ void WebContents::OnEnterOrSpace() {
drm->OnUserGesture(this);
}
+bool WebContents::CanTerminate() const {
+ return !delegate()->IsExternalTabContainer();
+}
+
void WebContents::FileSelected(const std::wstring& path, void* params) {
render_view_host()->FileSelected(path);
}
diff --git a/chrome/browser/web_contents.h b/chrome/browser/web_contents.h
index 0001b3f..b7bb356 100644
--- a/chrome/browser/web_contents.h
+++ b/chrome/browser/web_contents.h
@@ -314,6 +314,8 @@ class WebContents : public TabContents,
int32 page_id,
const webkit_glue::WebApplicationInfo& info);
virtual void OnEnterOrSpace();
+ virtual bool CanTerminate() const;
+
// SelectFileDialog::Listener ------------------------------------------------