diff options
-rw-r--r-- | chrome/browser/external_tab_container.h | 2 | ||||
-rw-r--r-- | chrome/browser/render_process_host.cc | 2 | ||||
-rw-r--r-- | chrome/browser/render_view_host.cc | 7 | ||||
-rw-r--r-- | chrome/browser/render_view_host.h | 3 | ||||
-rw-r--r-- | chrome/browser/render_view_host_delegate.h | 3 | ||||
-rw-r--r-- | chrome/browser/tab_contents_delegate.h | 3 | ||||
-rw-r--r-- | chrome/browser/web_contents.cc | 4 | ||||
-rw-r--r-- | chrome/browser/web_contents.h | 2 |
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 ------------------------------------------------ |