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* frame_tree_node = render_frame_host->frame_tree_node(); |
542 bool oopifs_possible = SiteIsolationPolicy::AreCrossProcessFramesPossible(); | 542 FrameTree* frame_tree = frame_tree_node->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 != |
552 render_frame_host->frame_tree_node() | 552 frame_tree_node->render_manager()->current_frame_host()) { |
553 ->render_manager() | |
554 ->current_frame_host()) { | |
555 bad_message::ReceivedBadMessage(render_frame_host->GetProcess(), | 553 bad_message::ReceivedBadMessage(render_frame_host->GetProcess(), |
556 bad_message::NI_IN_PAGE_NAVIGATION); | 554 bad_message::NI_IN_PAGE_NAVIGATION); |
557 is_navigation_within_page = false; | 555 is_navigation_within_page = false; |
558 } | 556 } |
559 | 557 |
560 if (ui::PageTransitionIsMainFrame(params.transition)) { | 558 if (ui::PageTransitionIsMainFrame(params.transition)) { |
561 if (delegate_) { | 559 if (delegate_) { |
562 // When overscroll navigation gesture is enabled, a screenshot of the page | 560 // 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 | 561 // 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 | 562 // nav-gesture. It is necessary to take the screenshot here, before |
565 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can | 563 // calling RenderFrameHostManager::DidNavigateMainFrame, because that can |
566 // change WebContents::GetRenderViewHost to return the new host, instead | 564 // change WebContents::GetRenderViewHost to return the new host, instead |
567 // of the one that may have just been swapped out. | 565 // of the one that may have just been swapped out. |
568 if (delegate_->CanOverscrollContent()) { | 566 if (delegate_->CanOverscrollContent()) { |
569 // Don't take screenshots if we are staying on the same document. We | 567 // 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 | 568 // want same-document navigations to be super fast, and taking a |
571 // screenshot currently blocks GPU for a longer time than we are willing | 569 // screenshot currently blocks GPU for a longer time than we are willing |
572 // to tolerate in this use case. | 570 // to tolerate in this use case. |
573 if (!params.was_within_same_document) | 571 if (!params.was_within_same_document) |
574 controller_->TakeScreenshot(); | 572 controller_->TakeScreenshot(); |
575 } | 573 } |
576 | 574 |
577 // Run tasks that must execute just before the commit. | 575 // Run tasks that must execute just before the commit. |
578 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page); | 576 delegate_->DidNavigateMainFramePreCommit(is_navigation_within_page); |
579 } | 577 } |
580 | |
581 if (!oopifs_possible) | |
582 frame_tree->root()->render_manager()->DidNavigateFrame( | |
583 render_frame_host, params.gesture == NavigationGestureUser); | |
584 } | 578 } |
585 | 579 |
586 // Save the origin of the new page. Do this before calling | 580 // Save the origin of the new page. Do this before calling |
587 // DidNavigateFrame(), because the origin needs to be included in the SwapOut | 581 // DidNavigateFrame(), because the origin needs to be included in the SwapOut |
588 // message, which is sent inside DidNavigateFrame(). SwapOut needs the | 582 // message, which is sent inside DidNavigateFrame(). SwapOut needs the |
589 // origin because it creates a RenderFrameProxy that needs this to initialize | 583 // origin because it creates a RenderFrameProxy that needs this to initialize |
590 // its security context. This origin will also be sent to RenderFrameProxies | 584 // its security context. This origin will also be sent to RenderFrameProxies |
591 // created via mojom::Renderer::CreateView and | 585 // created via mojom::Renderer::CreateView and |
592 // mojom::Renderer::CreateFrameProxy. | 586 // mojom::Renderer::CreateFrameProxy. |
593 render_frame_host->frame_tree_node()->SetCurrentOrigin( | 587 frame_tree_node->SetCurrentOrigin( |
594 params.origin, params.has_potentially_trustworthy_unique_origin); | 588 params.origin, params.has_potentially_trustworthy_unique_origin); |
595 | 589 |
596 render_frame_host->frame_tree_node()->SetInsecureRequestPolicy( | 590 frame_tree_node->SetInsecureRequestPolicy(params.insecure_request_policy); |
597 params.insecure_request_policy); | |
598 | 591 |
599 // Navigating to a new location means a new, fresh set of http headers and/or | 592 // 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. | 593 // <meta> elements - we need to reset CSP and Feature Policy. |
601 if (!is_navigation_within_page) { | 594 if (!is_navigation_within_page) { |
602 render_frame_host->ResetContentSecurityPolicies(); | 595 render_frame_host->ResetContentSecurityPolicies(); |
603 render_frame_host->frame_tree_node()->ResetCspHeaders(); | 596 frame_tree_node->ResetCspHeaders(); |
604 render_frame_host->frame_tree_node()->ResetFeaturePolicyHeader(); | 597 frame_tree_node->ResetFeaturePolicyHeader(); |
605 } | 598 } |
606 | 599 |
607 // When using --site-per-process, we notify the RFHM for all navigations, | 600 frame_tree_node->render_manager()->DidNavigateFrame( |
608 // not just main frame navigations. | 601 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 | 602 |
615 // Update the site of the SiteInstance if it doesn't have one yet, unless | 603 // 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 | 604 // 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 | 605 // error page. In that case, the SiteInstance can still be considered unused |
618 // until a navigation to a real page. | 606 // until a navigation to a real page. |
619 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); | 607 SiteInstanceImpl* site_instance = render_frame_host->GetSiteInstance(); |
620 if (!site_instance->HasSite() && ShouldAssignSiteForURL(params.url) && | 608 if (!site_instance->HasSite() && ShouldAssignSiteForURL(params.url) && |
621 !params.url_is_unreachable) { | 609 !params.url_is_unreachable) { |
622 site_instance->SetSite(params.url); | 610 site_instance->SetSite(params.url); |
623 } | 611 } |
(...skipping 27 matching lines...) Expand all Loading... |
651 new PageMsg_SetHistoryOffsetAndLength( | 639 new PageMsg_SetHistoryOffsetAndLength( |
652 MSG_ROUTING_NONE, controller_->GetLastCommittedEntryIndex(), | 640 MSG_ROUTING_NONE, controller_->GetLastCommittedEntryIndex(), |
653 controller_->GetEntryCount()), | 641 controller_->GetEntryCount()), |
654 site_instance); | 642 site_instance); |
655 } | 643 } |
656 | 644 |
657 // Keep track of the last committed URL and origin in the RenderFrameHost | 645 // Keep track of the last committed URL and origin in the RenderFrameHost |
658 // itself. These allow GetLastCommittedURL and GetLastCommittedOrigin to | 646 // itself. These allow GetLastCommittedURL and GetLastCommittedOrigin to |
659 // stay correct even if the render_frame_host later becomes pending deletion. | 647 // 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. | 648 // 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); | 649 frame_tree_node->SetCurrentURL(params.url); |
662 render_frame_host->SetLastCommittedOrigin(params.origin); | 650 render_frame_host->SetLastCommittedOrigin(params.origin); |
663 | 651 |
664 // Separately, update the frame's last successful URL except for net error | 652 // 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 | 653 // 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 | 654 // (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 | 655 // or transfer should decide whether to swap as if the net error had not |
668 // occurred. | 656 // occurred. |
669 // TODO(creis): Remove this block and always set the URL once transfers handle | 657 // 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. | 658 // network errors or PlzNavigate is enabled. See https://crbug.com/588314. |
671 if (!params.url_is_unreachable) | 659 if (!params.url_is_unreachable) |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 if (navigation_handle) | 1284 if (navigation_handle) |
1297 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); | 1285 navigation_handle->update_entry_id_for_transfer(entry->GetUniqueID()); |
1298 | 1286 |
1299 controller_->SetPendingEntry(std::move(entry)); | 1287 controller_->SetPendingEntry(std::move(entry)); |
1300 if (delegate_) | 1288 if (delegate_) |
1301 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); | 1289 delegate_->NotifyChangedNavigationState(content::INVALIDATE_TYPE_URL); |
1302 } | 1290 } |
1303 } | 1291 } |
1304 | 1292 |
1305 } // namespace content | 1293 } // namespace content |
OLD | NEW |