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), |
Charlie Reis
2014/12/04 21:46:28
weak_factory_ must be last.
carlosk
2014/12/09 07:55:41
Done.
| |
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; | |
Charlie Reis
2014/12/04 21:46:28
I'm not sure this is correct.
What happens if a D
clamy
2014/12/05 17:16:19
If we go along with committing the NavigationEntry
Charlie Reis
2014/12/05 19:06:23
I'm nervous about this as well: ignoring a commit
carlosk
2014/12/09 07:55:42
I'm having trouble following your lines of thought
clamy
2014/12/09 15:09:51
Indeed, it seems we are in agreement that the spec
carlosk
2014/12/16 01:53:47
Done.
| |
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
553 // --site-per-process is used. | 567 // --site-per-process is used. |
554 DCHECK(is_main_frame); | 568 DCHECK(is_main_frame); |
555 | 569 |
556 // The old RenderFrameHost will stay alive inside the proxy so that existing | 570 // The old RenderFrameHost will stay alive inside the proxy so that existing |
557 // JavaScript window references to it stay valid. | 571 // JavaScript window references to it stay valid. |
558 proxy->TakeFrameHostOwnership(old_render_frame_host.Pass()); | 572 proxy->TakeFrameHostOwnership(old_render_frame_host.Pass()); |
559 } | 573 } |
560 } | 574 } |
561 | 575 |
562 void RenderFrameHostManager::DiscardUnusedFrame( | 576 void RenderFrameHostManager::DiscardUnusedFrame( |
563 scoped_ptr<RenderFrameHostImpl> render_frame_host) { | 577 scoped_ptr<RenderFrameHostImpl> render_frame_host) { |
carlosk
2014/12/03 16:25:25
Continuing the discussion that was started in crre
clamy
2014/12/03 17:24:48
Speaking of swapped out state, does the CommitPend
Charlie Reis
2014/12/04 21:46:28
Sounds good.
clamy
2014/12/05 17:16:19
One option could be to have RFH::CommitNavigation
carlosk
2014/12/09 07:55:42
It seems we need a test for a speculative RFH that
clamy
2014/12/09 15:09:51
If we go with swapping the speculative RFH in afte
Charlie Reis
2014/12/10 22:37:44
That sounds right. The only reason we swapped it
carlosk
2014/12/16 01:53:47
Done.
| |
564 // TODO(carlosk): this code is very similar to what can be found in | 578 // TODO(carlosk): this code is very similar to what can be found in |
565 // SwapOutOldFrame and we should see that these are unified at some point. | 579 // SwapOutOldFrame and we should see that these are unified at some point. |
566 | 580 |
567 // If the SiteInstance for the pending RFH is being used by others don't | 581 // If the SiteInstance for the pending RFH is being used by others don't |
568 // delete the RFH. Just swap it out and it can be reused at a later point. | 582 // delete the RFH. Just swap it out and it can be reused at a later point. |
569 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); | 583 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); |
570 if (site_instance->HasSite() && site_instance->active_frame_count() > 1) { | 584 if (site_instance->HasSite() && site_instance->active_frame_count() > 1) { |
571 // Any currently suspended navigations are no longer needed. | 585 // Any currently suspended navigations are no longer needed. |
572 render_frame_host->CancelSuspendedNavigations(); | 586 render_frame_host->CancelSuspendedNavigations(); |
573 | 587 |
574 RenderFrameProxyHost* proxy = | 588 RenderFrameProxyHost* proxy = |
575 new RenderFrameProxyHost(site_instance, frame_tree_node_); | 589 new RenderFrameProxyHost(site_instance, frame_tree_node_); |
576 proxy_hosts_[site_instance->GetId()] = proxy; | 590 proxy_hosts_[site_instance->GetId()] = proxy; |
577 render_frame_host->SwapOut(proxy); | 591 |
592 if (!render_frame_host->is_swapped_out()) | |
593 render_frame_host->SwapOut(proxy); | |
594 | |
578 if (frame_tree_node_->IsMainFrame()) | 595 if (frame_tree_node_->IsMainFrame()) |
579 proxy->TakeFrameHostOwnership(render_frame_host.Pass()); | 596 proxy->TakeFrameHostOwnership(render_frame_host.Pass()); |
580 } else { | 597 } else { |
581 // We won't be coming back, so delete this one. | 598 // We won't be coming back, so delete this one. |
582 render_frame_host.reset(); | 599 render_frame_host.reset(); |
583 } | 600 } |
584 } | 601 } |
585 | 602 |
586 void RenderFrameHostManager::MoveToPendingDeleteHosts( | 603 void RenderFrameHostManager::MoveToPendingDeleteHosts( |
587 scoped_ptr<RenderFrameHostImpl> render_frame_host) { | 604 scoped_ptr<RenderFrameHostImpl> render_frame_host) { |
(...skipping 24 matching lines...) Expand all Loading... | |
612 } | 629 } |
613 } | 630 } |
614 return false; | 631 return false; |
615 } | 632 } |
616 | 633 |
617 void RenderFrameHostManager::ResetProxyHosts() { | 634 void RenderFrameHostManager::ResetProxyHosts() { |
618 STLDeleteValues(&proxy_hosts_); | 635 STLDeleteValues(&proxy_hosts_); |
619 } | 636 } |
620 | 637 |
621 // PlzNavigate | 638 // PlzNavigate |
639 void RenderFrameHostManager::BeginNavigation( | |
Charlie Reis
2014/12/04 21:46:28
This code looks a lot like UpdateStateForNavigate,
carlosk
2014/12/09 07:55:42
Both methods do check if the current SiteInstance
| |
640 const FrameHostMsg_BeginNavigation_Params& params, | |
641 const CommonNavigationParams& common_params) { | |
642 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( | |
643 switches::kEnableBrowserSideNavigation)); | |
644 // If there is an ongoing navigation, cancel it. | |
Charlie Reis
2014/12/04 21:46:28
cancel it -> cancel any state we have for it.
(RF
clamy
2014/12/05 17:16:19
NavigatorImpl is normally responsible for cancelin
carlosk
2014/12/09 07:55:42
Updated the comment.
This was more of a just-in-c
clamy
2014/12/09 15:09:52
The way the code is written, there would not have
carlosk
2014/12/16 01:53:47
It is already being called in NavigatorImpl::Cance
| |
645 CleanUpNavigation(); | |
646 | |
647 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | |
648 // TODO(carlosk): Replace the default values with the right ones. | |
Charlie Reis
2014/12/04 21:46:28
I see this is the same TODO as in GetFrameHostForN
clamy
2014/12/05 17:16:19
Note that it also concerns the SiteInstance pointe
carlosk
2014/12/09 07:55:42
Updated comment.
| |
649 scoped_refptr<SiteInstanceImpl> new_instance = | |
650 static_cast<SiteInstanceImpl*>(GetSiteInstanceForNavigation( | |
651 common_params.url, nullptr, common_params.transition, false, false)); | |
652 | |
653 if (new_instance.get() != current_instance && | |
654 (frame_tree_node_->IsMainFrame() || | |
Charlie Reis
2014/12/04 21:46:28
These additional checks are non-obvious, so please
clamy
2014/12/05 17:16:19
In that case, we need to be able to distinguish he
Charlie Reis
2014/12/05 19:06:23
Yes, but this is an important TODO we'll need to r
carlosk
2014/12/09 07:55:42
I inverted the logic here to match the similar sni
clamy
2014/12/09 15:09:51
I think it is fine to have an if-block with just a
carlosk
2014/12/16 01:53:47
Done!
| |
655 CommandLine::ForCurrentProcess()->HasSwitch( | |
656 switches::kSitePerProcess))) { | |
657 // Navigating to a new SiteInstance -> speculatively create a new RFH. | |
658 | |
659 // TODO(carlosk): enable bindings check below. | |
660 bool success = CreateSpeculativeRenderFrameHost( | |
661 common_params.url, current_instance, new_instance.get(), | |
662 NavigationEntryImpl::kInvalidBindings); | |
663 if (!success) | |
664 return; | |
665 DCHECK(new_instance->GetProcess()->HasConnection()); | |
666 DCHECK(new_instance->GetProcess()->GetBrowserContext()); | |
Charlie Reis
2014/12/04 21:46:28
This second check seems unnecessary. Is there a w
carlosk
2014/12/09 07:55:42
I was going to say this was a copy/paste from anot
| |
667 } else { | |
Charlie Reis
2014/12/04 21:46:28
nit: Return here inside the previous block, so tha
carlosk
2014/12/09 07:55:42
Done.
| |
668 // Navigating to the same SiteInstance -> make sure the current RFH is | |
669 // alive. | |
670 if (!render_frame_host_->render_view_host()->IsRenderViewLive()) { | |
671 // Recreate the opener chain. | |
672 int opener_route_id = delegate_->CreateOpenerRenderViewsForRenderManager( | |
673 render_frame_host_->GetSiteInstance()); | |
674 if (!InitRenderView(render_frame_host_->render_view_host(), | |
675 opener_route_id, MSG_ROUTING_NONE, | |
676 frame_tree_node_->IsMainFrame())) { | |
677 return; | |
678 } | |
679 } | |
680 DCHECK(current_instance->GetProcess()->HasConnection()); | |
681 DCHECK(current_instance->GetProcess()->GetBrowserContext()); | |
682 } | |
683 } | |
684 | |
685 // PlzNavigate | |
686 bool RenderFrameHostManager::CreateSpeculativeRenderFrameHost( | |
687 const GURL& url, | |
688 SiteInstance* old_instance, | |
689 SiteInstance* new_instance, | |
690 int bindings) { | |
691 CHECK(new_instance); | |
692 CHECK_NE(old_instance, new_instance); | |
693 | |
694 const NavigationEntry* current_navigation_entry = | |
695 delegate_->GetLastCommittedNavigationEntryForRenderManager(); | |
696 scoped_ptr<WebUIImpl> new_web_ui; | |
697 should_reuse_web_ui_ = ShouldReuseWebUI(current_navigation_entry, url); | |
698 if (!should_reuse_web_ui_) | |
699 new_web_ui = CreateWebUI(url, bindings); | |
700 | |
701 int opener_route_id = | |
702 CreateOpenerRenderViewsIfNeeded(old_instance, new_instance); | |
703 | |
704 int create_render_frame_flags = 0; | |
705 if (frame_tree_node_->IsMainFrame()) | |
706 create_render_frame_flags |= CREATE_RF_FOR_MAIN_FRAME_NAVIGATION; | |
707 if (delegate_->IsHidden()) | |
708 create_render_frame_flags |= CREATE_RF_HIDDEN; | |
709 scoped_ptr<RenderFrameHostImpl> new_render_frame_host = | |
710 CreateRenderFrame(new_instance, new_web_ui.get(), opener_route_id, | |
711 create_render_frame_flags, nullptr); | |
712 if (!new_render_frame_host) { | |
713 return false; | |
714 } | |
715 speculative_render_frame_host_.reset(new_render_frame_host.release()); | |
716 speculative_web_ui_.reset(new_web_ui.release()); | |
717 return true; | |
718 } | |
719 | |
720 // PlzNavigate | |
622 RenderFrameHostImpl* RenderFrameHostManager::GetFrameHostForNavigation( | 721 RenderFrameHostImpl* RenderFrameHostManager::GetFrameHostForNavigation( |
623 const GURL& url, | 722 const GURL& url, |
624 ui::PageTransition transition) { | 723 ui::PageTransition transition) { |
625 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( | 724 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( |
626 switches::kEnableBrowserSideNavigation)); | 725 switches::kEnableBrowserSideNavigation)); |
627 // TODO(clamy): When we handle renderer initiated navigations, make sure not | 726 // 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 | 727 // to use a different process for subframes if --site-per-process is not |
629 // enabled. | 728 // enabled. |
630 | 729 |
631 // Pick the right RenderFrameHost to commit the navigation. | 730 // Pick the right RenderFrameHost to commit the navigation. |
(...skipping 11 matching lines...) Expand all Loading... | |
643 if (!InitRenderView(render_frame_host->render_view_host(), | 742 if (!InitRenderView(render_frame_host->render_view_host(), |
644 opener_route_id, | 743 opener_route_id, |
645 MSG_ROUTING_NONE, | 744 MSG_ROUTING_NONE, |
646 frame_tree_node_->IsMainFrame())) { | 745 frame_tree_node_->IsMainFrame())) { |
647 return NULL; | 746 return NULL; |
648 } | 747 } |
649 } | 748 } |
650 return render_frame_host; | 749 return render_frame_host; |
651 } | 750 } |
652 | 751 |
752 // PlzNavigate | |
753 void RenderFrameHostManager::CleanUpNavigation() { | |
754 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( | |
755 switches::kEnableBrowserSideNavigation)); | |
756 if (speculative_render_frame_host_) { | |
757 speculative_render_frame_host_->GetProcess()->RemovePendingView(); | |
758 DiscardUnusedFrame(speculative_render_frame_host_.Pass()); | |
759 } | |
760 if (speculative_web_ui_) | |
761 speculative_web_ui_.reset(); | |
762 should_reuse_web_ui_ = false; | |
763 } | |
764 | |
653 void RenderFrameHostManager::Observe( | 765 void RenderFrameHostManager::Observe( |
654 int type, | 766 int type, |
655 const NotificationSource& source, | 767 const NotificationSource& source, |
656 const NotificationDetails& details) { | 768 const NotificationDetails& details) { |
657 switch (type) { | 769 switch (type) { |
658 case NOTIFICATION_RENDERER_PROCESS_CLOSED: | 770 case NOTIFICATION_RENDERER_PROCESS_CLOSED: |
659 case NOTIFICATION_RENDERER_PROCESS_CLOSING: | 771 case NOTIFICATION_RENDERER_PROCESS_CLOSING: |
660 RendererProcessClosing( | 772 RendererProcessClosing( |
661 Source<RenderProcessHost>(source).ptr()); | 773 Source<RenderProcessHost>(source).ptr()); |
662 break; | 774 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. | 1215 // longer relies on swapped out RFH for the top-level frame. |
1104 if (!frame_tree_node_->IsMainFrame()) { | 1216 if (!frame_tree_node_->IsMainFrame()) { |
1105 CHECK(!swapped_out); | 1217 CHECK(!swapped_out); |
1106 } | 1218 } |
1107 | 1219 |
1108 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; | 1220 scoped_ptr<RenderFrameHostImpl> new_render_frame_host; |
1109 bool success = true; | 1221 bool success = true; |
1110 if (view_routing_id_ptr) | 1222 if (view_routing_id_ptr) |
1111 *view_routing_id_ptr = MSG_ROUTING_NONE; | 1223 *view_routing_id_ptr = MSG_ROUTING_NONE; |
1112 | 1224 |
1113 // We are creating a pending or swapped out RFH here. We should never create | 1225 // We are creating a pending, speculative or swapped out RFH here. We should |
1114 // it in the same SiteInstance as our current RFH. | 1226 // never create it in the same SiteInstance as our current RFH. |
1115 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); | 1227 CHECK_NE(render_frame_host_->GetSiteInstance(), instance); |
1116 | 1228 |
1117 // Check if we've already created an RFH for this SiteInstance. If so, try | 1229 // 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 | 1230 // 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. | 1231 // remove it from the list of proxy hosts below if it will be active. |
1120 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); | 1232 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(instance); |
1121 if (proxy && proxy->render_frame_host()) { | 1233 if (proxy && proxy->render_frame_host()) { |
1122 if (view_routing_id_ptr) | 1234 if (view_routing_id_ptr) |
1123 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); | 1235 *view_routing_id_ptr = proxy->GetRenderViewHost()->GetRoutingID(); |
1124 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. | 1236 // Delete the existing RenderFrameProxyHost, but reuse the RenderFrameHost. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1287 | 1399 |
1288 void RenderFrameHostManager::CommitPending() { | 1400 void RenderFrameHostManager::CommitPending() { |
1289 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", | 1401 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", |
1290 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | 1402 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
1291 // First check whether we're going to want to focus the location bar after | 1403 // 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 | 1404 // 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 | 1405 // 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. | 1406 // this triggers won't be able to figure out what's going on. |
1295 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 1407 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); |
1296 | 1408 |
1297 // Next commit the Web UI, if any. Either replace |web_ui_| with | 1409 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
Charlie Reis
2014/12/04 21:46:28
Please cache this in a bool so we don't repeatedly
carlosk
2014/12/09 07:55:42
Ha! I had just undone that. :) Re-added the boolea
| |
1298 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or | 1410 switches::kEnableBrowserSideNavigation)) { |
1299 // leave |web_ui_| as is if reusing it. | 1411 DCHECK(!speculative_web_ui_); |
1300 DCHECK(!(pending_web_ui_.get() && pending_and_current_web_ui_.get())); | 1412 // Next commit the Web UI, if any. Either replace |web_ui_| with |
1301 if (pending_web_ui_) { | 1413 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or |
1302 web_ui_.reset(pending_web_ui_.release()); | 1414 // leave |web_ui_| as is if reusing it. |
1303 } else if (!pending_and_current_web_ui_.get()) { | 1415 DCHECK(!(pending_web_ui_.get() && pending_and_current_web_ui_.get())); |
1304 web_ui_.reset(); | 1416 if (pending_web_ui_) { |
1417 web_ui_.reset(pending_web_ui_.release()); | |
1418 } else if (!pending_and_current_web_ui_.get()) { | |
1419 web_ui_.reset(); | |
1420 } else { | |
1421 DCHECK_EQ(pending_and_current_web_ui_.get(), web_ui_.get()); | |
1422 pending_and_current_web_ui_.reset(); | |
1423 } | |
1305 } else { | 1424 } else { |
1306 DCHECK_EQ(pending_and_current_web_ui_.get(), web_ui_.get()); | 1425 if (!should_reuse_web_ui_) |
1307 pending_and_current_web_ui_.reset(); | 1426 web_ui_.reset(speculative_web_ui_.release()); |
Charlie Reis
2014/12/04 21:46:28
Let's add a DCHECK(!speculative_web_ui_) after thi
carlosk
2014/12/09 07:55:42
Done.
| |
1308 } | 1427 } |
1309 | 1428 |
1310 // It's possible for the pending_render_frame_host_ to be NULL when we aren't | 1429 // 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 | 1430 // crossing process boundaries. If so, we just needed to handle the Web UI |
1312 // committing above and we're done. | 1431 // committing above and we're done. |
1313 if (!pending_render_frame_host_) { | 1432 if (!pending_render_frame_host_ && |
1433 !CommandLine::ForCurrentProcess()->HasSwitch( | |
1434 switches::kEnableBrowserSideNavigation)) { | |
Charlie Reis
2014/12/04 21:46:28
Can we make this !pending_render_frame_host_ && !s
carlosk
2014/12/09 07:55:42
Makes sense. Done.
| |
1314 if (will_focus_location_bar) | 1435 if (will_focus_location_bar) |
1315 delegate_->SetFocusToLocationBar(false); | 1436 delegate_->SetFocusToLocationBar(false); |
1316 return; | 1437 return; |
1317 } | 1438 } |
1318 | 1439 |
1319 // Remember if the page was focused so we can focus the new renderer in | 1440 // Remember if the page was focused so we can focus the new renderer in |
1320 // that case. | 1441 // that case. |
1321 bool focus_render_view = !will_focus_location_bar && | 1442 bool focus_render_view = !will_focus_location_bar && |
1322 render_frame_host_->render_view_host()->GetView() && | 1443 render_frame_host_->render_view_host()->GetView() && |
1323 render_frame_host_->render_view_host()->GetView()->HasFocus(); | 1444 render_frame_host_->render_view_host()->GetView()->HasFocus(); |
1324 | 1445 |
1325 bool is_main_frame = frame_tree_node_->IsMainFrame(); | 1446 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
1326 | 1447 |
1327 // Swap in the pending frame and make it active. Also ensure the FrameTree | 1448 scoped_ptr<RenderFrameHostImpl> old_render_frame_host; |
1328 // stays in sync. | 1449 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
1329 scoped_ptr<RenderFrameHostImpl> old_render_frame_host = | 1450 switches::kEnableBrowserSideNavigation)) { |
1330 SetRenderFrameHost(pending_render_frame_host_.Pass()); | 1451 DCHECK(!speculative_render_frame_host_); |
1452 // Swap in the pending frame and make it active. Also ensure the FrameTree | |
1453 // stays in sync. | |
1454 old_render_frame_host = | |
1455 SetRenderFrameHost(pending_render_frame_host_.Pass()); | |
1456 } else { | |
1457 DCHECK(speculative_render_frame_host_); | |
1458 old_render_frame_host = | |
1459 SetRenderFrameHost(speculative_render_frame_host_.Pass()); | |
1460 } | |
1461 | |
1331 if (is_main_frame) | 1462 if (is_main_frame) |
1332 render_frame_host_->render_view_host()->AttachToFrameTree(); | 1463 render_frame_host_->render_view_host()->AttachToFrameTree(); |
1333 | 1464 |
1334 // The process will no longer try to exit, so we can decrement the count. | 1465 // The process will no longer try to exit, so we can decrement the count. |
1335 render_frame_host_->GetProcess()->RemovePendingView(); | 1466 render_frame_host_->GetProcess()->RemovePendingView(); |
1336 | 1467 |
1337 // Show the new view (or a sad tab) if necessary. | 1468 // Show the new view (or a sad tab) if necessary. |
1338 bool new_rfh_has_view = !!render_frame_host_->render_view_host()->GetView(); | 1469 bool new_rfh_has_view = !!render_frame_host_->render_view_host()->GetView(); |
1339 if (!delegate_->IsHidden() && new_rfh_has_view) { | 1470 if (!delegate_->IsHidden() && new_rfh_has_view) { |
1340 // In most cases, we need to show the new view. | 1471 // 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_) { | 1580 if (cross_navigation_pending_) { |
1450 if (pending_render_frame_host_) | 1581 if (pending_render_frame_host_) |
1451 CancelPending(); | 1582 CancelPending(); |
1452 cross_navigation_pending_ = false; | 1583 cross_navigation_pending_ = false; |
1453 } | 1584 } |
1454 | 1585 |
1455 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 1586 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
1456 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( | 1587 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( |
1457 url, instance, transition, is_restore, is_view_source_mode); | 1588 url, instance, transition, is_restore, is_view_source_mode); |
1458 | 1589 |
1590 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
Charlie Reis
2014/12/04 21:46:28
This doesn't feel like it fits here. Most of Upda
carlosk
2014/12/09 07:55:42
Makes total sense and so I moved it.
It might nee
| |
1591 switches::kEnableBrowserSideNavigation)) { | |
1592 if (current_instance == new_instance.get() || | |
1593 (!frame_tree_node_->IsMainFrame() && | |
Charlie Reis
2014/12/04 21:46:28
Same concern about the process model policy.
carlosk
2014/12/09 07:55:41
Done: TODO + reference in crbug.com/440266 .
| |
1594 !CommandLine::ForCurrentProcess()->HasSwitch( | |
1595 switches::kSitePerProcess))) { | |
1596 CleanUpNavigation(); | |
1597 } else { | |
1598 // If the SiteInstance for the final URL doesn't match the one from the | |
1599 // speculatively created RenderFrameHost, create a new one using the | |
1600 // former. | |
1601 if (!speculative_render_frame_host_ || | |
1602 speculative_render_frame_host_->GetSiteInstance() != | |
1603 new_instance.get()) { | |
1604 CleanUpNavigation(); | |
1605 // TODO(carlosk): Should rename this method and the speculative members | |
Charlie Reis
2014/12/04 21:46:28
I'm not concerned about the name. We're creating
carlosk
2014/12/09 07:55:41
Great! Later on I realized that as soon as we begi
| |
1606 // because in this case they are not speculative. Suggestions are | |
1607 // very welcome! | |
1608 bool success = CreateSpeculativeRenderFrameHost( | |
1609 url, current_instance, new_instance.get(), bindings); | |
1610 if (!success) | |
1611 return nullptr; | |
1612 } | |
1613 DCHECK(speculative_render_frame_host_); | |
1614 CommitPending(); | |
1615 DCHECK(!speculative_render_frame_host_); | |
1616 } | |
1617 return render_frame_host_.get(); | |
1618 } | |
1619 | |
1459 const NavigationEntry* current_entry = | 1620 const NavigationEntry* current_entry = |
1460 delegate_->GetLastCommittedNavigationEntryForRenderManager(); | 1621 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
1461 | 1622 |
1462 if (new_instance.get() != current_instance) { | 1623 if (new_instance.get() != current_instance) { |
1463 TRACE_EVENT_INSTANT2( | 1624 TRACE_EVENT_INSTANT2( |
1464 "navigation", | 1625 "navigation", |
1465 "RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance", | 1626 "RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance", |
1466 TRACE_EVENT_SCOPE_THREAD, | 1627 TRACE_EVENT_SCOPE_THREAD, |
1467 "current_instance id", current_instance->GetId(), | 1628 "current_instance id", current_instance->GetId(), |
1468 "new_instance id", new_instance->GetId()); | 1629 "new_instance id", new_instance->GetId()); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1674 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1835 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
1675 SiteInstance* instance) { | 1836 SiteInstance* instance) { |
1676 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1837 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
1677 if (iter != proxy_hosts_.end()) { | 1838 if (iter != proxy_hosts_.end()) { |
1678 delete iter->second; | 1839 delete iter->second; |
1679 proxy_hosts_.erase(iter); | 1840 proxy_hosts_.erase(iter); |
1680 } | 1841 } |
1681 } | 1842 } |
1682 | 1843 |
1683 } // namespace content | 1844 } // namespace content |
OLD | NEW |