summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-27 20:15:40 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-27 20:15:40 +0000
commitae23c272faf85d4cf779ae15d28fc59f5a8162ab (patch)
tree8c409202170b3cb9866b98d6e89185ba036323cf /chrome/browser/tab_contents
parentd138713180c3aea617f4c612deb164dfdb305751 (diff)
downloadchromium_src-ae23c272faf85d4cf779ae15d28fc59f5a8162ab.zip
chromium_src-ae23c272faf85d4cf779ae15d28fc59f5a8162ab.tar.gz
chromium_src-ae23c272faf85d4cf779ae15d28fc59f5a8162ab.tar.bz2
Re-landing r21673 without re-enabling the BrowserTest, which apparently is
still failing. Make downloads not prevent tabs from closing. If a download creates a cross-site transition (for example, if you click a link in Gmail that results in a download in a new tab), that tab will be stuck and you can't close it or the browser. This is the opposite problem with a similar cause as bug 16246. In both cases we were using some secondary signal to tell us if we're closing for a cross site transition or closing the tab, and that signal was wrong. In this case, we were running the onunload handler, but because there was a pending RenderViewHost, the RenderManager would think that the close was a cross-site one, and not forward the close message to actually close the tab. This patch adds a flag to the on unload handlers that indicates whether it's for a tab closure or a cross-site transition, so we can do the right thing unambiguously when the message returns. In this case I keep this information in the RenderView in case we send multiple close requests, we'll close the tab if any of them were for the entire tab, even if that particular one was dropped because we don't want to have more than one in flight at once. BUG=17560 TEST=none. Review URL: http://codereview.chromium.org/160122 Review URL: http://codereview.chromium.org/159426 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21685 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/render_view_host_manager.cc41
-rw-r--r--chrome/browser/tab_contents/render_view_host_manager.h2
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc4
-rw-r--r--chrome/browser/tab_contents/tab_contents.h1
4 files changed, 21 insertions, 27 deletions
diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc
index 4146f862..959db7f 100644
--- a/chrome/browser/tab_contents/render_view_host_manager.cc
+++ b/chrome/browser/tab_contents/render_view_host_manager.cc
@@ -211,33 +211,32 @@ void RenderViewHostManager::OnJavaScriptMessageBoxWindowDestroyed() {
render_view_host_->JavaScriptMessageBoxWindowDestroyed();
}
-void RenderViewHostManager::ShouldClosePage(bool proceed) {
- // Should only see this while we have a pending renderer. Otherwise, we
- // should ignore.
- if (!pending_render_view_host_) {
+void RenderViewHostManager::ShouldClosePage(bool for_cross_site_transition,
+ bool proceed) {
+ if (for_cross_site_transition) {
+ if (proceed) {
+ // Ok to unload the current page, so proceed with the cross-site
+ // navigation. Note that if navigations are not currently suspended, it
+ // might be because the renderer was deemed unresponsive and this call was
+ // already made by ShouldCloseTabOnUnresponsiveRenderer. In that case, it
+ // is ok to do nothing here.
+ if (pending_render_view_host_->are_navigations_suspended())
+ pending_render_view_host_->SetNavigationsSuspended(false);
+ } else {
+ // Current page says to cancel.
+ CancelPending();
+ cross_navigation_pending_ = false;
+ }
+ } else {
+ // Non-cross site transition means closing the entire tab.
bool proceed_to_fire_unload;
delegate_->BeforeUnloadFiredFromRenderManager(proceed,
&proceed_to_fire_unload);
if (proceed_to_fire_unload) {
// This is not a cross-site navigation, the tab is being closed.
- render_view_host_->ClosePage(true, -1, -1);
+ render_view_host_->ClosePage(false, -1, -1);
}
- return;
- }
-
- if (proceed) {
- // Ok to unload the current page, so proceed with the cross-site
- // navigation. Note that if navigations are not currently suspended, it
- // might be because the renderer was deemed unresponsive and this call was
- // already made by ShouldCloseTabOnUnresponsiveRenderer. In that case, it
- // is ok to do nothing here.
- if (pending_render_view_host_->are_navigations_suspended())
- pending_render_view_host_->SetNavigationsSuspended(false);
- } else {
- // Current page says to cancel.
- CancelPending();
- cross_navigation_pending_ = false;
}
}
@@ -567,7 +566,7 @@ RenderViewHost* RenderViewHostManager::UpdateRendererStateForNavigate(
// Tell the old render view to run its onbeforeunload handler, since it
// doesn't otherwise know that the cross-site request is happening. This
// will trigger a call to ShouldClosePage with the reply.
- render_view_host_->FirePageBeforeUnload();
+ render_view_host_->FirePageBeforeUnload(true);
return pending_render_view_host_;
} else {
diff --git a/chrome/browser/tab_contents/render_view_host_manager.h b/chrome/browser/tab_contents/render_view_host_manager.h
index 0b2460b..8c8dde2 100644
--- a/chrome/browser/tab_contents/render_view_host_manager.h
+++ b/chrome/browser/tab_contents/render_view_host_manager.h
@@ -160,7 +160,7 @@ class RenderViewHostManager
}
// RenderViewHostDelegate::RendererManagement implementation.
- virtual void ShouldClosePage(bool proceed);
+ virtual void ShouldClosePage(bool for_cross_site_transition, bool proceed);
virtual void OnCrossSiteResponse(int new_render_process_host_id,
int new_request_id);
virtual void OnCrossSiteNavigationCanceled();
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 9b5098f..4546161 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -2204,10 +2204,6 @@ void TabContents::OnJSOutOfMemory() {
this, l10n_util::GetString(IDS_JS_OUT_OF_MEMORY_PROMPT), NULL));
}
-void TabContents::ShouldClosePage(bool proceed) {
- render_manager_.ShouldClosePage(proceed);
-}
-
void TabContents::OnCrossSiteResponse(int new_render_process_host_id,
int new_request_id) {
// Allows the TabContents to react when a cross-site response is ready to be
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index fc6f76f..5d987a2 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -850,7 +850,6 @@ class TabContents : public PageNavigator,
virtual RendererPreferences GetRendererPrefs() const;
virtual WebPreferences GetWebkitPrefs();
virtual void OnJSOutOfMemory();
- virtual void ShouldClosePage(bool proceed);
virtual void OnCrossSiteResponse(int new_render_process_host_id,
int new_request_id);
virtual bool CanBlur() const;