Chromium Code Reviews| 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 RenderFrameHostImpl* render_frame_host) { | 401 RenderFrameHostImpl* render_frame_host) { |
| 402 // Make sure this is from our current RFH, and that we have a pending | 402 // Make sure this is from our current RFH, and that we have a pending |
| 403 // navigation from OnCrossSiteResponse. (There may be no pending navigation | 403 // navigation from OnCrossSiteResponse. (There may be no pending navigation |
| 404 // for data URLs that don't make network requests, for example.) If not, | 404 // for data URLs that don't make network requests, for example.) If not, |
| 405 // just return early and ignore. | 405 // just return early and ignore. |
| 406 if (render_frame_host != render_frame_host_ || !pending_nav_params_.get()) { | 406 if (render_frame_host != render_frame_host_ || !pending_nav_params_.get()) { |
| 407 pending_nav_params_.reset(); | 407 pending_nav_params_.reset(); |
| 408 return; | 408 return; |
| 409 } | 409 } |
| 410 | 410 |
| 411 // Sanity check that this is for the correct frame. | |
| 412 DCHECK_EQ(render_frame_host_->GetRoutingID(), | |
| 413 pending_nav_params_->render_frame_id); | |
| 414 DCHECK_EQ(render_frame_host_->GetProcess()->GetID(), | |
| 415 pending_nav_params_->global_request_id.child_id); | |
| 416 | |
| 417 // Now that the unload handler has run, we need to either initiate the | 411 // Now that the unload handler has run, we need to either initiate the |
| 418 // pending transfer (if there is one) or resume the paused response (if not). | 412 // pending transfer (if there is one) or resume the paused response (if not). |
| 419 // TODO(creis): The blank swapped out page is visible during this time, but | 413 // TODO(creis): The blank swapped out page is visible during this time, but |
| 420 // we can shorten this by delivering the response directly, rather than | 414 // we can shorten this by delivering the response directly, rather than |
| 421 // forcing an identical request to be made. | 415 // forcing an identical request to be made. |
| 422 if (pending_nav_params_->cross_site_transferring_request) { | 416 if (pending_nav_params_->cross_site_transferring_request) { |
| 417 // Sanity check that this is for the correct frame. | |
|
Charlie Reis
2014/03/21 23:24:33
This check only makes sense for transfers, not bro
| |
| 418 DCHECK_EQ(render_frame_host_->GetRoutingID(), | |
| 419 pending_nav_params_->render_frame_id); | |
| 420 DCHECK_EQ(render_frame_host_->GetProcess()->GetID(), | |
| 421 pending_nav_params_->global_request_id.child_id); | |
| 422 | |
| 423 // Treat the last URL in the chain as the destination and the remainder as | 423 // Treat the last URL in the chain as the destination and the remainder as |
| 424 // the redirect chain. | 424 // the redirect chain. |
| 425 CHECK(pending_nav_params_->transfer_url_chain.size()); | 425 CHECK(pending_nav_params_->transfer_url_chain.size()); |
| 426 GURL transfer_url = pending_nav_params_->transfer_url_chain.back(); | 426 GURL transfer_url = pending_nav_params_->transfer_url_chain.back(); |
| 427 pending_nav_params_->transfer_url_chain.pop_back(); | 427 pending_nav_params_->transfer_url_chain.pop_back(); |
| 428 | 428 |
| 429 // We don't know whether the original request had |user_action| set to true. | 429 // We don't know whether the original request had |user_action| set to true. |
| 430 // However, since we force the navigation to be in the current tab, it | 430 // However, since we force the navigation to be in the current tab, it |
| 431 // doesn't matter. | 431 // doesn't matter. |
| 432 render_frame_host_->frame_tree_node()->navigator()->RequestTransferURL( | 432 render_frame_host_->frame_tree_node()->navigator()->RequestTransferURL( |
| (...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1304 // handlers, because those have already been done. | 1304 // handlers, because those have already been done. |
| 1305 DCHECK(pending_nav_params_->global_request_id == | 1305 DCHECK(pending_nav_params_->global_request_id == |
| 1306 entry.transferred_global_request_id()); | 1306 entry.transferred_global_request_id()); |
| 1307 } else { | 1307 } else { |
| 1308 // Also make sure the old render view stops, in case a load is in | 1308 // Also make sure the old render view stops, in case a load is in |
| 1309 // progress. (We don't want to do this for transfers, since it will | 1309 // progress. (We don't want to do this for transfers, since it will |
| 1310 // interrupt the transfer with an unexpected DidStopLoading.) | 1310 // interrupt the transfer with an unexpected DidStopLoading.) |
| 1311 render_frame_host_->render_view_host()->Send(new ViewMsg_Stop( | 1311 render_frame_host_->render_view_host()->Send(new ViewMsg_Stop( |
| 1312 render_frame_host_->render_view_host()->GetRoutingID())); | 1312 render_frame_host_->render_view_host()->GetRoutingID())); |
| 1313 | 1313 |
| 1314 pending_render_frame_host_->render_view_host()->SetNavigationsSuspended( | 1314 // TODO(creis): Skip this for subframes until we can run beforeunload |
| 1315 true, base::TimeTicks()); | 1315 // handlers on them. |
| 1316 if (frame_tree_node_->IsMainFrame()) { | |
| 1317 pending_render_frame_host_->render_view_host()->SetNavigationsSuspended( | |
| 1318 true, base::TimeTicks()); | |
| 1319 } | |
| 1316 | 1320 |
| 1317 // Tell the CrossSiteRequestManager that this RVH has a pending cross-site | 1321 // Tell the CrossSiteRequestManager that this RVH has a pending cross-site |
| 1318 // request, so that ResourceDispatcherHost will know to tell us to run the | 1322 // request, so that ResourceDispatcherHost will know to tell us to run the |
| 1319 // old page's unload handler before it sends the response. | 1323 // old page's unload handler before it sends the response. |
| 1320 // TODO(creis): This needs to be on the RFH. | 1324 // TODO(creis): This needs to be on the RFH. |
| 1321 pending_render_frame_host_->render_view_host()-> | 1325 pending_render_frame_host_->render_view_host()-> |
| 1322 SetHasPendingCrossSiteRequest(true); | 1326 SetHasPendingCrossSiteRequest(true); |
| 1323 } | 1327 } |
| 1324 | 1328 |
| 1325 // We now have a pending RFH. | 1329 // We now have a pending RFH. |
| 1326 DCHECK(!cross_navigation_pending_); | 1330 DCHECK(!cross_navigation_pending_); |
| 1327 cross_navigation_pending_ = true; | 1331 cross_navigation_pending_ = true; |
| 1328 | 1332 |
| 1329 // Unless we are transferring an existing request, we should now | 1333 // Unless we are transferring an existing request, we should now |
| 1330 // tell the old render view to run its beforeunload handler, since it | 1334 // tell the old render view to run its beforeunload handler, since it |
| 1331 // doesn't otherwise know that the cross-site request is happening. This | 1335 // doesn't otherwise know that the cross-site request is happening. This |
| 1332 // will trigger a call to OnBeforeUnloadACK with the reply. | 1336 // will trigger a call to OnBeforeUnloadACK with the reply. |
| 1333 if (!is_transfer) | 1337 // TODO(creis): Support beforeunload on subframes. |
| 1338 if (!is_transfer && frame_tree_node_->IsMainFrame()) | |
| 1334 render_frame_host_->DispatchBeforeUnload(true); | 1339 render_frame_host_->DispatchBeforeUnload(true); |
| 1335 | 1340 |
| 1336 return pending_render_frame_host_.get(); | 1341 return pending_render_frame_host_.get(); |
| 1337 } | 1342 } |
| 1338 | 1343 |
| 1339 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. | 1344 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. |
| 1340 DCHECK(!cross_navigation_pending_); | 1345 DCHECK(!cross_navigation_pending_); |
| 1341 if (ShouldReuseWebUI(current_entry, &entry)) { | 1346 if (ShouldReuseWebUI(current_entry, &entry)) { |
| 1342 pending_web_ui_.reset(); | 1347 pending_web_ui_.reset(); |
| 1343 pending_and_current_web_ui_ = web_ui_->AsWeakPtr(); | 1348 pending_and_current_web_ui_ = web_ui_->AsWeakPtr(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1463 SiteInstance* instance) const { | 1468 SiteInstance* instance) const { |
| 1464 RenderFrameHostMap::const_iterator iter = | 1469 RenderFrameHostMap::const_iterator iter = |
| 1465 swapped_out_hosts_.find(instance->GetId()); | 1470 swapped_out_hosts_.find(instance->GetId()); |
| 1466 if (iter != swapped_out_hosts_.end()) | 1471 if (iter != swapped_out_hosts_.end()) |
| 1467 return iter->second; | 1472 return iter->second; |
| 1468 | 1473 |
| 1469 return NULL; | 1474 return NULL; |
| 1470 } | 1475 } |
| 1471 | 1476 |
| 1472 } // namespace content | 1477 } // namespace content |
| OLD | NEW |