| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 RenderFrameHostManager::~RenderFrameHostManager() { | 100 RenderFrameHostManager::~RenderFrameHostManager() { |
| 101 if (pending_render_frame_host_) | 101 if (pending_render_frame_host_) |
| 102 CancelPending(); | 102 CancelPending(); |
| 103 | 103 |
| 104 // We should always have a current RenderFrameHost except in some tests. | 104 // We should always have a current RenderFrameHost except in some tests. |
| 105 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); | 105 SetRenderFrameHost(scoped_ptr<RenderFrameHostImpl>()); |
| 106 | 106 |
| 107 // Delete any swapped out RenderFrameHosts. | 107 // Delete any swapped out RenderFrameHosts. |
| 108 STLDeleteValues(&proxy_hosts_); | 108 STLDeleteValues(&proxy_hosts_); |
| 109 |
| 110 // PlzNavigate |
| 111 // There is an active navigation request for this RFHM so it needs to be |
| 112 // canceled. |
| 113 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 114 switches::kEnableBrowserSideNavigation)) { |
| 115 if (navigation_request_.get()) |
| 116 navigation_request_->CancelNavigation(); |
| 117 } |
| 118 |
| 109 } | 119 } |
| 110 | 120 |
| 111 void RenderFrameHostManager::Init(BrowserContext* browser_context, | 121 void RenderFrameHostManager::Init(BrowserContext* browser_context, |
| 112 SiteInstance* site_instance, | 122 SiteInstance* site_instance, |
| 113 int view_routing_id, | 123 int view_routing_id, |
| 114 int frame_routing_id) { | 124 int frame_routing_id) { |
| 115 // Create a RenderViewHost and RenderFrameHost, once we have an instance. It | 125 // Create a RenderViewHost and RenderFrameHost, once we have an instance. It |
| 116 // is important to immediately give this SiteInstance to a RenderViewHost so | 126 // is important to immediately give this SiteInstance to a RenderViewHost so |
| 117 // that the SiteInstance is ref counted. | 127 // that the SiteInstance is ref counted. |
| 118 if (!site_instance) | 128 if (!site_instance) |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 static_cast<RenderProcessHostImpl*>(render_frame_host_->GetProcess()); | 431 static_cast<RenderProcessHostImpl*>(render_frame_host_->GetProcess()); |
| 422 process->ResumeResponseDeferredAtStart(*response_started_id_); | 432 process->ResumeResponseDeferredAtStart(*response_started_id_); |
| 423 | 433 |
| 424 render_frame_host_->ClearPendingTransitionRequestData(); | 434 render_frame_host_->ClearPendingTransitionRequestData(); |
| 425 | 435 |
| 426 response_started_id_.reset(); | 436 response_started_id_.reset(); |
| 427 } | 437 } |
| 428 | 438 |
| 429 void RenderFrameHostManager::DidNavigateFrame( | 439 void RenderFrameHostManager::DidNavigateFrame( |
| 430 RenderFrameHostImpl* render_frame_host) { | 440 RenderFrameHostImpl* render_frame_host) { |
| 441 // PlzNavigate |
| 442 // The navigation request has been committed so the browser process doesn't |
| 443 // need to care about it anymore. |
| 444 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 445 switches::kEnableBrowserSideNavigation)) { |
| 446 navigation_request_.reset(); |
| 447 } |
| 448 |
| 431 if (!cross_navigation_pending_) { | 449 if (!cross_navigation_pending_) { |
| 432 DCHECK(!pending_render_frame_host_); | 450 DCHECK(!pending_render_frame_host_); |
| 433 | 451 |
| 434 // We should only hear this from our current renderer. | 452 // We should only hear this from our current renderer. |
| 435 DCHECK_EQ(render_frame_host_, render_frame_host); | 453 DCHECK_EQ(render_frame_host_, render_frame_host); |
| 436 | 454 |
| 437 // Even when there is no pending RVH, there may be a pending Web UI. | 455 // Even when there is no pending RVH, there may be a pending Web UI. |
| 438 if (pending_web_ui()) | 456 if (pending_web_ui()) |
| 439 CommitPending(); | 457 CommitPending(); |
| 440 return; | 458 return; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 info.first_party_for_cookies = frame_tree_node_->IsMainFrame() ? | 593 info.first_party_for_cookies = frame_tree_node_->IsMainFrame() ? |
| 576 params.url : frame_tree_node_->frame_tree()->root()->current_url(); | 594 params.url : frame_tree_node_->frame_tree()->root()->current_url(); |
| 577 info.is_main_frame = frame_tree_node_->IsMainFrame(); | 595 info.is_main_frame = frame_tree_node_->IsMainFrame(); |
| 578 info.parent_is_main_frame = !frame_tree_node_->parent() ? | 596 info.parent_is_main_frame = !frame_tree_node_->parent() ? |
| 579 false : frame_tree_node_->parent()->IsMainFrame(); | 597 false : frame_tree_node_->parent()->IsMainFrame(); |
| 580 | 598 |
| 581 // TODO(clamy): Check if the current RFH should be initialized (in case it has | 599 // TODO(clamy): Check if the current RFH should be initialized (in case it has |
| 582 // crashed) not to display a sad tab while navigating. | 600 // crashed) not to display a sad tab while navigating. |
| 583 // TODO(clamy): Spawn a speculative renderer process if we do not have one to | 601 // TODO(clamy): Spawn a speculative renderer process if we do not have one to |
| 584 // use for the navigation. | 602 // use for the navigation. |
| 603 |
| 604 // If there is an ongoing request it must be canceled. |
| 605 if (navigation_request_.get()) |
| 606 navigation_request_->CancelNavigation(); |
| 607 |
| 585 navigation_request_.reset(new NavigationRequest( | 608 navigation_request_.reset(new NavigationRequest( |
| 586 info, frame_tree_node_->frame_tree_node_id())); | 609 info, frame_tree_node_->frame_tree_node_id())); |
| 587 navigation_request_->BeginNavigation(params.request_body); | 610 navigation_request_->BeginNavigation(params.request_body); |
| 588 } | 611 } |
| 589 | 612 |
| 590 // PlzNavigate | 613 // PlzNavigate |
| 591 void RenderFrameHostManager::CommitNavigation( | 614 void RenderFrameHostManager::CommitNavigation( |
| 592 const NavigationBeforeCommitInfo& info) { | 615 const NavigationBeforeCommitInfo& info) { |
| 593 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( | 616 CHECK(CommandLine::ForCurrentProcess()->HasSwitch( |
| 594 switches::kEnableBrowserSideNavigation)); | 617 switches::kEnableBrowserSideNavigation)); |
| 618 DCHECK(navigation_request_.get()); |
| 619 // Ignores navigation commits if the request ID doesn't match the current |
| 620 // active request. |
| 621 if (navigation_request_->navigation_request_id() != |
| 622 info.navigation_request_id) { |
| 623 return; |
| 624 } |
| 625 |
| 595 // Pick the right RenderFrameHost to commit the navigation. | 626 // Pick the right RenderFrameHost to commit the navigation. |
| 596 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); | 627 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); |
| 597 // TODO(clamy): Replace the default values by the right ones. This may require | 628 // TODO(clamy): Replace the default values by the right ones. This may require |
| 598 // some storing in RequestNavigation. | 629 // some storing in RequestNavigation. |
| 599 SiteInstance* new_instance = GetSiteInstanceForNavigation( | 630 SiteInstance* new_instance = GetSiteInstanceForNavigation( |
| 600 info.navigation_url, | 631 info.navigation_url, |
| 601 NULL, | 632 NULL, |
| 602 navigation_request_->info().navigation_params.transition_type, | 633 navigation_request_->info().navigation_params.transition_type, |
| 603 false, | 634 false, |
| 604 false); | 635 false); |
| (...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1686 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 1717 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
| 1687 SiteInstance* instance) { | 1718 SiteInstance* instance) { |
| 1688 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 1719 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
| 1689 if (iter != proxy_hosts_.end()) { | 1720 if (iter != proxy_hosts_.end()) { |
| 1690 delete iter->second; | 1721 delete iter->second; |
| 1691 proxy_hosts_.erase(iter); | 1722 proxy_hosts_.erase(iter); |
| 1692 } | 1723 } |
| 1693 } | 1724 } |
| 1694 | 1725 |
| 1695 } // namespace content | 1726 } // namespace content |
| OLD | NEW |