| 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 12 matching lines...) Expand all Loading... |
| 23 #include "content/browser/frame_host/navigation_request.h" | 23 #include "content/browser/frame_host/navigation_request.h" |
| 24 #include "content/browser/frame_host/navigator.h" | 24 #include "content/browser/frame_host/navigator.h" |
| 25 #include "content/browser/frame_host/render_frame_host_factory.h" | 25 #include "content/browser/frame_host/render_frame_host_factory.h" |
| 26 #include "content/browser/frame_host/render_frame_host_impl.h" | 26 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 27 #include "content/browser/frame_host/render_frame_proxy_host.h" | 27 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 28 #include "content/browser/renderer_host/render_process_host_impl.h" | 28 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 29 #include "content/browser/renderer_host/render_view_host_factory.h" | 29 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 30 #include "content/browser/renderer_host/render_view_host_impl.h" | 30 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 31 #include "content/browser/site_instance_impl.h" | 31 #include "content/browser/site_instance_impl.h" |
| 32 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 32 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| 33 #include "content/browser/webui/web_ui_impl.h" |
| 33 #include "content/common/frame_messages.h" | 34 #include "content/common/frame_messages.h" |
| 34 #include "content/common/site_isolation_policy.h" | 35 #include "content/common/site_isolation_policy.h" |
| 35 #include "content/common/view_messages.h" | 36 #include "content/common/view_messages.h" |
| 36 #include "content/public/browser/content_browser_client.h" | 37 #include "content/public/browser/content_browser_client.h" |
| 37 #include "content/public/browser/render_process_host_observer.h" | 38 #include "content/public/browser/render_process_host_observer.h" |
| 38 #include "content/public/browser/render_widget_host_iterator.h" | 39 #include "content/public/browser/render_widget_host_iterator.h" |
| 39 #include "content/public/browser/render_widget_host_view.h" | 40 #include "content/public/browser/render_widget_host_view.h" |
| 40 #include "content/public/browser/user_metrics.h" | 41 #include "content/public/browser/user_metrics.h" |
| 42 #include "content/public/browser/web_ui_controller.h" |
| 41 #include "content/public/common/browser_plugin_guest_mode.h" | 43 #include "content/public/common/browser_plugin_guest_mode.h" |
| 42 #include "content/public/common/content_switches.h" | 44 #include "content/public/common/content_switches.h" |
| 43 #include "content/public/common/referrer.h" | 45 #include "content/public/common/referrer.h" |
| 44 #include "content/public/common/url_constants.h" | 46 #include "content/public/common/url_constants.h" |
| 45 | 47 |
| 46 namespace content { | 48 namespace content { |
| 47 | 49 |
| 48 namespace { | 50 namespace { |
| 49 | 51 |
| 50 // Helper function to add the FrameTree of the given node's opener to the list | 52 // Helper function to add the FrameTree of the given node's opener to the list |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 int exit_code) { | 200 int exit_code) { |
| 199 manager_->RendererProcessClosing(host); | 201 manager_->RendererProcessClosing(host); |
| 200 } | 202 } |
| 201 | 203 |
| 202 // static | 204 // static |
| 203 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { | 205 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { |
| 204 node->render_manager()->pending_delete_hosts_.clear(); | 206 node->render_manager()->pending_delete_hosts_.clear(); |
| 205 return true; | 207 return true; |
| 206 } | 208 } |
| 207 | 209 |
| 208 // static | |
| 209 bool RenderFrameHostManager::ClearWebUIInstances(FrameTreeNode* node) { | |
| 210 node->current_frame_host()->ClearAllWebUI(); | |
| 211 if (node->render_manager()->pending_render_frame_host_) | |
| 212 node->render_manager()->pending_render_frame_host_->ClearAllWebUI(); | |
| 213 // PlzNavigate | |
| 214 if (node->render_manager()->speculative_render_frame_host_) | |
| 215 node->render_manager()->speculative_render_frame_host_->ClearAllWebUI(); | |
| 216 return true; | |
| 217 } | |
| 218 | |
| 219 RenderFrameHostManager::RenderFrameHostManager( | 210 RenderFrameHostManager::RenderFrameHostManager( |
| 220 FrameTreeNode* frame_tree_node, | 211 FrameTreeNode* frame_tree_node, |
| 221 RenderFrameHostDelegate* render_frame_delegate, | 212 RenderFrameHostDelegate* render_frame_delegate, |
| 222 RenderViewHostDelegate* render_view_delegate, | 213 RenderViewHostDelegate* render_view_delegate, |
| 223 RenderWidgetHostDelegate* render_widget_delegate, | 214 RenderWidgetHostDelegate* render_widget_delegate, |
| 224 Delegate* delegate) | 215 Delegate* delegate) |
| 225 : frame_tree_node_(frame_tree_node), | 216 : frame_tree_node_(frame_tree_node), |
| 226 delegate_(delegate), | 217 delegate_(delegate), |
| 227 render_frame_delegate_(render_frame_delegate), | 218 render_frame_delegate_(render_frame_delegate), |
| 228 render_view_delegate_(render_view_delegate), | 219 render_view_delegate_(render_view_delegate), |
| 229 render_widget_delegate_(render_widget_delegate), | 220 render_widget_delegate_(render_widget_delegate), |
| 230 proxy_hosts_(new RenderFrameProxyHostMap(this)), | 221 proxy_hosts_(new RenderFrameProxyHostMap(this)), |
| 231 interstitial_page_(nullptr), | 222 interstitial_page_(nullptr), |
| 223 should_reuse_web_ui_(false), |
| 232 weak_factory_(this) { | 224 weak_factory_(this) { |
| 233 DCHECK(frame_tree_node_); | 225 DCHECK(frame_tree_node_); |
| 234 } | 226 } |
| 235 | 227 |
| 236 RenderFrameHostManager::~RenderFrameHostManager() { | 228 RenderFrameHostManager::~RenderFrameHostManager() { |
| 237 if (pending_render_frame_host_) { | 229 if (pending_render_frame_host_) { |
| 238 scoped_ptr<RenderFrameHostImpl> relic = UnsetPendingRenderFrameHost(); | 230 scoped_ptr<RenderFrameHostImpl> relic = UnsetPendingRenderFrameHost(); |
| 239 ShutdownProxiesIfLastActiveFrameInSiteInstance(relic.get()); | 231 ShutdownProxiesIfLastActiveFrameInSiteInstance(relic.get()); |
| 240 } | 232 } |
| 241 | 233 |
| 242 if (speculative_render_frame_host_) { | 234 if (speculative_render_frame_host_) { |
| 243 scoped_ptr<RenderFrameHostImpl> relic = UnsetSpeculativeRenderFrameHost(); | 235 scoped_ptr<RenderFrameHostImpl> relic = UnsetSpeculativeRenderFrameHost(); |
| 244 ShutdownProxiesIfLastActiveFrameInSiteInstance(relic.get()); | 236 ShutdownProxiesIfLastActiveFrameInSiteInstance(relic.get()); |
| 245 } | 237 } |
| 246 | 238 |
| 247 ShutdownProxiesIfLastActiveFrameInSiteInstance(render_frame_host_.get()); | 239 ShutdownProxiesIfLastActiveFrameInSiteInstance(render_frame_host_.get()); |
| 248 | 240 |
| 249 // Delete any RenderFrameProxyHosts and swapped out RenderFrameHosts. | 241 // Delete any RenderFrameProxyHosts and swapped out RenderFrameHosts. |
| 250 // It is important to delete those prior to deleting the current | 242 // It is important to delete those prior to deleting the current |
| 251 // RenderFrameHost, since the CrossProcessFrameConnector (owned by | 243 // RenderFrameHost, since the CrossProcessFrameConnector (owned by |
| 252 // RenderFrameProxyHost) points to the RenderWidgetHostView associated with | 244 // RenderFrameProxyHost) points to the RenderWidgetHostView associated with |
| 253 // the current RenderFrameHost and uses it during its destructor. | 245 // the current RenderFrameHost and uses it during its destructor. |
| 254 ResetProxyHosts(); | 246 ResetProxyHosts(); |
| 255 | 247 |
| 248 // Release the WebUI prior to resetting the current RenderFrameHost, as the |
| 249 // WebUI accesses the RenderFrameHost during cleanup. |
| 250 web_ui_.reset(); |
| 251 |
| 256 // We should always have a current RenderFrameHost except in some tests. | 252 // We should always have a current RenderFrameHost except in some tests. |
| 257 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); | 253 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); |
| 258 } | 254 } |
| 259 | 255 |
| 260 void RenderFrameHostManager::Init(SiteInstance* site_instance, | 256 void RenderFrameHostManager::Init(SiteInstance* site_instance, |
| 261 int32 view_routing_id, | 257 int32 view_routing_id, |
| 262 int32 frame_routing_id, | 258 int32 frame_routing_id, |
| 263 int32 widget_routing_id) { | 259 int32 widget_routing_id) { |
| 264 DCHECK(site_instance); | 260 DCHECK(site_instance); |
| 265 // TODO(avi): While RenderViewHostImpl is-a RenderWidgetHostImpl, this must | 261 // TODO(avi): While RenderViewHostImpl is-a RenderWidgetHostImpl, this must |
| (...skipping 20 matching lines...) Expand all Loading... |
| 286 return nullptr; | 282 return nullptr; |
| 287 return render_frame_host_->render_view_host(); | 283 return render_frame_host_->render_view_host(); |
| 288 } | 284 } |
| 289 | 285 |
| 290 RenderViewHostImpl* RenderFrameHostManager::pending_render_view_host() const { | 286 RenderViewHostImpl* RenderFrameHostManager::pending_render_view_host() const { |
| 291 if (!pending_render_frame_host_) | 287 if (!pending_render_frame_host_) |
| 292 return nullptr; | 288 return nullptr; |
| 293 return pending_render_frame_host_->render_view_host(); | 289 return pending_render_frame_host_->render_view_host(); |
| 294 } | 290 } |
| 295 | 291 |
| 296 WebUIImpl* RenderFrameHostManager::GetNavigatingWebUI() const { | |
| 297 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 298 switches::kEnableBrowserSideNavigation)) { | |
| 299 if (speculative_render_frame_host_) | |
| 300 return speculative_render_frame_host_->web_ui(); | |
| 301 } else { | |
| 302 if (pending_render_frame_host_) | |
| 303 return pending_render_frame_host_->web_ui(); | |
| 304 } | |
| 305 return render_frame_host_->pending_web_ui(); | |
| 306 } | |
| 307 | |
| 308 RenderWidgetHostView* RenderFrameHostManager::GetRenderWidgetHostView() const { | 292 RenderWidgetHostView* RenderFrameHostManager::GetRenderWidgetHostView() const { |
| 309 if (interstitial_page_) | 293 if (interstitial_page_) |
| 310 return interstitial_page_->GetView(); | 294 return interstitial_page_->GetView(); |
| 311 if (render_frame_host_) | 295 if (render_frame_host_) |
| 312 return render_frame_host_->GetView(); | 296 return render_frame_host_->GetView(); |
| 313 return nullptr; | 297 return nullptr; |
| 314 } | 298 } |
| 315 | 299 |
| 316 bool RenderFrameHostManager::ForInnerDelegate() { | 300 bool RenderFrameHostManager::ForInnerDelegate() { |
| 317 return delegate_->GetOuterDelegateFrameTreeNodeID() != | 301 return delegate_->GetOuterDelegateFrameTreeNodeID() != |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 350 |
| 367 void RenderFrameHostManager::RemoveOuterDelegateFrame() { | 351 void RenderFrameHostManager::RemoveOuterDelegateFrame() { |
| 368 FrameTreeNode* outer_delegate_frame_tree_node = | 352 FrameTreeNode* outer_delegate_frame_tree_node = |
| 369 FrameTreeNode::GloballyFindByID( | 353 FrameTreeNode::GloballyFindByID( |
| 370 delegate_->GetOuterDelegateFrameTreeNodeID()); | 354 delegate_->GetOuterDelegateFrameTreeNodeID()); |
| 371 DCHECK(outer_delegate_frame_tree_node->parent()); | 355 DCHECK(outer_delegate_frame_tree_node->parent()); |
| 372 outer_delegate_frame_tree_node->frame_tree()->RemoveFrame( | 356 outer_delegate_frame_tree_node->frame_tree()->RemoveFrame( |
| 373 outer_delegate_frame_tree_node); | 357 outer_delegate_frame_tree_node); |
| 374 } | 358 } |
| 375 | 359 |
| 360 void RenderFrameHostManager::SetPendingWebUI(const GURL& url, int bindings) { |
| 361 pending_web_ui_ = CreateWebUI(url, bindings); |
| 362 pending_and_current_web_ui_.reset(); |
| 363 } |
| 364 |
| 365 scoped_ptr<WebUIImpl> RenderFrameHostManager::CreateWebUI(const GURL& url, |
| 366 int bindings) { |
| 367 scoped_ptr<WebUIImpl> new_web_ui(delegate_->CreateWebUIForRenderManager(url)); |
| 368 |
| 369 // If we have assigned (zero or more) bindings to this NavigationEntry in the |
| 370 // past, make sure we're not granting it different bindings than it had |
| 371 // before. If so, note it and don't give it any bindings, to avoid a |
| 372 // potential privilege escalation. |
| 373 if (new_web_ui && bindings != NavigationEntryImpl::kInvalidBindings && |
| 374 new_web_ui->GetBindings() != bindings) { |
| 375 RecordAction(base::UserMetricsAction("ProcessSwapBindingsMismatch_RVHM")); |
| 376 return nullptr; |
| 377 } |
| 378 return new_web_ui.Pass(); |
| 379 } |
| 380 |
| 376 RenderFrameHostImpl* RenderFrameHostManager::Navigate( | 381 RenderFrameHostImpl* RenderFrameHostManager::Navigate( |
| 377 const GURL& dest_url, | 382 const GURL& dest_url, |
| 378 const FrameNavigationEntry& frame_entry, | 383 const FrameNavigationEntry& frame_entry, |
| 379 const NavigationEntryImpl& entry) { | 384 const NavigationEntryImpl& entry) { |
| 380 TRACE_EVENT1("navigation", "RenderFrameHostManager:Navigate", | 385 TRACE_EVENT1("navigation", "RenderFrameHostManager:Navigate", |
| 381 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | 386 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
| 382 // Create a pending RenderFrameHost to use for the navigation. | 387 // Create a pending RenderFrameHost to use for the navigation. |
| 383 RenderFrameHostImpl* dest_render_frame_host = UpdateStateForNavigate( | 388 RenderFrameHostImpl* dest_render_frame_host = UpdateStateForNavigate( |
| 384 dest_url, | 389 dest_url, |
| 385 // TODO(creis): Move source_site_instance to FNE. | 390 // TODO(creis): Move source_site_instance to FNE. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 414 // site that is handled via Mojo, then Mojo WebUI code in //chrome will | 419 // site that is handled via Mojo, then Mojo WebUI code in //chrome will |
| 415 // add a service to this RFH's ServiceRegistry). | 420 // add a service to this RFH's ServiceRegistry). |
| 416 dest_render_frame_host->SetUpMojoIfNeeded(); | 421 dest_render_frame_host->SetUpMojoIfNeeded(); |
| 417 | 422 |
| 418 // Recreate the opener chain. | 423 // Recreate the opener chain. |
| 419 CreateOpenerProxies(dest_render_frame_host->GetSiteInstance(), | 424 CreateOpenerProxies(dest_render_frame_host->GetSiteInstance(), |
| 420 frame_tree_node_); | 425 frame_tree_node_); |
| 421 if (!InitRenderView(dest_render_frame_host->render_view_host(), nullptr)) | 426 if (!InitRenderView(dest_render_frame_host->render_view_host(), nullptr)) |
| 422 return nullptr; | 427 return nullptr; |
| 423 | 428 |
| 424 if (GetNavigatingWebUI()) { | |
| 425 // A new RenderView was created and there is a navigating WebUI which | |
| 426 // never interacted with it. So notify the WebUI using RenderViewCreated. | |
| 427 GetNavigatingWebUI()->RenderViewCreated( | |
| 428 dest_render_frame_host->render_view_host()); | |
| 429 } | |
| 430 | |
| 431 // Now that we've created a new renderer, be sure to hide it if it isn't | 429 // Now that we've created a new renderer, be sure to hide it if it isn't |
| 432 // our primary one. Otherwise, we might crash if we try to call Show() | 430 // our primary one. Otherwise, we might crash if we try to call Show() |
| 433 // on it later. | 431 // on it later. |
| 434 if (dest_render_frame_host != render_frame_host_.get()) { | 432 if (dest_render_frame_host != render_frame_host_.get()) { |
| 435 if (dest_render_frame_host->GetView()) | 433 if (dest_render_frame_host->GetView()) |
| 436 dest_render_frame_host->GetView()->Hide(); | 434 dest_render_frame_host->GetView()->Hide(); |
| 437 } else { | 435 } else { |
| 438 // After a renderer crash we'd have marked the host as invisible, so we | 436 // After a renderer crash we'd have marked the host as invisible, so we |
| 439 // need to set the visibility of the new View to the correct value here | 437 // need to set the visibility of the new View to the correct value here |
| 440 // after reload. | 438 // after reload. |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 | 671 |
| 674 // Make sure any dynamic changes to this frame's sandbox flags that were made | 672 // Make sure any dynamic changes to this frame's sandbox flags that were made |
| 675 // prior to navigation take effect. | 673 // prior to navigation take effect. |
| 676 CommitPendingSandboxFlags(); | 674 CommitPendingSandboxFlags(); |
| 677 } | 675 } |
| 678 | 676 |
| 679 void RenderFrameHostManager::CommitPendingIfNecessary( | 677 void RenderFrameHostManager::CommitPendingIfNecessary( |
| 680 RenderFrameHostImpl* render_frame_host, | 678 RenderFrameHostImpl* render_frame_host, |
| 681 bool was_caused_by_user_gesture) { | 679 bool was_caused_by_user_gesture) { |
| 682 if (!pending_render_frame_host_ && !speculative_render_frame_host_) { | 680 if (!pending_render_frame_host_ && !speculative_render_frame_host_) { |
| 681 DCHECK(!should_reuse_web_ui_ || web_ui_); |
| 683 | 682 |
| 684 // We should only hear this from our current renderer. | 683 // We should only hear this from our current renderer. |
| 685 DCHECK_EQ(render_frame_host_.get(), render_frame_host); | 684 DCHECK_EQ(render_frame_host_.get(), render_frame_host); |
| 686 | 685 |
| 687 // If the current RenderFrameHost has a pending WebUI it must be committed. | 686 // Even when there is no pending RVH, there may be a pending Web UI. |
| 688 // Note: When one tries to move same-site commit logic into RenderFrameHost | 687 if (pending_web_ui() || speculative_web_ui_) |
| 689 // itself, mind that the focus setting logic inside CommitPending also needs | |
| 690 // to be moved there. | |
| 691 if (render_frame_host_->pending_web_ui()) | |
| 692 CommitPending(); | 688 CommitPending(); |
| 693 return; | 689 return; |
| 694 } | 690 } |
| 695 | 691 |
| 696 if (render_frame_host == pending_render_frame_host_.get() || | 692 if (render_frame_host == pending_render_frame_host_.get() || |
| 697 render_frame_host == speculative_render_frame_host_.get()) { | 693 render_frame_host == speculative_render_frame_host_.get()) { |
| 698 // The pending cross-process navigation completed, so show the renderer. | 694 // The pending cross-process navigation completed, so show the renderer. |
| 699 CommitPending(); | 695 CommitPending(); |
| 700 } else if (render_frame_host == render_frame_host_.get()) { | 696 } else if (render_frame_host == render_frame_host_.get()) { |
| 701 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 697 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 // as browser-initiated navigations. NavigationRequests marked as | 1016 // as browser-initiated navigations. NavigationRequests marked as |
| 1021 // renderer-initiated are created by receiving a BeginNavigation IPC, and will | 1017 // renderer-initiated are created by receiving a BeginNavigation IPC, and will |
| 1022 // then proceed in the same renderer that sent the IPC due to the condition | 1018 // then proceed in the same renderer that sent the IPC due to the condition |
| 1023 // below. | 1019 // below. |
| 1024 // Subframe navigations will use the current renderer, unless | 1020 // Subframe navigations will use the current renderer, unless |
| 1025 // --site-per-process is enabled. | 1021 // --site-per-process is enabled. |
| 1026 // TODO(carlosk): Have renderer-initated main frame navigations swap processes | 1022 // TODO(carlosk): Have renderer-initated main frame navigations swap processes |
| 1027 // if needed when it no longer breaks OAuth popups (see | 1023 // if needed when it no longer breaks OAuth popups (see |
| 1028 // https://crbug.com/440266). | 1024 // https://crbug.com/440266). |
| 1029 bool is_main_frame = frame_tree_node_->IsMainFrame(); | 1025 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
| 1030 bool notify_webui_of_rv_creation = false; | |
| 1031 if (current_site_instance == dest_site_instance.get() || | 1026 if (current_site_instance == dest_site_instance.get() || |
| 1032 (!request.browser_initiated() && is_main_frame) || | 1027 (!request.browser_initiated() && is_main_frame) || |
| 1033 (!is_main_frame && !dest_site_instance->RequiresDedicatedProcess() && | 1028 (!is_main_frame && !dest_site_instance->RequiresDedicatedProcess() && |
| 1034 !current_site_instance->RequiresDedicatedProcess())) { | 1029 !current_site_instance->RequiresDedicatedProcess())) { |
| 1035 // Reuse the current RenderFrameHost if its SiteInstance matches the | 1030 // Reuse the current RFH if its SiteInstance matches the the navigation's |
| 1036 // navigation's or if this is a subframe navigation. We only swap | 1031 // or if this is a subframe navigation. We only swap RFHs for subframes when |
| 1037 // RenderFrameHosts for subframes when --site-per-process is enabled. | 1032 // --site-per-process is enabled. |
| 1038 | 1033 CleanUpNavigation(); |
| 1039 // GetFrameHostForNavigation will be called more than once during a | |
| 1040 // navigation (currently twice, on request and when it's about to commit in | |
| 1041 // the renderer). In the follow up calls an existing pending WebUI should | |
| 1042 // not be recreated if the URL didn't change. So instead of calling | |
| 1043 // CleanUpNavigation just discard the speculative RenderFrameHost if one | |
| 1044 // exists. | |
| 1045 if (speculative_render_frame_host_) | |
| 1046 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); | |
| 1047 | |
| 1048 UpdatePendingWebUIOnCurrentFrameHost(request.common_params().url, | |
| 1049 request.bindings()); | |
| 1050 | |
| 1051 navigation_rfh = render_frame_host_.get(); | 1034 navigation_rfh = render_frame_host_.get(); |
| 1052 | 1035 |
| 1053 DCHECK(!speculative_render_frame_host_); | 1036 // As SiteInstances are the same, check if the WebUI should be reused. |
| 1037 const NavigationEntry* current_navigation_entry = |
| 1038 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
| 1039 should_reuse_web_ui_ = ShouldReuseWebUI(current_navigation_entry, |
| 1040 request.common_params().url); |
| 1041 if (!should_reuse_web_ui_) { |
| 1042 speculative_web_ui_ = CreateWebUI(request.common_params().url, |
| 1043 request.bindings()); |
| 1044 // Make sure the current RenderViewHost has the right bindings. |
| 1045 if (speculative_web_ui() && |
| 1046 !render_frame_host_->GetProcess()->IsForGuestsOnly()) { |
| 1047 render_frame_host_->render_view_host()->AllowBindings( |
| 1048 speculative_web_ui()->GetBindings()); |
| 1049 } |
| 1050 } |
| 1054 } else { | 1051 } else { |
| 1055 // If the current RenderFrameHost cannot be used a speculative one is | 1052 // If the SiteInstance for the final URL doesn't match the one from the |
| 1056 // created with the SiteInstance for the current URL. If a speculative | 1053 // speculatively created RenderFrameHost, create a new RenderFrameHost using |
| 1057 // RenderFrameHost already exists we try as much as possible to reuse it and | 1054 // this new SiteInstance. |
| 1058 // its associated WebUI. | |
| 1059 | |
| 1060 // Check if an existing speculative RenderFrameHost can be reused. | |
| 1061 if (!speculative_render_frame_host_ || | 1055 if (!speculative_render_frame_host_ || |
| 1062 speculative_render_frame_host_->GetSiteInstance() != | 1056 speculative_render_frame_host_->GetSiteInstance() != |
| 1063 dest_site_instance.get()) { | 1057 dest_site_instance.get()) { |
| 1064 // If a previous speculative RenderFrameHost didn't exist or if its | |
| 1065 // SiteInstance differs from the one for the current URL, a new one needs | |
| 1066 // to be created. | |
| 1067 CleanUpNavigation(); | 1058 CleanUpNavigation(); |
| 1068 bool success = CreateSpeculativeRenderFrameHost(current_site_instance, | 1059 bool success = CreateSpeculativeRenderFrameHost( |
| 1069 dest_site_instance.get()); | 1060 request.common_params().url, current_site_instance, |
| 1061 dest_site_instance.get(), request.bindings()); |
| 1070 DCHECK(success); | 1062 DCHECK(success); |
| 1071 } | 1063 } |
| 1072 DCHECK(speculative_render_frame_host_); | 1064 DCHECK(speculative_render_frame_host_); |
| 1073 | |
| 1074 bool changed_web_ui = speculative_render_frame_host_->UpdatePendingWebUI( | |
| 1075 request.common_params().url, request.bindings()); | |
| 1076 speculative_render_frame_host_->CommitPendingWebUI(); | |
| 1077 DCHECK_EQ(GetNavigatingWebUI(), speculative_render_frame_host_->web_ui()); | |
| 1078 notify_webui_of_rv_creation = | |
| 1079 changed_web_ui && speculative_render_frame_host_->web_ui(); | |
| 1080 | |
| 1081 navigation_rfh = speculative_render_frame_host_.get(); | 1065 navigation_rfh = speculative_render_frame_host_.get(); |
| 1082 | 1066 |
| 1083 // Check if our current RFH is live. | 1067 // Check if our current RFH is live. |
| 1084 if (!render_frame_host_->IsRenderFrameLive()) { | 1068 if (!render_frame_host_->IsRenderFrameLive()) { |
| 1085 // The current RFH is not live. There's no reason to sit around with a | 1069 // The current RFH is not live. There's no reason to sit around with a |
| 1086 // sad tab or a newly created RFH while we wait for the navigation to | 1070 // sad tab or a newly created RFH while we wait for the navigation to |
| 1087 // complete. Just switch to the speculative RFH now and go back to normal. | 1071 // complete. Just switch to the speculative RFH now and go back to normal. |
| 1088 // (Note that we don't care about on{before}unload handlers if the current | 1072 // (Note that we don't care about on{before}unload handlers if the current |
| 1089 // RFH isn't live.) | 1073 // RFH isn't live.) |
| 1090 CommitPending(); | 1074 CommitPending(); |
| 1091 } | 1075 } |
| 1092 } | 1076 } |
| 1093 DCHECK(navigation_rfh && | 1077 DCHECK(navigation_rfh && |
| 1094 (navigation_rfh == render_frame_host_.get() || | 1078 (navigation_rfh == render_frame_host_.get() || |
| 1095 navigation_rfh == speculative_render_frame_host_.get())); | 1079 navigation_rfh == speculative_render_frame_host_.get())); |
| 1096 | 1080 |
| 1097 // If the RenderFrame that needs to navigate is not live (its process was just | 1081 // If the RenderFrame that needs to navigate is not live (its process was just |
| 1098 // created or has crashed), initialize it. | 1082 // created or has crashed), initialize it. |
| 1099 if (!navigation_rfh->IsRenderFrameLive()) { | 1083 if (!navigation_rfh->IsRenderFrameLive()) { |
| 1100 // Recreate the opener chain. | 1084 // Recreate the opener chain. |
| 1101 CreateOpenerProxies(navigation_rfh->GetSiteInstance(), frame_tree_node_); | 1085 CreateOpenerProxies(navigation_rfh->GetSiteInstance(), frame_tree_node_); |
| 1102 if (!InitRenderView(navigation_rfh->render_view_host(), nullptr)) | 1086 if (!InitRenderView(navigation_rfh->render_view_host(), nullptr)) { |
| 1103 return nullptr; | 1087 return nullptr; |
| 1104 notify_webui_of_rv_creation = true; | 1088 } |
| 1105 | 1089 |
| 1106 if (navigation_rfh == render_frame_host_.get()) { | 1090 if (navigation_rfh == render_frame_host_.get()) { |
| 1107 // TODO(nasko): This is a very ugly hack. The Chrome extensions process | 1091 // TODO(nasko): This is a very ugly hack. The Chrome extensions process |
| 1108 // manager still uses NotificationService and expects to see a | 1092 // manager still uses NotificationService and expects to see a |
| 1109 // RenderViewHost changed notification after WebContents and | 1093 // RenderViewHost changed notification after WebContents and |
| 1110 // RenderFrameHostManager are completely initialized. This should be | 1094 // RenderFrameHostManager are completely initialized. This should be |
| 1111 // removed once the process manager moves away from NotificationService. | 1095 // removed once the process manager moves away from NotificationService. |
| 1112 // See https://crbug.com/462682. | 1096 // See https://crbug.com/462682. |
| 1113 delegate_->NotifyMainFrameSwappedFromRenderManager( | 1097 delegate_->NotifyMainFrameSwappedFromRenderManager( |
| 1114 nullptr, render_frame_host_->render_view_host()); | 1098 nullptr, render_frame_host_->render_view_host()); |
| 1115 } | 1099 } |
| 1116 DCHECK(navigation_rfh->IsRenderFrameLive()); | |
| 1117 } | 1100 } |
| 1118 | 1101 |
| 1119 // If a WebUI was created in a speculative RenderFrameHost or a new RenderView | |
| 1120 // was created then the WebUI never interacted with the RenderView. Notify | |
| 1121 // using RenderViewCreated. | |
| 1122 if (notify_webui_of_rv_creation && GetNavigatingWebUI()) | |
| 1123 GetNavigatingWebUI()->RenderViewCreated(navigation_rfh->render_view_host()); | |
| 1124 | |
| 1125 return navigation_rfh; | 1102 return navigation_rfh; |
| 1126 } | 1103 } |
| 1127 | 1104 |
| 1128 // PlzNavigate | 1105 // PlzNavigate |
| 1129 void RenderFrameHostManager::CleanUpNavigation() { | 1106 void RenderFrameHostManager::CleanUpNavigation() { |
| 1130 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1107 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1131 switches::kEnableBrowserSideNavigation)); | 1108 switches::kEnableBrowserSideNavigation)); |
| 1132 render_frame_host_->ClearPendingWebUI(); | 1109 speculative_web_ui_.reset(); |
| 1110 should_reuse_web_ui_ = false; |
| 1133 if (speculative_render_frame_host_) | 1111 if (speculative_render_frame_host_) |
| 1134 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); | 1112 DiscardUnusedFrame(UnsetSpeculativeRenderFrameHost()); |
| 1135 } | 1113 } |
| 1136 | 1114 |
| 1137 // PlzNavigate | 1115 // PlzNavigate |
| 1138 scoped_ptr<RenderFrameHostImpl> | 1116 scoped_ptr<RenderFrameHostImpl> |
| 1139 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() { | 1117 RenderFrameHostManager::UnsetSpeculativeRenderFrameHost() { |
| 1140 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 1118 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1141 switches::kEnableBrowserSideNavigation)); | 1119 switches::kEnableBrowserSideNavigation)); |
| 1142 speculative_render_frame_host_->GetProcess()->RemovePendingView(); | 1120 speculative_render_frame_host_->GetProcess()->RemovePendingView(); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 // We can't switch a RenderView between view source and non-view source mode | 1293 // We can't switch a RenderView between view source and non-view source mode |
| 1316 // without screwing up the session history sometimes (when navigating between | 1294 // without screwing up the session history sometimes (when navigating between |
| 1317 // "view-source:http://foo.com/" and "http://foo.com/", Blink doesn't treat | 1295 // "view-source:http://foo.com/" and "http://foo.com/", Blink doesn't treat |
| 1318 // it as a new navigation). So require a BrowsingInstance switch. | 1296 // it as a new navigation). So require a BrowsingInstance switch. |
| 1319 if (current_is_view_source_mode != new_is_view_source_mode) | 1297 if (current_is_view_source_mode != new_is_view_source_mode) |
| 1320 return true; | 1298 return true; |
| 1321 | 1299 |
| 1322 return false; | 1300 return false; |
| 1323 } | 1301 } |
| 1324 | 1302 |
| 1303 bool RenderFrameHostManager::ShouldReuseWebUI( |
| 1304 const NavigationEntry* current_entry, |
| 1305 const GURL& new_url) const { |
| 1306 NavigationControllerImpl& controller = |
| 1307 delegate_->GetControllerForRenderManager(); |
| 1308 return current_entry && web_ui_ && |
| 1309 (WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( |
| 1310 controller.GetBrowserContext(), current_entry->GetURL()) == |
| 1311 WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( |
| 1312 controller.GetBrowserContext(), new_url)); |
| 1313 } |
| 1314 |
| 1325 SiteInstance* RenderFrameHostManager::GetSiteInstanceForNavigation( | 1315 SiteInstance* RenderFrameHostManager::GetSiteInstanceForNavigation( |
| 1326 const GURL& dest_url, | 1316 const GURL& dest_url, |
| 1327 SiteInstance* source_instance, | 1317 SiteInstance* source_instance, |
| 1328 SiteInstance* dest_instance, | 1318 SiteInstance* dest_instance, |
| 1329 SiteInstance* candidate_instance, | 1319 SiteInstance* candidate_instance, |
| 1330 ui::PageTransition transition, | 1320 ui::PageTransition transition, |
| 1331 bool dest_is_restore, | 1321 bool dest_is_restore, |
| 1332 bool dest_is_view_source_mode) { | 1322 bool dest_is_view_source_mode) { |
| 1333 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 1323 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
| 1334 | 1324 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 // The process for the new SiteInstance may (if we're sharing a process with | 1637 // The process for the new SiteInstance may (if we're sharing a process with |
| 1648 // another host that already initialized it) or may not (we have our own | 1638 // another host that already initialized it) or may not (we have our own |
| 1649 // process or the existing process crashed) have been initialized. Calling | 1639 // process or the existing process crashed) have been initialized. Calling |
| 1650 // Init multiple times will be ignored, so this is safe. | 1640 // Init multiple times will be ignored, so this is safe. |
| 1651 if (!new_instance->GetProcess()->Init()) | 1641 if (!new_instance->GetProcess()->Init()) |
| 1652 return; | 1642 return; |
| 1653 | 1643 |
| 1654 CreateProxiesForNewRenderFrameHost(old_instance, new_instance); | 1644 CreateProxiesForNewRenderFrameHost(old_instance, new_instance); |
| 1655 | 1645 |
| 1656 // Create a non-swapped-out RFH with the given opener. | 1646 // Create a non-swapped-out RFH with the given opener. |
| 1657 pending_render_frame_host_ = | 1647 pending_render_frame_host_ = CreateRenderFrame( |
| 1658 CreateRenderFrame(new_instance, create_render_frame_flags, nullptr); | 1648 new_instance, pending_web_ui(), create_render_frame_flags, nullptr); |
| 1659 } | 1649 } |
| 1660 | 1650 |
| 1661 void RenderFrameHostManager::CreateProxiesForNewRenderFrameHost( | 1651 void RenderFrameHostManager::CreateProxiesForNewRenderFrameHost( |
| 1662 SiteInstance* old_instance, | 1652 SiteInstance* old_instance, |
| 1663 SiteInstance* new_instance) { | 1653 SiteInstance* new_instance) { |
| 1664 // Only create opener proxies if they are in the same BrowsingInstance. | 1654 // Only create opener proxies if they are in the same BrowsingInstance. |
| 1665 if (new_instance->IsRelatedSiteInstance(old_instance)) { | 1655 if (new_instance->IsRelatedSiteInstance(old_instance)) { |
| 1666 CreateOpenerProxies(new_instance, frame_tree_node_); | 1656 CreateOpenerProxies(new_instance, frame_tree_node_); |
| 1667 } else if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { | 1657 } else if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { |
| 1668 // Ensure that the frame tree has RenderFrameProxyHosts for the | 1658 // Ensure that the frame tree has RenderFrameProxyHosts for the |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 } | 1734 } |
| 1745 | 1735 |
| 1746 return RenderFrameHostFactory::Create( | 1736 return RenderFrameHostFactory::Create( |
| 1747 site_instance, render_view_host, render_frame_delegate_, | 1737 site_instance, render_view_host, render_frame_delegate_, |
| 1748 render_widget_delegate_, frame_tree, frame_tree_node_, frame_routing_id, | 1738 render_widget_delegate_, frame_tree, frame_tree_node_, frame_routing_id, |
| 1749 widget_routing_id, flags); | 1739 widget_routing_id, flags); |
| 1750 } | 1740 } |
| 1751 | 1741 |
| 1752 // PlzNavigate | 1742 // PlzNavigate |
| 1753 bool RenderFrameHostManager::CreateSpeculativeRenderFrameHost( | 1743 bool RenderFrameHostManager::CreateSpeculativeRenderFrameHost( |
| 1744 const GURL& url, |
| 1754 SiteInstance* old_instance, | 1745 SiteInstance* old_instance, |
| 1755 SiteInstance* new_instance) { | 1746 SiteInstance* new_instance, |
| 1747 int bindings) { |
| 1756 CHECK(new_instance); | 1748 CHECK(new_instance); |
| 1757 CHECK_NE(old_instance, new_instance); | 1749 CHECK_NE(old_instance, new_instance); |
| 1750 CHECK(!should_reuse_web_ui_); |
| 1751 |
| 1752 // Note: |speculative_web_ui_| must be initialized before starting the |
| 1753 // |speculative_render_frame_host_| creation steps otherwise the WebUI |
| 1754 // won't be properly initialized. |
| 1755 speculative_web_ui_ = CreateWebUI(url, bindings); |
| 1758 | 1756 |
| 1759 // The process for the new SiteInstance may (if we're sharing a process with | 1757 // The process for the new SiteInstance may (if we're sharing a process with |
| 1760 // another host that already initialized it) or may not (we have our own | 1758 // another host that already initialized it) or may not (we have our own |
| 1761 // process or the existing process crashed) have been initialized. Calling | 1759 // process or the existing process crashed) have been initialized. Calling |
| 1762 // Init multiple times will be ignored, so this is safe. | 1760 // Init multiple times will be ignored, so this is safe. |
| 1763 if (!new_instance->GetProcess()->Init()) | 1761 if (!new_instance->GetProcess()->Init()) |
| 1764 return false; | 1762 return false; |
| 1765 | 1763 |
| 1766 CreateProxiesForNewRenderFrameHost(old_instance, new_instance); | 1764 CreateProxiesForNewRenderFrameHost(old_instance, new_instance); |
| 1767 | 1765 |
| 1768 int create_render_frame_flags = 0; | 1766 int create_render_frame_flags = 0; |
| 1769 if (delegate_->IsHidden()) | 1767 if (delegate_->IsHidden()) |
| 1770 create_render_frame_flags |= CREATE_RF_HIDDEN; | 1768 create_render_frame_flags |= CREATE_RF_HIDDEN; |
| 1771 speculative_render_frame_host_ = | 1769 speculative_render_frame_host_ = |
| 1772 CreateRenderFrame(new_instance, create_render_frame_flags, nullptr); | 1770 CreateRenderFrame(new_instance, speculative_web_ui_.get(), |
| 1771 create_render_frame_flags, nullptr); |
| 1773 | 1772 |
| 1774 return !!speculative_render_frame_host_; | 1773 if (!speculative_render_frame_host_) { |
| 1774 speculative_web_ui_.reset(); |
| 1775 return false; |
| 1776 } |
| 1777 return true; |
| 1775 } | 1778 } |
| 1776 | 1779 |
| 1777 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame( | 1780 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::CreateRenderFrame( |
| 1778 SiteInstance* instance, | 1781 SiteInstance* instance, |
| 1782 WebUIImpl* web_ui, |
| 1779 int flags, | 1783 int flags, |
| 1780 int* view_routing_id_ptr) { | 1784 int* view_routing_id_ptr) { |
| 1781 bool swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); | 1785 bool swapped_out = !!(flags & CREATE_RF_SWAPPED_OUT); |
| 1782 bool swapped_out_forbidden = | 1786 bool swapped_out_forbidden = |
| 1783 SiteIsolationPolicy::IsSwappedOutStateForbidden(); | 1787 SiteIsolationPolicy::IsSwappedOutStateForbidden(); |
| 1784 | 1788 |
| 1785 CHECK(instance); | 1789 CHECK(instance); |
| 1786 CHECK(!swapped_out_forbidden || !swapped_out); | 1790 CHECK(!swapped_out_forbidden || !swapped_out); |
| 1787 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible() || | 1791 CHECK(SiteIsolationPolicy::AreCrossProcessFramesPossible() || |
| 1788 frame_tree_node_->IsMainFrame()); | 1792 frame_tree_node_->IsMainFrame()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1886 success = InitRenderFrame(new_render_frame_host.get()); | 1890 success = InitRenderFrame(new_render_frame_host.get()); |
| 1887 } | 1891 } |
| 1888 } | 1892 } |
| 1889 | 1893 |
| 1890 if (success) { | 1894 if (success) { |
| 1891 if (view_routing_id_ptr) | 1895 if (view_routing_id_ptr) |
| 1892 *view_routing_id_ptr = render_view_host->GetRoutingID(); | 1896 *view_routing_id_ptr = render_view_host->GetRoutingID(); |
| 1893 } | 1897 } |
| 1894 } | 1898 } |
| 1895 | 1899 |
| 1900 // When a new RenderView is created by the renderer process, the new |
| 1901 // WebContents gets a RenderViewHost in the SiteInstance of its opener |
| 1902 // WebContents. If not used in the first navigation, this RVH is swapped out |
| 1903 // and is not granted bindings, so we may need to grant them when swapping it |
| 1904 // in. |
| 1905 if (web_ui && !new_render_frame_host->GetProcess()->IsForGuestsOnly()) { |
| 1906 int required_bindings = web_ui->GetBindings(); |
| 1907 RenderViewHost* render_view_host = |
| 1908 new_render_frame_host->render_view_host(); |
| 1909 if ((render_view_host->GetEnabledBindings() & required_bindings) != |
| 1910 required_bindings) { |
| 1911 render_view_host->AllowBindings(required_bindings); |
| 1912 } |
| 1913 } |
| 1914 |
| 1896 // Returns the new RFH if it isn't swapped out. | 1915 // Returns the new RFH if it isn't swapped out. |
| 1897 if (success && !swapped_out) { | 1916 if (success && !swapped_out) { |
| 1898 DCHECK(new_render_frame_host->GetSiteInstance() == instance); | 1917 DCHECK(new_render_frame_host->GetSiteInstance() == instance); |
| 1899 return new_render_frame_host.Pass(); | 1918 return new_render_frame_host.Pass(); |
| 1900 } | 1919 } |
| 1901 return nullptr; | 1920 return nullptr; |
| 1902 } | 1921 } |
| 1903 | 1922 |
| 1904 int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance) { | 1923 int RenderFrameHostManager::CreateRenderFrameProxy(SiteInstance* instance) { |
| 1905 // A RenderFrameProxyHost should never be created in the same SiteInstance as | 1924 // A RenderFrameProxyHost should never be created in the same SiteInstance as |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2004 RenderFrameProxyHost* proxy) { | 2023 RenderFrameProxyHost* proxy) { |
| 2005 // Ensure the renderer process is initialized before creating the | 2024 // Ensure the renderer process is initialized before creating the |
| 2006 // RenderView. | 2025 // RenderView. |
| 2007 if (!render_view_host->GetProcess()->Init()) | 2026 if (!render_view_host->GetProcess()->Init()) |
| 2008 return false; | 2027 return false; |
| 2009 | 2028 |
| 2010 // We may have initialized this RenderViewHost for another RenderFrameHost. | 2029 // We may have initialized this RenderViewHost for another RenderFrameHost. |
| 2011 if (render_view_host->IsRenderViewLive()) | 2030 if (render_view_host->IsRenderViewLive()) |
| 2012 return true; | 2031 return true; |
| 2013 | 2032 |
| 2033 // If |render_view_host| is not for a proxy and the navigation is to a WebUI, |
| 2034 // and if the RenderView is not in a guest process, tell |render_view_host| |
| 2035 // about any bindings it will need enabled. |
| 2036 // TODO(carlosk): Move WebUI to RenderFrameHost in https://crbug.com/508850. |
| 2037 WebUIImpl* dest_web_ui = nullptr; |
| 2038 if (!proxy) { |
| 2039 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2040 switches::kEnableBrowserSideNavigation)) { |
| 2041 dest_web_ui = |
| 2042 should_reuse_web_ui_ ? web_ui_.get() : speculative_web_ui_.get(); |
| 2043 } else { |
| 2044 dest_web_ui = pending_web_ui(); |
| 2045 } |
| 2046 } |
| 2047 if (dest_web_ui && !render_view_host->GetProcess()->IsForGuestsOnly()) { |
| 2048 render_view_host->AllowBindings(dest_web_ui->GetBindings()); |
| 2049 } else { |
| 2050 // Ensure that we don't create an unprivileged RenderView in a WebUI-enabled |
| 2051 // process unless it's swapped out. |
| 2052 if (render_view_host->is_active()) { |
| 2053 CHECK(!ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
| 2054 render_view_host->GetProcess()->GetID())); |
| 2055 } |
| 2056 } |
| 2057 |
| 2014 int opener_frame_routing_id = | 2058 int opener_frame_routing_id = |
| 2015 GetOpenerRoutingID(render_view_host->GetSiteInstance()); | 2059 GetOpenerRoutingID(render_view_host->GetSiteInstance()); |
| 2016 | 2060 |
| 2017 bool created = delegate_->CreateRenderViewForRenderManager( | 2061 bool created = delegate_->CreateRenderViewForRenderManager( |
| 2018 render_view_host, opener_frame_routing_id, | 2062 render_view_host, opener_frame_routing_id, |
| 2019 proxy ? proxy->GetRoutingID() : MSG_ROUTING_NONE, | 2063 proxy ? proxy->GetRoutingID() : MSG_ROUTING_NONE, |
| 2020 frame_tree_node_->current_replication_state()); | 2064 frame_tree_node_->current_replication_state()); |
| 2021 | 2065 |
| 2022 if (created && proxy) | 2066 if (created && proxy) |
| 2023 proxy->set_render_frame_proxy_created(true); | 2067 proxy->set_render_frame_proxy_created(true); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2095 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); | 2139 RenderFrameProxyHost* proxy = GetRenderFrameProxyHost(site_instance); |
| 2096 if (proxy) | 2140 if (proxy) |
| 2097 return proxy->GetRoutingID(); | 2141 return proxy->GetRoutingID(); |
| 2098 | 2142 |
| 2099 return MSG_ROUTING_NONE; | 2143 return MSG_ROUTING_NONE; |
| 2100 } | 2144 } |
| 2101 | 2145 |
| 2102 void RenderFrameHostManager::CommitPending() { | 2146 void RenderFrameHostManager::CommitPending() { |
| 2103 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", | 2147 TRACE_EVENT1("navigation", "RenderFrameHostManager::CommitPending", |
| 2104 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | 2148 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
| 2149 bool browser_side_navigation = |
| 2150 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2151 switches::kEnableBrowserSideNavigation); |
| 2152 |
| 2105 // First check whether we're going to want to focus the location bar after | 2153 // First check whether we're going to want to focus the location bar after |
| 2106 // this commit. We do this now because the navigation hasn't formally | 2154 // this commit. We do this now because the navigation hasn't formally |
| 2107 // committed yet, so if we've already cleared the pending WebUI the call chain | 2155 // committed yet, so if we've already cleared |pending_web_ui_| the call chain |
| 2108 // this triggers won't be able to figure out what's going on. | 2156 // this triggers won't be able to figure out what's going on. |
| 2109 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 2157 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); |
| 2110 | 2158 |
| 2111 // If the current RenderFrameHost has a pending WebUI then just commit it and | 2159 // Next commit the Web UI, if any. Either replace |web_ui_| with |
| 2112 // return (there should be nothing else to commit). | 2160 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or |
| 2113 if (render_frame_host_->pending_web_ui()) { | 2161 // leave |web_ui_| as is if reusing it. |
| 2114 DCHECK(!pending_render_frame_host_ && !speculative_render_frame_host_); | 2162 DCHECK(!(pending_web_ui_ && pending_and_current_web_ui_)); |
| 2115 render_frame_host_->CommitPendingWebUI(); | 2163 if (pending_web_ui_ || speculative_web_ui_) { |
| 2164 DCHECK(!should_reuse_web_ui_); |
| 2165 web_ui_.reset(browser_side_navigation ? speculative_web_ui_.release() |
| 2166 : pending_web_ui_.release()); |
| 2167 } else if (pending_and_current_web_ui_ || should_reuse_web_ui_) { |
| 2168 if (browser_side_navigation) { |
| 2169 DCHECK(web_ui_); |
| 2170 should_reuse_web_ui_ = false; |
| 2171 } else { |
| 2172 DCHECK_EQ(pending_and_current_web_ui_.get(), web_ui_.get()); |
| 2173 pending_and_current_web_ui_.reset(); |
| 2174 } |
| 2175 } else { |
| 2176 web_ui_.reset(); |
| 2177 } |
| 2178 DCHECK(!speculative_web_ui_); |
| 2179 DCHECK(!should_reuse_web_ui_); |
| 2180 |
| 2181 // It's possible for the pending_render_frame_host_ to be nullptr when we |
| 2182 // aren't crossing process boundaries. If so, we just needed to handle the Web |
| 2183 // UI committing above and we're done. |
| 2184 if (!pending_render_frame_host_ && !speculative_render_frame_host_) { |
| 2116 if (will_focus_location_bar) | 2185 if (will_focus_location_bar) |
| 2117 delegate_->SetFocusToLocationBar(false); | 2186 delegate_->SetFocusToLocationBar(false); |
| 2118 return; | 2187 return; |
| 2119 } | 2188 } |
| 2120 | 2189 |
| 2121 // Remember if the page was focused so we can focus the new renderer in | 2190 // Remember if the page was focused so we can focus the new renderer in |
| 2122 // that case. | 2191 // that case. |
| 2123 bool focus_render_view = !will_focus_location_bar && | 2192 bool focus_render_view = !will_focus_location_bar && |
| 2124 render_frame_host_->GetView() && | 2193 render_frame_host_->GetView() && |
| 2125 render_frame_host_->GetView()->HasFocus(); | 2194 render_frame_host_->GetView()->HasFocus(); |
| 2126 | 2195 |
| 2127 bool is_main_frame = frame_tree_node_->IsMainFrame(); | 2196 bool is_main_frame = frame_tree_node_->IsMainFrame(); |
| 2128 | 2197 |
| 2129 // Swap in the pending or speculative frame and make it active. Also ensure | 2198 // Swap in the pending or speculative frame and make it active. Also ensure |
| 2130 // the FrameTree stays in sync. | 2199 // the FrameTree stays in sync. |
| 2131 scoped_ptr<RenderFrameHostImpl> old_render_frame_host; | 2200 scoped_ptr<RenderFrameHostImpl> old_render_frame_host; |
| 2132 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 2201 if (!browser_side_navigation) { |
| 2133 switches::kEnableBrowserSideNavigation)) { | |
| 2134 DCHECK(!speculative_render_frame_host_); | 2202 DCHECK(!speculative_render_frame_host_); |
| 2135 old_render_frame_host = | 2203 old_render_frame_host = |
| 2136 SetRenderFrameHost(pending_render_frame_host_.Pass()); | 2204 SetRenderFrameHost(pending_render_frame_host_.Pass()); |
| 2137 } else { | 2205 } else { |
| 2138 // PlzNavigate | 2206 // PlzNavigate |
| 2139 DCHECK(speculative_render_frame_host_); | 2207 DCHECK(speculative_render_frame_host_); |
| 2140 old_render_frame_host = | 2208 old_render_frame_host = |
| 2141 SetRenderFrameHost(speculative_render_frame_host_.Pass()); | 2209 SetRenderFrameHost(speculative_render_frame_host_.Pass()); |
| 2142 } | 2210 } |
| 2143 | 2211 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2293 // If we are currently navigating cross-process, we want to get back to normal | 2361 // If we are currently navigating cross-process, we want to get back to normal |
| 2294 // and then navigate as usual. | 2362 // and then navigate as usual. |
| 2295 if (pending_render_frame_host_) | 2363 if (pending_render_frame_host_) |
| 2296 CancelPending(); | 2364 CancelPending(); |
| 2297 | 2365 |
| 2298 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 2366 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
| 2299 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( | 2367 scoped_refptr<SiteInstance> new_instance = GetSiteInstanceForNavigation( |
| 2300 dest_url, source_instance, dest_instance, nullptr, transition, | 2368 dest_url, source_instance, dest_instance, nullptr, transition, |
| 2301 dest_is_restore, dest_is_view_source_mode); | 2369 dest_is_restore, dest_is_view_source_mode); |
| 2302 | 2370 |
| 2371 const NavigationEntry* current_entry = |
| 2372 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
| 2373 |
| 2303 DCHECK(!pending_render_frame_host_); | 2374 DCHECK(!pending_render_frame_host_); |
| 2304 | 2375 |
| 2305 if (new_instance.get() != current_instance) { | 2376 if (new_instance.get() != current_instance) { |
| 2306 TRACE_EVENT_INSTANT2( | 2377 TRACE_EVENT_INSTANT2( |
| 2307 "navigation", | 2378 "navigation", |
| 2308 "RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance", | 2379 "RenderFrameHostManager::UpdateStateForNavigate:New SiteInstance", |
| 2309 TRACE_EVENT_SCOPE_THREAD, | 2380 TRACE_EVENT_SCOPE_THREAD, |
| 2310 "current_instance id", current_instance->GetId(), | 2381 "current_instance id", current_instance->GetId(), |
| 2311 "new_instance id", new_instance->GetId()); | 2382 "new_instance id", new_instance->GetId()); |
| 2312 | 2383 |
| 2313 // New SiteInstance: create a pending RFH to navigate. | 2384 // New SiteInstance: create a pending RFH to navigate. |
| 2314 | 2385 |
| 2386 // This will possibly create (set to nullptr) a Web UI object for the |
| 2387 // pending page. We'll use this later to give the page special access. This |
| 2388 // must happen before the new renderer is created below so it will get |
| 2389 // bindings. It must also happen after the above conditional call to |
| 2390 // CancelPending(), otherwise CancelPending may clear the pending_web_ui_ |
| 2391 // and the page will not have its bindings set appropriately. |
| 2392 SetPendingWebUI(dest_url, bindings); |
| 2315 CreatePendingRenderFrameHost(current_instance, new_instance.get()); | 2393 CreatePendingRenderFrameHost(current_instance, new_instance.get()); |
| 2316 DCHECK(pending_render_frame_host_); | |
| 2317 if (!pending_render_frame_host_) | 2394 if (!pending_render_frame_host_) |
| 2318 return nullptr; | 2395 return nullptr; |
| 2319 | 2396 |
| 2320 pending_render_frame_host_->UpdatePendingWebUI(dest_url, bindings); | |
| 2321 pending_render_frame_host_->CommitPendingWebUI(); | |
| 2322 DCHECK_EQ(GetNavigatingWebUI(), pending_render_frame_host_->web_ui()); | |
| 2323 | |
| 2324 // If a WebUI exists in the pending RenderFrameHost it was just created, as | |
| 2325 // well as the RenderView, and they never interacted. So notify it using | |
| 2326 // RenderViewCreated. | |
| 2327 if (pending_render_frame_host_->web_ui()) { | |
| 2328 pending_render_frame_host_->web_ui()->RenderViewCreated( | |
| 2329 pending_render_frame_host_->render_view_host()); | |
| 2330 } | |
| 2331 | |
| 2332 // Check if our current RFH is live before we set up a transition. | 2397 // Check if our current RFH is live before we set up a transition. |
| 2333 if (!render_frame_host_->IsRenderFrameLive()) { | 2398 if (!render_frame_host_->IsRenderFrameLive()) { |
| 2334 // The current RFH is not live. There's no reason to sit around with a | 2399 // The current RFH is not live. There's no reason to sit around with a |
| 2335 // sad tab or a newly created RFH while we wait for the pending RFH to | 2400 // sad tab or a newly created RFH while we wait for the pending RFH to |
| 2336 // navigate. Just switch to the pending RFH now and go back to normal. | 2401 // navigate. Just switch to the pending RFH now and go back to normal. |
| 2337 // (Note that we don't care about on{before}unload handlers if the current | 2402 // (Note that we don't care about on{before}unload handlers if the current |
| 2338 // RFH isn't live.) | 2403 // RFH isn't live.) |
| 2339 CommitPending(); | 2404 CommitPending(); |
| 2340 return render_frame_host_.get(); | 2405 return render_frame_host_.get(); |
| 2341 } | 2406 } |
| 2342 // Otherwise, it's safe to treat this as a pending cross-process transition. | 2407 // Otherwise, it's safe to treat this as a pending cross-process transition. |
| 2343 | 2408 |
| 2409 // We now have a pending RFH. |
| 2410 DCHECK(pending_render_frame_host_); |
| 2411 |
| 2344 // We need to wait until the beforeunload handler has run, unless we are | 2412 // We need to wait until the beforeunload handler has run, unless we are |
| 2345 // transferring an existing request (in which case it has already run). | 2413 // transferring an existing request (in which case it has already run). |
| 2346 // Suspend the new render view (i.e., don't let it send the cross-process | 2414 // Suspend the new render view (i.e., don't let it send the cross-process |
| 2347 // Navigate message) until we hear back from the old renderer's | 2415 // Navigate message) until we hear back from the old renderer's |
| 2348 // beforeunload handler. If the handler returns false, we'll have to | 2416 // beforeunload handler. If the handler returns false, we'll have to |
| 2349 // cancel the request. | 2417 // cancel the request. |
| 2418 // |
| 2350 DCHECK(!pending_render_frame_host_->are_navigations_suspended()); | 2419 DCHECK(!pending_render_frame_host_->are_navigations_suspended()); |
| 2351 bool is_transfer = transferred_request_id != GlobalRequestID(); | 2420 bool is_transfer = transferred_request_id != GlobalRequestID(); |
| 2352 if (is_transfer) { | 2421 if (is_transfer) { |
| 2353 // We don't need to stop the old renderer or run beforeunload/unload | 2422 // We don't need to stop the old renderer or run beforeunload/unload |
| 2354 // handlers, because those have already been done. | 2423 // handlers, because those have already been done. |
| 2355 DCHECK(cross_site_transferring_request_->request_id() == | 2424 DCHECK(cross_site_transferring_request_->request_id() == |
| 2356 transferred_request_id); | 2425 transferred_request_id); |
| 2357 } else { | 2426 } else { |
| 2358 // Also make sure the old render view stops, in case a load is in | 2427 // Also make sure the old render view stops, in case a load is in |
| 2359 // progress. (We don't want to do this for transfers, since it will | 2428 // progress. (We don't want to do this for transfers, since it will |
| 2360 // interrupt the transfer with an unexpected DidStopLoading.) | 2429 // interrupt the transfer with an unexpected DidStopLoading.) |
| 2361 render_frame_host_->Send(new FrameMsg_Stop( | 2430 render_frame_host_->Send(new FrameMsg_Stop( |
| 2362 render_frame_host_->GetRoutingID())); | 2431 render_frame_host_->GetRoutingID())); |
| 2363 pending_render_frame_host_->SetNavigationsSuspended(true, | 2432 pending_render_frame_host_->SetNavigationsSuspended(true, |
| 2364 base::TimeTicks()); | 2433 base::TimeTicks()); |
| 2365 // Unless we are transferring an existing request, we should now tell the | 2434 // Unless we are transferring an existing request, we should now tell the |
| 2366 // old render view to run its beforeunload handler, since it doesn't | 2435 // old render view to run its beforeunload handler, since it doesn't |
| 2367 // otherwise know that the cross-site request is happening. This will | 2436 // otherwise know that the cross-site request is happening. This will |
| 2368 // trigger a call to OnBeforeUnloadACK with the reply. | 2437 // trigger a call to OnBeforeUnloadACK with the reply. |
| 2369 render_frame_host_->DispatchBeforeUnload(true); | 2438 render_frame_host_->DispatchBeforeUnload(true); |
| 2370 } | 2439 } |
| 2371 | 2440 |
| 2372 DCHECK(!render_frame_host_->pending_web_ui()); | |
| 2373 return pending_render_frame_host_.get(); | 2441 return pending_render_frame_host_.get(); |
| 2374 } | 2442 } |
| 2375 | 2443 |
| 2376 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. | 2444 // Otherwise the same SiteInstance can be used. Navigate render_frame_host_. |
| 2377 | 2445 |
| 2378 // It's possible to swap out the current RFH and then decide to navigate in it | 2446 // It's possible to swap out the current RFH and then decide to navigate in it |
| 2379 // anyway (e.g., a cross-process navigation that redirects back to the | 2447 // anyway (e.g., a cross-process navigation that redirects back to the |
| 2380 // original site). In that case, we have a proxy for the current RFH but | 2448 // original site). In that case, we have a proxy for the current RFH but |
| 2381 // haven't deleted it yet. The new navigation will swap it back in, so we can | 2449 // haven't deleted it yet. The new navigation will swap it back in, so we can |
| 2382 // delete the proxy. | 2450 // delete the proxy. |
| 2383 proxy_hosts_->Remove(new_instance.get()->GetId()); | 2451 proxy_hosts_->Remove(new_instance.get()->GetId()); |
| 2384 | 2452 |
| 2385 UpdatePendingWebUIOnCurrentFrameHost(dest_url, bindings); | 2453 if (ShouldReuseWebUI(current_entry, dest_url)) { |
| 2454 pending_web_ui_.reset(); |
| 2455 pending_and_current_web_ui_ = web_ui_->AsWeakPtr(); |
| 2456 } else { |
| 2457 SetPendingWebUI(dest_url, bindings); |
| 2458 // Make sure the new RenderViewHost has the right bindings. |
| 2459 if (pending_web_ui() && |
| 2460 !render_frame_host_->GetProcess()->IsForGuestsOnly()) { |
| 2461 render_frame_host_->render_view_host()->AllowBindings( |
| 2462 pending_web_ui()->GetBindings()); |
| 2463 } |
| 2464 } |
| 2465 |
| 2466 if (pending_web_ui() && render_frame_host_->IsRenderFrameLive()) { |
| 2467 pending_web_ui()->RenderViewReused(render_frame_host_->render_view_host(), |
| 2468 frame_tree_node_->IsMainFrame()); |
| 2469 } |
| 2386 | 2470 |
| 2387 // The renderer can exit view source mode when any error or cancellation | 2471 // The renderer can exit view source mode when any error or cancellation |
| 2388 // happen. We must overwrite to recover the mode. | 2472 // happen. We must overwrite to recover the mode. |
| 2389 if (dest_is_view_source_mode) { | 2473 if (dest_is_view_source_mode) { |
| 2390 render_frame_host_->render_view_host()->Send( | 2474 render_frame_host_->render_view_host()->Send( |
| 2391 new ViewMsg_EnableViewSourceMode( | 2475 new ViewMsg_EnableViewSourceMode( |
| 2392 render_frame_host_->render_view_host()->GetRoutingID())); | 2476 render_frame_host_->render_view_host()->GetRoutingID())); |
| 2393 } | 2477 } |
| 2394 | 2478 |
| 2395 return render_frame_host_.get(); | 2479 return render_frame_host_.get(); |
| 2396 } | 2480 } |
| 2397 | 2481 |
| 2398 void RenderFrameHostManager::UpdatePendingWebUIOnCurrentFrameHost( | |
| 2399 const GURL& dest_url, | |
| 2400 int entry_bindings) { | |
| 2401 bool pending_webui_changed = | |
| 2402 render_frame_host_->UpdatePendingWebUI(dest_url, entry_bindings); | |
| 2403 DCHECK_EQ(GetNavigatingWebUI(), render_frame_host_->pending_web_ui()); | |
| 2404 | |
| 2405 if (render_frame_host_->pending_web_ui() && pending_webui_changed && | |
| 2406 render_frame_host_->IsRenderFrameLive()) { | |
| 2407 // If a pending WebUI exists in the current RenderFrameHost and it has been | |
| 2408 // updated and the associated RenderFrame is alive, notify the WebUI about | |
| 2409 // the RenderView. | |
| 2410 // Note: If the RenderFrame is not alive at this point the notification will | |
| 2411 // happen later, when the RenderView is created. | |
| 2412 if (render_frame_host_->pending_web_ui() == render_frame_host_->web_ui()) { | |
| 2413 // If the active WebUI is being reused it has already interacting with | |
| 2414 // this RenderView in the past, so call RenderViewReused. | |
| 2415 render_frame_host_->pending_web_ui()->RenderViewReused( | |
| 2416 render_frame_host_->render_view_host(), | |
| 2417 frame_tree_node_->IsMainFrame()); | |
| 2418 } else { | |
| 2419 // If this is a new WebUI it has never interacted with the existing | |
| 2420 // RenderView so call RenderViewCreated. | |
| 2421 render_frame_host_->pending_web_ui()->RenderViewCreated( | |
| 2422 render_frame_host_->render_view_host()); | |
| 2423 } | |
| 2424 } | |
| 2425 } | |
| 2426 | |
| 2427 void RenderFrameHostManager::CancelPending() { | 2482 void RenderFrameHostManager::CancelPending() { |
| 2428 TRACE_EVENT1("navigation", "RenderFrameHostManager::CancelPending", | 2483 TRACE_EVENT1("navigation", "RenderFrameHostManager::CancelPending", |
| 2429 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | 2484 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
| 2430 render_frame_host_->ClearPendingWebUI(); | |
| 2431 DiscardUnusedFrame(UnsetPendingRenderFrameHost()); | 2485 DiscardUnusedFrame(UnsetPendingRenderFrameHost()); |
| 2432 } | 2486 } |
| 2433 | 2487 |
| 2434 scoped_ptr<RenderFrameHostImpl> | 2488 scoped_ptr<RenderFrameHostImpl> |
| 2435 RenderFrameHostManager::UnsetPendingRenderFrameHost() { | 2489 RenderFrameHostManager::UnsetPendingRenderFrameHost() { |
| 2436 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host = | 2490 scoped_ptr<RenderFrameHostImpl> pending_render_frame_host = |
| 2437 pending_render_frame_host_.Pass(); | 2491 pending_render_frame_host_.Pass(); |
| 2438 | 2492 |
| 2439 RenderFrameDevToolsAgentHost::OnCancelPendingNavigation( | 2493 RenderFrameDevToolsAgentHost::OnCancelPendingNavigation( |
| 2440 pending_render_frame_host.get(), | 2494 pending_render_frame_host.get(), |
| 2441 render_frame_host_.get()); | 2495 render_frame_host_.get()); |
| 2442 | 2496 |
| 2443 // We no longer need to prevent the process from exiting. | 2497 // We no longer need to prevent the process from exiting. |
| 2444 pending_render_frame_host->GetProcess()->RemovePendingView(); | 2498 pending_render_frame_host->GetProcess()->RemovePendingView(); |
| 2445 | 2499 |
| 2500 pending_web_ui_.reset(); |
| 2501 pending_and_current_web_ui_.reset(); |
| 2502 |
| 2446 return pending_render_frame_host.Pass(); | 2503 return pending_render_frame_host.Pass(); |
| 2447 } | 2504 } |
| 2448 | 2505 |
| 2449 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::SetRenderFrameHost( | 2506 scoped_ptr<RenderFrameHostImpl> RenderFrameHostManager::SetRenderFrameHost( |
| 2450 scoped_ptr<RenderFrameHostImpl> render_frame_host) { | 2507 scoped_ptr<RenderFrameHostImpl> render_frame_host) { |
| 2451 // Swap the two. | 2508 // Swap the two. |
| 2452 scoped_ptr<RenderFrameHostImpl> old_render_frame_host = | 2509 scoped_ptr<RenderFrameHostImpl> old_render_frame_host = |
| 2453 render_frame_host_.Pass(); | 2510 render_frame_host_.Pass(); |
| 2454 render_frame_host_ = render_frame_host.Pass(); | 2511 render_frame_host_ = render_frame_host.Pass(); |
| 2455 | 2512 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2610 if (rvh && !rvh->IsRenderViewLive()) { | 2667 if (rvh && !rvh->IsRenderViewLive()) { |
| 2611 EnsureRenderViewInitialized(rvh, instance); | 2668 EnsureRenderViewInitialized(rvh, instance); |
| 2612 } else { | 2669 } else { |
| 2613 // Create a swapped out RenderView in the given SiteInstance if none | 2670 // Create a swapped out RenderView in the given SiteInstance if none |
| 2614 // exists. Since an opener can point to a subframe, do this on the root | 2671 // exists. Since an opener can point to a subframe, do this on the root |
| 2615 // frame of the current opener's frame tree. | 2672 // frame of the current opener's frame tree. |
| 2616 if (SiteIsolationPolicy::IsSwappedOutStateForbidden()) { | 2673 if (SiteIsolationPolicy::IsSwappedOutStateForbidden()) { |
| 2617 frame_tree->root()->render_manager()->CreateRenderFrameProxy(instance); | 2674 frame_tree->root()->render_manager()->CreateRenderFrameProxy(instance); |
| 2618 } else { | 2675 } else { |
| 2619 frame_tree->root()->render_manager()->CreateRenderFrame( | 2676 frame_tree->root()->render_manager()->CreateRenderFrame( |
| 2620 instance, CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, nullptr); | 2677 instance, nullptr, CREATE_RF_SWAPPED_OUT | CREATE_RF_HIDDEN, |
| 2678 nullptr); |
| 2621 } | 2679 } |
| 2622 } | 2680 } |
| 2623 } | 2681 } |
| 2624 } | 2682 } |
| 2625 | 2683 |
| 2626 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { | 2684 int RenderFrameHostManager::GetOpenerRoutingID(SiteInstance* instance) { |
| 2627 if (!frame_tree_node_->opener()) | 2685 if (!frame_tree_node_->opener()) |
| 2628 return MSG_ROUTING_NONE; | 2686 return MSG_ROUTING_NONE; |
| 2629 | 2687 |
| 2630 return frame_tree_node_->opener() | 2688 return frame_tree_node_->opener() |
| 2631 ->render_manager() | 2689 ->render_manager() |
| 2632 ->GetRoutingIdForSiteInstance(instance); | 2690 ->GetRoutingIdForSiteInstance(instance); |
| 2633 } | 2691 } |
| 2634 | 2692 |
| 2635 } // namespace content | 2693 } // namespace content |
| OLD | NEW |