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