| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 // if needed when it no longer breaks OAuth popups (see | 993 // if needed when it no longer breaks OAuth popups (see |
| 994 // https://crbug.com/440266). | 994 // https://crbug.com/440266). |
| 995 bool is_main_frame = frame_tree_node_->IsMainFrame(); | 995 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
| 996 if (current_site_instance == dest_site_instance.get() || | 996 if (current_site_instance == dest_site_instance.get() || |
| 997 (!request.browser_initiated() && is_main_frame) || | 997 (!request.browser_initiated() && is_main_frame) || |
| 998 (!is_main_frame && !dest_site_instance->RequiresDedicatedProcess() && | 998 (!is_main_frame && !dest_site_instance->RequiresDedicatedProcess() && |
| 999 !current_site_instance->RequiresDedicatedProcess())) { | 999 !current_site_instance->RequiresDedicatedProcess())) { |
| 1000 // Reuse the current RFH if its SiteInstance matches the the navigation's | 1000 // Reuse the current RFH if its SiteInstance matches the the navigation's |
| 1001 // or if this is a subframe navigation. We only swap RFHs for subframes when | 1001 // or if this is a subframe navigation. We only swap RFHs for subframes when |
| 1002 // --site-per-process is enabled. | 1002 // --site-per-process is enabled. |
| 1003 CleanUpNavigation(); | 1003 |
| 1004 // There might be a pending WebUI in the current RenderFrameHost from a |
| 1005 // previous call of this function in the same navigation and it should be |
| 1006 // maintained for the next call to RenderFrameHostImpl::UpdatePendingWebUI. |
| 1007 // So instead of calling CleanUpNavigation, discard the speculative |
| 1008 // RenderFrameHost. |
| 1009 if (speculative_render_frame_host_) |
| 1010 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); |
| 1011 |
| 1004 navigation_rfh = render_frame_host_.get(); | 1012 navigation_rfh = render_frame_host_.get(); |
| 1005 | 1013 |
| 1006 // As SiteInstances are the same, make the RFH update its possible pending | 1014 // As SiteInstances are the same, make the RFH update its possible pending |
| 1007 // WebUI. | 1015 // WebUI. |
| 1008 render_frame_host_->UpdatePendingWebUI(request.common_params().url, | 1016 render_frame_host_->UpdatePendingWebUI(request.common_params().url, |
| 1009 request.bindings()); | 1017 request.bindings()); |
| 1010 DCHECK(speculative_web_ui() == render_frame_host_->pending_web_ui()); | 1018 DCHECK(speculative_web_ui() == render_frame_host_->pending_web_ui()); |
| 1011 | 1019 |
| 1012 // If a pending WebUI was set on the current RenderFrameHost (be it a new | 1020 // If a pending WebUI was set on the current RenderFrameHost (be it a new |
| 1013 // one or the reused current one) and the associated RenderFrame is alive, | 1021 // one or the reused current one) and the associated RenderFrame is alive, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 } | 1093 } |
| 1086 } | 1094 } |
| 1087 | 1095 |
| 1088 return navigation_rfh; | 1096 return navigation_rfh; |
| 1089 } | 1097 } |
| 1090 | 1098 |
| 1091 // PlzNavigate | 1099 // PlzNavigate |
| 1092 void RenderFrameHostManager::CleanUpNavigation() { | 1100 void RenderFrameHostManager::CleanUpNavigation() { |
| 1093 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1101 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1094 switches::kEnableBrowserSideNavigation)); | 1102 switches::kEnableBrowserSideNavigation)); |
| 1095 // TODO(carlosk): the discarding of the current RFH WebUI and the cleanup of | |
| 1096 // the speculative RFH should not always happen together. | |
| 1097 render_frame_host_->DiscardPendingWebUI(); | 1103 render_frame_host_->DiscardPendingWebUI(); |
| 1098 if (speculative_render_frame_host_) | 1104 if (speculative_render_frame_host_) |
| 1099 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); | 1105 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); |
| 1100 } | 1106 } |
| 1101 | 1107 |
| 1102 // PlzNavigate | 1108 // PlzNavigate |
| 1103 scoped_ptr<RenderFrameHostImpl> | 1109 scoped_ptr<RenderFrameHostImpl> |
| 1104 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() { | 1110 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() { |
| 1105 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1111 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1106 switches::kEnableBrowserSideNavigation)); | 1112 switches::kEnableBrowserSideNavigation)); |
| (...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2577 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { | 2583 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { |
| 2578 if (!frame_tree_node_->opener()) | 2584 if (!frame_tree_node_->opener()) |
| 2579 return MSG_ROUTING_NONE; | 2585 return MSG_ROUTING_NONE; |
| 2580 | 2586 |
| 2581 return frame_tree_node_->opener() | 2587 return frame_tree_node_->opener() |
| 2582 ->render_manager() | 2588 ->render_manager() |
| 2583 ->GetRoutingIdForSiteInstance(instance); | 2589 ->GetRoutingIdForSiteInstance(instance); |
| 2584 } | 2590 } |
| 2585 | 2591 |
| 2586 } // namespace content | 2592 } // namespace content |
| OLD | NEW |