| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/tab_contents/render_view_host_manager.h" | 5 #include "chrome/browser/tab_contents/render_view_host_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/dom_ui/dom_ui.h" |
| 9 #include "chrome/browser/dom_ui/dom_ui_factory.h" | 10 #include "chrome/browser/dom_ui/dom_ui_factory.h" |
| 10 #include "chrome/browser/renderer_host/render_view_host.h" | 11 #include "chrome/browser/renderer_host/render_view_host.h" |
| 11 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 12 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 12 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 13 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 13 #include "chrome/browser/tab_contents/navigation_controller.h" | 14 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 14 #include "chrome/browser/tab_contents/navigation_entry.h" | 15 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 15 #include "chrome/browser/tab_contents/site_instance.h" | 16 #include "chrome/browser/tab_contents/site_instance.h" |
| 16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/common/notification_service.h" | 18 #include "chrome/common/notification_service.h" |
| 18 #include "chrome/common/notification_type.h" | 19 #include "chrome/common/notification_type.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 // immediately give this SiteInstance to a RenderViewHost so that it is | 51 // immediately give this SiteInstance to a RenderViewHost so that it is |
| 51 // ref counted. | 52 // ref counted. |
| 52 if (!site_instance) | 53 if (!site_instance) |
| 53 site_instance = SiteInstance::CreateSiteInstance(profile); | 54 site_instance = SiteInstance::CreateSiteInstance(profile); |
| 54 render_view_host_ = CreateRenderViewHost( | 55 render_view_host_ = CreateRenderViewHost( |
| 55 site_instance, routing_id, modal_dialog_event); | 56 site_instance, routing_id, modal_dialog_event); |
| 56 } | 57 } |
| 57 | 58 |
| 58 void RenderViewHostManager::Shutdown() { | 59 void RenderViewHostManager::Shutdown() { |
| 59 if (pending_render_view_host_) | 60 if (pending_render_view_host_) |
| 60 CancelPendingRenderView(); | 61 CancelPending(); |
| 61 | 62 |
| 62 // We should always have a main RenderViewHost. | 63 // We should always have a main RenderViewHost. |
| 63 RenderViewHost* render_view_host = render_view_host_; | 64 RenderViewHost* render_view_host = render_view_host_; |
| 64 render_view_host_ = NULL; | 65 render_view_host_ = NULL; |
| 65 render_view_host->Shutdown(); | 66 render_view_host->Shutdown(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) { | 69 RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) { |
| 69 RenderViewHost* dest_render_view_host = UpdateRendererStateNavigate(entry); | 70 // This will possibly create (set to NULL) a DOM UI object for the pending |
| 71 // page. We'll use this later to give the page special access. This must |
| 72 // happen before the new renderer is created below so it will get bindings. |
| 73 pending_dom_ui_.reset(delegate_->CreateDOMUIForRenderManager(entry.url())); |
| 74 |
| 75 // Create a pending RenderViewHost. It will give us the one we should use |
| 76 RenderViewHost* dest_render_view_host = UpdateRendererStateForNavigate(entry); |
| 70 if (!dest_render_view_host) | 77 if (!dest_render_view_host) |
| 71 return NULL; // We weren't able to create a pending render view host. | 78 return NULL; // We weren't able to create a pending render view host. |
| 72 | 79 |
| 73 // If the current render_view_host_ isn't live, we should create it so | 80 // If the current render_view_host_ isn't live, we should create it so |
| 74 // that we don't show a sad tab while the dest_render_view_host fetches | 81 // that we don't show a sad tab while the dest_render_view_host fetches |
| 75 // its first page. (Bug 1145340) | 82 // its first page. (Bug 1145340) |
| 76 if (dest_render_view_host != render_view_host_ && | 83 if (dest_render_view_host != render_view_host_ && |
| 77 !render_view_host_->IsRenderViewLive()) { | 84 !render_view_host_->IsRenderViewLive()) { |
| 78 delegate_->CreateRenderViewForRenderManager(render_view_host_); | 85 delegate_->CreateRenderViewForRenderManager(render_view_host_); |
| 79 } | 86 } |
| 80 | 87 |
| 81 // If the renderer crashed, then try to create a new one to satisfy this | 88 // If the renderer crashed, then try to create a new one to satisfy this |
| 82 // navigation request. | 89 // navigation request. |
| 83 if (!dest_render_view_host->IsRenderViewLive()) { | 90 if (!dest_render_view_host->IsRenderViewLive()) { |
| 84 if (!delegate_->CreateRenderViewForRenderManager(dest_render_view_host)) | 91 if (!delegate_->CreateRenderViewForRenderManager(dest_render_view_host)) |
| 85 return NULL; | 92 return NULL; |
| 86 | 93 |
| 87 // Now that we've created a new renderer, be sure to hide it if it isn't | 94 // Now that we've created a new renderer, be sure to hide it if it isn't |
| 88 // our primary one. Otherwise, we might crash if we try to call Show() | 95 // our primary one. Otherwise, we might crash if we try to call Show() |
| 89 // on it later. | 96 // on it later. |
| 90 if (dest_render_view_host != render_view_host_ && | 97 if (dest_render_view_host != render_view_host_ && |
| 91 dest_render_view_host->view()) { | 98 dest_render_view_host->view()) { |
| 92 dest_render_view_host->view()->Hide(); | 99 dest_render_view_host->view()->Hide(); |
| 93 } else { | 100 } else { |
| 94 // This is our primary renderer, notify here as we won't be calling | 101 // This is our primary renderer, notify here as we won't be calling |
| 95 // SwapToRenderView (which does the notify). | 102 // CommitPending (which does the notify). |
| 96 RenderViewHostSwitchedDetails details; | 103 RenderViewHostSwitchedDetails details; |
| 97 details.new_host = render_view_host_; | 104 details.new_host = render_view_host_; |
| 98 details.old_host = NULL; | 105 details.old_host = NULL; |
| 99 NotificationService::current()->Notify( | 106 NotificationService::current()->Notify( |
| 100 NotificationType::RENDER_VIEW_HOST_CHANGED, | 107 NotificationType::RENDER_VIEW_HOST_CHANGED, |
| 101 Source<NavigationController>( | 108 Source<NavigationController>( |
| 102 delegate_->GetControllerForRenderManager()), | 109 delegate_->GetControllerForRenderManager()), |
| 103 Details<RenderViewHostSwitchedDetails>(&details)); | 110 Details<RenderViewHostSwitchedDetails>(&details)); |
| 104 } | 111 } |
| 105 } | 112 } |
| 106 | 113 |
| 107 return dest_render_view_host; | 114 return dest_render_view_host; |
| 108 } | 115 } |
| 109 | 116 |
| 110 void RenderViewHostManager::Stop() { | 117 void RenderViewHostManager::Stop() { |
| 111 render_view_host_->Stop(); | 118 render_view_host_->Stop(); |
| 112 | 119 |
| 113 // If we are cross-navigating, we should stop the pending renderers. This | 120 // If we are cross-navigating, we should stop the pending renderers. This |
| 114 // will lead to a DidFailProvisionalLoad, which will properly destroy them. | 121 // will lead to a DidFailProvisionalLoad, which will properly destroy them. |
| 115 if (cross_navigation_pending_) { | 122 if (cross_navigation_pending_) |
| 116 pending_render_view_host_->Stop(); | 123 pending_render_view_host_->Stop(); |
| 117 | |
| 118 } | |
| 119 } | 124 } |
| 120 | 125 |
| 121 void RenderViewHostManager::SetIsLoading(bool is_loading) { | 126 void RenderViewHostManager::SetIsLoading(bool is_loading) { |
| 122 render_view_host_->SetIsLoading(is_loading); | 127 render_view_host_->SetIsLoading(is_loading); |
| 123 if (pending_render_view_host_) | 128 if (pending_render_view_host_) |
| 124 pending_render_view_host_->SetIsLoading(is_loading); | 129 pending_render_view_host_->SetIsLoading(is_loading); |
| 125 } | 130 } |
| 126 | 131 |
| 127 bool RenderViewHostManager::ShouldCloseTabOnUnresponsiveRenderer() { | 132 bool RenderViewHostManager::ShouldCloseTabOnUnresponsiveRenderer() { |
| 128 if (!cross_navigation_pending_) | 133 if (!cross_navigation_pending_) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 150 // CrossSiteResourceHandler will already be cleaned up.) | 155 // CrossSiteResourceHandler will already be cleaned up.) |
| 151 current_host()->process()->CrossSiteClosePageACK( | 156 current_host()->process()->CrossSiteClosePageACK( |
| 152 pending_render_view_host_->process()->pid(), pending_request_id); | 157 pending_render_view_host_->process()->pid(), pending_request_id); |
| 153 } | 158 } |
| 154 return false; | 159 return false; |
| 155 } | 160 } |
| 156 | 161 |
| 157 void RenderViewHostManager::DidNavigateMainFrame( | 162 void RenderViewHostManager::DidNavigateMainFrame( |
| 158 RenderViewHost* render_view_host) { | 163 RenderViewHost* render_view_host) { |
| 159 if (!cross_navigation_pending_) { | 164 if (!cross_navigation_pending_) { |
| 165 DCHECK(!pending_render_view_host_); |
| 166 |
| 160 // We should only hear this from our current renderer. | 167 // We should only hear this from our current renderer. |
| 161 DCHECK(render_view_host == render_view_host_); | 168 DCHECK(render_view_host == render_view_host_); |
| 169 |
| 170 // Even when there is no pending RVH, there may be a pending DOM UI. |
| 171 if (pending_dom_ui_.get()) |
| 172 CommitPending(); |
| 162 return; | 173 return; |
| 163 } | 174 } |
| 164 | 175 |
| 165 if (render_view_host == pending_render_view_host_) { | 176 if (render_view_host == pending_render_view_host_) { |
| 166 // The pending cross-site navigation completed, so show the renderer. | 177 // The pending cross-site navigation completed, so show the renderer. |
| 167 SwapToRenderView(&pending_render_view_host_, true); | 178 CommitPending(); |
| 168 cross_navigation_pending_ = false; | 179 cross_navigation_pending_ = false; |
| 169 } else if (render_view_host == render_view_host_) { | 180 } else if (render_view_host == render_view_host_) { |
| 170 // A navigation in the original page has taken place. Cancel the pending | 181 // A navigation in the original page has taken place. Cancel the pending |
| 171 // one. | 182 // one. |
| 172 CancelPendingRenderView(); | 183 CancelPending(); |
| 173 cross_navigation_pending_ = false; | 184 cross_navigation_pending_ = false; |
| 174 } else { | 185 } else { |
| 175 // No one else should be sending us DidNavigate in this state. | 186 // No one else should be sending us DidNavigate in this state. |
| 176 DCHECK(false); | 187 DCHECK(false); |
| 177 } | 188 } |
| 178 } | 189 } |
| 179 | 190 |
| 180 void RenderViewHostManager::OnCrossSiteResponse(int new_render_process_host_id, | 191 void RenderViewHostManager::OnCrossSiteResponse(int new_render_process_host_id, |
| 181 int new_request_id) { | 192 int new_request_id) { |
| 182 // Should only see this while we have a pending renderer. | 193 // Should only see this while we have a pending renderer. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 if (proceed) { | 241 if (proceed) { |
| 231 // Ok to unload the current page, so proceed with the cross-site | 242 // Ok to unload the current page, so proceed with the cross-site |
| 232 // navigation. Note that if navigations are not currently suspended, it | 243 // navigation. Note that if navigations are not currently suspended, it |
| 233 // might be because the renderer was deemed unresponsive and this call was | 244 // might be because the renderer was deemed unresponsive and this call was |
| 234 // already made by ShouldCloseTabOnUnresponsiveRenderer. In that case, it | 245 // already made by ShouldCloseTabOnUnresponsiveRenderer. In that case, it |
| 235 // is ok to do nothing here. | 246 // is ok to do nothing here. |
| 236 if (pending_render_view_host_->are_navigations_suspended()) | 247 if (pending_render_view_host_->are_navigations_suspended()) |
| 237 pending_render_view_host_->SetNavigationsSuspended(false); | 248 pending_render_view_host_->SetNavigationsSuspended(false); |
| 238 } else { | 249 } else { |
| 239 // Current page says to cancel. | 250 // Current page says to cancel. |
| 240 CancelPendingRenderView(); | 251 CancelPending(); |
| 241 cross_navigation_pending_ = false; | 252 cross_navigation_pending_ = false; |
| 242 } | 253 } |
| 243 } | 254 } |
| 244 | 255 |
| 245 void RenderViewHostManager::OnJavaScriptMessageBoxClosed( | 256 void RenderViewHostManager::OnJavaScriptMessageBoxClosed( |
| 246 IPC::Message* reply_msg, | 257 IPC::Message* reply_msg, |
| 247 bool success, | 258 bool success, |
| 248 const std::wstring& prompt) { | 259 const std::wstring& prompt) { |
| 249 render_view_host_->JavaScriptMessageBoxClosed(reply_msg, success, prompt); | 260 render_view_host_->JavaScriptMessageBoxClosed(reply_msg, success, prompt); |
| 250 } | 261 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 401 |
| 391 pending_render_view_host_ = | 402 pending_render_view_host_ = |
| 392 CreateRenderViewHost(instance, MSG_ROUTING_NONE, NULL); | 403 CreateRenderViewHost(instance, MSG_ROUTING_NONE, NULL); |
| 393 | 404 |
| 394 bool success = delegate_->CreateRenderViewForRenderManager( | 405 bool success = delegate_->CreateRenderViewForRenderManager( |
| 395 pending_render_view_host_); | 406 pending_render_view_host_); |
| 396 if (success) { | 407 if (success) { |
| 397 // Don't show the view until we get a DidNavigate from it. | 408 // Don't show the view until we get a DidNavigate from it. |
| 398 pending_render_view_host_->view()->Hide(); | 409 pending_render_view_host_->view()->Hide(); |
| 399 } else { | 410 } else { |
| 400 CancelPendingRenderView(); | 411 CancelPending(); |
| 401 } | 412 } |
| 402 return success; | 413 return success; |
| 403 } | 414 } |
| 404 | 415 |
| 405 RenderViewHost* RenderViewHostManager::CreateRenderViewHost( | 416 RenderViewHost* RenderViewHostManager::CreateRenderViewHost( |
| 406 SiteInstance* instance, | 417 SiteInstance* instance, |
| 407 int routing_id, | 418 int routing_id, |
| 408 base::WaitableEvent* modal_dialog_event) { | 419 base::WaitableEvent* modal_dialog_event) { |
| 409 if (render_view_factory_) { | 420 if (render_view_factory_) { |
| 410 return render_view_factory_->CreateRenderViewHost( | 421 return render_view_factory_->CreateRenderViewHost( |
| 411 instance, render_view_delegate_, routing_id, modal_dialog_event); | 422 instance, render_view_delegate_, routing_id, modal_dialog_event); |
| 412 } else { | 423 } else { |
| 413 return new RenderViewHost(instance, render_view_delegate_, routing_id, | 424 return new RenderViewHost(instance, render_view_delegate_, routing_id, |
| 414 modal_dialog_event); | 425 modal_dialog_event); |
| 415 } | 426 } |
| 416 } | 427 } |
| 417 | 428 |
| 418 void RenderViewHostManager::SwapToRenderView( | 429 void RenderViewHostManager::CommitPending() { |
| 419 RenderViewHost** new_render_view_host, | 430 // First commit the DOM UI, if any. |
| 420 bool destroy_after) { | 431 dom_ui_.swap(pending_dom_ui_); |
| 432 pending_dom_ui_.reset(); |
| 433 |
| 434 // It's possible for the pending_render_view_host_ to be NULL when we aren't |
| 435 // crossing process boundaries. If so, we just needed to handle the DOM UI |
| 436 // committing above and we're done. |
| 437 if (!pending_render_view_host_) |
| 438 return; |
| 439 |
| 421 // Remember if the page was focused so we can focus the new renderer in | 440 // Remember if the page was focused so we can focus the new renderer in |
| 422 // that case. | 441 // that case. |
| 423 bool focus_render_view = render_view_host_->view() && | 442 bool focus_render_view = render_view_host_->view() && |
| 424 render_view_host_->view()->HasFocus(); | 443 render_view_host_->view()->HasFocus(); |
| 425 | 444 |
| 426 // Hide the current view and prepare to destroy it. | 445 // Hide the current view and prepare to destroy it. |
| 427 // TODO(creis): Get the old RenderViewHost to send us an UpdateState message | 446 // TODO(creis): Get the old RenderViewHost to send us an UpdateState message |
| 428 // before we destroy it. | 447 // before we destroy it. |
| 429 if (render_view_host_->view()) | 448 if (render_view_host_->view()) |
| 430 render_view_host_->view()->Hide(); | 449 render_view_host_->view()->Hide(); |
| 431 RenderViewHost* old_render_view_host = render_view_host_; | 450 RenderViewHost* old_render_view_host = render_view_host_; |
| 432 | 451 |
| 433 // Swap in the pending view and make it active. | 452 // Swap in the pending view and make it active. |
| 434 render_view_host_ = (*new_render_view_host); | 453 render_view_host_ = pending_render_view_host_; |
| 435 (*new_render_view_host) = NULL; | 454 pending_render_view_host_ = NULL; |
| 436 | 455 |
| 437 // If the view is gone, then this RenderViewHost died while it was hidden. | 456 // If the view is gone, then this RenderViewHost died while it was hidden. |
| 438 // We ignored the RenderViewGone call at the time, so we should send it now | 457 // We ignored the RenderViewGone call at the time, so we should send it now |
| 439 // to make sure the sad tab shows up, etc. | 458 // to make sure the sad tab shows up, etc. |
| 440 if (render_view_host_->view()) | 459 if (render_view_host_->view()) |
| 441 render_view_host_->view()->Show(); | 460 render_view_host_->view()->Show(); |
| 442 else | 461 else |
| 443 delegate_->RenderViewGoneFromRenderManager(render_view_host_); | 462 delegate_->RenderViewGoneFromRenderManager(render_view_host_); |
| 444 | 463 |
| 445 // Make sure the size is up to date. (Fix for bug 1079768.) | 464 // Make sure the size is up to date. (Fix for bug 1079768.) |
| 446 delegate_->UpdateRenderViewSizeForRenderManager(); | 465 delegate_->UpdateRenderViewSizeForRenderManager(); |
| 447 | 466 |
| 448 if (focus_render_view && render_view_host_->view()) | 467 if (focus_render_view && render_view_host_->view()) |
| 449 render_view_host_->view()->Focus(); | 468 render_view_host_->view()->Focus(); |
| 450 | 469 |
| 451 RenderViewHostSwitchedDetails details; | 470 RenderViewHostSwitchedDetails details; |
| 452 details.new_host = render_view_host_; | 471 details.new_host = render_view_host_; |
| 453 details.old_host = old_render_view_host; | 472 details.old_host = old_render_view_host; |
| 454 NotificationService::current()->Notify( | 473 NotificationService::current()->Notify( |
| 455 NotificationType::RENDER_VIEW_HOST_CHANGED, | 474 NotificationType::RENDER_VIEW_HOST_CHANGED, |
| 456 Source<NavigationController>(delegate_->GetControllerForRenderManager()), | 475 Source<NavigationController>(delegate_->GetControllerForRenderManager()), |
| 457 Details<RenderViewHostSwitchedDetails>(&details)); | 476 Details<RenderViewHostSwitchedDetails>(&details)); |
| 458 | 477 |
| 459 if (destroy_after) | 478 old_render_view_host->Shutdown(); |
| 460 old_render_view_host->Shutdown(); | |
| 461 | 479 |
| 462 // Let the task manager know that we've swapped RenderViewHosts, since it | 480 // Let the task manager know that we've swapped RenderViewHosts, since it |
| 463 // might need to update its process groupings. | 481 // might need to update its process groupings. |
| 464 delegate_->NotifySwappedFromRenderManager(); | 482 delegate_->NotifySwappedFromRenderManager(); |
| 465 } | 483 } |
| 466 | 484 |
| 467 RenderViewHost* RenderViewHostManager::UpdateRendererStateNavigate( | 485 RenderViewHost* RenderViewHostManager::UpdateRendererStateForNavigate( |
| 468 const NavigationEntry& entry) { | 486 const NavigationEntry& entry) { |
| 469 // If we are cross-navigating, then we want to get back to normal and navigate | 487 // If we are cross-navigating, then we want to get back to normal and navigate |
| 470 // as usual. | 488 // as usual. |
| 471 if (cross_navigation_pending_) { | 489 if (cross_navigation_pending_) { |
| 472 if (pending_render_view_host_) | 490 if (pending_render_view_host_) |
| 473 CancelPendingRenderView(); | 491 CancelPending(); |
| 474 cross_navigation_pending_ = false; | 492 cross_navigation_pending_ = false; |
| 475 } | 493 } |
| 476 | 494 |
| 477 // render_view_host_ will not be deleted before the end of this method, so we | 495 // render_view_host_ will not be deleted before the end of this method, so we |
| 478 // don't have to worry about this SiteInstance's ref count dropping to zero. | 496 // don't have to worry about this SiteInstance's ref count dropping to zero. |
| 479 SiteInstance* curr_instance = render_view_host_->site_instance(); | 497 SiteInstance* curr_instance = render_view_host_->site_instance(); |
| 480 | 498 |
| 481 // Determine if we need a new SiteInstance for this entry. | 499 // Determine if we need a new SiteInstance for this entry. |
| 482 // Again, new_instance won't be deleted before the end of this method, so it | 500 // Again, new_instance won't be deleted before the end of this method, so it |
| 483 // is safe to use a normal pointer here. | 501 // is safe to use a normal pointer here. |
| 484 SiteInstance* new_instance = curr_instance; | 502 SiteInstance* new_instance = curr_instance; |
| 485 if (ShouldTransitionCrossSite()) | 503 if (ShouldTransitionCrossSite()) |
| 486 new_instance = GetSiteInstanceForEntry(entry, curr_instance); | 504 new_instance = GetSiteInstanceForEntry(entry, curr_instance); |
| 487 | 505 |
| 488 if (new_instance != curr_instance || ShouldSwapRenderViewsForNavigation( | 506 if (new_instance != curr_instance || |
| 507 ShouldSwapRenderViewsForNavigation( |
| 489 delegate_->GetLastCommittedNavigationEntryForRenderManager(), | 508 delegate_->GetLastCommittedNavigationEntryForRenderManager(), |
| 490 &entry)) { | 509 &entry)) { |
| 491 // New SiteInstance. | 510 // New SiteInstance. |
| 492 DCHECK(!cross_navigation_pending_); | 511 DCHECK(!cross_navigation_pending_); |
| 493 | 512 |
| 494 // Create a pending RVH and navigate it. | 513 // Create a pending RVH and navigate it. |
| 495 bool success = CreatePendingRenderView(new_instance); | 514 bool success = CreatePendingRenderView(new_instance); |
| 496 if (!success) | 515 if (!success) |
| 497 return NULL; | 516 return NULL; |
| 498 | 517 |
| 499 // Check if our current RVH is live before we set up a transition. | 518 // Check if our current RVH is live before we set up a transition. |
| 500 if (!render_view_host_->IsRenderViewLive()) { | 519 if (!render_view_host_->IsRenderViewLive()) { |
| 501 if (!cross_navigation_pending_) { | 520 if (!cross_navigation_pending_) { |
| 502 // The current RVH is not live. There's no reason to sit around with a | 521 // The current RVH is not live. There's no reason to sit around with a |
| 503 // sad tab or a newly created RVH while we wait for the pending RVH to | 522 // sad tab or a newly created RVH while we wait for the pending RVH to |
| 504 // navigate. Just switch to the pending RVH now and go back to non | 523 // navigate. Just switch to the pending RVH now and go back to non |
| 505 // cross-navigating (Note that we don't care about on{before}unload | 524 // cross-navigating (Note that we don't care about on{before}unload |
| 506 // handlers if the current RVH isn't live.) | 525 // handlers if the current RVH isn't live.) |
| 507 SwapToRenderView(&pending_render_view_host_, true); | 526 CommitPending(); |
| 508 return render_view_host_; | 527 return render_view_host_; |
| 509 } else { | 528 } else { |
| 510 NOTREACHED(); | 529 NOTREACHED(); |
| 511 return render_view_host_; | 530 return render_view_host_; |
| 512 } | 531 } |
| 513 } | 532 } |
| 514 // Otherwise, it's safe to treat this as a pending cross-site transition. | 533 // Otherwise, it's safe to treat this as a pending cross-site transition. |
| 515 | 534 |
| 516 // Make sure the old render view stops, in case a load is in progress. | 535 // Make sure the old render view stops, in case a load is in progress. |
| 517 render_view_host_->Stop(); | 536 render_view_host_->Stop(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 539 | 558 |
| 540 return pending_render_view_host_; | 559 return pending_render_view_host_; |
| 541 } | 560 } |
| 542 | 561 |
| 543 // Same SiteInstance can be used. Navigate render_view_host_ if we are not | 562 // Same SiteInstance can be used. Navigate render_view_host_ if we are not |
| 544 // cross navigating. | 563 // cross navigating. |
| 545 DCHECK(!cross_navigation_pending_); | 564 DCHECK(!cross_navigation_pending_); |
| 546 return render_view_host_; | 565 return render_view_host_; |
| 547 } | 566 } |
| 548 | 567 |
| 549 void RenderViewHostManager::CancelPendingRenderView() { | 568 void RenderViewHostManager::CancelPending() { |
| 550 RenderViewHost* pending_render_view_host = pending_render_view_host_; | 569 RenderViewHost* pending_render_view_host = pending_render_view_host_; |
| 551 pending_render_view_host_ = NULL; | 570 pending_render_view_host_ = NULL; |
| 552 pending_render_view_host->Shutdown(); | 571 pending_render_view_host->Shutdown(); |
| 572 |
| 573 pending_dom_ui_.reset(); |
| 553 } | 574 } |
| 554 | 575 |
| 555 void RenderViewHostManager::CrossSiteNavigationCanceled() { | 576 void RenderViewHostManager::CrossSiteNavigationCanceled() { |
| 556 DCHECK(cross_navigation_pending_); | 577 DCHECK(cross_navigation_pending_); |
| 557 cross_navigation_pending_ = false; | 578 cross_navigation_pending_ = false; |
| 558 if (pending_render_view_host_) | 579 if (pending_render_view_host_) |
| 559 CancelPendingRenderView(); | 580 CancelPending(); |
| 560 } | 581 } |
| OLD | NEW |