summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents/render_view_host_manager.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-25 18:41:13 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-25 18:41:13 +0000
commitcbb79de5eaddb45e519332e09d6826d53448d54e (patch)
treecf94ca25162b770c9dc2220a7f979bc2167eef13 /chrome/browser/tab_contents/render_view_host_manager.cc
parentd043c2cccc2705908f2a3d39d404c8bf1a51c0de (diff)
downloadchromium_src-cbb79de5eaddb45e519332e09d6826d53448d54e.zip
chromium_src-cbb79de5eaddb45e519332e09d6826d53448d54e.tar.gz
chromium_src-cbb79de5eaddb45e519332e09d6826d53448d54e.tar.bz2
Reverting 12469.
Review URL: http://codereview.chromium.org/53062 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents/render_view_host_manager.cc')
-rw-r--r--chrome/browser/tab_contents/render_view_host_manager.cc66
1 files changed, 23 insertions, 43 deletions
diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc
index d22b052..d1f8259 100644
--- a/chrome/browser/tab_contents/render_view_host_manager.cc
+++ b/chrome/browser/tab_contents/render_view_host_manager.cc
@@ -6,7 +6,6 @@
#include "base/command_line.h"
#include "base/logging.h"
-#include "chrome/browser/dom_ui/dom_ui.h"
#include "chrome/browser/dom_ui/dom_ui_factory.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
@@ -58,7 +57,7 @@ void RenderViewHostManager::Init(Profile* profile,
void RenderViewHostManager::Shutdown() {
if (pending_render_view_host_)
- CancelPending();
+ CancelPendingRenderView();
// We should always have a main RenderViewHost.
RenderViewHost* render_view_host = render_view_host_;
@@ -67,15 +66,10 @@ void RenderViewHostManager::Shutdown() {
}
RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) {
- // Create a pending RenderViewHost. It will give us the one we should use
- RenderViewHost* dest_render_view_host = UpdateRendererStateForNavigate(entry);
+ RenderViewHost* dest_render_view_host = UpdateRendererStateNavigate(entry);
if (!dest_render_view_host)
return NULL; // We weren't able to create a pending render view host.
- // This will possibly create (set to NULL) a DOM UI object for the pending
- // page. We'll use this later to give the page special access.
- pending_dom_ui_.reset(delegate_->CreateDOMUIForRenderManager(entry.url()));
-
// If the current render_view_host_ isn't live, we should create it so
// that we don't show a sad tab while the dest_render_view_host fetches
// its first page. (Bug 1145340)
@@ -98,7 +92,7 @@ RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) {
dest_render_view_host->view()->Hide();
} else {
// This is our primary renderer, notify here as we won't be calling
- // CommitPending (which does the notify).
+ // SwapToRenderView (which does the notify).
RenderViewHostSwitchedDetails details;
details.new_host = render_view_host_;
details.old_host = NULL;
@@ -118,8 +112,10 @@ void RenderViewHostManager::Stop() {
// If we are cross-navigating, we should stop the pending renderers. This
// will lead to a DidFailProvisionalLoad, which will properly destroy them.
- if (cross_navigation_pending_)
+ if (cross_navigation_pending_) {
pending_render_view_host_->Stop();
+
+ }
}
void RenderViewHostManager::SetIsLoading(bool is_loading) {
@@ -161,25 +157,19 @@ bool RenderViewHostManager::ShouldCloseTabOnUnresponsiveRenderer() {
void RenderViewHostManager::DidNavigateMainFrame(
RenderViewHost* render_view_host) {
if (!cross_navigation_pending_) {
- DCHECK(!pending_render_view_host_);
-
// We should only hear this from our current renderer.
DCHECK(render_view_host == render_view_host_);
-
- // Even when there is no pending RVH, there may be a pending DOM UI.
- if (pending_dom_ui_.get())
- CommitPending();
return;
}
if (render_view_host == pending_render_view_host_) {
// The pending cross-site navigation completed, so show the renderer.
- CommitPending();
+ SwapToRenderView(&pending_render_view_host_, true);
cross_navigation_pending_ = false;
} else if (render_view_host == render_view_host_) {
// A navigation in the original page has taken place. Cancel the pending
// one.
- CancelPending();
+ CancelPendingRenderView();
cross_navigation_pending_ = false;
} else {
// No one else should be sending us DidNavigate in this state.
@@ -247,7 +237,7 @@ void RenderViewHostManager::ShouldClosePage(bool proceed) {
pending_render_view_host_->SetNavigationsSuspended(false);
} else {
// Current page says to cancel.
- CancelPending();
+ CancelPendingRenderView();
cross_navigation_pending_ = false;
}
}
@@ -407,7 +397,7 @@ bool RenderViewHostManager::CreatePendingRenderView(SiteInstance* instance) {
// Don't show the view until we get a DidNavigate from it.
pending_render_view_host_->view()->Hide();
} else {
- CancelPending();
+ CancelPendingRenderView();
}
return success;
}
@@ -425,17 +415,9 @@ RenderViewHost* RenderViewHostManager::CreateRenderViewHost(
}
}
-void RenderViewHostManager::CommitPending() {
- // First commit the DOM UI, if any.
- dom_ui_.swap(pending_dom_ui_);
- pending_dom_ui_.reset();
-
- // It's possible for the pending_render_view_host_ to be NULL when we aren't
- // crossing process boundaries. If so, we just needed to handle the DOM UI
- // committing above and we're done.
- if (!pending_render_view_host_)
- return;
-
+void RenderViewHostManager::SwapToRenderView(
+ RenderViewHost** new_render_view_host,
+ bool destroy_after) {
// Remember if the page was focused so we can focus the new renderer in
// that case.
bool focus_render_view = render_view_host_->view() &&
@@ -449,8 +431,8 @@ void RenderViewHostManager::CommitPending() {
RenderViewHost* old_render_view_host = render_view_host_;
// Swap in the pending view and make it active.
- render_view_host_ = pending_render_view_host_;
- pending_render_view_host_ = NULL;
+ render_view_host_ = (*new_render_view_host);
+ (*new_render_view_host) = NULL;
// If the view is gone, then this RenderViewHost died while it was hidden.
// We ignored the RenderViewGone call at the time, so we should send it now
@@ -474,20 +456,21 @@ void RenderViewHostManager::CommitPending() {
Source<NavigationController>(delegate_->GetControllerForRenderManager()),
Details<RenderViewHostSwitchedDetails>(&details));
- old_render_view_host->Shutdown();
+ if (destroy_after)
+ old_render_view_host->Shutdown();
// Let the task manager know that we've swapped RenderViewHosts, since it
// might need to update its process groupings.
delegate_->NotifySwappedFromRenderManager();
}
-RenderViewHost* RenderViewHostManager::UpdateRendererStateForNavigate(
+RenderViewHost* RenderViewHostManager::UpdateRendererStateNavigate(
const NavigationEntry& entry) {
// If we are cross-navigating, then we want to get back to normal and navigate
// as usual.
if (cross_navigation_pending_) {
if (pending_render_view_host_)
- CancelPending();
+ CancelPendingRenderView();
cross_navigation_pending_ = false;
}
@@ -502,8 +485,7 @@ RenderViewHost* RenderViewHostManager::UpdateRendererStateForNavigate(
if (ShouldTransitionCrossSite())
new_instance = GetSiteInstanceForEntry(entry, curr_instance);
- if (new_instance != curr_instance ||
- ShouldSwapRenderViewsForNavigation(
+ if (new_instance != curr_instance || ShouldSwapRenderViewsForNavigation(
delegate_->GetLastCommittedNavigationEntryForRenderManager(),
&entry)) {
// New SiteInstance.
@@ -522,7 +504,7 @@ RenderViewHost* RenderViewHostManager::UpdateRendererStateForNavigate(
// navigate. Just switch to the pending RVH now and go back to non
// cross-navigating (Note that we don't care about on{before}unload
// handlers if the current RVH isn't live.)
- CommitPending();
+ SwapToRenderView(&pending_render_view_host_, true);
return render_view_host_;
} else {
NOTREACHED();
@@ -564,17 +546,15 @@ RenderViewHost* RenderViewHostManager::UpdateRendererStateForNavigate(
return render_view_host_;
}
-void RenderViewHostManager::CancelPending() {
+void RenderViewHostManager::CancelPendingRenderView() {
RenderViewHost* pending_render_view_host = pending_render_view_host_;
pending_render_view_host_ = NULL;
pending_render_view_host->Shutdown();
-
- pending_dom_ui_.reset();
}
void RenderViewHostManager::CrossSiteNavigationCanceled() {
DCHECK(cross_navigation_pending_);
cross_navigation_pending_ = false;
if (pending_render_view_host_)
- CancelPending();
+ CancelPendingRenderView();
}