prerender: Pass is_prerendering to RenderView instead of nav commit.
Before this CL, the browser only tells the renderer that a document is being prerendered as part of the CommitNavigation IPC. But some documents in the renderer are created before CommitNavigation or do not go through it. Therefore these documents do not know that they are being prerendered. This CL fixes the issue by moving the is_prerendering bit from CommitNavigation to CreateRenderView. This ensures that RenderViews understand whether they are being prerendered, and any document that is created in that RenderView/Page starts out with the desired state. We also add an Activate IPC to RenderView, which means that documents created after that IPC arrives start out with the desired state. This is redundant with the existing per-frame IPC, which a subsequent CL will remove. The per-frame IPC is kept only as an intermediate implementation step. This is the result of a discussion on navigation-dev[1]. A summary is of the design is available at [2]. [1] https://groups.google.com/a/chromium.org/g/navigation-dev/c/v3T8NfWPTg8/m/brmF98nKAAAJ [2] https://docs.google.com/document/d/1S8_ilRC_TkDa4Wz3PvBPYhhqIuGNHDX0DKsvjMFotKM/edit?usp=sharing Bug: 1185965 Change-Id: I4876655615782de0d6645853f12a598637675d52 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3017926 Commit-Queue: Matt Falkenhagen <falken@chromium.org> Owners-Override: Matt Falkenhagen <falken@chromium.org> Reviewed-by: Alexander Timin <altimin@chromium.org> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org> Cr-Commit-Position: refs/heads/master@{#901189}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
afc0068418
commit
84e9a9b442
components
content
browser
prerender
prerender_browsertest.ccprerender_host_unittest.ccprerender_subframe_navigation_throttle.ccprerender_subframe_navigation_throttle.h
renderer_host
common
renderer
test
extensions/renderer
third_party/blink
public
renderer
core
dom
exported
frame
loader
page
modules
peerconnection
platform
@ -269,6 +269,7 @@ WebViewPlugin::WebViewHelper::WebViewHelper(
|
||||
web_view_ =
|
||||
WebView::Create(/*client=*/this,
|
||||
/*is_hidden=*/false,
|
||||
/*is_prerendering=*/false,
|
||||
/*is_inside_portal=*/false,
|
||||
/*compositing_enabled=*/false,
|
||||
/*widgets_never_composited=*/false,
|
||||
|
@ -702,7 +702,8 @@ void PrintRenderFrameHelper::PrintHeaderAndFooter(
|
||||
|
||||
blink::WebView* web_view = blink::WebView::Create(
|
||||
/*client=*/nullptr,
|
||||
/*is_hidden=*/false, /*is_inside_portal=*/false,
|
||||
/*is_hidden=*/false, /*is_prerendering=*/false,
|
||||
/*is_inside_portal=*/false,
|
||||
/*compositing_enabled=*/false, /*widgets_never_composited=*/false,
|
||||
/*opener=*/nullptr, mojo::NullAssociatedReceiver(),
|
||||
*source_frame.GetAgentGroupScheduler(),
|
||||
@ -981,6 +982,7 @@ void PrepareFrameAndViewForPrint::CopySelection(
|
||||
blink::WebView* web_view = blink::WebView::Create(
|
||||
/*client=*/this,
|
||||
/*is_hidden=*/false,
|
||||
/*is_prerendering=*/false,
|
||||
/*is_inside_portal=*/false,
|
||||
/*compositing_enabled=*/false,
|
||||
/*widgets_never_composited=*/false,
|
||||
|
@ -270,6 +270,14 @@ class PrerenderBrowserTest : public ContentBrowserTest {
|
||||
EXPECT_EQ(rfhi->lifecycle_state(),
|
||||
RenderFrameHostImpl::LifecycleStateImpl::kActive);
|
||||
EXPECT_FALSE(rfhi->frame_tree()->is_prerendering());
|
||||
|
||||
// Check that each document can use a deferred Mojo interface. Choose
|
||||
// WebLocks API as the feature is enabled by default and does not require
|
||||
// permission.
|
||||
const std::string kMojoScript = R"(
|
||||
navigator.locks.request('hi', {mode:'shared'}, () => {});
|
||||
)";
|
||||
EXPECT_TRUE(ExecJs(rfhi, kMojoScript));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1278,8 +1286,7 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderIframe) {
|
||||
|
||||
// Blank <iframe> is a special case. Tests that the blank iframe knows the
|
||||
// prerendering state as well.
|
||||
// TODO(https://crbug.com/1185965): This test is disabled for flakiness.
|
||||
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, DISABLED_PrerenderBlankIframe) {
|
||||
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, PrerenderBlankIframe) {
|
||||
TestHostPrerenderingState(GetUrl("/page_with_blank_iframe.html"));
|
||||
}
|
||||
|
||||
@ -2591,11 +2598,8 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, OpenURLInPrerenderingFrame) {
|
||||
// Ensures WebContents::OpenURL with a cross-origin URL targeting a frame in a
|
||||
// prerendered host will successfully navigate that frame, though it should be
|
||||
// deferred until activation.
|
||||
// TODO(bokan): This test exposes a race condition between the iframe
|
||||
// navigation and the prerenderingchange event being dispatched.
|
||||
// https://crbug.com/1213454.
|
||||
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
|
||||
DISABLED_OpenURLCrossOriginInPrerenderingFrame) {
|
||||
OpenURLCrossOriginInPrerenderingFrame) {
|
||||
const GURL kInitialUrl = GetUrl("/empty.html");
|
||||
const GURL kPrerenderingUrl = GetUrl("/page_with_blank_iframe.html");
|
||||
const GURL kNewIframeUrl = GetCrossOriginUrl("/simple_page.html");
|
||||
@ -2673,9 +2677,8 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
|
||||
auto* prerender_ftn = prerendered_rfh->frame_tree_node();
|
||||
EXPECT_FALSE(prerender_ftn->HasNavigation());
|
||||
|
||||
// Now navigate the primary page to the prerendered URL so that we activate
|
||||
// the prerender. Use a CommitDeferringCondition to pause activation
|
||||
// before it completes.
|
||||
// Start an activation navigation for the prerender. Use a
|
||||
// CommitDeferringCondition to pause activation before it completes.
|
||||
TestNavigationManager activation_observer(shell()->web_contents(),
|
||||
kPrerenderingUrl);
|
||||
MockCommitDeferringConditionWrapper condition(/*is_ready_to_commit=*/false);
|
||||
@ -2686,6 +2689,9 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
|
||||
|
||||
// Wait for the condition to pause the activation.
|
||||
condition.WaitUntilInvoked();
|
||||
NavigationRequest* request =
|
||||
web_contents_impl()->GetFrameTree()->root()->navigation_request();
|
||||
EXPECT_TRUE(request->IsCommitDeferringConditionDeferredForTesting());
|
||||
EXPECT_EQ(web_contents()->GetURL(), kInitialUrl);
|
||||
}
|
||||
|
||||
@ -2719,10 +2725,88 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
|
||||
EXPECT_EQ(shell()->web_contents()->GetURL(), kPrerenderingUrl);
|
||||
}
|
||||
|
||||
// Ensures WebContents::OpenURL to a frame in a currently activating (i.e.
|
||||
// "reserved") prerendering host navigates the frame.
|
||||
// Tests that cross-origin subframe navigations in a prerendered page are
|
||||
// deferred even if they start after the a navigation starts that will
|
||||
// attempt to activate the prerendered page.
|
||||
//
|
||||
// Regression test for https://crbug.com/1190262.
|
||||
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
|
||||
OpenURLInReservedPrerenderingFrame) {
|
||||
CrossOriginSubframeNavigationDuringActivation) {
|
||||
const GURL kInitialUrl = GetUrl("/empty.html");
|
||||
const GURL kPrerenderingUrl = GetUrl("/page_with_blank_iframe.html");
|
||||
const GURL kCrossOriginUrl = GetCrossOriginUrl("/simple_page.html");
|
||||
|
||||
// Navigate to an initial page.
|
||||
ASSERT_TRUE(NavigateToURL(shell(), kInitialUrl));
|
||||
ASSERT_EQ(shell()->web_contents()->GetURL(), kInitialUrl);
|
||||
|
||||
// Start prerendering `kPrerenderingUrl`.
|
||||
int prerender_host_id = RenderFrameHost::kNoFrameTreeNodeId;
|
||||
RenderFrameHost* prerender_main_frame = nullptr;
|
||||
{
|
||||
prerender_host_id = AddPrerender(kPrerenderingUrl);
|
||||
ASSERT_NE(prerender_host_id, RenderFrameHost::kNoFrameTreeNodeId);
|
||||
|
||||
prerender_main_frame = GetPrerenderedMainFrameHost(prerender_host_id);
|
||||
RenderFrameHost* child_frame = ChildFrameAt(prerender_main_frame, 0);
|
||||
ASSERT_TRUE(child_frame);
|
||||
}
|
||||
|
||||
// Start an activation navigation for the prerender. Use a
|
||||
// CommitDeferringCondition to pause activation before it completes.
|
||||
test::PrerenderHostObserver prerender_observer(*web_contents(),
|
||||
kPrerenderingUrl);
|
||||
TestNavigationManager activation_observer(shell()->web_contents(),
|
||||
kPrerenderingUrl);
|
||||
MockCommitDeferringConditionWrapper condition(/*is_ready_to_commit=*/false);
|
||||
{
|
||||
MockCommitDeferringConditionInstaller installer(condition.PassToDelegate());
|
||||
ASSERT_TRUE(ExecJs(web_contents()->GetMainFrame(),
|
||||
JsReplace("location = $1", kPrerenderingUrl)));
|
||||
|
||||
// Wait for the condition to pause the activation.
|
||||
condition.WaitUntilInvoked();
|
||||
NavigationRequest* request =
|
||||
web_contents_impl()->GetFrameTree()->root()->navigation_request();
|
||||
EXPECT_TRUE(request->IsCommitDeferringConditionDeferredForTesting());
|
||||
EXPECT_EQ(web_contents()->GetURL(), kInitialUrl);
|
||||
}
|
||||
|
||||
// Start a cross-origin subframe navigation in the prerendered page. It
|
||||
// should be deferred.
|
||||
std::string kNavigateScript = R"(
|
||||
document.querySelector('iframe').src = $1;
|
||||
)";
|
||||
TestNavigationManager iframe_nav_observer(shell()->web_contents(),
|
||||
kCrossOriginUrl);
|
||||
ASSERT_TRUE(ExecJs(prerender_main_frame,
|
||||
JsReplace(kNavigateScript, kCrossOriginUrl)));
|
||||
|
||||
iframe_nav_observer.WaitForFirstYieldAfterDidStartNavigation();
|
||||
|
||||
// The PrerenderSubframeNavigationThrottle should defer it until activation.
|
||||
auto* child_ftn =
|
||||
FrameTreeNode::GloballyFindByID(prerender_host_id)->child_at(0);
|
||||
auto* child_navigation = child_ftn->navigation_request();
|
||||
ASSERT_NE(child_navigation, nullptr);
|
||||
EXPECT_TRUE(child_navigation->IsDeferredForTesting());
|
||||
|
||||
// Allow the activation navigation to complete.
|
||||
condition.CallResumeClosure();
|
||||
activation_observer.WaitForNavigationFinished();
|
||||
EXPECT_TRUE(activation_observer.was_prerendered_page_activation());
|
||||
|
||||
// The iframe navigation should finish.
|
||||
iframe_nav_observer.WaitForNavigationFinished();
|
||||
EXPECT_EQ(ChildFrameAt(prerender_main_frame, 0)->GetLastCommittedURL(),
|
||||
kCrossOriginUrl);
|
||||
}
|
||||
|
||||
// Tests WebContents::OpenURL to a frame in a prerendered page when a
|
||||
// navigation that will attempt to activate the page has already started. The
|
||||
// subframe navigation should succeed.
|
||||
IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
|
||||
OpenURLInSubframeDuringActivation) {
|
||||
const GURL kInitialUrl = GetUrl("/empty.html");
|
||||
const GURL kPrerenderingUrl = GetUrl("/page_with_blank_iframe.html");
|
||||
const GURL kNewIframeUrl = GetUrl("/simple_page.html");
|
||||
@ -2746,8 +2830,8 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
|
||||
ASSERT_TRUE(child_frame);
|
||||
}
|
||||
|
||||
// Now navigate the primary page to the prerendered URL so that we activate
|
||||
// the prerender.
|
||||
// Start an activation navigation for the prerender. Use a
|
||||
// CommitDeferringCondition to pause activation before it completes.
|
||||
test::PrerenderHostObserver prerender_observer(*web_contents(),
|
||||
kPrerenderingUrl);
|
||||
TestNavigationManager activation_observer(shell()->web_contents(),
|
||||
@ -2760,11 +2844,14 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
|
||||
|
||||
// Wait for the condition to pause the activation.
|
||||
condition.WaitUntilInvoked();
|
||||
NavigationRequest* request =
|
||||
web_contents_impl()->GetFrameTree()->root()->navigation_request();
|
||||
EXPECT_TRUE(request->IsCommitDeferringConditionDeferredForTesting());
|
||||
EXPECT_EQ(web_contents()->GetURL(), kInitialUrl);
|
||||
}
|
||||
|
||||
// Use the OpenURL API to navigate the iframe in the reserved prerendering
|
||||
// frame tree. This navigation should succeed.
|
||||
// Use the OpenURL API to navigate the iframe in the prerendering frame tree.
|
||||
// This navigation should succeed.
|
||||
{
|
||||
TestNavigationManager iframe_observer(shell()->web_contents(),
|
||||
kNewIframeUrl);
|
||||
@ -2776,12 +2863,10 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
|
||||
EXPECT_EQ(child_frame->GetLastCommittedURL(), kNewIframeUrl);
|
||||
}
|
||||
|
||||
// Allow the navigation to complete to activation, the iframe navigation
|
||||
// should be able to finish. Ensure the navigation completes in the iframe.
|
||||
{
|
||||
condition.CallResumeClosure();
|
||||
prerender_observer.WaitForActivation();
|
||||
}
|
||||
// Allow the activation navigation to complete.
|
||||
condition.CallResumeClosure();
|
||||
activation_observer.WaitForNavigationFinished();
|
||||
EXPECT_TRUE(activation_observer.was_prerendered_page_activation());
|
||||
}
|
||||
|
||||
class ScopedDataSaverTestContentBrowserClient
|
||||
|
@ -244,73 +244,6 @@ TEST_F(PrerenderHostTest, MainFrameNavigationForReservedHost) {
|
||||
kPrerenderingUrl);
|
||||
}
|
||||
|
||||
// Tests that cross-origin subframe navigations in a prerendered page are
|
||||
// deferred even if they start after the prerendered page has been reserved for
|
||||
// activation.
|
||||
//
|
||||
// Regression test for https://crbug.com/1190262.
|
||||
TEST_F(PrerenderHostTest, SubframeNavigationForReservedHost) {
|
||||
const GURL kOriginUrl("https://example.com/");
|
||||
std::unique_ptr<TestWebContents> web_contents = CreateWebContents(kOriginUrl);
|
||||
RenderFrameHostImpl* initiator_rfh = web_contents->GetMainFrame();
|
||||
PrerenderHostRegistry* registry = web_contents->GetPrerenderHostRegistry();
|
||||
|
||||
// Start prerendering a page.
|
||||
const GURL kPrerenderingUrl("https://example.com/next");
|
||||
RenderFrameHostImpl* prerender_rfh =
|
||||
web_contents->AddPrerenderAndCommitNavigation(kPrerenderingUrl);
|
||||
const int prerender_ftn_id = prerender_rfh->GetFrameTreeNodeId();
|
||||
PrerenderHost* prerender_host =
|
||||
registry->FindNonReservedHostById(prerender_ftn_id);
|
||||
|
||||
ActivationObserver activation_observer;
|
||||
prerender_host->AddObserver(&activation_observer);
|
||||
|
||||
// Now navigate the primary page to the prerendered URL so that we activate
|
||||
// the prerender. Use a CommitDeferringCondition to pause activation
|
||||
// before it completes.
|
||||
std::unique_ptr<NavigationSimulatorImpl> navigation;
|
||||
MockCommitDeferringConditionWrapper condition(/*is_ready_to_commit=*/false);
|
||||
{
|
||||
MockCommitDeferringConditionInstaller installer(condition.PassToDelegate());
|
||||
|
||||
// Start trying to activate the prerendered page.
|
||||
navigation = NavigationSimulatorImpl::CreateRendererInitiated(
|
||||
kPrerenderingUrl, initiator_rfh);
|
||||
navigation->Start();
|
||||
|
||||
// Wait for the condition to pause the activation.
|
||||
condition.WaitUntilInvoked();
|
||||
}
|
||||
|
||||
// The primary page should still be the original page.
|
||||
EXPECT_EQ(web_contents->GetURL(), kOriginUrl);
|
||||
|
||||
// Start a cross-origin subframe navigation in the prerendered page. It
|
||||
// should be deferred.
|
||||
RenderFrameHost* subframe =
|
||||
RenderFrameHostTester::For(prerender_rfh)->AppendChild("subframe");
|
||||
std::unique_ptr<NavigationSimulatorImpl> subframe_nav_sim =
|
||||
NavigationSimulatorImpl::CreateRendererInitiated(
|
||||
GURL("https://example2.test/"), subframe);
|
||||
subframe_nav_sim->SetAutoAdvance(false);
|
||||
subframe_nav_sim->Start();
|
||||
EXPECT_TRUE(subframe_nav_sim->IsDeferred());
|
||||
|
||||
// Resume the activation.
|
||||
condition.CallResumeClosure();
|
||||
activation_observer.WaitUntilHostDestroyed();
|
||||
EXPECT_TRUE(activation_observer.was_activated());
|
||||
EXPECT_EQ(registry->FindHostByUrlForTesting(kPrerenderingUrl), nullptr);
|
||||
ExpectFinalStatus(PrerenderHost::FinalStatus::kActivated);
|
||||
EXPECT_EQ(web_contents->GetMainFrame()->GetLastCommittedURL(),
|
||||
kPrerenderingUrl);
|
||||
|
||||
// The subframe navigation should no longer be deferred.
|
||||
subframe_nav_sim->Wait();
|
||||
EXPECT_FALSE(subframe_nav_sim->IsDeferred());
|
||||
}
|
||||
|
||||
// Tests that an activation can successfully commit after the prerendering page
|
||||
// has updated its PageState.
|
||||
TEST_F(PrerenderHostTest, ActivationAfterPageStateUpdate) {
|
||||
|
@ -34,8 +34,13 @@ PrerenderSubframeNavigationThrottle::MaybeCreateThrottleFor(
|
||||
}
|
||||
|
||||
PrerenderSubframeNavigationThrottle::PrerenderSubframeNavigationThrottle(
|
||||
NavigationHandle* navigation_handle)
|
||||
: NavigationThrottle(navigation_handle) {}
|
||||
NavigationHandle* nav_handle)
|
||||
: NavigationThrottle(nav_handle),
|
||||
prerender_root_ftn_id_(NavigationRequest::From(nav_handle)
|
||||
->frame_tree_node()
|
||||
->frame_tree()
|
||||
->root()
|
||||
->frame_tree_node_id()) {}
|
||||
|
||||
PrerenderSubframeNavigationThrottle::~PrerenderSubframeNavigationThrottle() =
|
||||
default;
|
||||
@ -79,11 +84,46 @@ void PrerenderSubframeNavigationThrottle::OnActivated() {
|
||||
->frame_tree_node()
|
||||
->frame_tree()
|
||||
->is_prerendering());
|
||||
if (is_deferred_) {
|
||||
is_deferred_ = false;
|
||||
// May delete `this`.
|
||||
Resume();
|
||||
}
|
||||
// OnActivated() is called right before activation navigation commit which is
|
||||
// a little early. We want to resume the subframe navigation after the
|
||||
// PageBroadcast ActivatePrerenderedPage IPC is sent, to
|
||||
// guarantee that the new document starts in the non-prerendered state and
|
||||
// does not get a prerenderingchange event.
|
||||
//
|
||||
// Listen to the WebContents to wait for the activation navigation to finish
|
||||
// before resuming the subframe navigation.
|
||||
Observe(navigation_handle()->GetWebContents());
|
||||
}
|
||||
|
||||
// Use DidFinishNavigation() rather than PrimaryPageChanged() in order to
|
||||
// Resume() after the PageBroadcast Activate IPC is sent, which happens a
|
||||
// little after PrimaryPageChanged() and before DidFinishNavigation(). This
|
||||
// guarantees the new document starts in non-prerendered state.
|
||||
void PrerenderSubframeNavigationThrottle::DidFinishNavigation(
|
||||
NavigationHandle* nav_handle) {
|
||||
// Ignore finished navigations that are not the activation navigation for the
|
||||
// prerendering frame tree that this subframe navigation started in.
|
||||
auto* finished_navigation = NavigationRequest::From(nav_handle);
|
||||
if (finished_navigation->prerender_frame_tree_node_id() !=
|
||||
prerender_root_ftn_id_)
|
||||
return;
|
||||
|
||||
// If the finished navigation did not commit, do not Resume(). We expect that
|
||||
// the prerendered page and therefore the subframe navigation will eventually
|
||||
// be cancelled.
|
||||
if (!finished_navigation->HasCommitted())
|
||||
return;
|
||||
|
||||
// The activation is finished. There is no need to listen to the WebContents
|
||||
// anymore.
|
||||
Observe(nullptr);
|
||||
|
||||
// Resume the subframe navigation.
|
||||
if (!is_deferred_)
|
||||
return;
|
||||
is_deferred_ = false;
|
||||
Resume();
|
||||
// Resume() may have deleted `this`.
|
||||
}
|
||||
|
||||
void PrerenderSubframeNavigationThrottle::OnHostDestroyed() {
|
||||
@ -114,12 +154,12 @@ PrerenderSubframeNavigationThrottle::WillStartOrRedirectRequest() {
|
||||
PrerenderHostRegistry* registry = frame_tree_node->current_frame_host()
|
||||
->delegate()
|
||||
->GetPrerenderHostRegistry();
|
||||
int id = frame_tree_node->frame_tree()->GetMainFrame()->GetFrameTreeNodeId();
|
||||
PrerenderHost* prerender_host = registry->FindNonReservedHostById(id);
|
||||
PrerenderHost* prerender_host =
|
||||
registry->FindNonReservedHostById(prerender_root_ftn_id_);
|
||||
if (!prerender_host) {
|
||||
// The host might be reserved already for activation. In either case, we
|
||||
// defer until activation for simplicity.
|
||||
prerender_host = registry->FindReservedHostById(id);
|
||||
prerender_host = registry->FindReservedHostById(prerender_root_ftn_id_);
|
||||
}
|
||||
DCHECK(prerender_host);
|
||||
|
||||
|
@ -14,7 +14,8 @@ namespace content {
|
||||
// PrerenderSubframeNavigationThrottle defers cross-origin subframe loading
|
||||
// during the main frame is in a prerendered state.
|
||||
class PrerenderSubframeNavigationThrottle : public NavigationThrottle,
|
||||
public PrerenderHost::Observer {
|
||||
public PrerenderHost::Observer,
|
||||
public WebContentsObserver {
|
||||
public:
|
||||
~PrerenderSubframeNavigationThrottle() override;
|
||||
|
||||
@ -35,9 +36,13 @@ class PrerenderSubframeNavigationThrottle : public NavigationThrottle,
|
||||
void OnActivated() override;
|
||||
void OnHostDestroyed() override;
|
||||
|
||||
// WebContentsObserver:
|
||||
void DidFinishNavigation(NavigationHandle* nav_handle) override;
|
||||
|
||||
ThrottleCheckResult WillStartOrRedirectRequest();
|
||||
|
||||
bool is_deferred_ = false;
|
||||
const int prerender_root_ftn_id_;
|
||||
base::ScopedObservation<PrerenderHost, PrerenderHost::Observer> observation_{
|
||||
this};
|
||||
};
|
||||
|
@ -3518,7 +3518,6 @@ NavigationControllerImpl::CreateNavigationRequestFromLoadParams(
|
||||
std::string(), /* data_url_as_string */
|
||||
#endif
|
||||
!params.is_renderer_initiated, /* is_browser_initiated */
|
||||
node->frame_tree()->is_prerendering() /* is_prerendering */,
|
||||
GURL() /* web_bundle_physical_url */,
|
||||
GURL() /* base_url_override_for_web_bundle */,
|
||||
ukm::kInvalidSourceId /* document_ukm_source_id */,
|
||||
|
@ -107,6 +107,7 @@ class MockPageBroadcast : public blink::mojom::PageBroadcast {
|
||||
SetPageLifecycleStateCallback callback),
|
||||
(override));
|
||||
MOCK_METHOD(void, AudioStateChanged, (bool is_audio_playing), (override));
|
||||
MOCK_METHOD(void, ActivatePrerenderedPage, (), (override));
|
||||
MOCK_METHOD(void, SetInsidePortal, (bool is_inside_portal), (override));
|
||||
MOCK_METHOD(void,
|
||||
UpdateWebPreferences,
|
||||
|
@ -872,7 +872,7 @@ NavigationEntryImpl::ConstructCommitNavigationParams(
|
||||
#if defined(OS_ANDROID)
|
||||
std::string(),
|
||||
#endif
|
||||
false /* is_browser_initiated */, false /* is_prerendering */,
|
||||
false /* is_browser_initiated */,
|
||||
GURL() /* web_bundle_physical_url */,
|
||||
GURL() /* base_url_override_for_web_bundle */,
|
||||
ukm::kInvalidSourceId /* document_ukm_source_id */, frame_policy,
|
||||
|
@ -1009,7 +1009,6 @@ std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated(
|
||||
/*data_url_as_string=*/std::string(),
|
||||
#endif
|
||||
/*is_browser_initiated=*/false,
|
||||
frame_tree_node->frame_tree()->is_prerendering(),
|
||||
/*web_bundle_physical_url=*/GURL(),
|
||||
/*base_url_override_for_web_bundle=*/GURL(),
|
||||
/*document_ukm_source_id=*/ukm::kInvalidSourceId,
|
||||
@ -1132,7 +1131,6 @@ NavigationRequest::CreateForSynchronousRendererCommit(
|
||||
std::string() /* data_url_as_string */,
|
||||
#endif
|
||||
false /* is_browser_initiated */,
|
||||
frame_tree_node->frame_tree()->is_prerendering(),
|
||||
GURL() /* web_bundle_physical_url */,
|
||||
GURL() /* base_url_override_for_web_bundle */,
|
||||
ukm::kInvalidSourceId /* document_ukm_source_id */,
|
||||
@ -3965,16 +3963,6 @@ void NavigationRequest::CommitErrorPage(
|
||||
redirect_chain_.clear();
|
||||
redirect_chain_.push_back(GetURL());
|
||||
|
||||
// Set `is_prerendering` here so it's accurate before sending it to the
|
||||
// renderer, as it may be out of sync with the source of truth which is the
|
||||
// frame tree state. The frame tree may have changed if activation happened
|
||||
// while this navigation is occurring in an iframe.
|
||||
// TODO(crbug.com/1189481): With MPArch, the NavigationRequest should be
|
||||
// notified when it transfers frame trees, and commit_params should be updated
|
||||
// then.
|
||||
commit_params_->is_prerendering =
|
||||
frame_tree_node_->frame_tree()->is_prerendering();
|
||||
|
||||
ReadyToCommitNavigation(true /* is_error */);
|
||||
|
||||
// Use a separate cache shard, and no cookies, for error pages.
|
||||
@ -4145,16 +4133,6 @@ void NavigationRequest::CommitNavigation() {
|
||||
}
|
||||
}
|
||||
|
||||
// Set `is_prerendering` here so it's accurate before sending it to the
|
||||
// renderer, as it may be out of sync with the source of truth which is the
|
||||
// frame tree state. The frame tree may have changed if activation happened
|
||||
// while this navigation is occurring in an iframe.
|
||||
// TODO(crbug.com/1189481): With MPArch, the NavigationRequest should be
|
||||
// notified when it transfers frame trees, and commit_params should be updated
|
||||
// then.
|
||||
commit_params_->is_prerendering =
|
||||
frame_tree_node_->frame_tree()->is_prerendering();
|
||||
|
||||
if (!IsSameDocument())
|
||||
GetNavigationController()->PopulateAppHistoryEntryVectors(this);
|
||||
|
||||
|
@ -3292,6 +3292,9 @@ void RenderFrameHostManager::CommitPending(
|
||||
} else {
|
||||
DCHECK_EQ(prev_state,
|
||||
RenderFrameHostImpl::LifecycleStateImpl::kPrerendering);
|
||||
for (RenderViewHostImpl* rvh : render_view_hosts_to_restore) {
|
||||
rvh->ActivatePrerenderedPage();
|
||||
}
|
||||
current_frame_host()->ActivateForPrerendering();
|
||||
}
|
||||
}
|
||||
|
@ -429,6 +429,8 @@ bool RenderViewHostImpl::CreateRenderView(
|
||||
params->replication_state =
|
||||
frame_tree_node->current_replication_state().Clone();
|
||||
params->devtools_main_frame_token = frame_tree_node->devtools_frame_token();
|
||||
DCHECK_EQ(frame_tree_node->frame_tree(), frame_tree_);
|
||||
params->is_prerendering = frame_tree_->is_prerendering();
|
||||
|
||||
if (main_rfh) {
|
||||
auto local_frame_params = mojom::CreateLocalMainFrameParams::New();
|
||||
@ -558,6 +560,15 @@ void RenderViewHostImpl::LeaveBackForwardCache(
|
||||
is_in_back_forward_cache_, std::move(page_restore_params));
|
||||
}
|
||||
|
||||
void RenderViewHostImpl::ActivatePrerenderedPage() {
|
||||
// Null in some unit tests that use TestRenderViewHost.
|
||||
// TODO(falken): Bind this in tests.
|
||||
if (!page_broadcast_)
|
||||
return;
|
||||
|
||||
page_broadcast_->ActivatePrerenderedPage();
|
||||
}
|
||||
|
||||
void RenderViewHostImpl::SetFrameTreeVisibility(
|
||||
blink::mojom::PageVisibilityState visibility) {
|
||||
page_lifecycle_state_manager_->SetFrameTreeVisibility(visibility);
|
||||
|
@ -240,6 +240,8 @@ class CONTENT_EXPORT RenderViewHostImpl
|
||||
|
||||
bool is_in_back_forward_cache() const { return is_in_back_forward_cache_; }
|
||||
|
||||
void ActivatePrerenderedPage();
|
||||
|
||||
void SetFrameTreeVisibility(blink::mojom::PageVisibilityState visibility);
|
||||
|
||||
void SetIsFrozen(bool frozen);
|
||||
|
@ -109,6 +109,9 @@ struct CreateViewParams {
|
||||
// Whether the RenderView should initially be hidden.
|
||||
bool hidden;
|
||||
|
||||
// Prerender2: Whether the RenderView is for a prerendered page.
|
||||
bool is_prerendering;
|
||||
|
||||
// When true, all RenderWidgets under this RenderView will never be shown to
|
||||
// the user, and thus never composited, and will not need to produce pixels
|
||||
// for display. This allows the renderer to optimize and avoid resources used
|
||||
|
@ -1017,7 +1017,6 @@ void FillMiscNavigationParams(
|
||||
common_params.text_fragment_token;
|
||||
|
||||
navigation_params->is_browser_initiated = commit_params.is_browser_initiated;
|
||||
navigation_params->is_prerendering = commit_params.is_prerendering;
|
||||
|
||||
navigation_params->is_cross_site_cross_browsing_context_group =
|
||||
commit_params.is_cross_site_cross_browsing_context_group;
|
||||
|
@ -115,7 +115,7 @@ void RenderViewImpl::Initialize(
|
||||
|
||||
// The newly created webview_ is owned by this instance.
|
||||
webview_ = WebView::Create(
|
||||
this, params->hidden,
|
||||
this, params->hidden, params->is_prerendering,
|
||||
params->type == mojom::ViewWidgetType::kPortal ? true : false,
|
||||
/*compositing_enabled=*/true, params->never_composited,
|
||||
opener_frame ? opener_frame->View() : nullptr,
|
||||
|
@ -54,8 +54,10 @@ void MockCommitDeferringConditionWrapper::WillCommitNavigationCalled(
|
||||
base::OnceClosure resume_closure) {
|
||||
did_call_will_commit_navigation_ = true;
|
||||
resume_closure_ = std::move(resume_closure);
|
||||
if (invoked_closure_)
|
||||
std::move(invoked_closure_).Run();
|
||||
if (invoked_closure_) {
|
||||
base::SequencedTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, std::move(invoked_closure_));
|
||||
}
|
||||
}
|
||||
|
||||
MockCommitDeferringCondition::MockCommitDeferringCondition(
|
||||
|
@ -21,6 +21,7 @@ ScopedWebFrame::ScopedWebFrame()
|
||||
view_(blink::WebView::Create(
|
||||
/*client=*/nullptr,
|
||||
/*is_hidden=*/false,
|
||||
/*is_prerendering=*/false,
|
||||
/*is_inside_portal=*/false,
|
||||
/*compositing_enabled=*/false,
|
||||
/*widgets_never_composited=*/false,
|
||||
|
@ -410,15 +410,6 @@ struct CommitNavigationParams {
|
||||
// Whether this navigation was browser initiated.
|
||||
bool is_browser_initiated = false;
|
||||
|
||||
// Whether this navigation is happening in a prerendering frame tree.
|
||||
// Should not be referred to in the browser process, as it is only guaranteed
|
||||
// to be accurate just before sending it to the renderer process. The browser
|
||||
// process should use the frame tree's `is_prerendering` state instead.
|
||||
// TODO(crbug.com/1189481): With MPArch, the NavigationRequest should be
|
||||
// notified when it transfers frame trees, and commit_params should be updated
|
||||
// then.
|
||||
bool is_prerendering = false;
|
||||
|
||||
// The physical URL of Web Bundle from which the document is loaded.
|
||||
// Used as an additional identifier for MemoryCache.
|
||||
url.mojom.Url web_bundle_physical_url;
|
||||
|
@ -62,6 +62,9 @@ interface PageBroadcast {
|
||||
// Notifies the renderer when audio is started or stopped.
|
||||
AudioStateChanged(bool is_audio_playing);
|
||||
|
||||
// Notifies renderers when a prerendered page is activated.
|
||||
ActivatePrerenderedPage();
|
||||
|
||||
// Notifies renderers when a portal web contents is activated or if a
|
||||
// web contents is adopted as a portal.
|
||||
SetInsidePortal(bool is_inside_portal);
|
||||
|
@ -344,8 +344,6 @@ struct BLINK_EXPORT WebNavigationParams {
|
||||
bool has_text_fragment_token = false;
|
||||
// Whether this navigation was browser initiated.
|
||||
bool is_browser_initiated = false;
|
||||
// Whether this navigation was for prerendering.
|
||||
bool is_prerendering = false;
|
||||
// Whether the document should be able to access local file:// resources.
|
||||
bool grant_load_local_resources = false;
|
||||
// The previews state which should be used for this navigation.
|
||||
|
3
third_party/blink/public/web/web_view.h
vendored
3
third_party/blink/public/web/web_view.h
vendored
@ -98,6 +98,8 @@ class WebView {
|
||||
//
|
||||
// clients may be null, but should both be null or not together.
|
||||
// |is_hidden| defines the initial visibility of the page.
|
||||
// |is_prerendering| defines whether the page is being prerendered by the
|
||||
// Prerender2 feature (see content/browser/prerender/README.md).
|
||||
// [is_inside_portal] defines whether the page is inside_portal.
|
||||
// |compositing_enabled| dictates whether accelerated compositing should be
|
||||
// enabled for the page. It must be false if no clients are provided, or if a
|
||||
@ -121,6 +123,7 @@ class WebView {
|
||||
BLINK_EXPORT static WebView* Create(
|
||||
WebViewClient*,
|
||||
bool is_hidden,
|
||||
bool is_prerendering,
|
||||
bool is_inside_portal,
|
||||
bool compositing_enabled,
|
||||
bool widgets_never_composited,
|
||||
|
@ -8180,13 +8180,6 @@ const Node* Document::GetFindInPageActiveMatchNode() const {
|
||||
void Document::ActivateForPrerendering(base::TimeTicks activation_start) {
|
||||
DCHECK(features::IsPrerender2Enabled());
|
||||
|
||||
// For subframes, this can be called before the navigation commit, and this
|
||||
// document may be the initial empty one with `is_prerendering_` being false.
|
||||
if (is_initial_empty_document_) {
|
||||
DCHECK(!is_prerendering_);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO(bokan): Portals will change this assumption since they mean an active
|
||||
// document can be "adopted" into a portal.
|
||||
DCHECK(is_prerendering_);
|
||||
|
@ -446,6 +446,7 @@ SkFontHinting RendererPreferencesToSkiaHinting(
|
||||
WebView* WebView::Create(
|
||||
WebViewClient* client,
|
||||
bool is_hidden,
|
||||
bool is_prerendering,
|
||||
bool is_inside_portal,
|
||||
bool compositing_enabled,
|
||||
bool widgets_never_composited,
|
||||
@ -459,14 +460,16 @@ WebView* WebView::Create(
|
||||
client,
|
||||
is_hidden ? mojom::blink::PageVisibilityState::kHidden
|
||||
: mojom::blink::PageVisibilityState::kVisible,
|
||||
is_inside_portal, compositing_enabled, widgets_never_composited,
|
||||
To<WebViewImpl>(opener), std::move(page_handle), agent_group_scheduler,
|
||||
session_storage_namespace_id, std::move(page_base_background_color));
|
||||
is_prerendering, is_inside_portal, compositing_enabled,
|
||||
widgets_never_composited, To<WebViewImpl>(opener), std::move(page_handle),
|
||||
agent_group_scheduler, session_storage_namespace_id,
|
||||
std::move(page_base_background_color));
|
||||
}
|
||||
|
||||
WebViewImpl* WebViewImpl::Create(
|
||||
WebViewClient* client,
|
||||
mojom::blink::PageVisibilityState visibility,
|
||||
bool is_prerendering,
|
||||
bool is_inside_portal,
|
||||
bool compositing_enabled,
|
||||
bool widgets_never_composited,
|
||||
@ -477,11 +480,11 @@ WebViewImpl* WebViewImpl::Create(
|
||||
absl::optional<SkColor> page_base_background_color) {
|
||||
// Take a self-reference for WebViewImpl that is released by calling Close(),
|
||||
// then return a raw pointer to the caller.
|
||||
auto web_view = base::AdoptRef(
|
||||
new WebViewImpl(client, visibility, is_inside_portal, compositing_enabled,
|
||||
widgets_never_composited, opener, std::move(page_handle),
|
||||
agent_group_scheduler, session_storage_namespace_id,
|
||||
std::move(page_base_background_color)));
|
||||
auto web_view = base::AdoptRef(new WebViewImpl(
|
||||
client, visibility, is_prerendering, is_inside_portal,
|
||||
compositing_enabled, widgets_never_composited, opener,
|
||||
std::move(page_handle), agent_group_scheduler,
|
||||
session_storage_namespace_id, std::move(page_base_background_color)));
|
||||
web_view->AddRef();
|
||||
return web_view.get();
|
||||
}
|
||||
@ -539,6 +542,7 @@ void WebViewImpl::DoDeferredCloseWindowSoon() {
|
||||
WebViewImpl::WebViewImpl(
|
||||
WebViewClient* client,
|
||||
mojom::blink::PageVisibilityState visibility,
|
||||
bool is_prerendering,
|
||||
bool is_inside_portal,
|
||||
bool does_composite,
|
||||
bool widgets_never_composited,
|
||||
@ -569,6 +573,7 @@ WebViewImpl::WebViewImpl(
|
||||
*page_, session_storage_namespace_id_);
|
||||
|
||||
SetVisibilityState(visibility, /*is_initial_state=*/true);
|
||||
page_->SetIsPrerendering(is_prerendering);
|
||||
|
||||
// We pass this state to Page, but it's only used by the main frame in the
|
||||
// page.
|
||||
@ -3139,6 +3144,10 @@ void WebViewImpl::UpdateFontRenderingFromRendererPrefs() {
|
||||
#endif // !defined(OS_MAC)
|
||||
}
|
||||
|
||||
void WebViewImpl::ActivatePrerenderedPage() {
|
||||
GetPage()->SetIsPrerendering(false);
|
||||
}
|
||||
|
||||
void WebViewImpl::SetInsidePortal(bool inside_portal) {
|
||||
GetPage()->SetInsidePortal(inside_portal);
|
||||
|
||||
|
@ -114,6 +114,7 @@ class CORE_EXPORT WebViewImpl final : public WebView,
|
||||
static WebViewImpl* Create(
|
||||
WebViewClient*,
|
||||
mojom::blink::PageVisibilityState visibility,
|
||||
bool is_prerendering,
|
||||
bool is_inside_portal,
|
||||
bool compositing_enabled,
|
||||
bool widgets_never_composited,
|
||||
@ -278,6 +279,7 @@ class CORE_EXPORT WebViewImpl final : public WebView,
|
||||
mojom::blink::PageRestoreParamsPtr page_restore_params,
|
||||
SetPageLifecycleStateCallback callback) override;
|
||||
void AudioStateChanged(bool is_audio_playing) override;
|
||||
void ActivatePrerenderedPage() override;
|
||||
void SetInsidePortal(bool is_inside_portal) override;
|
||||
void UpdateWebPreferences(
|
||||
const blink::web_pref::WebPreferences& preferences) override;
|
||||
@ -638,6 +640,7 @@ class CORE_EXPORT WebViewImpl final : public WebView,
|
||||
WebViewImpl(
|
||||
WebViewClient*,
|
||||
mojom::blink::PageVisibilityState visibility,
|
||||
bool is_prerendering,
|
||||
bool is_inside_portal,
|
||||
bool does_composite,
|
||||
bool widgets_never_composite,
|
||||
|
@ -488,6 +488,7 @@ TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) {
|
||||
WebViewImpl* web_view = To<WebViewImpl>(
|
||||
WebView::Create(&web_view_client,
|
||||
/*is_hidden=*/false,
|
||||
/*is_prerendering=*/false,
|
||||
/*is_inside_portal=*/false,
|
||||
/*compositing_enabled=*/true,
|
||||
/*widgets_never_composited=*/false,
|
||||
@ -2736,7 +2737,8 @@ TEST_F(WebViewTest, ClientTapHandlingNullWebViewClient) {
|
||||
// Note: this test doesn't use WebViewHelper since WebViewHelper creates an
|
||||
// internal WebViewClient on demand if the supplied WebViewClient is null.
|
||||
WebViewImpl* web_view = To<WebViewImpl>(WebView::Create(
|
||||
/*client=*/nullptr, /*is_hidden=*/false, /*is_inside_portal=*/false,
|
||||
/*client=*/nullptr, /*is_hidden=*/false, /*is_prerendering=*/false,
|
||||
/*is_inside_portal=*/false,
|
||||
/*compositing_enabled=*/false,
|
||||
/*widgets_never_composited=*/false,
|
||||
/*opener=*/nullptr, mojo::NullAssociatedReceiver(),
|
||||
|
@ -619,6 +619,7 @@ void WebViewHelper::InitializeWebView(TestWebViewClient* web_view_client,
|
||||
web_view_ = To<WebViewImpl>(
|
||||
WebView::Create(test_web_view_client_,
|
||||
/*is_hidden=*/false,
|
||||
/*is_prerendering=*/false,
|
||||
/*is_inside_portal=*/false,
|
||||
/*compositing_enabled=*/true,
|
||||
/*widgets_never_composited=*/false,
|
||||
|
@ -2327,16 +2327,18 @@ void LocalFrame::ForceSynchronousDocumentInstall(
|
||||
scoped_refptr<const SharedBuffer> data) {
|
||||
CHECK(GetDocument()->IsInitialEmptyDocument());
|
||||
DCHECK(!Client()->IsLocalFrameClientImpl());
|
||||
DCHECK(GetPage());
|
||||
|
||||
// Any Document requires Shutdown() before detach, even the initial empty
|
||||
// document.
|
||||
GetDocument()->Shutdown();
|
||||
DomWindow()->ClearForReuse();
|
||||
|
||||
Document* document =
|
||||
DomWindow()->InstallNewDocument(DocumentInit::Create()
|
||||
.WithWindow(DomWindow(), nullptr)
|
||||
.WithTypeFrom(mime_type));
|
||||
Document* document = DomWindow()->InstallNewDocument(
|
||||
DocumentInit::Create()
|
||||
.WithWindow(DomWindow(), nullptr)
|
||||
.WithTypeFrom(mime_type)
|
||||
.ForPrerendering(GetPage()->IsPrerendering()));
|
||||
DocumentParser* parser = document->OpenForNavigation(
|
||||
kForceSynchronousParsing, mime_type, AtomicString("UTF-8"));
|
||||
for (const auto& segment : *data)
|
||||
|
@ -14086,35 +14086,4 @@ TEST_F(WebFrameTest, LargeScaleRemoteFrameCompositingScaleFactor) {
|
||||
EXPECT_EQ(remote_frame->GetCompositingScaleFactor(), 5.0f);
|
||||
}
|
||||
|
||||
TEST_F(WebFrameTest, IsPrerendering) {
|
||||
frame_test_helpers::WebViewHelper web_view_helper;
|
||||
web_view_helper.Initialize();
|
||||
auto params = std::make_unique<WebNavigationParams>();
|
||||
params->url = KURL("about:blank");
|
||||
params->is_prerendering = false;
|
||||
web_view_helper.LocalMainFrame()->CommitNavigation(std::move(params),
|
||||
nullptr);
|
||||
WebViewImpl* web_view = web_view_helper.GetWebView();
|
||||
|
||||
EXPECT_FALSE(web_view->MainFrameImpl()
|
||||
->GetFrame()
|
||||
->GetDocument()
|
||||
->Fetcher()
|
||||
->Context()
|
||||
.IsPrerendering());
|
||||
|
||||
params = std::make_unique<WebNavigationParams>();
|
||||
params->url = KURL("about:blank");
|
||||
params->is_prerendering = true;
|
||||
web_view_helper.LocalMainFrame()->CommitNavigation(std::move(params),
|
||||
nullptr);
|
||||
|
||||
EXPECT_TRUE(web_view->MainFrameImpl()
|
||||
->GetFrame()
|
||||
->GetDocument()
|
||||
->Fetcher()
|
||||
->Context()
|
||||
.IsPrerendering());
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
|
@ -401,7 +401,6 @@ DocumentLoader::DocumentLoader(
|
||||
params_->had_transient_user_activation),
|
||||
had_sticky_activation_(params_->is_user_activated),
|
||||
is_browser_initiated_(params_->is_browser_initiated),
|
||||
is_prerendering_(params_->is_prerendering),
|
||||
was_discarded_(params_->was_discarded),
|
||||
loading_srcdoc_(url_.IsAboutSrcdocURL()),
|
||||
loading_url_as_empty_document_(!params_->is_static_data &&
|
||||
@ -526,7 +525,6 @@ DocumentLoader::CreateWebNavigationParamsToCloneDocument() {
|
||||
params->had_transient_user_activation =
|
||||
last_navigation_had_transient_user_activation_;
|
||||
params->is_browser_initiated = is_browser_initiated_;
|
||||
params->is_prerendering = is_prerendering_;
|
||||
params->was_discarded = was_discarded_;
|
||||
params->web_bundle_physical_url = web_bundle_physical_url_;
|
||||
params->web_bundle_claimed_url = web_bundle_claimed_url_;
|
||||
@ -2255,6 +2253,7 @@ void DocumentLoader::CommitNavigation() {
|
||||
|
||||
WillCommitNavigation();
|
||||
|
||||
is_prerendering_ = frame_->GetPage()->IsPrerendering();
|
||||
Document* document = frame_->DomWindow()->InstallNewDocument(
|
||||
DocumentInit::Create()
|
||||
.WithWindow(frame_->DomWindow(), owner_document)
|
||||
|
@ -581,7 +581,8 @@ class CORE_EXPORT DocumentLoader : public GarbageCollected<DocumentLoader>,
|
||||
// Whether this load request was initiated by the browser.
|
||||
const bool is_browser_initiated_ = false;
|
||||
|
||||
// Whether this loader is working for a prerendering document.
|
||||
// Whether this loader committed a document in a prerendered page that has not
|
||||
// yet been activated. This is only set after commit.
|
||||
bool is_prerendering_ = false;
|
||||
|
||||
// If true, the navigation loading this document should allow a text fragment
|
||||
|
13
third_party/blink/renderer/core/page/page.h
vendored
13
third_party/blink/renderer/core/page/page.h
vendored
@ -330,6 +330,11 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>,
|
||||
void SetInsidePortal(bool inside_portal);
|
||||
bool InsidePortal() const;
|
||||
|
||||
void SetIsPrerendering(bool is_prerendering) {
|
||||
is_prerendering_ = is_prerendering;
|
||||
}
|
||||
bool IsPrerendering() const { return is_prerendering_; }
|
||||
|
||||
void SetTextAutosizerPageInfo(
|
||||
const mojom::blink::TextAutosizerPageInfo& page_info) {
|
||||
web_text_autosizer_page_info_ = page_info;
|
||||
@ -493,6 +498,14 @@ class CORE_EXPORT Page final : public GarbageCollected<Page>,
|
||||
// Accessed by frames to determine whether to expose the PortalHost object.
|
||||
bool inside_portal_ = false;
|
||||
|
||||
// Whether the page is being prerendered by the Prerender2
|
||||
// feature. See content/browser/prerender/README.md.
|
||||
//
|
||||
// This is ordinarily initialized by WebViewImpl immediately after creating
|
||||
// this Page. Once initialized, it can only transition from true to false on
|
||||
// prerender activation; it does not go from false to true.
|
||||
bool is_prerendering_ = false;
|
||||
|
||||
mojom::blink::TextAutosizerPageInfo web_text_autosizer_page_info_;
|
||||
|
||||
WebScopedVirtualTimePauser history_navigation_virtual_time_pauser_;
|
||||
|
@ -142,6 +142,7 @@ class MAYBE_WebRtcAudioRendererTest : public testing::Test {
|
||||
web_view_(blink::WebView::Create(
|
||||
/*client=*/nullptr,
|
||||
/*is_hidden=*/false,
|
||||
/*is_prerendering=*/false,
|
||||
/*is_inside_portal=*/false,
|
||||
/*compositing_enabled=*/false,
|
||||
/*widgets_never_composited=*/false,
|
||||
|
@ -327,6 +327,7 @@ class WebMediaPlayerImplTest
|
||||
web_view_(WebView::Create(
|
||||
/*client=*/nullptr,
|
||||
/*is_hidden=*/false,
|
||||
/*is_prerendering=*/false,
|
||||
/*is_inside_portal=*/false,
|
||||
/*compositing_enabled=*/false,
|
||||
/*widgets_never_composited=*/false,
|
||||
|
Reference in New Issue
Block a user