Chromium Code Reviews| 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/navigator_impl.h" | 5 #include "content/browser/frame_host/navigator_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 531 } | 531 } |
| 532 | 532 |
| 533 return NavigateToEntry(render_frame_host->frame_tree_node(), *frame_entry, | 533 return NavigateToEntry(render_frame_host->frame_tree_node(), *frame_entry, |
| 534 *entry, ReloadType::NONE, false, true, false, nullptr); | 534 *entry, ReloadType::NONE, false, true, false, nullptr); |
| 535 } | 535 } |
| 536 | 536 |
| 537 void NavigatorImpl::DidNavigate( | 537 void NavigatorImpl::DidNavigate( |
| 538 RenderFrameHostImpl* render_frame_host, | 538 RenderFrameHostImpl* render_frame_host, |
| 539 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 539 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| 540 std::unique_ptr<NavigationHandleImpl> navigation_handle) { | 540 std::unique_ptr<NavigationHandleImpl> navigation_handle) { |
| 541 FrameTree* frame_tree = render_frame_host->frame_tree_node()->frame_tree(); | 541 FrameTreeNode* ftn = render_frame_host->frame_tree_node(); |
|
Charlie Reis
2017/05/22 23:29:02
nit: frame_tree_node (to be consistent with naming
alexmos
2017/05/22 23:43:02
Done.
| |
| 542 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible(); | 542 FrameTree* frame_tree = ftn->frame_tree(); |
| 543 | 543 |
| 544 bool is_navigation_within_page = controller_->IsURLInPageNavigation( | 544 bool is_navigation_within_page = controller_->IsURLInPageNavigation( |
| 545 params.url, params.origin, params.was_within_same_document, | 545 params.url, params.origin, params.was_within_same_document, |
| 546 render_frame_host); | 546 render_frame_host); |
| 547 | 547 |
| 548 // If a frame claims it navigated within page, it must be the current frame, | 548 // If a frame claims it navigated within page, it must be the current frame, |
| 549 // not a pending one. | 549 // not a pending one. |
| 550 if (is_navigation_within_page && | 550 if (is_navigation_within_page && |
| 551 render_frame_host != | 551 render_frame_host != ftn->render_manager()->current_frame_host()) { |
| 552 render_frame_host->frame_tree_node() | |
| 553 ->render_manager() | |
| 554 ->current_frame_host()) { | |
| 555 bad_message::ReceivedBadMessage(render_frame_host->GetProcess(), | 552 bad_message::ReceivedBadMessage(render_frame_host->GetProcess(), |
| 556 bad_message::NI_IN_PAGE_NAVIGATION); | 553 bad_message::NI_IN_PAGE_NAVIGATION); |
| 557 is_navigation_within_page = false; | 554 is_navigation_within_page = false; |
| 558 } | 555 } |
| 559 | 556 |
| 560 if (ui::PageTransitionIsMainFrame(params.transition)) { | 557 if (ui::PageTransitionIsMainFrame(params.transition)) { |
| 561 if (delegate_) { | 558 if (delegate_) { |
| 562 // When overscroll navigation gesture is enabled, a screenshot of the page | 559 // When overscroll navigation gesture is enabled, a screenshot of the page |
| 563 // in its current state is taken so that it can be used during the | 560 // in its current state is taken so that it can be used during the |
| 564 // nav-gesture. It is necessary to take the screenshot here, before | 561 // nav-gesture. It is necessary to take the screenshot here, before |
| 565 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can | 562 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can |
| 566 // change WebContents::GetRenderViewHost to return the new host, instead | 563 // change WebContents::GetRenderViewHost to return the new host, instead |
| 567 // of the one that may have just been swapped out. | 564 // of the one that may have just been swapped out. |
| 568 if (delegate_->CanOverscrollContent()) { | 565 if (delegate_->CanOverscrollContent()) { |
| 569 // Don't take screenshots if we are staying on the same document. We | 566 // Don't take screenshots if we are staying on the same document. We |
| 570 // want same-document navigations to be super fast, and taking a | 567 // want same-document navigations to be super fast, and taking a |
| 571 // screenshot currently blocks GPU for a longer time than we are willing | 568 // screenshot currently blocks GPU for a longer time than we are willing |
| 572 // to tolerate in this use case. | 569 // to tolerate in this use case. |
| 573 if (!params.was_within_same_document) | 570 if (!params.was_within_same_document) |
| 574 controller_->TakeScreenshot(); | 571 controller_->TakeScreenshot(); |
| 575 } | 572 } |
| 576 | 573 |
| 577 // Run tasks that must execute just before the commit. | 574 // Run tasks that must execute just before the commit. |
| 578 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page); | 575 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page); |
| 579 } | 576 } |
| 580 | |
| 581 if (!oopifs_possible) | |
| 582 frame_tree->root()->render_manager()->DidNavigateFrame( | |
| 583 render_frame_host, params.gesture == NavigationGestureUser); | |
| 584 } | 577 } |
| 585 | 578 |
| 586 // Save the origin of the new page. Do this before calling | 579 // Save the origin of the new page. Do this before calling |
| 587 // DidNavigateFrame(), because the origin needs to be included in the SwapOut | 580 // DidNavigateFrame(), because the origin needs to be included in the SwapOut |
| 588 // message, which is sent inside DidNavigateFrame(). SwapOut needs the | 581 // message, which is sent inside DidNavigateFrame(). SwapOut needs the |
| 589 // origin because it creates a RenderFrameProxy that needs this to initialize | 582 // origin because it creates a RenderFrameProxy that needs this to initialize |
| 590 // its security context. This origin will also be sent to RenderFrameProxies | 583 // its security context. This origin will also be sent to RenderFrameProxies |
| 591 // created via mojom::Renderer::CreateView and | 584 // created via mojom::Renderer::CreateView and |
| 592 // mojom::Renderer::CreateFrameProxy. | 585 // mojom::Renderer::CreateFrameProxy. |
| 593 render_frame_host->frame_tree_node()->SetCurrentOrigin( | 586 ftn->SetCurrentOrigin(params.origin, |
| 594 params.origin, params.has_potentially_trustworthy_unique_origin); | 587 params.has_potentially_trustworthy_unique_origin); |
| 595 | 588 |
| 596 render_frame_host->frame_tree_node()->SetInsecureRequestPolicy( | 589 ftn->SetInsecureRequestPolicy(params.insecure_request_policy); |
| 597 params.insecure_request_policy); | |
| 598 | 590 |
| 599 // Navigating to a new location means a new, fresh set of http headers and/or | 591 // Navigating to a new location means a new, fresh set of http headers and/or |
| 600 // <meta> elements - we need to reset CSP and Feature Policy. | 592 // <meta> elements - we need to reset CSP and Feature Policy. |
| 601 if (!is_navigation_within_page) { | 593 if (!is_navigation_within_page) { |
| 602 render_frame_host->ResetContentSecurityPolicies(); | 594 render_frame_host->ResetContentSecurityPolicies(); |
| 603 render_frame_host->frame_tree_node()->ResetCspHeaders(); | 595 ftn->ResetCspHeaders(); |
| 604 render_frame_host->frame_tree_node()->ResetFeaturePolicyHeader(); | 596 ftn->ResetFeaturePolicyHeader(); |
| 605 } | 597 } |
| 606 | 598 |
| 607 // When using --site-per-process, we notify the RFHM for all navigations, | 599 ftn->render_manager()->DidNavigateFrame( |
| 608 // not just main frame navigations. | 600 render_frame_host, params.gesture == NavigationGestureUser); |
| 609 if (oopifs_possible) { | |
| 610 FrameTreeNode* frame = render_frame_host->frame_tree_node(); | |
| 611 frame->render_manager()->DidNavigateFrame( | |
| 612 render_frame_host, params.gesture == NavigationGestureUser); | |
| 613 } | |
| 614 | 601 |
| 615 // Update the site of the SiteInstance if it doesn't have one yet, unless | 602 // Update the site of the SiteInstance if it doesn't have one yet, unless |
| 616 // assigning a site is not necessary for this URL or the commit was for an | 603 // assigning a site is not necessary for this URL or the commit was for an |
| 617 // error page. In that case, the SiteInstance can still be considered unused | 604 // error page. In that case, the SiteInstance can still be considered unused |
| 618 // until a navigation to a real page. | 605 // until a navigation to a real page. |
| 619 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); | 606 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); |
| 620 if (!site_instance->HasSite() && ShouldAssignSiteForURL(params.url) && | 607 if (!site_instance->HasSite() && ShouldAssignSiteForURL(params.url) && |
| 621 !params.url_is_unreachable) { | 608 !params.url_is_unreachable) { |
| 622 site_instance->SetSite(params.url); | 609 site_instance->SetSite(params.url); |
| 623 } | 610 } |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 651 new PageMsg_SetHistoryOffsetAndLength( | 638 new PageMsg_SetHistoryOffsetAndLength( |
| 652 MSG_ROUTING_NONE, controller_->GetLastCommittedEntryIndex(), | 639 MSG_ROUTING_NONE, controller_->GetLastCommittedEntryIndex(), |
| 653 controller_->GetEntryCount()), | 640 controller_->GetEntryCount()), |
| 654 site_instance); | 641 site_instance); |
| 655 } | 642 } |
| 656 | 643 |
| 657 // Keep track of the last committed URL and origin in the RenderFrameHost | 644 // Keep track of the last committed URL and origin in the RenderFrameHost |
| 658 // itself. These allow GetLastCommittedURL and GetLastCommittedOrigin to | 645 // itself. These allow GetLastCommittedURL and GetLastCommittedOrigin to |
| 659 // stay correct even if the render_frame_host later becomes pending deletion. | 646 // stay correct even if the render_frame_host later becomes pending deletion. |
| 660 // The URL is set regardless of whether it's for a net error or not. | 647 // The URL is set regardless of whether it's for a net error or not. |
| 661 render_frame_host->frame_tree_node()->SetCurrentURL(params.url); | 648 ftn->SetCurrentURL(params.url); |
| 662 render_frame_host->SetLastCommittedOrigin(params.origin); | 649 render_frame_host->SetLastCommittedOrigin(params.origin); |
| 663 | 650 |
| 664 // Separately, update the frame's last successful URL except for net error | 651 // Separately, update the frame's last successful URL except for net error |
| 665 // pages, since those do not end up in the correct process after transfers | 652 // pages, since those do not end up in the correct process after transfers |
| 666 // (see https://crbug.com/560511). Instead, the next cross-process navigation | 653 // (see https://crbug.com/560511). Instead, the next cross-process navigation |
| 667 // or transfer should decide whether to swap as if the net error had not | 654 // or transfer should decide whether to swap as if the net error had not |
| 668 // occurred. | 655 // occurred. |
| 669 // TODO(creis): Remove this block and always set the URL once transfers handle | 656 // TODO(creis): Remove this block and always set the URL once transfers handle |
| 670 // network errors or PlzNavigate is enabled. See https://crbug.com/588314. | 657 // network errors or PlzNavigate is enabled. See https://crbug.com/588314. |
| 671 if (!params.url_is_unreachable) | 658 if (!params.url_is_unreachable) |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1296 if (navigation_handle) | 1283 if (navigation_handle) |
| 1297 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); | 1284 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); |
| 1298 | 1285 |
| 1299 controller_->SetPendingEntry(std::move(entry)); | 1286 controller_->SetPendingEntry(std::move(entry)); |
| 1300 if (delegate_) | 1287 if (delegate_) |
| 1301 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1288 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
| 1302 } | 1289 } |
| 1303 } | 1290 } |
| 1304 | 1291 |
| 1305 } // namespace content | 1292 } // namespace content |
| OLD | NEW |