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

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

Issue 1722623003: PlzNavigate: use RenderFrameHostImpl::IsRendererTransferNeededForNavigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation-policy
Patch Set: Rebase + updates to tests Created 4 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 scoped_refptr<SiteInstance> dest_site_instance = GetSiteInstanceForNavigation( 805 scoped_refptr<SiteInstance> dest_site_instance = GetSiteInstanceForNavigation(
806 request.common_params().url, request.source_site_instance(), 806 request.common_params().url, request.source_site_instance(),
807 request.dest_site_instance(), candidate_site_instance, 807 request.dest_site_instance(), candidate_site_instance,
808 request.common_params().transition, 808 request.common_params().transition,
809 request.restore_type() != NavigationEntryImpl::RESTORE_NONE, 809 request.restore_type() != NavigationEntryImpl::RESTORE_NONE,
810 request.is_view_source()); 810 request.is_view_source());
811 811
812 // The appropriate RenderFrameHost to commit the navigation. 812 // The appropriate RenderFrameHost to commit the navigation.
813 RenderFrameHostImpl* navigation_rfh = nullptr; 813 RenderFrameHostImpl* navigation_rfh = nullptr;
814 814
815 // Renderer-initiated main frame navigations that may require a SiteInstance
816 // swap are sent to the browser via the OpenURL IPC and are afterwards treated
817 // as browser-initiated navigations. NavigationRequests marked as
818 // renderer-initiated are created by receiving a BeginNavigation IPC, and will
819 // then proceed in the same renderer that sent the IPC due to the condition
820 // below.
821 // Subframe navigations will use the current renderer, unless
822 // --site-per-process is enabled.
823 // TODO(carlosk): Have renderer-initated main frame navigations swap processes
824 // if needed when it no longer breaks OAuth popups (see
825 // https://crbug.com/440266).
826 bool is_main_frame = frame_tree_node_->IsMainFrame();
827 bool notify_webui_of_rv_creation = false; 815 bool notify_webui_of_rv_creation = false;
828 if (current_site_instance == dest_site_instance.get() ||
829 (!request.browser_initiated() && is_main_frame) ||
830 (!is_main_frame && !dest_site_instance->RequiresDedicatedProcess() &&
831 !current_site_instance->RequiresDedicatedProcess())) {
832 // Reuse the current RenderFrameHost if its SiteInstance matches the
833 // navigation's or if this is a subframe navigation. We only swap
834 // RenderFrameHosts for subframes when --site-per-process is enabled.
835 816
817 // Reuse the current RenderFrameHost if its SiteInstance matches the
818 // navigation's.
819 bool no_renderer_swap = current_site_instance == dest_site_instance.get();
820 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) {
821 // Check if the current renderer should be changed for the navigation.
822 no_renderer_swap |=
823 render_frame_host_->IsRenderFrameLive() &&
824 ShouldMakeNetworkRequestForURL(request.common_params().url) &&
825 !IsRendererTransferNeededForNavigation(render_frame_host_.get(),
826 request.common_params().url);
827 } else {
828 // Subframe navigations will use the current renderer.
829 no_renderer_swap |= !frame_tree_node_->IsMainFrame();
830
831 // Renderer-initiated main frame navigations that may require a
832 // SiteInstance swap are sent to the browser via the OpenURL IPC and are
833 // afterwards treated as browser-initiated navigations. NavigationRequests
834 // marked as renderer-initiated are created by receiving a BeginNavigation
835 // IPC, and will then proceed in the same renderer that sent the IPC due to
836 // the condition below.
837 // TODO(carlosk): Have renderer-initated main frame navigations swap
838 // processes if needed when it no longer breaks OAuth popups (see
839 // https://crbug.com/440266).
840 no_renderer_swap |= !request.browser_initiated();
841 }
842
843 if (no_renderer_swap) {
836 // GetFrameHostForNavigation will be called more than once during a 844 // GetFrameHostForNavigation will be called more than once during a
837 // navigation (currently twice, on request and when it's about to commit in 845 // navigation (currently twice, on request and when it's about to commit in
838 // the renderer). In the follow up calls an existing pending WebUI should 846 // the renderer). In the follow up calls an existing pending WebUI should
839 // not be recreated if the URL didn't change. So instead of calling 847 // not be recreated if the URL didn't change. So instead of calling
840 // CleanUpNavigation just discard the speculative RenderFrameHost if one 848 // CleanUpNavigation just discard the speculative RenderFrameHost if one
841 // exists. 849 // exists.
842 if (speculative_render_frame_host_) 850 if (speculative_render_frame_host_)
843 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); 851 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost());
844 852
845 UpdatePendingWebUIOnCurrentFrameHost(request.common_params().url, 853 UpdatePendingWebUIOnCurrentFrameHost(request.common_params().url,
(...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after
2498 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { 2506 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) {
2499 if (!frame_tree_node_->opener()) 2507 if (!frame_tree_node_->opener())
2500 return MSG_ROUTING_NONE; 2508 return MSG_ROUTING_NONE;
2501 2509
2502 return frame_tree_node_->opener() 2510 return frame_tree_node_->opener()
2503 ->render_manager() 2511 ->render_manager()
2504 ->GetRoutingIdForSiteInstance(instance); 2512 ->GetRoutingIdForSiteInstance(instance);
2505 } 2513 }
2506 2514
2507 } // namespace content 2515 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698