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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 RenderViewHostDelegate* render_view_delegate, | 54 RenderViewHostDelegate* render_view_delegate, |
55 RenderWidgetHostDelegate* render_widget_delegate, | 55 RenderWidgetHostDelegate* render_widget_delegate, |
56 Delegate* delegate) | 56 Delegate* delegate) |
57 : frame_tree_node_(frame_tree_node), | 57 : frame_tree_node_(frame_tree_node), |
58 delegate_(delegate), | 58 delegate_(delegate), |
59 cross_navigation_pending_(false), | 59 cross_navigation_pending_(false), |
60 render_frame_delegate_(render_frame_delegate), | 60 render_frame_delegate_(render_frame_delegate), |
61 render_view_delegate_(render_view_delegate), | 61 render_view_delegate_(render_view_delegate), |
62 render_widget_delegate_(render_widget_delegate), | 62 render_widget_delegate_(render_widget_delegate), |
63 interstitial_page_(NULL), | 63 interstitial_page_(NULL), |
64 weak_factory_(this) { | 64 weak_factory_(this), |
| 65 should_reuse_web_ui_(false) { |
65 DCHECK(frame_tree_node_); | 66 DCHECK(frame_tree_node_); |
66 } | 67 } |
67 | 68 |
68 RenderFrameHostManager::~RenderFrameHostManager() { | 69 RenderFrameHostManager::~RenderFrameHostManager() { |
69 if (pending_render_frame_host_) | 70 if (pending_render_frame_host_) |
70 CancelPending(); | 71 CancelPending(); |
71 | 72 |
| 73 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 74 switches::kEnableBrowserSideNavigation)) { |
| 75 CleanUpNavigation(); |
| 76 } |
| 77 |
72 // We should always have a current RenderFrameHost except in some tests. | 78 // We should always have a current RenderFrameHost except in some tests. |
73 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); | 79 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); |
74 | 80 |
75 // Delete any swapped out RenderFrameHosts. | 81 // Delete any swapped out RenderFrameHosts. |
76 STLDeleteValues(&proxy_hosts_); | 82 STLDeleteValues(&proxy_hosts_); |
77 } | 83 } |
78 | 84 |
79 void RenderFrameHostManager::Init(BrowserContext* browser_context, | 85 void RenderFrameHostManager::Init(BrowserContext* browser_context, |
80 SiteInstance* site_instance, | 86 SiteInstance* site_instance, |
81 int view_routing_id, | 87 int view_routing_id, |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 } | 287 } |
282 } | 288 } |
283 return false; | 289 return false; |
284 } | 290 } |
285 | 291 |
286 void RenderFrameHostManager::OnBeforeUnloadACK( | 292 void RenderFrameHostManager::OnBeforeUnloadACK( |
287 bool for_cross_site_transition, | 293 bool for_cross_site_transition, |
288 bool proceed, | 294 bool proceed, |
289 const base::TimeTicks& proceed_time) { | 295 const base::TimeTicks& proceed_time) { |
290 if (for_cross_site_transition) { | 296 if (for_cross_site_transition) { |
| 297 DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch( |
| 298 switches::kEnableBrowserSideNavigation)); |
291 // Ignore if we're not in a cross-site navigation. | 299 // Ignore if we're not in a cross-site navigation. |
292 if (!cross_navigation_pending_) | 300 if (!cross_navigation_pending_) |
293 return; | 301 return; |
294 | 302 |
295 if (proceed) { | 303 if (proceed) { |
296 // Ok to unload the current page, so proceed with the cross-site | 304 // Ok to unload the current page, so proceed with the cross-site |
297 // navigation. Note that if navigations are not currently suspended, it | 305 // navigation. Note that if navigations are not currently suspended, it |
298 // might be because the renderer was deemed unresponsive and this call was | 306 // might be because the renderer was deemed unresponsive and this call was |
299 // already made by ShouldCloseTabOnUnresponsiveRenderer. In that case, it | 307 // already made by ShouldCloseTabOnUnresponsiveRenderer. In that case, it |
300 // is ok to do nothing here. | 308 // is ok to do nothing here. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 | 420 |
413 response_started_id_.reset(); | 421 response_started_id_.reset(); |
414 } | 422 } |
415 | 423 |
416 void RenderFrameHostManager::ClearNavigationTransitionData() { | 424 void RenderFrameHostManager::ClearNavigationTransitionData() { |
417 render_frame_host_->ClearPendingTransitionRequestData(); | 425 render_frame_host_->ClearPendingTransitionRequestData(); |
418 } | 426 } |
419 | 427 |
420 void RenderFrameHostManager::DidNavigateFrame( | 428 void RenderFrameHostManager::DidNavigateFrame( |
421 RenderFrameHostImpl* render_frame_host) { | 429 RenderFrameHostImpl* render_frame_host) { |
| 430 DCHECK(render_frame_host); |
| 431 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 432 switches::kEnableBrowserSideNavigation)) { |
| 433 return; |
| 434 } |
| 435 |
422 if (!cross_navigation_pending_) { | 436 if (!cross_navigation_pending_) { |
423 DCHECK(!pending_render_frame_host_); | 437 DCHECK(!pending_render_frame_host_); |
424 | 438 |
425 // We should only hear this from our current renderer. | 439 // We should only hear this from our current renderer. |
426 DCHECK_EQ(render_frame_host_, render_frame_host); | 440 DCHECK_EQ(render_frame_host_, render_frame_host); |
427 | 441 |
428 // Even when there is no pending RVH, there may be a pending Web UI. | 442 // Even when there is no pending RVH, there may be a pending Web UI. |
429 if (pending_web_ui()) | 443 if (pending_web_ui()) |
430 CommitPending(); | 444 CommitPending(); |
431 return; | 445 return; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 } | 626 } |
613 } | 627 } |
614 return false; | 628 return false; |
615 } | 629 } |
616 | 630 |
617 void RenderFrameHostManager::ResetProxyHosts() { | 631 void RenderFrameHostManager::ResetProxyHosts() { |
618 STLDeleteValues(&proxy_hosts_); | 632 STLDeleteValues(&proxy_hosts_); |
619 } | 633 } |
620 | 634 |
621 // PlzNavigate | 635 // PlzNavigate |
| 636 void RenderFrameHostManager::BeginNavigation( |
| 637 const FrameHostMsg_BeginNavigation_Params& params, |
| 638 const CommonNavigationParams& common_params) { |
| 639 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( |
| 640 switches::kEnableBrowserSideNavigation)); |
| 641 // If there is an ongoing navigation, cancel it. |
| 642 CleanUpNavigation(); |
| 643 |
| 644 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
| 645 // TODO(carlosk): Replace the default values with the right ones. |
| 646 scoped_refptr<SiteInstanceImpl> new_instance = |
| 647 static_cast<SiteInstanceImpl*>(GetSiteInstanceForNavigation( |
| 648 common_params.url, nullptr, common_params.transition, false, false)); |
| 649 |
| 650 if (new_instance.get() != current_instance && |
| 651 (frame_tree_node_->IsMainFrame() || |
| 652 CommandLine::ForCurrentProcess()->HasSwitch( |
| 653 switches::kSitePerProcess))) { |
| 654 // Navigating to a new SiteInstance -> speculatively create a new RFH. |
| 655 |
| 656 // TODO(carlosk): enable bindings check below. |
| 657 bool success = CreateSpeculativeRenderFrameHost( |
| 658 common_params.url, current_instance, new_instance.get(), |
| 659 NavigationEntryImpl::kInvalidBindings); |
| 660 if (!success) |
| 661 return; |
| 662 DCHECK(new_instance->GetProcess()->HasConnection()); |
| 663 DCHECK(new_instance->GetProcess()->GetBrowserContext()); |
| 664 } else { |
| 665 // Navigating to the same SiteInstance -> make sure the current RFH is |
| 666 // alive. |
| 667 if (!render_frame_host_->render_view_host()->IsRenderViewLive()) { |
| 668 // Recreate the opener chain. |
| 669 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( |
| 670 render_frame_host_->GetSiteInstance()); |
| 671 if (!InitRenderView(render_frame_host_->render_view_host(), |
| 672 opener_route_id, MSG_ROUTING_NONE, |
| 673 frame_tree_node_->IsMainFrame())) { |
| 674 return; |
| 675 } |
| 676 } |
| 677 DCHECK(current_instance->GetProcess()->HasConnection()); |
| 678 DCHECK(current_instance->GetProcess()->GetBrowserContext()); |
| 679 } |
| 680 } |
| 681 |
| 682 // PlzNavigate |
| 683 bool RenderFrameHostManager::CreateSpeculativeRenderFrameHost( |
| 684 const GURL& url, |
| 685 SiteInstance* old_instance, |
| 686 SiteInstance* new_instance, |
| 687 int bindings) { |
| 688 CHECK(new_instance); |
| 689 CHECK_NE(old_instance, new_instance); |
| 690 |
| 691 const NavigationEntry* current_navigation_entry = |
| 692 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
| 693 scoped_ptr<WebUIImpl> new_web_ui; |
| 694 should_reuse_web_ui_ = ShouldReuseWebUI(current_navigation_entry, url); |
| 695 if (!should_reuse_web_ui_) |
| 696 new_web_ui = CreateWebUI(url, bindings); |
| 697 |
| 698 int opener_route_id = |
| 699 CreateOpenerRenderViewsIfNeeded(old_instance, new_instance); |
| 700 |
| 701 int create_render_frame_flags = 0; |
| 702 if (frame_tree_node_->IsMainFrame()) |
| 703 create_render_frame_flags |= CREATE_RF_FOR_MAIN_FRAME_NAVIGATION; |
| 704 if (delegate_->IsHidden()) |
| 705 create_render_frame_flags |= CREATE_RF_HIDDEN; |
| 706 scoped_ptr<RenderFrameHostImpl> new_render_frame_host = |
| 707 CreateRenderFrame(new_instance, new_web_ui.get(), opener_route_id, |
| 708 create_render_frame_flags, nullptr); |
| 709 if (!new_render_frame_host) { |
| 710 return false; |
| 711 } |
| 712 speculative_render_frame_host_.reset(new_render_frame_host.release()); |
| 713 speculative_web_ui_.reset(new_web_ui.release()); |
| 714 return true; |
| 715 } |
| 716 |
| 717 // PlzNavigate |
622 RenderFrameHostImpl* RenderFrameHostManager::GetFrameHostForNavigation( | 718 RenderFrameHostImpl* RenderFrameHostManager::GetFrameHostForNavigation( |
623 const GURL& url, | 719 const GURL& url, |
624 ui::PageTransition transition) { | 720 ui::PageTransition transition) { |
625 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( | 721 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( |
626 switches::kEnableBrowserSideNavigation)); | 722 switches::kEnableBrowserSideNavigation)); |
627 // TODO(clamy): When we handle renderer initiated navigations, make sure not | 723 // TODO(clamy): When we handle renderer initiated navigations, make sure not |
628 // to use a different process for subframes if --site-per-process is not | 724 // to use a different process for subframes if --site-per-process is not |
629 // enabled. | 725 // enabled. |
630 | 726 |
631 // Pick the right RenderFrameHost to commit the navigation. | 727 // Pick the right RenderFrameHost to commit the navigation. |
(...skipping 11 matching lines...) Expand all Loading... |
643 if (!InitRenderView(render_frame_host->render_view_host(), | 739 if (!InitRenderView(render_frame_host->render_view_host(), |
644 opener_route_id, | 740 opener_route_id, |
645 MSG_ROUTING_NONE, | 741 MSG_ROUTING_NONE, |
646 frame_tree_node_->IsMainFrame())) { | 742 frame_tree_node_->IsMainFrame())) { |
647 return NULL; | 743 return NULL; |
648 } | 744 } |
649 } | 745 } |
650 return render_frame_host; | 746 return render_frame_host; |
651 } | 747 } |
652 | 748 |
| 749 // PlzNavigate |
| 750 void RenderFrameHostManager::CleanUpNavigation() { |
| 751 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( |
| 752 switches::kEnableBrowserSideNavigation)); |
| 753 if (speculative_render_frame_host_) { |
| 754 speculative_render_frame_host_->GetProcess()->RemovePendingView(); |
| 755 DiscardUnusedFrame(speculative_render_frame_host_.Pass()); |
| 756 } |
| 757 if (speculative_web_ui_) |
| 758 speculative_web_ui_.reset(); |
| 759 } |
| 760 |
653 void RenderFrameHostManager::Observe( | 761 void RenderFrameHostManager::Observe( |
654 int type, | 762 int type, |
655 const NotificationSource& source, | 763 const NotificationSource& source, |
656 const NotificationDetails& details) { | 764 const NotificationDetails& details) { |
657 switch (type) { | 765 switch (type) { |
658 case NOTIFICATION_RENDERER_PROCESS_CLOSED: | 766 case NOTIFICATION_RENDERER_PROCESS_CLOSED: |
659 case NOTIFICATION_RENDERER_PROCESS_CLOSING: | 767 case NOTIFICATION_RENDERER_PROCESS_CLOSING: |
660 RendererProcessClosing( | 768 RendererProcessClosing( |
661 Source<RenderProcessHost>(source).ptr()); | 769 Source<RenderProcessHost>(source).ptr()); |
662 break; | 770 break; |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 // longer relies on swapped out RFH for the top-level frame. | 1211 // longer relies on swapped out RFH for the top-level frame. |
1104 if (!frame_tree_node_->IsMainFrame()) { | 1212 if (!frame_tree_node_->IsMainFrame()) { |
1105 CHECK(!swapped_out); | 1213 CHECK(!swapped_out); |
1106 } | 1214 } |
1107 | 1215 |
1108 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; | 1216 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; |
1109 bool success = true; | 1217 bool success = true; |
1110 if (view_routing_id_ptr) | 1218 if (view_routing_id_ptr) |
1111 *view_routing_id_ptr = MSG_ROUTING_NONE; | 1219 *view_routing_id_ptr = MSG_ROUTING_NONE; |
1112 | 1220 |
1113 // We are creating a pending or swapped out RFH here. We should never create | 1221 // We are creating a pending, speculative or swapped out RFH here. We should |
1114 // it in the same SiteInstance as our current RFH. | 1222 // never create it in the same SiteInstance as our current RFH. |
1115 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); | 1223 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); |
1116 | 1224 |
1117 // Check if we've already created an RFH for this SiteInstance. If so, try | 1225 // Check if we've already created an RFH for this SiteInstance. If so, try |
1118 // to re-use the existing one, which has already been initialized. We'll | 1226 // to re-use the existing one, which has already been initialized. We'll |
1119 // remove it from the list of proxy hosts below if it will be active. | 1227 // remove it from the list of proxy hosts below if it will be active. |
1120 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 1228 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
1121 if (proxy && proxy->render_frame_host()) { | 1229 if (proxy && proxy->render_frame_host()) { |
1122 if (view_routing_id_ptr) | 1230 if (view_routing_id_ptr) |
1123 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); | 1231 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); |
1124 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. | 1232 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 proxy_hosts_.find(site_instance->GetId()); | 1389 proxy_hosts_.find(site_instance->GetId()); |
1282 if (iter != proxy_hosts_.end()) | 1390 if (iter != proxy_hosts_.end()) |
1283 return iter->second->GetRoutingID(); | 1391 return iter->second->GetRoutingID(); |
1284 | 1392 |
1285 return MSG_ROUTING_NONE; | 1393 return MSG_ROUTING_NONE; |
1286 } | 1394 } |
1287 | 1395 |
1288 void RenderFrameHostManager::CommitPending() { | 1396 void RenderFrameHostManager::CommitPending() { |
1289 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", | 1397 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", |
1290 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | 1398 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
| 1399 bool use_speculative_rfh = CommandLine::ForCurrentProcess()->HasSwitch( |
| 1400 switches::kEnableBrowserSideNavigation); |
| 1401 |
1291 // First check whether we're going to want to focus the location bar after | 1402 // First check whether we're going to want to focus the location bar after |
1292 // this commit. We do this now because the navigation hasn't formally | 1403 // this commit. We do this now because the navigation hasn't formally |
1293 // committed yet, so if we've already cleared |pending_web_ui_| the call chain | 1404 // committed yet, so if we've already cleared |pending_web_ui_| the call chain |
1294 // this triggers won't be able to figure out what's going on. | 1405 // this triggers won't be able to figure out what's going on. |
1295 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 1406 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); |
1296 | 1407 |
1297 // Next commit the Web UI, if any. Either replace |web_ui_| with | 1408 if (!use_speculative_rfh) { |
1298 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or | 1409 DCHECK(!speculative_web_ui_); |
1299 // leave |web_ui_| as is if reusing it. | 1410 // Next commit the Web UI, if any. Either replace |web_ui_| with |
1300 DCHECK(!(pending_web_ui_.get() && pending_and_current_web_ui_.get())); | 1411 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or |
1301 if (pending_web_ui_) { | 1412 // leave |web_ui_| as is if reusing it. |
1302 web_ui_.reset(pending_web_ui_.release()); | 1413 DCHECK(!(pending_web_ui_.get() && pending_and_current_web_ui_.get())); |
1303 } else if (!pending_and_current_web_ui_.get()) { | 1414 if (pending_web_ui_) { |
1304 web_ui_.reset(); | 1415 web_ui_.reset(pending_web_ui_.release()); |
| 1416 } else if (!pending_and_current_web_ui_.get()) { |
| 1417 web_ui_.reset(); |
| 1418 } else { |
| 1419 DCHECK_EQ(pending_and_current_web_ui_.get(), web_ui_.get()); |
| 1420 pending_and_current_web_ui_.reset(); |
| 1421 } |
1305 } else { | 1422 } else { |
1306 DCHECK_EQ(pending_and_current_web_ui_.get(), web_ui_.get()); | 1423 if (!should_reuse_web_ui_) |
1307 pending_and_current_web_ui_.reset(); | 1424 web_ui_.reset(speculative_web_ui_.release()); |
1308 } | 1425 } |
1309 | 1426 |
1310 // It's possible for the pending_render_frame_host_ to be NULL when we aren't | 1427 // It's possible for the pending_render_frame_host_ to be NULL when we aren't |
1311 // crossing process boundaries. If so, we just needed to handle the Web UI | 1428 // crossing process boundaries. If so, we just needed to handle the Web UI |
1312 // committing above and we're done. | 1429 // committing above and we're done. |
1313 if (!pending_render_frame_host_) { | 1430 if (!pending_render_frame_host_ && !use_speculative_rfh) { |
1314 if (will_focus_location_bar) | 1431 if (will_focus_location_bar) |
1315 delegate_->SetFocusToLocationBar(false); | 1432 delegate_->SetFocusToLocationBar(false); |
1316 return; | 1433 return; |
1317 } | 1434 } |
1318 | 1435 |
1319 // Remember if the page was focused so we can focus the new renderer in | 1436 // Remember if the page was focused so we can focus the new renderer in |
1320 // that case. | 1437 // that case. |
1321 bool focus_render_view = !will_focus_location_bar && | 1438 bool focus_render_view = !will_focus_location_bar && |
1322 render_frame_host_->render_view_host()->GetView() && | 1439 render_frame_host_->render_view_host()->GetView() && |
1323 render_frame_host_->render_view_host()->GetView()->HasFocus(); | 1440 render_frame_host_->render_view_host()->GetView()->HasFocus(); |
1324 | 1441 |
1325 bool is_main_frame = frame_tree_node_->IsMainFrame(); | 1442 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
1326 | 1443 |
1327 // Swap in the pending frame and make it active. Also ensure the FrameTree | 1444 scoped_ptr<RenderFrameHostImpl> old_render_frame_host; |
1328 // stays in sync. | 1445 if (!use_speculative_rfh) { |
1329 scoped_ptr<RenderFrameHostImpl> old_render_frame_host = | 1446 DCHECK(!speculative_render_frame_host_); |
1330 SetRenderFrameHost(pending_render_frame_host_.Pass()); | 1447 // Swap in the pending frame and make it active. Also ensure the FrameTree |
| 1448 // stays in sync. |
| 1449 old_render_frame_host = |
| 1450 SetRenderFrameHost(pending_render_frame_host_.Pass()); |
| 1451 } else { |
| 1452 DCHECK(speculative_render_frame_host_); |
| 1453 old_render_frame_host = |
| 1454 SetRenderFrameHost(speculative_render_frame_host_.Pass()); |
| 1455 } |
| 1456 |
1331 if (is_main_frame) | 1457 if (is_main_frame) |
1332 render_frame_host_->render_view_host()->AttachToFrameTree(); | 1458 render_frame_host_->render_view_host()->AttachToFrameTree(); |
1333 | 1459 |
1334 // The process will no longer try to exit, so we can decrement the count. | 1460 // The process will no longer try to exit, so we can decrement the count. |
1335 render_frame_host_->GetProcess()->RemovePendingView(); | 1461 render_frame_host_->GetProcess()->RemovePendingView(); |
1336 | 1462 |
1337 // Show the new view (or a sad tab) if necessary. | 1463 // Show the new view (or a sad tab) if necessary. |
1338 bool new_rfh_has_view = !!render_frame_host_->render_view_host()->GetView(); | 1464 bool new_rfh_has_view = !!render_frame_host_->render_view_host()->GetView(); |
1339 if (!delegate_->IsHidden() && new_rfh_has_view) { | 1465 if (!delegate_->IsHidden() && new_rfh_has_view) { |
1340 // In most cases, we need to show the new view. | 1466 // In most cases, we need to show the new view. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 if (cross_navigation_pending_) { | 1575 if (cross_navigation_pending_) { |
1450 if (pending_render_frame_host_) | 1576 if (pending_render_frame_host_) |
1451 CancelPending(); | 1577 CancelPending(); |
1452 cross_navigation_pending_ = false; | 1578 cross_navigation_pending_ = false; |
1453 } | 1579 } |
1454 | 1580 |
1455 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 1581 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
1456 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( | 1582 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( |
1457 url, instance, transition, is_restore, is_view_source_mode); | 1583 url, instance, transition, is_restore, is_view_source_mode); |
1458 | 1584 |
| 1585 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1586 switches::kEnableBrowserSideNavigation)) { |
| 1587 if (current_instance == new_instance.get() || |
| 1588 (!frame_tree_node_->IsMainFrame() && |
| 1589 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 1590 switches::kSitePerProcess))) { |
| 1591 CleanUpNavigation(); |
| 1592 } else { |
| 1593 // If the SiteInstance for the final URL doesn't match the one form the |
| 1594 // speculatively created RenderFrameHost, create a new one using the |
| 1595 // former. |
| 1596 if (!speculative_render_frame_host_ || |
| 1597 speculative_render_frame_host_->GetSiteInstance() != |
| 1598 new_instance.get()) { |
| 1599 CleanUpNavigation(); |
| 1600 // TODO(carlosk): Should rename this method and the speculative members |
| 1601 // because in this case they are not speculative. Suggestions are |
| 1602 // very welcome! |
| 1603 bool success = CreateSpeculativeRenderFrameHost( |
| 1604 url, current_instance, new_instance.get(), bindings); |
| 1605 if (!success) |
| 1606 return nullptr; |
| 1607 } |
| 1608 DCHECK(speculative_render_frame_host_); |
| 1609 CommitPending(); |
| 1610 DCHECK(!speculative_render_frame_host_); |
| 1611 } |
| 1612 return render_frame_host_.get(); |
| 1613 } |
| 1614 |
1459 const NavigationEntry* current_entry = | 1615 const NavigationEntry* current_entry = |
1460 delegate_->GetLastCommittedNavigationEntryForRenderManager(); | 1616 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
1461 | 1617 |
1462 if (new_instance.get() != current_instance) { | 1618 if (new_instance.get() != current_instance) { |
1463 TRACE_EVENT_INSTANT2( | 1619 TRACE_EVENT_INSTANT2( |
1464 "navigation", | 1620 "navigation", |
1465 "RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance", | 1621 "RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance", |
1466 TRACE_EVENT_SCOPE_THREAD, | 1622 TRACE_EVENT_SCOPE_THREAD, |
1467 "current_instance id", current_instance->GetId(), | 1623 "current_instance id", current_instance->GetId(), |
1468 "new_instance id", new_instance->GetId()); | 1624 "new_instance id", new_instance->GetId()); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1830 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
1675 SiteInstance* instance) { | 1831 SiteInstance* instance) { |
1676 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1832 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
1677 if (iter != proxy_hosts_.end()) { | 1833 if (iter != proxy_hosts_.end()) { |
1678 delete iter->second; | 1834 delete iter->second; |
1679 proxy_hosts_.erase(iter); | 1835 proxy_hosts_.erase(iter); |
1680 } | 1836 } |
1681 } | 1837 } |
1682 | 1838 |
1683 } // namespace content | 1839 } // namespace content |
OLD | NEW |