NavigationThrottleRunner2: void CreateThrottlesForNavigation
Change the CreateThrottlesForNavigation's signature to deprecate legacy registration approach, returning a vector. Bug: 412524375 Change-Id: Ia7bc8b6ed7e8407ef3b0b3d2e559a7a1c12b5638 Cq-Include-Trybots: luci.chromium.try:android-cast-arm64-rel Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6493688 Reviewed-by: Nate Fischer <ntfschr@chromium.org> Reviewed-by: Alex Moshchuk <alexmos@chromium.org> Commit-Queue: Takashi Toyoshima <toyoshim@chromium.org> Reviewed-by: Andrey Kosyakov <caseq@chromium.org> Reviewed-by: Devlin Cronin <rdevlin.cronin@chromium.org> Reviewed-by: Simeon Anfinrud <sanfin@chromium.org> Reviewed-by: David Dorwin <ddorwin@chromium.org> Reviewed-by: Nidhi Jaju <nidhijaju@chromium.org> Cr-Commit-Position: refs/heads/main@{#1456795}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
b736216d23
commit
2a7f8cc0a3
android_webview/browser
chrome/browser
chromecast/browser
components
error_page
content
page_load_metrics
content
browser
back_forward_cache_internal_browsertest.cc
preloading
prerender
renderer_host
navigation_request_browsertest.ccnavigation_request_unittest.ccnavigation_throttle_runner.ccnavigator_delegate.h
web_contents
public
shell
web_test
extensions/shell/browser
fuchsia_web/webengine/browser
headless/lib/browser
@ -662,8 +662,7 @@ void AwContentBrowserClient::OverrideWebPreferences(
|
|||||||
(delegate) ? delegate->isModalContextMenu() : false;
|
(delegate) ? delegate->isModalContextMenu() : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void AwContentBrowserClient::CreateThrottlesForNavigation(
|
||||||
AwContentBrowserClient::CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) {
|
content::NavigationThrottleRegistry& registry) {
|
||||||
// We allow intercepting only navigations within main frames. This
|
// We allow intercepting only navigations within main frames. This
|
||||||
// is used to post onPageStarted. We handle shouldOverrideUrlLoading
|
// is used to post onPageStarted. We handle shouldOverrideUrlLoading
|
||||||
@ -711,8 +710,6 @@ AwContentBrowserClient::CreateThrottlesForNavigation(
|
|||||||
&navigation_handle, urlClassifier));
|
&navigation_handle, urlClassifier));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<content::PrefetchServiceDelegate>
|
std::unique_ptr<content::PrefetchServiceDelegate>
|
||||||
|
@ -149,8 +149,7 @@ class AwContentBrowserClient : public content::ContentBrowserClient {
|
|||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
content::SiteInstance& main_frame_site,
|
content::SiteInstance& main_frame_site,
|
||||||
blink::web_pref::WebPreferences* web_prefs) override;
|
blink::web_pref::WebPreferences* web_prefs) override;
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void CreateThrottlesForNavigation(
|
||||||
CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) override;
|
content::NavigationThrottleRegistry& registry) override;
|
||||||
std::unique_ptr<content::PrefetchServiceDelegate>
|
std::unique_ptr<content::PrefetchServiceDelegate>
|
||||||
CreatePrefetchServiceDelegate(
|
CreatePrefetchServiceDelegate(
|
||||||
|
@ -5395,8 +5395,7 @@ void ChromeContentBrowserClient::RemovePresentationObserver(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void ChromeContentBrowserClient::CreateThrottlesForNavigation(
|
||||||
ChromeContentBrowserClient::CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) {
|
content::NavigationThrottleRegistry& registry) {
|
||||||
// MetricsNavigationThrottle requires that it runs before NavigationThrottles
|
// MetricsNavigationThrottle requires that it runs before NavigationThrottles
|
||||||
// that may delay or cancel navigations, so only NavigationThrottles that
|
// that may delay or cancel navigations, so only NavigationThrottles that
|
||||||
@ -5767,8 +5766,6 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation(
|
|||||||
registry.MaybeAddThrottle(
|
registry.MaybeAddThrottle(
|
||||||
web_app::IsolatedWebAppThrottle::MaybeCreateThrottleFor(&handle));
|
web_app::IsolatedWebAppThrottle::MaybeCreateThrottleFor(&handle));
|
||||||
#endif // !BUILDFLAG(IS_ANDROID)
|
#endif // !BUILDFLAG(IS_ANDROID)
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<content::CommitDeferringCondition>>
|
std::vector<std::unique_ptr<content::CommitDeferringCondition>>
|
||||||
|
@ -635,8 +635,7 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
|
|||||||
content::WebContents* web_contents) override;
|
content::WebContents* web_contents) override;
|
||||||
void RemovePresentationObserver(content::PresentationObserver* observer,
|
void RemovePresentationObserver(content::PresentationObserver* observer,
|
||||||
content::WebContents* web_contents) override;
|
content::WebContents* web_contents) override;
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void CreateThrottlesForNavigation(
|
||||||
CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) override;
|
content::NavigationThrottleRegistry& registry) override;
|
||||||
std::vector<std::unique_ptr<content::CommitDeferringCondition>>
|
std::vector<std::unique_ptr<content::CommitDeferringCondition>>
|
||||||
CreateCommitDeferringConditionsForNavigation(
|
CreateCommitDeferringConditionsForNavigation(
|
||||||
|
@ -46,11 +46,10 @@ class MockBrowserClient : public content::ContentBrowserClient {
|
|||||||
|
|
||||||
// Only construct an ExtensionNavigationThrottle so that we can test it in
|
// Only construct an ExtensionNavigationThrottle so that we can test it in
|
||||||
// isolation.
|
// isolation.
|
||||||
std::vector<std::unique_ptr<NavigationThrottle>> CreateThrottlesForNavigation(
|
void CreateThrottlesForNavigation(
|
||||||
content::NavigationThrottleRegistry& registry) override {
|
content::NavigationThrottleRegistry& registry) override {
|
||||||
registry.AddThrottle(std::make_unique<ExtensionNavigationThrottle>(
|
registry.AddThrottle(std::make_unique<ExtensionNavigationThrottle>(
|
||||||
®istry.GetNavigationHandle()));
|
®istry.GetNavigationHandle()));
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -809,8 +809,7 @@ CastContentBrowserClient::CreateCrashHandlerHost(
|
|||||||
}
|
}
|
||||||
#endif // BUILDFLAG(IS_ANDROID)
|
#endif // BUILDFLAG(IS_ANDROID)
|
||||||
|
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void CastContentBrowserClient::CreateThrottlesForNavigation(
|
||||||
CastContentBrowserClient::CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) {
|
content::NavigationThrottleRegistry& registry) {
|
||||||
if (chromecast::IsFeatureEnabled(kEnableGeneralAudienceBrowsing)) {
|
if (chromecast::IsFeatureEnabled(kEnableGeneralAudienceBrowsing)) {
|
||||||
registry.AddThrottle(
|
registry.AddThrottle(
|
||||||
@ -818,8 +817,6 @@ CastContentBrowserClient::CreateThrottlesForNavigation(
|
|||||||
®istry.GetNavigationHandle(),
|
®istry.GetNavigationHandle(),
|
||||||
general_audience_browsing_service_.get()));
|
general_audience_browsing_service_.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CastContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
|
void CastContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories(
|
||||||
|
@ -241,8 +241,7 @@ class CastContentBrowserClient
|
|||||||
std::unique_ptr<content::NavigationUIData> GetNavigationUIData(
|
std::unique_ptr<content::NavigationUIData> GetNavigationUIData(
|
||||||
content::NavigationHandle* navigation_handle) override;
|
content::NavigationHandle* navigation_handle) override;
|
||||||
bool ShouldEnableStrictSiteIsolation() override;
|
bool ShouldEnableStrictSiteIsolation() override;
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void CreateThrottlesForNavigation(
|
||||||
CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) override;
|
content::NavigationThrottleRegistry& registry) override;
|
||||||
void RegisterNonNetworkSubresourceURLLoaderFactories(
|
void RegisterNonNetworkSubresourceURLLoaderFactories(
|
||||||
int render_process_id,
|
int render_process_id,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "base/memory/raw_ptr.h"
|
#include "base/memory/raw_ptr.h"
|
||||||
#include "base/test/bind.h"
|
#include "base/test/bind.h"
|
||||||
#include "content/public/browser/navigation_controller.h"
|
#include "content/public/browser/navigation_controller.h"
|
||||||
|
#include "content/public/browser/navigation_throttle_registry.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
#include "content/public/common/content_features.h"
|
#include "content/public/common/content_features.h"
|
||||||
@ -43,8 +44,9 @@ class NetErrorUrlInterceptor {
|
|||||||
interceptor_(base::BindLambdaForTesting(
|
interceptor_(base::BindLambdaForTesting(
|
||||||
[this,
|
[this,
|
||||||
error](content::URLLoaderInterceptor::RequestParams* params) {
|
error](content::URLLoaderInterceptor::RequestParams* params) {
|
||||||
if (params->url_request.url != url_)
|
if (params->url_request.url != url_) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
network::URLLoaderCompletionStatus status;
|
network::URLLoaderCompletionStatus status;
|
||||||
status.error_code = error;
|
status.error_code = error;
|
||||||
params->client->OnComplete(status);
|
params->client->OnComplete(status);
|
||||||
@ -133,15 +135,17 @@ class DeferNextNavigationThrottleInserter
|
|||||||
// content::WebContentsObserver:
|
// content::WebContentsObserver:
|
||||||
void DidFinishNavigation(content::NavigationHandle* handle) override {
|
void DidFinishNavigation(content::NavigationHandle* handle) override {
|
||||||
DCHECK(throttle_);
|
DCHECK(throttle_);
|
||||||
if (handle == throttle_->navigation_handle())
|
if (handle == throttle_->navigation_handle()) {
|
||||||
finish_wait_loop_.Quit();
|
finish_wait_loop_.Quit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<content::NavigationThrottle> MaybeCreateThrottle(
|
std::unique_ptr<content::NavigationThrottle> MaybeCreateThrottle(
|
||||||
content::NavigationHandle* handle) {
|
content::NavigationHandle* handle) {
|
||||||
if (throttle_)
|
if (throttle_) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
auto throttle = std::make_unique<DeferringThrottle>(
|
auto throttle = std::make_unique<DeferringThrottle>(
|
||||||
handle, defer_wait_loop_.QuitClosure());
|
handle, defer_wait_loop_.QuitClosure());
|
||||||
@ -170,15 +174,10 @@ class NetErrorAutoReloaderBrowserTest : public content::ContentBrowserTest {
|
|||||||
|
|
||||||
content::ShellContentBrowserClient::Get()
|
content::ShellContentBrowserClient::Get()
|
||||||
->set_create_throttles_for_navigation_callback(base::BindRepeating(
|
->set_create_throttles_for_navigation_callback(base::BindRepeating(
|
||||||
[](content::NavigationHandle* handle)
|
[](content::NavigationThrottleRegistry& registry) -> void {
|
||||||
-> std::vector<std::unique_ptr<content::NavigationThrottle>> {
|
registry.MaybeAddThrottle(
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
NetErrorAutoReloader::MaybeCreateThrottleFor(
|
||||||
throttles;
|
®istry.GetNavigationHandle()));
|
||||||
auto throttle =
|
|
||||||
NetErrorAutoReloader::MaybeCreateThrottleFor(handle);
|
|
||||||
if (throttle)
|
|
||||||
throttles.push_back(std::move(throttle));
|
|
||||||
return throttles;
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,8 +192,9 @@ class NetErrorAutoReloaderBrowserTest : public content::ContentBrowserTest {
|
|||||||
std::optional<base::TimeDelta> GetCurrentAutoReloadDelay() {
|
std::optional<base::TimeDelta> GetCurrentAutoReloadDelay() {
|
||||||
const std::optional<base::OneShotTimer>& timer =
|
const std::optional<base::OneShotTimer>& timer =
|
||||||
GetAutoReloader()->next_reload_timer_for_testing();
|
GetAutoReloader()->next_reload_timer_for_testing();
|
||||||
if (!timer)
|
if (!timer) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
}
|
||||||
return timer->GetCurrentDelay();
|
return timer->GetCurrentDelay();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,8 +239,9 @@ class NetErrorAutoReloaderBrowserTest : public content::ContentBrowserTest {
|
|||||||
error_page::NetErrorAutoReloader::FromWebContents(wc);
|
error_page::NetErrorAutoReloader::FromWebContents(wc);
|
||||||
std::optional<base::OneShotTimer>& timer =
|
std::optional<base::OneShotTimer>& timer =
|
||||||
reloader->next_reload_timer_for_testing();
|
reloader->next_reload_timer_for_testing();
|
||||||
if (timer && timer->IsRunning())
|
if (timer && timer->IsRunning()) {
|
||||||
timer->FireNow();
|
timer->FireNow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SimulateNetworkGoingOnline(content::WebContents* wc) {
|
static void SimulateNetworkGoingOnline(content::WebContents* wc) {
|
||||||
|
@ -19,15 +19,13 @@ PageLoadMetricsTestContentBrowserClient::
|
|||||||
PageLoadMetricsTestContentBrowserClient::
|
PageLoadMetricsTestContentBrowserClient::
|
||||||
~PageLoadMetricsTestContentBrowserClient() = default;
|
~PageLoadMetricsTestContentBrowserClient() = default;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void PageLoadMetricsTestContentBrowserClient::CreateThrottlesForNavigation(
|
||||||
PageLoadMetricsTestContentBrowserClient::CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) {
|
content::NavigationThrottleRegistry& registry) {
|
||||||
content::NavigationHandle& navigation_handle = registry.GetNavigationHandle();
|
content::NavigationHandle& navigation_handle = registry.GetNavigationHandle();
|
||||||
if (navigation_handle.IsInMainFrame()) {
|
if (navigation_handle.IsInMainFrame()) {
|
||||||
registry.AddThrottle(page_load_metrics::MetricsNavigationThrottle::Create(
|
registry.AddThrottle(page_load_metrics::MetricsNavigationThrottle::Create(
|
||||||
&navigation_handle));
|
&navigation_handle));
|
||||||
}
|
}
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace page_load_metrics
|
} // namespace page_load_metrics
|
||||||
|
@ -24,8 +24,7 @@ class PageLoadMetricsTestContentBrowserClient
|
|||||||
~PageLoadMetricsTestContentBrowserClient() override;
|
~PageLoadMetricsTestContentBrowserClient() override;
|
||||||
|
|
||||||
// content::ContentBrowserClient:
|
// content::ContentBrowserClient:
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void CreateThrottlesForNavigation(
|
||||||
CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) override;
|
content::NavigationThrottleRegistry& registry) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3516,10 +3516,9 @@ IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, NoThrottlesOnCacheRestore) {
|
|||||||
// NavigationThrottles.
|
// NavigationThrottles.
|
||||||
content::ShellContentBrowserClient::Get()
|
content::ShellContentBrowserClient::Get()
|
||||||
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
||||||
[&did_register_throttles](content::NavigationHandle* handle)
|
[&did_register_throttles](
|
||||||
-> std::vector<std::unique_ptr<content::NavigationThrottle>> {
|
content::NavigationThrottleRegistry& registry) -> void {
|
||||||
did_register_throttles = true;
|
did_register_throttles = true;
|
||||||
return std::vector<std::unique_ptr<content::NavigationThrottle>>();
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// 2) Navigate to B.
|
// 2) Navigate to B.
|
||||||
|
@ -4101,8 +4101,9 @@ class RedirectChainObserver : public WebContentsObserver {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void DidFinishNavigation(NavigationHandle* handle) override {
|
void DidFinishNavigation(NavigationHandle* handle) override {
|
||||||
if (handle->GetURL() != url_)
|
if (handle->GetURL() != url_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
redirect_chain_ = handle->GetRedirectChain();
|
redirect_chain_ = handle->GetRedirectChain();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5409,8 +5410,9 @@ class IsActivationObserver : public WebContentsObserver {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void DidStartNavigation(NavigationHandle* handle) override {
|
void DidStartNavigation(NavigationHandle* handle) override {
|
||||||
if (handle->GetURL() != url_)
|
if (handle->GetURL() != url_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
did_navigate_ = true;
|
did_navigate_ = true;
|
||||||
was_activation_ = handle->IsPrerenderedPageActivation();
|
was_activation_ = handle->IsPrerenderedPageActivation();
|
||||||
}
|
}
|
||||||
@ -5470,20 +5472,16 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, ActivationDoesntRunThrottles) {
|
|||||||
// WillStartRequest into all new navigations.
|
// WillStartRequest into all new navigations.
|
||||||
ShellContentBrowserClient::Get()
|
ShellContentBrowserClient::Get()
|
||||||
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
||||||
[&throttle](NavigationHandle* handle)
|
[&throttle](NavigationThrottleRegistry& registry) -> void {
|
||||||
-> std::vector<std::unique_ptr<NavigationThrottle>> {
|
auto throttle_ptr = std::make_unique<TestNavigationThrottle>(
|
||||||
std::vector<std::unique_ptr<NavigationThrottle>> throttles;
|
®istry.GetNavigationHandle());
|
||||||
|
|
||||||
auto throttle_ptr =
|
|
||||||
std::make_unique<TestNavigationThrottle>(handle);
|
|
||||||
CHECK(!throttle);
|
CHECK(!throttle);
|
||||||
throttle = throttle_ptr.get();
|
throttle = throttle_ptr.get();
|
||||||
throttle_ptr->SetResponse(
|
throttle_ptr->SetResponse(
|
||||||
TestNavigationThrottle::WILL_START_REQUEST,
|
TestNavigationThrottle::WILL_START_REQUEST,
|
||||||
TestNavigationThrottle::SYNCHRONOUS, NavigationThrottle::DEFER);
|
TestNavigationThrottle::SYNCHRONOUS, NavigationThrottle::DEFER);
|
||||||
|
|
||||||
throttles.push_back(std::move(throttle_ptr));
|
registry.AddThrottle(std::move(throttle_ptr));
|
||||||
return throttles;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Start a prerender and ensure that a NavigationThrottle can defer the
|
// Start a prerender and ensure that a NavigationThrottle can defer the
|
||||||
@ -5768,13 +5766,11 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest,
|
|||||||
// before PrerenderSubframeNavigationThrottle.
|
// before PrerenderSubframeNavigationThrottle.
|
||||||
ShellContentBrowserClient::Get()
|
ShellContentBrowserClient::Get()
|
||||||
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
||||||
[](NavigationHandle* handle)
|
[](NavigationThrottleRegistry& registry) -> void {
|
||||||
-> std::vector<std::unique_ptr<NavigationThrottle>> {
|
registry.AddThrottle(
|
||||||
std::vector<std::unique_ptr<NavigationThrottle>> throttles;
|
|
||||||
throttles.push_back(
|
|
||||||
std::make_unique<
|
std::make_unique<
|
||||||
TestPrerenderCancellerSubframeNavigationThrottle>(handle));
|
TestPrerenderCancellerSubframeNavigationThrottle>(
|
||||||
return throttles;
|
®istry.GetNavigationHandle()));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Use ExecuteScriptAsync instead of EvalJs as inserted cross-origin iframe
|
// Use ExecuteScriptAsync instead of EvalJs as inserted cross-origin iframe
|
||||||
@ -6654,8 +6650,9 @@ IN_PROC_BROWSER_TEST_P(SSLPrerenderBrowserTest,
|
|||||||
// Skip the test when the block type is kCertError. With the type, this test
|
// Skip the test when the block type is kCertError. With the type, this test
|
||||||
// times out due to https://crbug.com/1311887.
|
// times out due to https://crbug.com/1311887.
|
||||||
// TODO(crbug.com/40220378): Enable the test with kCertError.
|
// TODO(crbug.com/40220378): Enable the test with kCertError.
|
||||||
if (GetParam() == SSLPrerenderTestErrorBlockType::kCertError)
|
if (GetParam() == SSLPrerenderTestErrorBlockType::kCertError) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Load an initial page and register a service worker that intercepts
|
// Load an initial page and register a service worker that intercepts
|
||||||
// resources requests.
|
// resources requests.
|
||||||
@ -8061,8 +8058,9 @@ IN_PROC_BROWSER_TEST_F(PrerenderSequentialPrerenderingBrowserTest,
|
|||||||
|
|
||||||
// Confirm that all the other prerender hosts are successfully cancelled.
|
// Confirm that all the other prerender hosts are successfully cancelled.
|
||||||
for (auto& url : prerender_urls) {
|
for (auto& url : prerender_urls) {
|
||||||
if (url == prerender_urls[0])
|
if (url == prerender_urls[0]) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
EXPECT_TRUE(GetHostForUrl(url).is_null());
|
EXPECT_TRUE(GetHostForUrl(url).is_null());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -11999,10 +11997,11 @@ class FrameDisplayStateChangedObserver : public WebContentsObserver {
|
|||||||
void FrameDisplayStateChanged(RenderFrameHost* host,
|
void FrameDisplayStateChanged(RenderFrameHost* host,
|
||||||
bool is_display_none) override {
|
bool is_display_none) override {
|
||||||
if (host == target_host_) {
|
if (host == target_host_) {
|
||||||
if (callback_)
|
if (callback_) {
|
||||||
std::move(callback_).Run();
|
std::move(callback_).Run();
|
||||||
else
|
} else {
|
||||||
changed_count_++;
|
changed_count_++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -12509,8 +12508,9 @@ class PrerenderRequestHeadersBrowserTest : public PrerenderBrowserTest {
|
|||||||
// Note: Checking the origin of `request.GetURL()` doesn't work here because
|
// Note: Checking the origin of `request.GetURL()` doesn't work here because
|
||||||
// the host part of the URL is translated (e.g., "a.test" to "127.0.0.1")
|
// the host part of the URL is translated (e.g., "a.test" to "127.0.0.1")
|
||||||
// based on the host resolver rule before this point.
|
// based on the host resolver rule before this point.
|
||||||
if (request.relative_url.find("cors") == std::string::npos)
|
if (request.relative_url.find("cors") == std::string::npos) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Serves a fake response with the ACAO header.
|
// Serves a fake response with the ACAO header.
|
||||||
auto response = std::make_unique<net::test_server::BasicHttpResponse>();
|
auto response = std::make_unique<net::test_server::BasicHttpResponse>();
|
||||||
@ -13257,8 +13257,9 @@ IN_PROC_BROWSER_TEST_F(PrerenderFencedFrameBrowserTest,
|
|||||||
// child frames.
|
// child frames.
|
||||||
size_t child_frame_count = 0;
|
size_t child_frame_count = 0;
|
||||||
prerendered_rfh->ForEachRenderFrameHostImpl([&](RenderFrameHostImpl* rfh) {
|
prerendered_rfh->ForEachRenderFrameHostImpl([&](RenderFrameHostImpl* rfh) {
|
||||||
if (rfh != prerendered_rfh)
|
if (rfh != prerendered_rfh) {
|
||||||
child_frame_count++;
|
child_frame_count++;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
EXPECT_EQ(0lu, child_frame_count);
|
EXPECT_EQ(0lu, child_frame_count);
|
||||||
|
|
||||||
@ -13444,8 +13445,9 @@ class PrerenderClientHintsBrowserTest : public PrerenderBrowserTest {
|
|||||||
|
|
||||||
static std::unique_ptr<net::test_server::HttpResponse> HandleRequest(
|
static std::unique_ptr<net::test_server::HttpResponse> HandleRequest(
|
||||||
const net::test_server::HttpRequest& request) {
|
const net::test_server::HttpRequest& request) {
|
||||||
if (request.relative_url.find("acceptch") == std::string::npos)
|
if (request.relative_url.find("acceptch") == std::string::npos) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Serve a response indicating clients to provide full version of UA.
|
// Serve a response indicating clients to provide full version of UA.
|
||||||
auto response = std::make_unique<net::test_server::BasicHttpResponse>();
|
auto response = std::make_unique<net::test_server::BasicHttpResponse>();
|
||||||
|
@ -272,32 +272,36 @@ class TestNavigationThrottleInstaller : public WebContentsObserver {
|
|||||||
TestNavigationThrottle* navigation_throttle() { return navigation_throttle_; }
|
TestNavigationThrottle* navigation_throttle() { return navigation_throttle_; }
|
||||||
|
|
||||||
void WaitForThrottleWillStart() {
|
void WaitForThrottleWillStart() {
|
||||||
if (will_start_called_)
|
if (will_start_called_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
will_start_loop_runner_ = new MessageLoopRunner();
|
will_start_loop_runner_ = new MessageLoopRunner();
|
||||||
will_start_loop_runner_->Run();
|
will_start_loop_runner_->Run();
|
||||||
will_start_loop_runner_ = nullptr;
|
will_start_loop_runner_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitForThrottleWillRedirect() {
|
void WaitForThrottleWillRedirect() {
|
||||||
if (will_redirect_called_)
|
if (will_redirect_called_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
will_redirect_loop_runner_ = new MessageLoopRunner();
|
will_redirect_loop_runner_ = new MessageLoopRunner();
|
||||||
will_redirect_loop_runner_->Run();
|
will_redirect_loop_runner_->Run();
|
||||||
will_redirect_loop_runner_ = nullptr;
|
will_redirect_loop_runner_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitForThrottleWillFail() {
|
void WaitForThrottleWillFail() {
|
||||||
if (will_fail_called_)
|
if (will_fail_called_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
will_fail_loop_runner_ = new MessageLoopRunner();
|
will_fail_loop_runner_ = new MessageLoopRunner();
|
||||||
will_fail_loop_runner_->Run();
|
will_fail_loop_runner_->Run();
|
||||||
will_fail_loop_runner_ = nullptr;
|
will_fail_loop_runner_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaitForThrottleWillProcess() {
|
void WaitForThrottleWillProcess() {
|
||||||
if (will_process_called_)
|
if (will_process_called_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
will_process_loop_runner_ = new MessageLoopRunner();
|
will_process_loop_runner_ = new MessageLoopRunner();
|
||||||
will_process_loop_runner_->Run();
|
will_process_loop_runner_->Run();
|
||||||
will_process_loop_runner_ = nullptr;
|
will_process_loop_runner_ = nullptr;
|
||||||
@ -314,10 +318,11 @@ class TestNavigationThrottleInstaller : public WebContentsObserver {
|
|||||||
|
|
||||||
void Continue(NavigationThrottle::ThrottleCheckResult result) {
|
void Continue(NavigationThrottle::ThrottleCheckResult result) {
|
||||||
ASSERT_NE(NavigationThrottle::DEFER, result.action());
|
ASSERT_NE(NavigationThrottle::DEFER, result.action());
|
||||||
if (result.action() == NavigationThrottle::PROCEED)
|
if (result.action() == NavigationThrottle::PROCEED) {
|
||||||
navigation_throttle()->ResumeNavigation();
|
navigation_throttle()->ResumeNavigation();
|
||||||
else
|
} else {
|
||||||
navigation_throttle()->CancelNavigation(result);
|
navigation_throttle()->CancelNavigation(result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int will_start_called() { return will_start_called_; }
|
int will_start_called() { return will_start_called_; }
|
||||||
@ -333,26 +338,30 @@ class TestNavigationThrottleInstaller : public WebContentsObserver {
|
|||||||
protected:
|
protected:
|
||||||
virtual void DidCallWillStartRequest() {
|
virtual void DidCallWillStartRequest() {
|
||||||
will_start_called_++;
|
will_start_called_++;
|
||||||
if (will_start_loop_runner_)
|
if (will_start_loop_runner_) {
|
||||||
will_start_loop_runner_->Quit();
|
will_start_loop_runner_->Quit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void DidCallWillRedirectRequest() {
|
virtual void DidCallWillRedirectRequest() {
|
||||||
will_redirect_called_++;
|
will_redirect_called_++;
|
||||||
if (will_redirect_loop_runner_)
|
if (will_redirect_loop_runner_) {
|
||||||
will_redirect_loop_runner_->Quit();
|
will_redirect_loop_runner_->Quit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void DidCallWillFailRequest() {
|
virtual void DidCallWillFailRequest() {
|
||||||
will_fail_called_++;
|
will_fail_called_++;
|
||||||
if (will_fail_loop_runner_)
|
if (will_fail_loop_runner_) {
|
||||||
will_fail_loop_runner_->Quit();
|
will_fail_loop_runner_->Quit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void DidCallWillProcessResponse() {
|
virtual void DidCallWillProcessResponse() {
|
||||||
will_process_called_++;
|
will_process_called_++;
|
||||||
if (will_process_loop_runner_)
|
if (will_process_loop_runner_) {
|
||||||
will_process_loop_runner_->Quit();
|
will_process_loop_runner_->Quit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void DidCallWillCommitWithoutUrlLoader() {
|
virtual void DidCallWillCommitWithoutUrlLoader() {
|
||||||
@ -365,8 +374,9 @@ class TestNavigationThrottleInstaller : public WebContentsObserver {
|
|||||||
private:
|
private:
|
||||||
void DidStartNavigation(NavigationHandle* handle) override {
|
void DidStartNavigation(NavigationHandle* handle) override {
|
||||||
if (!expected_start_url_.is_empty() &&
|
if (!expected_start_url_.is_empty() &&
|
||||||
handle->GetURL() != expected_start_url_)
|
handle->GetURL() != expected_start_url_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<NavigationThrottle> throttle(new TestNavigationThrottle(
|
std::unique_ptr<NavigationThrottle> throttle(new TestNavigationThrottle(
|
||||||
handle, will_start_result_, will_redirect_result_, will_fail_result_,
|
handle, will_start_result_, will_redirect_result_, will_fail_result_,
|
||||||
@ -391,11 +401,13 @@ class TestNavigationThrottleInstaller : public WebContentsObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DidFinishNavigation(NavigationHandle* handle) override {
|
void DidFinishNavigation(NavigationHandle* handle) override {
|
||||||
if (!navigation_throttle_)
|
if (!navigation_throttle_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (handle == navigation_throttle_->navigation_handle())
|
if (handle == navigation_throttle_->navigation_handle()) {
|
||||||
navigation_throttle_ = nullptr;
|
navigation_throttle_ = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NavigationThrottle::ThrottleCheckResult will_start_result_;
|
NavigationThrottle::ThrottleCheckResult will_start_result_;
|
||||||
@ -2663,19 +2675,17 @@ IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest,
|
|||||||
// |client_throttle| when its registered.
|
// |client_throttle| when its registered.
|
||||||
content::ShellContentBrowserClient::Get()
|
content::ShellContentBrowserClient::Get()
|
||||||
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
||||||
[&client_throttle](content::NavigationHandle* handle)
|
[&client_throttle](
|
||||||
-> std::vector<std::unique_ptr<content::NavigationThrottle>> {
|
content::NavigationThrottleRegistry& registry) -> void {
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>> throttles;
|
|
||||||
std::unique_ptr<TestNavigationThrottle> throttle(
|
std::unique_ptr<TestNavigationThrottle> throttle(
|
||||||
new TestNavigationThrottle(
|
new TestNavigationThrottle(
|
||||||
handle, NavigationThrottle::DEFER,
|
®istry.GetNavigationHandle(), NavigationThrottle::DEFER,
|
||||||
NavigationThrottle::PROCEED, NavigationThrottle::PROCEED,
|
NavigationThrottle::PROCEED, NavigationThrottle::PROCEED,
|
||||||
NavigationThrottle::PROCEED, NavigationThrottle::PROCEED,
|
NavigationThrottle::PROCEED, NavigationThrottle::PROCEED,
|
||||||
base::DoNothing(), base::DoNothing(), base::DoNothing(),
|
base::DoNothing(), base::DoNothing(), base::DoNothing(),
|
||||||
base::DoNothing(), base::DoNothing()));
|
base::DoNothing(), base::DoNothing()));
|
||||||
client_throttle = throttle.get();
|
client_throttle = throttle.get();
|
||||||
throttles.push_back(std::move(throttle));
|
registry.AddThrottle(std::move(throttle));
|
||||||
return throttles;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Add another similar throttle using the installer which will use
|
// Add another similar throttle using the installer which will use
|
||||||
@ -2938,8 +2948,9 @@ IN_PROC_BROWSER_TEST_F(NavigationRequestBrowserTest_IsolateAllSites,
|
|||||||
auto add_suffix = [&names](std::vector<std::string> suffixes) {
|
auto add_suffix = [&names](std::vector<std::string> suffixes) {
|
||||||
size_t original_size = names.size();
|
size_t original_size = names.size();
|
||||||
for (size_t i = 0; i < original_size; i++) {
|
for (size_t i = 0; i < original_size; i++) {
|
||||||
for (const std::string& suffix : suffixes)
|
for (const std::string& suffix : suffixes) {
|
||||||
names.push_back(names[i] + suffix);
|
names.push_back(names[i] + suffix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
add_suffix({kProcessSuffixes.at(process_type)});
|
add_suffix({kProcessSuffixes.at(process_type)});
|
||||||
@ -4493,9 +4504,9 @@ IN_PROC_BROWSER_TEST_P(NavigationRequestMPArchBrowserTest,
|
|||||||
DCHECK_EQ(navigation_handle->GetNavigatingFrameType(),
|
DCHECK_EQ(navigation_handle->GetNavigatingFrameType(),
|
||||||
GetParam() == TestMPArchType::kPrerender
|
GetParam() == TestMPArchType::kPrerender
|
||||||
? FrameType::kPrerenderMainFrame
|
? FrameType::kPrerenderMainFrame
|
||||||
: GetParam() == TestMPArchType::kFencedFrame
|
: GetParam() == TestMPArchType::kFencedFrame
|
||||||
? FrameType::kFencedFrameRoot
|
? FrameType::kFencedFrameRoot
|
||||||
: FrameType::kPrimaryMainFrame);
|
: FrameType::kPrimaryMainFrame);
|
||||||
EXPECT_FALSE(navigation_handle->ShouldUpdateHistory());
|
EXPECT_FALSE(navigation_handle->ShouldUpdateHistory());
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
@ -4689,14 +4700,12 @@ IN_PROC_BROWSER_TEST_F(NavigationRequestResponseBodyBrowserTest, Received) {
|
|||||||
// to this throttle in `client_throttle` on registration.
|
// to this throttle in `client_throttle` on registration.
|
||||||
content::ShellContentBrowserClient::Get()
|
content::ShellContentBrowserClient::Get()
|
||||||
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
||||||
[&client_throttle](content::NavigationHandle* handle)
|
[&client_throttle](
|
||||||
-> std::vector<std::unique_ptr<content::NavigationThrottle>> {
|
content::NavigationThrottleRegistry& registry) -> void {
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>> throttles;
|
auto throttle = std::make_unique<ResponseBodyNavigationThrottle>(
|
||||||
auto throttle =
|
®istry.GetNavigationHandle());
|
||||||
std::make_unique<ResponseBodyNavigationThrottle>(handle);
|
|
||||||
client_throttle = throttle.get();
|
client_throttle = throttle.get();
|
||||||
throttles.push_back(std::move(throttle));
|
registry.AddThrottle(std::move(throttle));
|
||||||
return throttles;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Start navigating.
|
// Start navigating.
|
||||||
@ -4732,14 +4741,12 @@ IN_PROC_BROWSER_TEST_F(NavigationRequestResponseBodyBrowserTest,
|
|||||||
// to this throttle in `client_throttle` on registration.
|
// to this throttle in `client_throttle` on registration.
|
||||||
content::ShellContentBrowserClient::Get()
|
content::ShellContentBrowserClient::Get()
|
||||||
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
||||||
[&client_throttle](content::NavigationHandle* handle)
|
[&client_throttle](
|
||||||
-> std::vector<std::unique_ptr<content::NavigationThrottle>> {
|
content::NavigationThrottleRegistry& registry) -> void {
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>> throttles;
|
auto throttle = std::make_unique<ResponseBodyNavigationThrottle>(
|
||||||
auto throttle =
|
®istry.GetNavigationHandle());
|
||||||
std::make_unique<ResponseBodyNavigationThrottle>(handle);
|
|
||||||
client_throttle = throttle.get();
|
client_throttle = throttle.get();
|
||||||
throttles.push_back(std::move(throttle));
|
registry.AddThrottle(std::move(throttle));
|
||||||
return throttles;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Start navigating.
|
// Start navigating.
|
||||||
@ -4775,14 +4782,12 @@ IN_PROC_BROWSER_TEST_F(NavigationRequestResponseBodyBrowserTest,
|
|||||||
// to this throttle in `client_throttle` on registration.
|
// to this throttle in `client_throttle` on registration.
|
||||||
content::ShellContentBrowserClient::Get()
|
content::ShellContentBrowserClient::Get()
|
||||||
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
->set_create_throttles_for_navigation_callback(base::BindLambdaForTesting(
|
||||||
[&client_throttle](content::NavigationHandle* handle)
|
[&client_throttle](
|
||||||
-> std::vector<std::unique_ptr<content::NavigationThrottle>> {
|
content::NavigationThrottleRegistry& registry) -> void {
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>> throttles;
|
auto throttle = std::make_unique<ResponseBodyNavigationThrottle>(
|
||||||
auto throttle =
|
®istry.GetNavigationHandle());
|
||||||
std::make_unique<ResponseBodyNavigationThrottle>(handle);
|
|
||||||
client_throttle = throttle.get();
|
client_throttle = throttle.get();
|
||||||
throttles.push_back(std::move(throttle));
|
registry.AddThrottle(std::move(throttle));
|
||||||
return throttles;
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Start navigating to a page with a large body (>5 million characters).
|
// Start navigating to a page with a large body (>5 million characters).
|
||||||
|
@ -592,13 +592,11 @@ class GetRenderFrameHostOnFailureNavigationThrottle
|
|||||||
};
|
};
|
||||||
|
|
||||||
class ThrottleTestContentBrowserClient : public ContentBrowserClient {
|
class ThrottleTestContentBrowserClient : public ContentBrowserClient {
|
||||||
std::vector<std::unique_ptr<NavigationThrottle>> CreateThrottlesForNavigation(
|
void CreateThrottlesForNavigation(
|
||||||
NavigationThrottleRegistry& registry) override {
|
NavigationThrottleRegistry& registry) override {
|
||||||
std::vector<std::unique_ptr<NavigationThrottle>> throttle;
|
|
||||||
registry.AddThrottle(
|
registry.AddThrottle(
|
||||||
std::make_unique<GetRenderFrameHostOnFailureNavigationThrottle>(
|
std::make_unique<GetRenderFrameHostOnFailureNavigationThrottle>(
|
||||||
®istry.GetNavigationHandle()));
|
®istry.GetNavigationHandle()));
|
||||||
return throttle;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -218,16 +218,7 @@ void NavigationThrottleRunner::RegisterNavigationThrottles() {
|
|||||||
// NavigationRequest.
|
// NavigationRequest.
|
||||||
NavigationRequest* request = static_cast<NavigationRequest*>(delegate_);
|
NavigationRequest* request = static_cast<NavigationRequest*>(delegate_);
|
||||||
|
|
||||||
std::vector<std::unique_ptr<NavigationThrottle>> throttles_under_migration =
|
request->GetDelegate()->CreateThrottlesForNavigation(*this);
|
||||||
request->GetDelegate()->CreateThrottlesForNavigation(*this);
|
|
||||||
// TODO(https://crbug.com/412524375): Remove `throttles_under_migration` and
|
|
||||||
// following code to move them to the member variable. When the call returns
|
|
||||||
// above, migrated throttles are already registered in `throttles_` via the
|
|
||||||
// new NavigationThrottleRegistry interface. So, we cannot assign the returned
|
|
||||||
// vector directly to `throttles_`.
|
|
||||||
throttles_.insert(throttles_.end(),
|
|
||||||
std::make_move_iterator(throttles_under_migration.begin()),
|
|
||||||
std::make_move_iterator(throttles_under_migration.end()));
|
|
||||||
|
|
||||||
// Check for renderer-inititated main frame navigations to blocked URL schemes
|
// Check for renderer-inititated main frame navigations to blocked URL schemes
|
||||||
// (data, filesystem). This is done early as it may block the main frame
|
// (data, filesystem). This is done early as it may block the main frame
|
||||||
|
@ -120,12 +120,8 @@ class NavigatorDelegate {
|
|||||||
// Returns the NavigationThrottles to add to this navigation. Normally these
|
// Returns the NavigationThrottles to add to this navigation. Normally these
|
||||||
// are defined by the content/ embedder, except in the case of interstitials
|
// are defined by the content/ embedder, except in the case of interstitials
|
||||||
// where no NavigationThrottles are added to the navigation.
|
// where no NavigationThrottles are added to the navigation.
|
||||||
// TODO(https://crbug.com/412524375): New code should add a NavigationThrottle
|
virtual void CreateThrottlesForNavigation(
|
||||||
// via the given `registry` instead of returning a NavigationThrottle from
|
NavigationThrottleRegistry& registry) = 0;
|
||||||
// this method. Once all existing NavigationThrottles are migrated, the
|
|
||||||
// returned type will be changed to `void`.
|
|
||||||
virtual std::vector<std::unique_ptr<NavigationThrottle>>
|
|
||||||
CreateThrottlesForNavigation(NavigationThrottleRegistry& registry) = 0;
|
|
||||||
|
|
||||||
// Returns commit deferring conditions to add to this navigation.
|
// Returns commit deferring conditions to add to this navigation.
|
||||||
virtual std::vector<std::unique_ptr<CommitDeferringCondition>>
|
virtual std::vector<std::unique_ptr<CommitDeferringCondition>>
|
||||||
|
@ -9534,13 +9534,12 @@ bool WebContentsImpl::IsHidden() {
|
|||||||
return GetPageVisibilityState() == PageVisibilityState::kHidden;
|
return GetPageVisibilityState() == PageVisibilityState::kHidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<NavigationThrottle>>
|
void WebContentsImpl::CreateThrottlesForNavigation(
|
||||||
WebContentsImpl::CreateThrottlesForNavigation(
|
|
||||||
NavigationThrottleRegistry& registry) {
|
NavigationThrottleRegistry& registry) {
|
||||||
OPTIONAL_TRACE_EVENT1("content",
|
OPTIONAL_TRACE_EVENT1("content",
|
||||||
"WebContentsImpl::CreateThrottlesForNavigation",
|
"WebContentsImpl::CreateThrottlesForNavigation",
|
||||||
"navigation", registry.GetNavigationHandle());
|
"navigation", registry.GetNavigationHandle());
|
||||||
return GetContentClient()->browser()->CreateThrottlesForNavigation(registry);
|
GetContentClient()->browser()->CreateThrottlesForNavigation(registry);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<CommitDeferringCondition>>
|
std::vector<std::unique_ptr<CommitDeferringCondition>>
|
||||||
|
@ -1067,7 +1067,7 @@ class CONTENT_EXPORT WebContentsImpl
|
|||||||
bool is_outermost_main_frame_navigation) override;
|
bool is_outermost_main_frame_navigation) override;
|
||||||
const blink::UserAgentOverride& GetUserAgentOverride(
|
const blink::UserAgentOverride& GetUserAgentOverride(
|
||||||
FrameTree& frame_tree) override;
|
FrameTree& frame_tree) override;
|
||||||
std::vector<std::unique_ptr<NavigationThrottle>> CreateThrottlesForNavigation(
|
void CreateThrottlesForNavigation(
|
||||||
NavigationThrottleRegistry& registry) override;
|
NavigationThrottleRegistry& registry) override;
|
||||||
std::vector<std::unique_ptr<CommitDeferringCondition>>
|
std::vector<std::unique_ptr<CommitDeferringCondition>>
|
||||||
CreateDeferringConditionsForNavigationCommit(
|
CreateDeferringConditionsForNavigationCommit(
|
||||||
|
@ -997,11 +997,8 @@ void ContentBrowserClient::OpenURL(
|
|||||||
std::move(callback).Run(nullptr);
|
std::move(callback).Run(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<NavigationThrottle>>
|
void ContentBrowserClient::CreateThrottlesForNavigation(
|
||||||
content::ContentBrowserClient::CreateThrottlesForNavigation(
|
NavigationThrottleRegistry& registry) {}
|
||||||
NavigationThrottleRegistry& registry) {
|
|
||||||
return std::vector<std::unique_ptr<NavigationThrottle>>();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::unique_ptr<CommitDeferringCondition>>
|
std::vector<std::unique_ptr<CommitDeferringCondition>>
|
||||||
ContentBrowserClient::CreateCommitDeferringConditionsForNavigation(
|
ContentBrowserClient::CreateCommitDeferringConditionsForNavigation(
|
||||||
|
@ -1705,12 +1705,8 @@ class CONTENT_EXPORT ContentBrowserClient {
|
|||||||
// navigations; they are specifically not run for page activating navigations
|
// navigations; they are specifically not run for page activating navigations
|
||||||
// such as prerender activation and back-forward cache restores or for
|
// such as prerender activation and back-forward cache restores or for
|
||||||
// navigations that don't use a URLLoader like same-document navigations.
|
// navigations that don't use a URLLoader like same-document navigations.
|
||||||
// TODO(https://crbug.com/412524375): New code should add a NavigationThrottle
|
virtual void CreateThrottlesForNavigation(
|
||||||
// via the given `registry` instead of returning a NavigationThrottle from
|
NavigationThrottleRegistry& registry);
|
||||||
// this method. Once all existing NavigationThrottles are migrated, the
|
|
||||||
// returned type will be changed to `void`.
|
|
||||||
virtual std::vector<std::unique_ptr<NavigationThrottle>>
|
|
||||||
CreateThrottlesForNavigation(NavigationThrottleRegistry& registry);
|
|
||||||
|
|
||||||
// Allows the embedder to register one or more CommitDeferringConditions for
|
// Allows the embedder to register one or more CommitDeferringConditions for
|
||||||
// the navigation indicated by |navigation_handle|. A
|
// the navigation indicated by |navigation_handle|. A
|
||||||
|
@ -693,16 +693,11 @@ void ShellContentBrowserClient::OpenURL(
|
|||||||
->web_contents());
|
->web_contents());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<NavigationThrottle>>
|
void ShellContentBrowserClient::CreateThrottlesForNavigation(
|
||||||
ShellContentBrowserClient::CreateThrottlesForNavigation(
|
|
||||||
NavigationThrottleRegistry& registry) {
|
NavigationThrottleRegistry& registry) {
|
||||||
std::vector<std::unique_ptr<NavigationThrottle>> empty_throttles;
|
|
||||||
if (create_throttles_for_navigation_callback_) {
|
if (create_throttles_for_navigation_callback_) {
|
||||||
// TODO(https://crbug.com/412524375): NavigationThrottleRegistry migration.
|
create_throttles_for_navigation_callback_.Run(registry);
|
||||||
return create_throttles_for_navigation_callback_.Run(
|
|
||||||
®istry.GetNavigationHandle());
|
|
||||||
}
|
}
|
||||||
return empty_throttles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<LoginDelegate> ShellContentBrowserClient::CreateLoginDelegate(
|
std::unique_ptr<LoginDelegate> ShellContentBrowserClient::CreateLoginDelegate(
|
||||||
|
@ -125,7 +125,7 @@ class ShellContentBrowserClient : public ContentBrowserClient {
|
|||||||
void OpenURL(SiteInstance* site_instance,
|
void OpenURL(SiteInstance* site_instance,
|
||||||
const OpenURLParams& params,
|
const OpenURLParams& params,
|
||||||
base::OnceCallback<void(WebContents*)> callback) override;
|
base::OnceCallback<void(WebContents*)> callback) override;
|
||||||
std::vector<std::unique_ptr<NavigationThrottle>> CreateThrottlesForNavigation(
|
void CreateThrottlesForNavigation(
|
||||||
NavigationThrottleRegistry& registry) override;
|
NavigationThrottleRegistry& registry) override;
|
||||||
std::unique_ptr<LoginDelegate> CreateLoginDelegate(
|
std::unique_ptr<LoginDelegate> CreateLoginDelegate(
|
||||||
const net::AuthChallengeInfo& auth_info,
|
const net::AuthChallengeInfo& auth_info,
|
||||||
@ -218,8 +218,8 @@ class ShellContentBrowserClient : public ContentBrowserClient {
|
|||||||
std::move(url_loader_factory_params_callback);
|
std::move(url_loader_factory_params_callback);
|
||||||
}
|
}
|
||||||
void set_create_throttles_for_navigation_callback(
|
void set_create_throttles_for_navigation_callback(
|
||||||
base::RepeatingCallback<std::vector<std::unique_ptr<NavigationThrottle>>(
|
base::RepeatingCallback<void(NavigationThrottleRegistry&)>
|
||||||
NavigationHandle*)> create_throttles_for_navigation_callback) {
|
create_throttles_for_navigation_callback) {
|
||||||
create_throttles_for_navigation_callback_ =
|
create_throttles_for_navigation_callback_ =
|
||||||
create_throttles_for_navigation_callback;
|
create_throttles_for_navigation_callback;
|
||||||
}
|
}
|
||||||
@ -271,8 +271,7 @@ class ShellContentBrowserClient : public ContentBrowserClient {
|
|||||||
bool is_for_isolated_world,
|
bool is_for_isolated_world,
|
||||||
bool is_for_service_worker)>
|
bool is_for_service_worker)>
|
||||||
url_loader_factory_params_callback_;
|
url_loader_factory_params_callback_;
|
||||||
base::RepeatingCallback<std::vector<std::unique_ptr<NavigationThrottle>>(
|
base::RepeatingCallback<void(NavigationThrottleRegistry&)>
|
||||||
NavigationHandle*)>
|
|
||||||
create_throttles_for_navigation_callback_;
|
create_throttles_for_navigation_callback_;
|
||||||
base::RepeatingCallback<void(blink::web_pref::WebPreferences*)>
|
base::RepeatingCallback<void(blink::web_pref::WebPreferences*)>
|
||||||
override_web_preferences_callback_;
|
override_web_preferences_callback_;
|
||||||
|
@ -420,21 +420,14 @@ void WebTestContentBrowserClient::OverrideWebPreferences(
|
|||||||
WebTestControlHost::Get()->OverrideWebPreferences(prefs);
|
WebTestControlHost::Get()->OverrideWebPreferences(prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void WebTestContentBrowserClient::CreateThrottlesForNavigation(
|
||||||
WebTestContentBrowserClient::CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) {
|
content::NavigationThrottleRegistry& registry) {
|
||||||
content::NavigationHandle* navigation_handle =
|
ShellContentBrowserClient::CreateThrottlesForNavigation(registry);
|
||||||
®istry.GetNavigationHandle();
|
content::NavigationHandle& navigation_handle = registry.GetNavigationHandle();
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>> throttles =
|
registry.AddThrottle(std::make_unique<WebTestOriginTrialThrottle>(
|
||||||
ShellContentBrowserClient::CreateThrottlesForNavigation(registry);
|
&navigation_handle, navigation_handle.GetWebContents()
|
||||||
|
->GetBrowserContext()
|
||||||
throttles.push_back(std::make_unique<WebTestOriginTrialThrottle>(
|
->GetOriginTrialsControllerDelegate()));
|
||||||
navigation_handle, navigation_handle->GetWebContents()
|
|
||||||
->GetBrowserContext()
|
|
||||||
->GetOriginTrialsControllerDelegate()));
|
|
||||||
|
|
||||||
// TODO(https://crbug.com/412524375): NavigationThrottleRegistry migration.
|
|
||||||
return throttles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebTestContentBrowserClient::AppendExtraCommandLineSwitches(
|
void WebTestContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||||
|
@ -75,8 +75,7 @@ class WebTestContentBrowserClient : public ShellContentBrowserClient {
|
|||||||
void OverrideWebPreferences(WebContents* web_contents,
|
void OverrideWebPreferences(WebContents* web_contents,
|
||||||
SiteInstance& main_frame_site,
|
SiteInstance& main_frame_site,
|
||||||
blink::web_pref::WebPreferences* prefs) override;
|
blink::web_pref::WebPreferences* prefs) override;
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void CreateThrottlesForNavigation(
|
||||||
CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) override;
|
content::NavigationThrottleRegistry& registry) override;
|
||||||
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
||||||
int child_process_id) override;
|
int child_process_id) override;
|
||||||
|
@ -252,8 +252,7 @@ void ShellContentBrowserClient::
|
|||||||
render_frame_host.GetGlobalId()));
|
render_frame_host.GetGlobalId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void ShellContentBrowserClient::CreateThrottlesForNavigation(
|
||||||
ShellContentBrowserClient::CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) {
|
content::NavigationThrottleRegistry& registry) {
|
||||||
content::NavigationHandle& navigation_handle =
|
content::NavigationHandle& navigation_handle =
|
||||||
registry.GetNavigationHandle();
|
registry.GetNavigationHandle();
|
||||||
@ -265,7 +264,6 @@ ShellContentBrowserClient::CreateThrottlesForNavigation(
|
|||||||
}
|
}
|
||||||
registry.MaybeAddThrottle(
|
registry.MaybeAddThrottle(
|
||||||
WebViewGuest::MaybeCreateNavigationThrottle(&navigation_handle));
|
WebViewGuest::MaybeCreateNavigationThrottle(&navigation_handle));
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<content::NavigationUIData>
|
std::unique_ptr<content::NavigationUIData>
|
||||||
|
@ -89,8 +89,7 @@ class ShellContentBrowserClient : public content::ContentBrowserClient {
|
|||||||
void RegisterAssociatedInterfaceBindersForRenderFrameHost(
|
void RegisterAssociatedInterfaceBindersForRenderFrameHost(
|
||||||
content::RenderFrameHost& render_frame_host,
|
content::RenderFrameHost& render_frame_host,
|
||||||
blink::AssociatedInterfaceRegistry& associated_registry) override;
|
blink::AssociatedInterfaceRegistry& associated_registry) override;
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void CreateThrottlesForNavigation(
|
||||||
CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) override;
|
content::NavigationThrottleRegistry& registry) override;
|
||||||
std::unique_ptr<content::NavigationUIData> GetNavigationUIData(
|
std::unique_ptr<content::NavigationUIData> GetNavigationUIData(
|
||||||
content::NavigationHandle* navigation_handle) override;
|
content::NavigationHandle* navigation_handle) override;
|
||||||
|
@ -310,8 +310,7 @@ base::OnceClosure WebEngineContentBrowserClient::SelectClientCertificate(
|
|||||||
return base::OnceClosure();
|
return base::OnceClosure();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void WebEngineContentBrowserClient::CreateThrottlesForNavigation(
|
||||||
WebEngineContentBrowserClient::CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) {
|
content::NavigationThrottleRegistry& registry) {
|
||||||
auto& navigation_handle = registry.GetNavigationHandle();
|
auto& navigation_handle = registry.GetNavigationHandle();
|
||||||
auto* frame_impl =
|
auto* frame_impl =
|
||||||
@ -334,8 +333,6 @@ WebEngineContentBrowserClient::CreateThrottlesForNavigation(
|
|||||||
navigation_handle.GetWebContents()->GetBrowserContext(),
|
navigation_handle.GetWebContents()->GetBrowserContext(),
|
||||||
*explicit_sites_filter_error_page));
|
*explicit_sites_filter_error_page));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
|
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
|
||||||
|
@ -62,8 +62,7 @@ class WebEngineContentBrowserClient final
|
|||||||
net::SSLCertRequestInfo* cert_request_info,
|
net::SSLCertRequestInfo* cert_request_info,
|
||||||
net::ClientCertIdentityList client_certs,
|
net::ClientCertIdentityList client_certs,
|
||||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void CreateThrottlesForNavigation(
|
||||||
CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) override;
|
content::NavigationThrottleRegistry& registry) override;
|
||||||
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
|
std::vector<std::unique_ptr<blink::URLLoaderThrottle>>
|
||||||
CreateURLLoaderThrottles(
|
CreateURLLoaderThrottles(
|
||||||
|
@ -453,21 +453,15 @@ void HeadlessContentBrowserClient::SessionEnding(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HEADLESS_USE_POLICY)
|
#if defined(HEADLESS_USE_POLICY)
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void HeadlessContentBrowserClient::CreateThrottlesForNavigation(
|
||||||
HeadlessContentBrowserClient::CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) {
|
content::NavigationThrottleRegistry& registry) {
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>> throttles;
|
|
||||||
|
|
||||||
// Avoid creating naviagtion throttle if preferences are not available
|
// Avoid creating naviagtion throttle if preferences are not available
|
||||||
// (happens in tests).
|
// (happens in tests).
|
||||||
content::NavigationHandle& handle = registry.GetNavigationHandle();
|
content::NavigationHandle& handle = registry.GetNavigationHandle();
|
||||||
if (browser_->GetPrefs()) {
|
if (browser_->GetPrefs()) {
|
||||||
throttles.push_back(std::make_unique<PolicyBlocklistNavigationThrottle>(
|
registry.AddThrottle(std::make_unique<PolicyBlocklistNavigationThrottle>(
|
||||||
&handle, handle.GetWebContents()->GetBrowserContext()));
|
&handle, handle.GetWebContents()->GetBrowserContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(https://crbug.com/412524375): NavigationThrottleRegistry migration.
|
|
||||||
return throttles;
|
|
||||||
}
|
}
|
||||||
#endif // defined(HEADLESS_USE_POLICY)
|
#endif // defined(HEADLESS_USE_POLICY)
|
||||||
|
|
||||||
|
@ -133,8 +133,7 @@ class HeadlessContentBrowserClient : public content::ContentBrowserClient {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HEADLESS_USE_POLICY)
|
#if defined(HEADLESS_USE_POLICY)
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
void CreateThrottlesForNavigation(
|
||||||
CreateThrottlesForNavigation(
|
|
||||||
content::NavigationThrottleRegistry& registry) override;
|
content::NavigationThrottleRegistry& registry) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user