| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/browser/frame_host/render_frame_host_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 int view_routing_id, | 100 int view_routing_id, |
| 101 int frame_routing_id) { | 101 int frame_routing_id) { |
| 102 // Create a RenderViewHost and RenderFrameHost, once we have an instance. It | 102 // Create a RenderViewHost and RenderFrameHost, once we have an instance. It |
| 103 // is important to immediately give this SiteInstance to a RenderViewHost so | 103 // is important to immediately give this SiteInstance to a RenderViewHost so |
| 104 // that the SiteInstance is ref counted. | 104 // that the SiteInstance is ref counted. |
| 105 if (!site_instance) | 105 if (!site_instance) |
| 106 site_instance = SiteInstance::Create(browser_context); | 106 site_instance = SiteInstance::Create(browser_context); |
| 107 | 107 |
| 108 // TODO(creis): Make render_frame_host_ a scoped_ptr. | 108 // TODO(creis): Make render_frame_host_ a scoped_ptr. |
| 109 render_frame_host_ = CreateRenderFrameHost(site_instance, view_routing_id, | 109 render_frame_host_ = CreateRenderFrameHost(site_instance, view_routing_id, |
| 110 frame_routing_id, false, false); | 110 frame_routing_id, false, |
| 111 delegate_->IsHidden()); |
| 111 | 112 |
| 112 // Keep track of renderer processes as they start to shut down or are | 113 // Keep track of renderer processes as they start to shut down or are |
| 113 // crashed/killed. | 114 // crashed/killed. |
| 114 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, | 115 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 115 NotificationService::AllSources()); | 116 NotificationService::AllSources()); |
| 116 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING, | 117 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING, |
| 117 NotificationService::AllSources()); | 118 NotificationService::AllSources()); |
| 118 } | 119 } |
| 119 | 120 |
| 120 RenderViewHostImpl* RenderFrameHostManager::current_host() const { | 121 RenderViewHostImpl* RenderFrameHostManager::current_host() const { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 | 187 |
| 187 // Now that we've created a new renderer, be sure to hide it if it isn't | 188 // Now that we've created a new renderer, be sure to hide it if it isn't |
| 188 // our primary one. Otherwise, we might crash if we try to call Show() | 189 // our primary one. Otherwise, we might crash if we try to call Show() |
| 189 // on it later. | 190 // on it later. |
| 190 if (dest_render_frame_host != render_frame_host_ && | 191 if (dest_render_frame_host != render_frame_host_ && |
| 191 dest_render_frame_host->render_view_host()->GetView()) { | 192 dest_render_frame_host->render_view_host()->GetView()) { |
| 192 dest_render_frame_host->render_view_host()->GetView()->Hide(); | 193 dest_render_frame_host->render_view_host()->GetView()->Hide(); |
| 193 } else { | 194 } else { |
| 194 // This is our primary renderer, notify here as we won't be calling | 195 // This is our primary renderer, notify here as we won't be calling |
| 195 // CommitPending (which does the notify). | 196 // CommitPending (which does the notify). |
| 197 // TODO(creis): only do this for top-level frames, when the RVH changes. |
| 196 delegate_->NotifySwappedFromRenderManager( | 198 delegate_->NotifySwappedFromRenderManager( |
| 197 NULL, render_frame_host_->render_view_host()); | 199 NULL, render_frame_host_->render_view_host()); |
| 198 } | 200 } |
| 199 } | 201 } |
| 200 | 202 |
| 201 // TODO(creis): Return the RFH instead, once we can navigate RFHs. | 203 // TODO(creis): Return the RFH instead, once we can navigate RFHs. |
| 202 return dest_render_frame_host->render_view_host(); | 204 return dest_render_frame_host->render_view_host(); |
| 203 } | 205 } |
| 204 | 206 |
| 205 void RenderFrameHostManager::Stop() { | 207 void RenderFrameHostManager::Stop() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // in this case because it took too long. | 249 // in this case because it took too long. |
| 248 if (pending_render_frame_host_->render_view_host()-> | 250 if (pending_render_frame_host_->render_view_host()-> |
| 249 are_navigations_suspended()) { | 251 are_navigations_suspended()) { |
| 250 pending_render_frame_host_->render_view_host()->SetNavigationsSuspended( | 252 pending_render_frame_host_->render_view_host()->SetNavigationsSuspended( |
| 251 false, base::TimeTicks::Now()); | 253 false, base::TimeTicks::Now()); |
| 252 } | 254 } |
| 253 } | 255 } |
| 254 return false; | 256 return false; |
| 255 } | 257 } |
| 256 | 258 |
| 257 // TODO(creis): This should take in a RenderFrameHost. | 259 // TODO(creis): Remove this in favor of SwappedOutFrame. |
| 258 void RenderFrameHostManager::SwappedOut(RenderViewHost* render_view_host) { | 260 void RenderFrameHostManager::SwappedOut(RenderViewHost* render_view_host) { |
| 259 // Make sure this is from our current RVH, and that we have a pending | 261 // Make sure this is from our current RVH, and that we have a pending |
| 260 // navigation from OnCrossSiteResponse. (There may be no pending navigation | 262 // navigation from OnCrossSiteResponse. (There may be no pending navigation |
| 261 // for data URLs that don't make network requests, for example.) If not, | 263 // for data URLs that don't make network requests, for example.) If not, |
| 262 // just return early and ignore. | 264 // just return early and ignore. |
| 263 if (render_view_host != render_frame_host_->render_view_host() || | 265 if (render_view_host != render_frame_host_->render_view_host() || |
| 264 !pending_nav_params_.get()) { | 266 !pending_nav_params_.get()) { |
| 265 pending_nav_params_.reset(); | 267 pending_nav_params_.reset(); |
| 266 return; | 268 return; |
| 267 } | 269 } |
| 268 | 270 |
| 271 // We should probably sanity check that this is for the correct frame. |
| 272 // TODO(creis): Is this frame ID trusted? Which frame is it for? |
| 273 //DCHECK_EQ(frame_tree_node_->GetID()?, pending_nav_params_->frame_id); |
| 274 |
| 269 // Now that the unload handler has run, we need to either initiate the | 275 // Now that the unload handler has run, we need to either initiate the |
| 270 // pending transfer (if there is one) or resume the paused response (if not). | 276 // pending transfer (if there is one) or resume the paused response (if not). |
| 271 // TODO(creis): The blank swapped out page is visible during this time, but | 277 // TODO(creis): The blank swapped out page is visible during this time, but |
| 272 // we can shorten this by delivering the response directly, rather than | 278 // we can shorten this by delivering the response directly, rather than |
| 273 // forcing an identical request to be made. | 279 // forcing an identical request to be made. |
| 274 if (pending_nav_params_->is_transfer) { | 280 if (pending_nav_params_->is_transfer) { |
| 275 // Treat the last URL in the chain as the destination and the remainder as | 281 // Treat the last URL in the chain as the destination and the remainder as |
| 276 // the redirect chain. | 282 // the redirect chain. |
| 277 CHECK(pending_nav_params_->transfer_url_chain.size()); | 283 CHECK(pending_nav_params_->transfer_url_chain.size()); |
| 278 GURL transfer_url = pending_nav_params_->transfer_url_chain.back(); | 284 GURL transfer_url = pending_nav_params_->transfer_url_chain.back(); |
| 279 pending_nav_params_->transfer_url_chain.pop_back(); | 285 pending_nav_params_->transfer_url_chain.pop_back(); |
| 280 | 286 |
| 281 // We don't know whether the original request had |user_action| set to true. | 287 // We don't know whether the original request had |user_action| set to true. |
| 282 // However, since we force the navigation to be in the current tab, it | 288 // However, since we force the navigation to be in the current tab, it |
| 283 // doesn't matter. | 289 // doesn't matter. |
| 290 // TODO(creis): Move RequestTransferURL to RenderFrameHost's navigator. |
| 284 render_view_host->GetDelegate()->RequestTransferURL( | 291 render_view_host->GetDelegate()->RequestTransferURL( |
| 285 transfer_url, | 292 transfer_url, |
| 286 pending_nav_params_->transfer_url_chain, | 293 pending_nav_params_->transfer_url_chain, |
| 287 pending_nav_params_->referrer, | 294 pending_nav_params_->referrer, |
| 288 pending_nav_params_->page_transition, | 295 pending_nav_params_->page_transition, |
| 289 CURRENT_TAB, | 296 CURRENT_TAB, |
| 290 pending_nav_params_->frame_id, | 297 pending_nav_params_->frame_id, |
| 291 pending_nav_params_->global_request_id, | 298 pending_nav_params_->global_request_id, |
| 292 pending_nav_params_->should_replace_current_entry, | 299 pending_nav_params_->should_replace_current_entry, |
| 293 true); | 300 true); |
| 294 } else if (pending_render_frame_host_) { | 301 } else if (pending_render_frame_host_) { |
| 295 RenderProcessHostImpl* pending_process = | 302 RenderProcessHostImpl* pending_process = |
| 296 static_cast<RenderProcessHostImpl*>( | 303 static_cast<RenderProcessHostImpl*>( |
| 297 pending_render_frame_host_->GetProcess()); | 304 pending_render_frame_host_->GetProcess()); |
| 298 pending_process->ResumeDeferredNavigation( | 305 pending_process->ResumeDeferredNavigation( |
| 299 pending_nav_params_->global_request_id); | 306 pending_nav_params_->global_request_id); |
| 300 } | 307 } |
| 301 pending_nav_params_.reset(); | 308 pending_nav_params_.reset(); |
| 302 } | 309 } |
| 303 | 310 |
| 311 void RenderFrameHostManager::SwappedOutFrame( |
| 312 RenderFrameHostImpl* render_frame_host) { |
| 313 // Make sure this is from our current RFH, and that we have a pending |
| 314 // navigation from OnCrossSiteResponse. (There may be no pending navigation |
| 315 // for data URLs that don't make network requests, for example.) If not, |
| 316 // just return early and ignore. |
| 317 if (render_frame_host != render_frame_host_ || !pending_nav_params_.get()) { |
| 318 pending_nav_params_.reset(); |
| 319 return; |
| 320 } |
| 321 |
| 322 // We should probably sanity check that this is for the correct frame. |
| 323 // TODO(creis): Is this frame ID trusted? Which frame is it for? |
| 324 //DCHECK_EQ(frame_tree_node_->GetID()?, pending_nav_params_->frame_id); |
| 325 |
| 326 // Now that the unload handler has run, we need to either initiate the |
| 327 // pending transfer (if there is one) or resume the paused response (if not). |
| 328 // TODO(creis): The blank swapped out page is visible during this time, but |
| 329 // we can shorten this by delivering the response directly, rather than |
| 330 // forcing an identical request to be made. |
| 331 if (pending_nav_params_->is_transfer) { |
| 332 // Treat the last URL in the chain as the destination and the remainder as |
| 333 // the redirect chain. |
| 334 CHECK(pending_nav_params_->transfer_url_chain.size()); |
| 335 GURL transfer_url = pending_nav_params_->transfer_url_chain.back(); |
| 336 pending_nav_params_->transfer_url_chain.pop_back(); |
| 337 |
| 338 // We don't know whether the original request had |user_action| set to true. |
| 339 // However, since we force the navigation to be in the current tab, it |
| 340 // doesn't matter. |
| 341 // TODO(creis): Move RequestTransferURL to RenderFrameHost's navigator. |
| 342 render_frame_host->render_view_host()->GetDelegate()->RequestTransferURL( |
| 343 transfer_url, |
| 344 pending_nav_params_->transfer_url_chain, |
| 345 pending_nav_params_->referrer, |
| 346 pending_nav_params_->page_transition, |
| 347 CURRENT_TAB, |
| 348 pending_nav_params_->frame_id, |
| 349 pending_nav_params_->global_request_id, |
| 350 false, |
| 351 true); |
| 352 } else if (pending_render_frame_host_) { |
| 353 RenderProcessHostImpl* pending_process = |
| 354 static_cast<RenderProcessHostImpl*>( |
| 355 pending_render_frame_host_->GetProcess()); |
| 356 pending_process->ResumeDeferredNavigation( |
| 357 pending_nav_params_->global_request_id); |
| 358 } |
| 359 pending_nav_params_.reset(); |
| 360 } |
| 361 |
| 304 // TODO(creis): This should take in a RenderFrameHost. | 362 // TODO(creis): This should take in a RenderFrameHost. |
| 305 void RenderFrameHostManager::DidNavigateMainFrame( | 363 void RenderFrameHostManager::DidNavigateMainFrame( |
| 306 RenderViewHost* render_view_host) { | 364 RenderViewHost* render_view_host) { |
| 307 if (!cross_navigation_pending_) { | 365 if (!cross_navigation_pending_) { |
| 308 DCHECK(!pending_render_frame_host_); | 366 DCHECK(!pending_render_frame_host_); |
| 309 | 367 |
| 310 // We should only hear this from our current renderer. | 368 // We should only hear this from our current renderer. |
| 311 DCHECK(render_view_host == render_frame_host_->render_view_host()); | 369 DCHECK(render_view_host == render_frame_host_->render_view_host()); |
| 312 | 370 |
| 313 // Even when there is no pending RVH, there may be a pending Web UI. | 371 // Even when there is no pending RVH, there may be a pending Web UI. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 // Now close any modal dialogs that would prevent us from swapping out. This | 531 // Now close any modal dialogs that would prevent us from swapping out. This |
| 474 // must be done separately from SwapOut, so that the PageGroupLoadDeferrer is | 532 // must be done separately from SwapOut, so that the PageGroupLoadDeferrer is |
| 475 // no longer on the stack when we send the SwapOut message. | 533 // no longer on the stack when we send the SwapOut message. |
| 476 delegate_->CancelModalDialogsForRenderManager(); | 534 delegate_->CancelModalDialogsForRenderManager(); |
| 477 | 535 |
| 478 // Tell the old renderer it is being swapped out. This will fire the unload | 536 // Tell the old renderer it is being swapped out. This will fire the unload |
| 479 // handler (without firing the beforeunload handler a second time). When the | 537 // handler (without firing the beforeunload handler a second time). When the |
| 480 // unload handler finishes and the navigation completes, we will send a | 538 // unload handler finishes and the navigation completes, we will send a |
| 481 // message to the ResourceDispatcherHost, allowing the pending RVH's response | 539 // message to the ResourceDispatcherHost, allowing the pending RVH's response |
| 482 // to resume. | 540 // to resume. |
| 483 // TODO(creis): We should do this on the RFH or else we'll swap out the | 541 // Note: this must be done on the RFH or else we'll swap out the |
| 484 // top-level page when subframes navigate. | 542 // top-level page. |
| 485 render_frame_host_->render_view_host()->SwapOut(); | 543 if (frame_tree_node_->IsMainFrame()) |
| 544 render_frame_host_->render_view_host()->SwapOut(); |
| 545 else |
| 546 render_frame_host_->SwapOut(); |
| 486 | 547 |
| 487 // ResourceDispatcherHost has told us to run the onunload handler, which | 548 // ResourceDispatcherHost has told us to run the onunload handler, which |
| 488 // means it is not a download or unsafe page, and we are going to perform the | 549 // means it is not a download or unsafe page, and we are going to perform the |
| 489 // navigation. Thus, we no longer need to remember that the RenderViewHost | 550 // navigation. Thus, we no longer need to remember that the RenderFrameHost |
| 490 // is part of a pending cross-site request. | 551 // is part of a pending cross-site request. |
| 491 if (pending_render_frame_host_) { | 552 if (pending_render_frame_host_) { |
| 492 pending_render_frame_host_->render_view_host()-> | 553 pending_render_frame_host_->render_view_host()-> |
| 493 SetHasPendingCrossSiteRequest(false); | 554 SetHasPendingCrossSiteRequest(false); |
| 494 } | 555 } |
| 495 } | 556 } |
| 496 | 557 |
| 497 void RenderFrameHostManager::Observe( | 558 void RenderFrameHostManager::Observe( |
| 498 int type, | 559 int type, |
| 499 const NotificationSource& source, | 560 const NotificationSource& source, |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 frame_routing_id = site_instance->GetProcess()->GetNextRoutingID(); | 830 frame_routing_id = site_instance->GetProcess()->GetNextRoutingID(); |
| 770 | 831 |
| 771 // Create a RVH for main frames, or find the existing one for subframes. | 832 // Create a RVH for main frames, or find the existing one for subframes. |
| 772 FrameTree* frame_tree = frame_tree_node_->frame_tree(); | 833 FrameTree* frame_tree = frame_tree_node_->frame_tree(); |
| 773 RenderViewHostImpl* render_view_host = NULL; | 834 RenderViewHostImpl* render_view_host = NULL; |
| 774 if (frame_tree_node_->IsMainFrame()) { | 835 if (frame_tree_node_->IsMainFrame()) { |
| 775 render_view_host = frame_tree->CreateRenderViewHostForMainFrame( | 836 render_view_host = frame_tree->CreateRenderViewHostForMainFrame( |
| 776 site_instance, view_routing_id, frame_routing_id, swapped_out, hidden); | 837 site_instance, view_routing_id, frame_routing_id, swapped_out, hidden); |
| 777 } else { | 838 } else { |
| 778 render_view_host = frame_tree->GetRenderViewHostForSubFrame(site_instance); | 839 render_view_host = frame_tree->GetRenderViewHostForSubFrame(site_instance); |
| 840 // TODO(creis): Mirror the frame tree so this check isn't necessary. |
| 841 if (!render_view_host) { |
| 842 render_view_host = frame_tree->CreateRenderViewHostForMainFrame( |
| 843 site_instance, view_routing_id, frame_routing_id, swapped_out, |
| 844 hidden); |
| 845 } |
| 779 } | 846 } |
| 780 | 847 |
| 781 // TODO(creis): Make render_frame_host a scoped_ptr. | 848 // TODO(creis): Make render_frame_host a scoped_ptr. |
| 782 // TODO(creis): Pass hidden to RFH. | 849 // TODO(creis): Pass hidden to RFH. |
| 783 RenderFrameHostImpl* render_frame_host = | 850 RenderFrameHostImpl* render_frame_host = |
| 784 RenderFrameHostFactory::Create(render_view_host, | 851 RenderFrameHostFactory::Create(render_view_host, |
| 785 render_frame_delegate_, | 852 render_frame_delegate_, |
| 786 frame_tree, | 853 frame_tree, |
| 787 frame_tree_node_, | 854 frame_tree_node_, |
| 788 frame_routing_id, | 855 frame_routing_id, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 } else { | 892 } else { |
| 826 new_render_frame_host->GetProcess()->AddPendingView(); | 893 new_render_frame_host->GetProcess()->AddPendingView(); |
| 827 } | 894 } |
| 828 | 895 |
| 829 RenderViewHostImpl* render_view_host = | 896 RenderViewHostImpl* render_view_host = |
| 830 new_render_frame_host->render_view_host(); | 897 new_render_frame_host->render_view_host(); |
| 831 bool success = InitRenderView(render_view_host, opener_route_id); | 898 bool success = InitRenderView(render_view_host, opener_route_id); |
| 832 if (success && frame_tree_node_->IsMainFrame()) { | 899 if (success && frame_tree_node_->IsMainFrame()) { |
| 833 // Don't show the main frame's view until we get a DidNavigate from it. | 900 // Don't show the main frame's view until we get a DidNavigate from it. |
| 834 render_view_host->GetView()->Hide(); | 901 render_view_host->GetView()->Hide(); |
| 835 } else if (!swapped_out) { | 902 } else if (!swapped_out && pending_render_frame_host_) { |
| 903 // TODO(creis): The lack of pending RFH check from before was a bug. |
| 836 CancelPending(); | 904 CancelPending(); |
| 837 } | 905 } |
| 838 } | 906 } |
| 839 | 907 |
| 840 // Use this as our new pending RFH if it isn't swapped out. | 908 // Use this as our new pending RFH if it isn't swapped out. |
| 841 if (!swapped_out) | 909 if (!swapped_out) |
| 842 pending_render_frame_host_ = new_render_frame_host; | 910 pending_render_frame_host_ = new_render_frame_host; |
| 843 | 911 |
| 844 return new_render_frame_host->render_view_host()->GetRoutingID(); | 912 return new_render_frame_host->render_view_host()->GetRoutingID(); |
| 845 } | 913 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 901 delegate_->SetFocusToLocationBar(false); | 969 delegate_->SetFocusToLocationBar(false); |
| 902 return; | 970 return; |
| 903 } | 971 } |
| 904 | 972 |
| 905 // Remember if the page was focused so we can focus the new renderer in | 973 // Remember if the page was focused so we can focus the new renderer in |
| 906 // that case. | 974 // that case. |
| 907 bool focus_render_view = !will_focus_location_bar && | 975 bool focus_render_view = !will_focus_location_bar && |
| 908 render_frame_host_->render_view_host()->GetView() && | 976 render_frame_host_->render_view_host()->GetView() && |
| 909 render_frame_host_->render_view_host()->GetView()->HasFocus(); | 977 render_frame_host_->render_view_host()->GetView()->HasFocus(); |
| 910 | 978 |
| 979 // TODO(creis): As long as show/hide are on RVH, we don't want to do them for |
| 980 // subframe navigations or they'll interfere with the top-level page. |
| 981 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
| 982 |
| 911 // Swap in the pending frame and make it active. Also ensure the FrameTree | 983 // Swap in the pending frame and make it active. Also ensure the FrameTree |
| 912 // stays in sync. | 984 // stays in sync. |
| 913 RenderFrameHostImpl* old_render_frame_host = render_frame_host_; | 985 RenderFrameHostImpl* old_render_frame_host = render_frame_host_; |
| 914 render_frame_host_ = pending_render_frame_host_; | 986 render_frame_host_ = pending_render_frame_host_; |
| 915 pending_render_frame_host_ = NULL; | 987 pending_render_frame_host_ = NULL; |
| 916 render_frame_host_->render_view_host()->AttachToFrameTree(); | 988 if (is_main_frame) |
| 989 frame_tree_node_->frame_tree()->ResetForMainFrameSwap(); |
| 917 | 990 |
| 918 // The process will no longer try to exit, so we can decrement the count. | 991 // The process will no longer try to exit, so we can decrement the count. |
| 919 render_frame_host_->GetProcess()->RemovePendingView(); | 992 render_frame_host_->GetProcess()->RemovePendingView(); |
| 920 | 993 |
| 921 // TODO(creis): As long as show/hide are on RVH, we don't want to do them for | |
| 922 // subframe navigations or they'll interfere with the top-level page. | |
| 923 bool is_main_frame = frame_tree_node_->IsMainFrame(); | |
| 924 | |
| 925 // If the view is gone, then this RenderViewHost died while it was hidden. | 994 // If the view is gone, then this RenderViewHost died while it was hidden. |
| 926 // We ignored the RenderProcessGone call at the time, so we should send it now | 995 // We ignored the RenderProcessGone call at the time, so we should send it now |
| 927 // to make sure the sad tab shows up, etc. | 996 // to make sure the sad tab shows up, etc. |
| 928 if (!render_frame_host_->render_view_host()->GetView()) { | 997 if (!render_frame_host_->render_view_host()->GetView()) { |
| 929 delegate_->RenderProcessGoneFromRenderManager( | 998 delegate_->RenderProcessGoneFromRenderManager( |
| 930 render_frame_host_->render_view_host()); | 999 render_frame_host_->render_view_host()); |
| 931 } else if (!delegate_->IsHidden() && is_main_frame) { | 1000 } else if (!delegate_->IsHidden() && is_main_frame) { |
| 932 render_frame_host_->render_view_host()->GetView()->Show(); | 1001 render_frame_host_->render_view_host()->GetView()->Show(); |
| 933 } | 1002 } |
| 934 | 1003 |
| 935 // Hide the old view now that the new one is visible. | 1004 // Hide the old view now that the new one is visible. |
| 1005 // TODO(creis): We don't want to hide the top-level view based on a frame |
| 1006 // swap. Hack for now. |
| 936 if (old_render_frame_host->render_view_host()->GetView()) { | 1007 if (old_render_frame_host->render_view_host()->GetView()) { |
| 937 old_render_frame_host->render_view_host()->GetView()->Hide(); | 1008 if (is_main_frame) { |
| 938 old_render_frame_host->render_view_host()->WasSwappedOut(); | 1009 old_render_frame_host->render_view_host()->GetView()->Hide(); |
| 1010 old_render_frame_host->render_view_host()->WasSwappedOut(); |
| 1011 } else { |
| 1012 // TODO(creis): We'll need to set this back to false when navigating a |
| 1013 // subframe RFH, but we can't navigate a subframe RFH yet. |
| 1014 old_render_frame_host->set_swapped_out(true); |
| 1015 } |
| 939 } | 1016 } |
| 940 | 1017 |
| 941 // Make sure the size is up to date. (Fix for bug 1079768.) | 1018 // Make sure the size is up to date. (Fix for bug 1079768.) |
| 942 delegate_->UpdateRenderViewSizeForRenderManager(); | 1019 delegate_->UpdateRenderViewSizeForRenderManager(); |
| 943 | 1020 |
| 944 if (will_focus_location_bar) { | 1021 if (will_focus_location_bar) { |
| 945 delegate_->SetFocusToLocationBar(false); | 1022 delegate_->SetFocusToLocationBar(false); |
| 946 } else if (focus_render_view && | 1023 } else if (focus_render_view && |
| 947 render_frame_host_->render_view_host()->GetView()) { | 1024 render_frame_host_->render_view_host()->GetView()) { |
| 948 RenderWidgetHostViewPort::FromRWHV( | 1025 RenderWidgetHostViewPort::FromRWHV( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 959 render_frame_host_->render_view_host()); | 1036 render_frame_host_->render_view_host()); |
| 960 } | 1037 } |
| 961 | 1038 |
| 962 // If the pending frame was on the swapped out list, we can remove it. | 1039 // If the pending frame was on the swapped out list, we can remove it. |
| 963 swapped_out_hosts_.erase(render_frame_host_->render_view_host()-> | 1040 swapped_out_hosts_.erase(render_frame_host_->render_view_host()-> |
| 964 GetSiteInstance()->GetId()); | 1041 GetSiteInstance()->GetId()); |
| 965 | 1042 |
| 966 if (old_render_frame_host->render_view_host()->IsRenderViewLive()) { | 1043 if (old_render_frame_host->render_view_host()->IsRenderViewLive()) { |
| 967 // If the old RFH is live, we are swapping it out and should keep track of | 1044 // If the old RFH is live, we are swapping it out and should keep track of |
| 968 // it in case we navigate back to it. | 1045 // it in case we navigate back to it. |
| 969 DCHECK(old_render_frame_host->render_view_host()->is_swapped_out()); | 1046 DCHECK(old_render_frame_host->is_swapped_out() || |
| 1047 old_render_frame_host->render_view_host()->is_swapped_out()); |
| 970 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make | 1048 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make |
| 971 // sure we don't get different rvh instances for the same site instance | 1049 // sure we don't get different rvh instances for the same site instance |
| 972 // in the same rvhmgr. | 1050 // in the same rvhmgr. |
| 973 // TODO(creis): Clean this up. | 1051 // TODO(creis): Clean this up. |
| 974 int32 old_site_instance_id = | 1052 int32 old_site_instance_id = |
| 975 old_render_frame_host->render_view_host()->GetSiteInstance()->GetId(); | 1053 old_render_frame_host->render_view_host()->GetSiteInstance()->GetId(); |
| 976 RenderFrameHostMap::iterator iter = | 1054 RenderFrameHostMap::iterator iter = |
| 977 swapped_out_hosts_.find(old_site_instance_id); | 1055 swapped_out_hosts_.find(old_site_instance_id); |
| 978 if (iter != swapped_out_hosts_.end() && | 1056 if (iter != swapped_out_hosts_.end() && |
| 979 iter->second != old_render_frame_host) { | 1057 iter->second != old_render_frame_host) { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 SiteInstance* instance) const { | 1363 SiteInstance* instance) const { |
| 1286 RenderFrameHostMap::const_iterator iter = | 1364 RenderFrameHostMap::const_iterator iter = |
| 1287 swapped_out_hosts_.find(instance->GetId()); | 1365 swapped_out_hosts_.find(instance->GetId()); |
| 1288 if (iter != swapped_out_hosts_.end()) | 1366 if (iter != swapped_out_hosts_.end()) |
| 1289 return iter->second; | 1367 return iter->second; |
| 1290 | 1368 |
| 1291 return NULL; | 1369 return NULL; |
| 1292 } | 1370 } |
| 1293 | 1371 |
| 1294 } // namespace content | 1372 } // namespace content |
| OLD | NEW |