Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 143183009: When cross-site navigations are cancelled, delete the request being transferred (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: *Really* remove AbortTransfer Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "content/browser/child_process_security_policy_impl.h" 12 #include "content/browser/child_process_security_policy_impl.h"
13 #include "content/browser/devtools/render_view_devtools_agent_host.h" 13 #include "content/browser/devtools/render_view_devtools_agent_host.h"
14 #include "content/browser/frame_host/cross_process_frame_connector.h" 14 #include "content/browser/frame_host/cross_process_frame_connector.h"
15 #include "content/browser/frame_host/debug_urls.h" 15 #include "content/browser/frame_host/debug_urls.h"
16 #include "content/browser/frame_host/interstitial_page_impl.h" 16 #include "content/browser/frame_host/interstitial_page_impl.h"
17 #include "content/browser/frame_host/navigation_controller_impl.h" 17 #include "content/browser/frame_host/navigation_controller_impl.h"
18 #include "content/browser/frame_host/navigation_entry_impl.h" 18 #include "content/browser/frame_host/navigation_entry_impl.h"
19 #include "content/browser/frame_host/render_frame_host_factory.h" 19 #include "content/browser/frame_host/render_frame_host_factory.h"
20 #include "content/browser/frame_host/render_frame_host_impl.h" 20 #include "content/browser/frame_host/render_frame_host_impl.h"
21 #include "content/browser/renderer_host/cross_site_transferring_request.h"
21 #include "content/browser/renderer_host/render_process_host_impl.h" 22 #include "content/browser/renderer_host/render_process_host_impl.h"
22 #include "content/browser/renderer_host/render_view_host_factory.h" 23 #include "content/browser/renderer_host/render_view_host_factory.h"
23 #include "content/browser/renderer_host/render_view_host_impl.h" 24 #include "content/browser/renderer_host/render_view_host_impl.h"
24 #include "content/browser/site_instance_impl.h" 25 #include "content/browser/site_instance_impl.h"
25 #include "content/browser/webui/web_ui_controller_factory_registry.h" 26 #include "content/browser/webui/web_ui_controller_factory_registry.h"
26 #include "content/browser/webui/web_ui_impl.h" 27 #include "content/browser/webui/web_ui_impl.h"
27 #include "content/common/view_messages.h" 28 #include "content/common/view_messages.h"
28 #include "content/port/browser/render_widget_host_view_port.h" 29 #include "content/port/browser/render_widget_host_view_port.h"
29 #include "content/public/browser/content_browser_client.h" 30 #include "content/public/browser/content_browser_client.h"
30 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
31 #include "content/public/browser/notification_types.h" 32 #include "content/public/browser/notification_types.h"
32 #include "content/public/browser/render_widget_host_iterator.h" 33 #include "content/public/browser/render_widget_host_iterator.h"
33 #include "content/public/browser/user_metrics.h" 34 #include "content/public/browser/user_metrics.h"
34 #include "content/public/browser/web_ui_controller.h" 35 #include "content/public/browser/web_ui_controller.h"
35 #include "content/public/common/content_switches.h" 36 #include "content/public/common/content_switches.h"
36 #include "content/public/common/url_constants.h" 37 #include "content/public/common/url_constants.h"
37 38
38 namespace content { 39 namespace content {
39 40
40 RenderFrameHostManager::PendingNavigationParams::PendingNavigationParams()
41 : is_transfer(false), frame_id(-1), should_replace_current_entry(false) {
42 }
43
44 RenderFrameHostManager::PendingNavigationParams::PendingNavigationParams( 41 RenderFrameHostManager::PendingNavigationParams::PendingNavigationParams(
45 const GlobalRequestID& global_request_id, 42 const GlobalRequestID& global_request_id,
46 bool is_transfer, 43 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request,
47 const std::vector<GURL>& transfer_url_chain, 44 const std::vector<GURL>& transfer_url_chain,
48 Referrer referrer, 45 Referrer referrer,
49 PageTransition page_transition, 46 PageTransition page_transition,
50 int64 frame_id, 47 int64 frame_id,
51 bool should_replace_current_entry) 48 bool should_replace_current_entry)
52 : global_request_id(global_request_id), 49 : global_request_id(global_request_id),
53 is_transfer(is_transfer), 50 cross_site_transferring_request(cross_site_transferring_request.Pass()),
54 transfer_url_chain(transfer_url_chain), 51 transfer_url_chain(transfer_url_chain),
55 referrer(referrer), 52 referrer(referrer),
56 page_transition(page_transition), 53 page_transition(page_transition),
57 frame_id(frame_id), 54 frame_id(frame_id),
58 should_replace_current_entry(should_replace_current_entry) { 55 should_replace_current_entry(should_replace_current_entry) {
59 } 56 }
60 57
61 RenderFrameHostManager::PendingNavigationParams::~PendingNavigationParams() {} 58 RenderFrameHostManager::PendingNavigationParams::~PendingNavigationParams() {}
62 59
63 RenderFrameHostManager::RenderFrameHostManager( 60 RenderFrameHostManager::RenderFrameHostManager(
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 dest_render_frame_host->render_view_host()->GetView()->Hide(); 197 dest_render_frame_host->render_view_host()->GetView()->Hide();
201 } else if (frame_tree_node_->IsMainFrame()) { 198 } else if (frame_tree_node_->IsMainFrame()) {
202 // This is our primary renderer, notify here as we won't be calling 199 // This is our primary renderer, notify here as we won't be calling
203 // CommitPending (which does the notify). We only do this for top-level 200 // CommitPending (which does the notify). We only do this for top-level
204 // frames. 201 // frames.
205 delegate_->NotifySwappedFromRenderManager( 202 delegate_->NotifySwappedFromRenderManager(
206 NULL, render_frame_host_->render_view_host()); 203 NULL, render_frame_host_->render_view_host());
207 } 204 }
208 } 205 }
209 206
207 // If entry includes the request ID of a request that is being transferred,
208 // the destination render frame will take ownership, so release ownership of
209 // the request.
210 if (pending_nav_params_ &&
211 pending_nav_params_->global_request_id ==
212 entry.transferred_global_request_id()) {
213 pending_nav_params_->cross_site_transferring_request->ReleaseRequest();
214 }
215
210 return dest_render_frame_host; 216 return dest_render_frame_host;
211 } 217 }
212 218
213 void RenderFrameHostManager::Stop() { 219 void RenderFrameHostManager::Stop() {
214 render_frame_host_->render_view_host()->Stop(); 220 render_frame_host_->render_view_host()->Stop();
215 221
216 // If we are cross-navigating, we should stop the pending renderers. This 222 // If we are cross-navigating, we should stop the pending renderers. This
217 // will lead to a DidFailProvisionalLoad, which will properly destroy them. 223 // will lead to a DidFailProvisionalLoad, which will properly destroy them.
218 if (cross_navigation_pending_) { 224 if (cross_navigation_pending_) {
219 pending_render_frame_host_->render_view_host()->Send(new ViewMsg_Stop( 225 pending_render_frame_host_->render_view_host()->Send(new ViewMsg_Stop(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 !pending_nav_params_.get()) { 278 !pending_nav_params_.get()) {
273 pending_nav_params_.reset(); 279 pending_nav_params_.reset();
274 return; 280 return;
275 } 281 }
276 282
277 // Now that the unload handler has run, we need to either initiate the 283 // Now that the unload handler has run, we need to either initiate the
278 // pending transfer (if there is one) or resume the paused response (if not). 284 // pending transfer (if there is one) or resume the paused response (if not).
279 // TODO(creis): The blank swapped out page is visible during this time, but 285 // TODO(creis): The blank swapped out page is visible during this time, but
280 // we can shorten this by delivering the response directly, rather than 286 // we can shorten this by delivering the response directly, rather than
281 // forcing an identical request to be made. 287 // forcing an identical request to be made.
282 if (pending_nav_params_->is_transfer) { 288 if (pending_nav_params_->cross_site_transferring_request) {
283 // Treat the last URL in the chain as the destination and the remainder as 289 // Treat the last URL in the chain as the destination and the remainder as
284 // the redirect chain. 290 // the redirect chain.
285 CHECK(pending_nav_params_->transfer_url_chain.size()); 291 CHECK(pending_nav_params_->transfer_url_chain.size());
286 GURL transfer_url = pending_nav_params_->transfer_url_chain.back(); 292 GURL transfer_url = pending_nav_params_->transfer_url_chain.back();
287 pending_nav_params_->transfer_url_chain.pop_back(); 293 pending_nav_params_->transfer_url_chain.pop_back();
288 294
289 // We don't know whether the original request had |user_action| set to true. 295 // We don't know whether the original request had |user_action| set to true.
290 // However, since we force the navigation to be in the current tab, it 296 // However, since we force the navigation to be in the current tab, it
291 // doesn't matter. 297 // doesn't matter.
292 render_view_host->GetDelegate()->RequestTransferURL( 298 render_view_host->GetDelegate()->RequestTransferURL(
(...skipping 28 matching lines...) Expand all
321 } 327 }
322 328
323 // Sanity check that this is for the correct frame. 329 // Sanity check that this is for the correct frame.
324 DCHECK_EQ(frame_tree_node_->frame_id(), pending_nav_params_->frame_id); 330 DCHECK_EQ(frame_tree_node_->frame_id(), pending_nav_params_->frame_id);
325 331
326 // Now that the unload handler has run, we need to either initiate the 332 // 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). 333 // 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 334 // 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 335 // we can shorten this by delivering the response directly, rather than
330 // forcing an identical request to be made. 336 // forcing an identical request to be made.
331 if (pending_nav_params_->is_transfer) { 337 if (pending_nav_params_->cross_site_transferring_request) {
332 // Treat the last URL in the chain as the destination and the remainder as 338 // Treat the last URL in the chain as the destination and the remainder as
333 // the redirect chain. 339 // the redirect chain.
334 CHECK(pending_nav_params_->transfer_url_chain.size()); 340 CHECK(pending_nav_params_->transfer_url_chain.size());
335 GURL transfer_url = pending_nav_params_->transfer_url_chain.back(); 341 GURL transfer_url = pending_nav_params_->transfer_url_chain.back();
336 pending_nav_params_->transfer_url_chain.pop_back(); 342 pending_nav_params_->transfer_url_chain.pop_back();
337 343
338 // We don't know whether the original request had |user_action| set to true. 344 // 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 345 // However, since we force the navigation to be in the current tab, it
340 // doesn't matter. 346 // doesn't matter.
341 // TODO(creis): Move RequestTransferURL to RenderFrameHost's navigator. 347 // TODO(creis): Move RequestTransferURL to RenderFrameHost's navigator.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // This is not a cross-site navigation, the tab is being closed. 479 // This is not a cross-site navigation, the tab is being closed.
474 render_frame_host_->render_view_host()->ClosePage(); 480 render_frame_host_->render_view_host()->ClosePage();
475 } 481 }
476 } 482 }
477 } 483 }
478 484
479 // TODO(creis): Take in a RenderFrameHost from CSRH. 485 // TODO(creis): Take in a RenderFrameHost from CSRH.
480 void RenderFrameHostManager::OnCrossSiteResponse( 486 void RenderFrameHostManager::OnCrossSiteResponse(
481 RenderViewHost* pending_render_view_host, 487 RenderViewHost* pending_render_view_host,
482 const GlobalRequestID& global_request_id, 488 const GlobalRequestID& global_request_id,
483 bool is_transfer, 489 scoped_ptr<CrossSiteTransferringRequest> cross_site_transferring_request,
484 const std::vector<GURL>& transfer_url_chain, 490 const std::vector<GURL>& transfer_url_chain,
485 const Referrer& referrer, 491 const Referrer& referrer,
486 PageTransition page_transition, 492 PageTransition page_transition,
487 int64 frame_id, 493 int64 frame_id,
488 bool should_replace_current_entry) { 494 bool should_replace_current_entry) {
489 // This should be called either when the pending RVH is ready to commit or 495 // This should be called either when the pending RVH is ready to commit or
490 // when we realize that the current RVH's request requires a transfer. 496 // when we realize that the current RVH's request requires a transfer.
491 DCHECK(pending_render_view_host == render_frame_host_->render_view_host() || 497 DCHECK(pending_render_view_host == render_frame_host_->render_view_host() ||
492 pending_render_view_host == 498 pending_render_view_host ==
493 pending_render_frame_host_->render_view_host()); 499 pending_render_frame_host_->render_view_host());
494 500
495 // TODO(creis): Eventually we will want to check all navigation responses 501 // TODO(creis): Eventually we will want to check all navigation responses
496 // here, but currently we pass information for a transfer if 502 // here, but currently we pass information for a transfer if
497 // ShouldSwapProcessesForRedirect returned true in the network stack. 503 // ShouldSwapProcessesForRedirect returned true in the network stack.
498 // In that case, we should set up a transfer after the unload handler runs. 504 // In that case, we should set up a transfer after the unload handler runs.
499 // If is_transfer is false, we will just run the unload handler and resume. 505 // If |cross_site_transferring_request| is NULL, we will just run the unload
506 // handler and resume.
500 pending_nav_params_.reset(new PendingNavigationParams( 507 pending_nav_params_.reset(new PendingNavigationParams(
501 global_request_id, is_transfer, transfer_url_chain, referrer, 508 global_request_id, cross_site_transferring_request.Pass(),
502 page_transition, frame_id, should_replace_current_entry)); 509 transfer_url_chain, referrer, page_transition, frame_id,
510 should_replace_current_entry));
503 511
504 // Run the unload handler of the current page. 512 // Run the unload handler of the current page.
505 SwapOutOldPage(); 513 SwapOutOldPage();
506 } 514 }
507 515
508 void RenderFrameHostManager::SwapOutOldPage() { 516 void RenderFrameHostManager::SwapOutOldPage() {
509 // Should only see this while we have a pending renderer or transfer. 517 // Should only see this while we have a pending renderer or transfer.
510 CHECK(cross_navigation_pending_ || pending_nav_params_.get()); 518 CHECK(cross_navigation_pending_ || pending_nav_params_.get());
511 519
512 // Tell the renderer to suppress any further modal dialogs so that we can swap 520 // Tell the renderer to suppress any further modal dialogs so that we can swap
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 SiteInstance* instance) const { 1449 SiteInstance* instance) const {
1442 RenderFrameHostMap::const_iterator iter = 1450 RenderFrameHostMap::const_iterator iter =
1443 swapped_out_hosts_.find(instance->GetId()); 1451 swapped_out_hosts_.find(instance->GetId());
1444 if (iter != swapped_out_hosts_.end()) 1452 if (iter != swapped_out_hosts_.end())
1445 return iter->second; 1453 return iter->second;
1446 1454
1447 return NULL; 1455 return NULL;
1448 } 1456 }
1449 1457
1450 } // namespace content 1458 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698