diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/chrome/browser/net | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/browser/net')
37 files changed, 1183 insertions, 377 deletions
diff --git a/chromium/chrome/browser/net/BUILD.gn b/chromium/chrome/browser/net/BUILD.gn index 0a05d7789d2..895aa8bb958 100644 --- a/chromium/chrome/browser/net/BUILD.gn +++ b/chromium/chrome/browser/net/BUILD.gn @@ -4,6 +4,16 @@ import("//third_party/protobuf/proto_library.gni") +if (is_android) { + import("//build/config/android/rules.gni") +} + proto_library("probe_message_proto") { sources = [ "probe_message.proto" ] } + +if (is_android) { + java_cpp_enum("secure_dns_management_mode_generated_enum") { + sources = [ "secure_dns_config.h" ] + } +} diff --git a/chromium/chrome/browser/net/cert_verify_proc_browsertest.cc b/chromium/chrome/browser/net/cert_verify_proc_browsertest.cc index 9ff2548e2cc..e86c8251662 100644 --- a/chromium/chrome/browser/net/cert_verify_proc_browsertest.cc +++ b/chromium/chrome/browser/net/cert_verify_proc_browsertest.cc @@ -7,12 +7,14 @@ #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" #include "base/json/json_reader.h" +#include "base/test/scoped_feature_list.h" #include "build/build_config.h" #include "chrome/test/base/chrome_test_utils.h" #include "content/public/browser/network_service_instance.h" #include "content/public/test/browser_test.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" +#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/network_switches.h" #if defined(OS_ANDROID) @@ -83,8 +85,20 @@ class NetLogPlatformBrowserTestBase : public PlatformBrowserTest { // This is an integration test to ensure that CertVerifyProc netlog events // continue to be logged once cert verification is moved out of the network // service process. (See crbug.com/1015134 and crbug.com/1040681.) -class CertVerifyProcNetLogBrowserTest : public NetLogPlatformBrowserTestBase { +class CertVerifyProcNetLogBrowserTest + : public NetLogPlatformBrowserTestBase, + public testing::WithParamInterface<bool> { public: + void SetUpInProcessBrowserTestFixture() override { + if (GetParam()) { + scoped_feature_list_.InitAndEnableFeature( + network::features::kCertVerifierService); + } else { + scoped_feature_list_.InitAndDisableFeature( + network::features::kCertVerifierService); + } + } + void SetUpOnMainThread() override { PlatformBrowserTest::SetUpOnMainThread(); @@ -129,10 +143,11 @@ class CertVerifyProcNetLogBrowserTest : public NetLogPlatformBrowserTestBase { const std::string kTestHost = "netlog-example.a.test"; protected: + base::test::ScopedFeatureList scoped_feature_list_; net::EmbeddedTestServer https_server_{net::EmbeddedTestServer::TYPE_HTTPS}; }; -IN_PROC_BROWSER_TEST_F(CertVerifyProcNetLogBrowserTest, Test) { +IN_PROC_BROWSER_TEST_P(CertVerifyProcNetLogBrowserTest, Test) { ASSERT_TRUE(https_server_.Start()); // Request using a unique host name to ensure that the cert verification wont @@ -150,3 +165,7 @@ IN_PROC_BROWSER_TEST_F(CertVerifyProcNetLogBrowserTest, Test) { base::RunLoop().RunUntilIdle(); content::FlushNetworkServiceInstanceForTesting(); } + +INSTANTIATE_TEST_SUITE_P(CertVerifierService, + CertVerifyProcNetLogBrowserTest, + ::testing::Bool()); diff --git a/chromium/chrome/browser/net/chrome_mojo_proxy_resolver_factory.cc b/chromium/chrome/browser/net/chrome_mojo_proxy_resolver_factory.cc index 1347508594b..99dfc4126b0 100644 --- a/chromium/chrome/browser/net/chrome_mojo_proxy_resolver_factory.cc +++ b/chromium/chrome/browser/net/chrome_mojo_proxy_resolver_factory.cc @@ -12,6 +12,7 @@ #include "base/single_thread_task_runner.h" #include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" +#include "chrome/browser/service_sandbox_type.h" #include "content/public/common/child_process_host.h" #include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h" @@ -24,10 +25,6 @@ #include "services/strings/grit/services_strings.h" #endif -#if defined(OS_WIN) -#include "services/service_manager/sandbox/sandbox_type.h" -#endif - namespace { proxy_resolver::mojom::ProxyResolverFactory* GetProxyResolverFactory() { @@ -47,9 +44,6 @@ proxy_resolver::mojom::ProxyResolverFactory* GetProxyResolverFactory() { remote->BindNewPipeAndPassReceiver(), content::ServiceProcessHost::Options() .WithDisplayName(IDS_PROXY_RESOLVER_DISPLAY_NAME) -#if defined(OS_WIN) - .WithSandboxType(service_manager::SandboxType::kProxyResolver) -#endif .Pass()); // The service will report itself idle once there are no more bound diff --git a/chromium/chrome/browser/net/chrome_mojo_proxy_resolver_factory_browsertest.cc b/chromium/chrome/browser/net/chrome_mojo_proxy_resolver_factory_browsertest.cc index 0fee3b8c2fb..7c38448c971 100644 --- a/chromium/chrome/browser/net/chrome_mojo_proxy_resolver_factory_browsertest.cc +++ b/chromium/chrome/browser/net/chrome_mojo_proxy_resolver_factory_browsertest.cc @@ -13,7 +13,6 @@ #include "base/process/process.h" #include "base/run_loop.h" #include "base/synchronization/waitable_event.h" -#include "base/task/post_task.h" #include "base/test/bind_test_util.h" #include "base/time/time.h" #include "chrome/test/base/in_process_browser_test.h" @@ -158,8 +157,8 @@ IN_PROC_BROWSER_TEST_F(ChromeMojoProxyResolverFactoryBrowserTest, // Wait a little bit and check it's still running. { base::RunLoop run_loop; - base::PostDelayedTask(FROM_HERE, {content::BrowserThread::UI}, - run_loop.QuitClosure(), kServiceShutdownTimeout); + content::GetUIThreadTaskRunner({})->PostDelayedTask( + FROM_HERE, run_loop.QuitClosure(), kServiceShutdownTimeout); run_loop.Run(); } @@ -202,8 +201,8 @@ IN_PROC_BROWSER_TEST_F(ChromeMojoProxyResolverFactoryBrowserTest, // Wait a little bit and check it's still running. { base::RunLoop run_loop; - base::PostDelayedTask(FROM_HERE, {content::BrowserThread::UI}, - run_loop.QuitClosure(), kServiceShutdownTimeout); + content::GetUIThreadTaskRunner({})->PostDelayedTask( + FROM_HERE, run_loop.QuitClosure(), kServiceShutdownTimeout); run_loop.Run(); } diff --git a/chromium/chrome/browser/net/chrome_network_service_browsertest.cc b/chromium/chrome/browser/net/chrome_network_service_browsertest.cc index 9ecc8c269a7..9092b2ddb9f 100644 --- a/chromium/chrome/browser/net/chrome_network_service_browsertest.cc +++ b/chromium/chrome/browser/net/chrome_network_service_browsertest.cc @@ -16,6 +16,7 @@ #include "content/public/test/browser_test.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/remote.h" +#include "net/cookies/cookie_inclusion_status.h" #include "net/cookies/cookie_util.h" #include "net/extras/sqlite/cookie_crypto_delegate.h" #include "services/network/public/cpp/features.h" @@ -53,9 +54,7 @@ void SetCookie( cookie, net::cookie_util::SimulatedCookieSource(cookie, "https"), net::CookieOptions(), base::BindLambdaForTesting( - [&](net::CanonicalCookie::CookieInclusionStatus status) { - run_loop.Quit(); - })); + [&](net::CookieInclusionStatus status) { run_loop.Quit(); })); run_loop.Run(); } @@ -89,6 +88,8 @@ class ChromeNetworkServiceBrowserTest context_params->enable_encrypted_cookies = enable_encrypted_cookies; context_params->cookie_path = browser()->profile()->GetPath().Append(FILE_PATH_LITERAL("cookies")); + context_params->cert_verifier_params = content::GetCertVerifierParams( + network::mojom::CertVerifierCreationParams::New()); GetNetworkService()->CreateNetworkContext( network_context.InitWithNewPipeAndPassReceiver(), std::move(context_params)); diff --git a/chromium/chrome/browser/net/cookie_policy_browsertest.cc b/chromium/chrome/browser/net/cookie_policy_browsertest.cc index d00770b46bc..de6dc9dcba7 100644 --- a/chromium/chrome/browser/net/cookie_policy_browsertest.cc +++ b/chromium/chrome/browser/net/cookie_policy_browsertest.cc @@ -9,6 +9,7 @@ #include "base/strings/stringprintf.h" #include "base/test/scoped_feature_list.h" #include "chrome/browser/content_settings/cookie_settings_factory.h" +#include "chrome/browser/net/storage_test_utils.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" @@ -33,15 +34,6 @@ using content::BrowserThread; namespace { -const std::vector<std::string> kStorageTypes{ - "Cookie", "LocalStorage", "FileSystem", "SessionStorage", "IndexedDb", - "WebSql", "CacheStorage", "ServiceWorker", "CookieStore"}; - -const std::vector<std::string> kCrossTabCommunicationTypes{ - "SharedWorker", - "WebLock", -}; - class CookiePolicyBrowserTest : public InProcessBrowserTest { protected: CookiePolicyBrowserTest() @@ -64,6 +56,11 @@ class CookiePolicyBrowserTest : public InProcessBrowserTest { "CookieStoreDocument"); } + GURL GetURL(const std::string& host) { + GURL url(https_server_.GetURL(host, "/")); + return url; + } + void SetBlockThirdPartyCookies(bool value) { browser()->profile()->GetPrefs()->SetBoolean(prefs::kBlockThirdPartyCookies, value); @@ -89,12 +86,7 @@ class CookiePolicyBrowserTest : public InProcessBrowserTest { } void ExpectFrameContent(const std::string& expected) { - std::string content; - ASSERT_TRUE(ExecuteScriptAndExtractString( - GetFrame(), - "window.domAutomationController.send(document.body.textContent)", - &content)); - EXPECT_EQ(expected, content); + storage::test::ExpectFrameContent(GetFrame(), expected); } void NavigateNestedFrameTo(const std::string& host, const std::string& path) { @@ -110,55 +102,7 @@ class CookiePolicyBrowserTest : public InProcessBrowserTest { } void ExpectNestedFrameContent(const std::string& expected) { - std::string content; - ASSERT_TRUE(ExecuteScriptAndExtractString( - GetNestedFrame(), - "window.domAutomationController.send(document.body.textContent)", - &content)); - EXPECT_EQ(expected, content); - } - - void ExpectCookiesOnHost(const std::string& host, - const std::string& expected) { - EXPECT_EQ(expected, content::GetCookies(browser()->profile(), - https_server_.GetURL(host, "/"))); - } - - void SetStorageForFrame(content::RenderFrameHost* frame) { - for (const auto& data_type : kStorageTypes) { - bool data; - EXPECT_TRUE(content::ExecuteScriptAndExtractBool( - frame, "set" + data_type + "()", &data)); - EXPECT_TRUE(data) << data_type; - } - } - - void ExpectStorageForFrame(content::RenderFrameHost* frame, bool expected) { - for (const auto& data_type : kStorageTypes) { - bool data; - EXPECT_TRUE(content::ExecuteScriptAndExtractBool( - frame, "has" + data_type + "();", &data)); - EXPECT_EQ(expected, data) << data_type; - } - } - - void SetCrossTabInfoForFrame(content::RenderFrameHost* frame) { - for (const auto& data_type : kCrossTabCommunicationTypes) { - bool data; - EXPECT_TRUE(content::ExecuteScriptAndExtractBool( - frame, "set" + data_type + "()", &data)); - EXPECT_TRUE(data) << data_type; - } - } - - void ExpectCrossTabInfoForFrame(content::RenderFrameHost* frame, - bool expected) { - for (const auto& data_type : kCrossTabCommunicationTypes) { - bool data; - EXPECT_TRUE(content::ExecuteScriptAndExtractBool( - frame, "has" + data_type + "();", &data)); - EXPECT_EQ(expected, data) << data_type; - } + storage::test::ExpectFrameContent(GetNestedFrame(), expected); } content::RenderFrameHost* GetFrame() { @@ -230,12 +174,13 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NavigateToPageWithFrame("a.com"); - ExpectCookiesOnHost("b.com", ""); + storage::test::ExpectCookiesOnHost(browser()->profile(), GetURL("b.com"), ""); // Navigate iframe to a cross-site, cookie-setting endpoint, and verify that // the cookie is set: NavigateFrameTo("b.com", "/set-cookie?thirdparty=1;SameSite=None;Secure"); - ExpectCookiesOnHost("b.com", "thirdparty=1"); + storage::test::ExpectCookiesOnHost(browser()->profile(), GetURL("b.com"), + "thirdparty=1"); // Navigate iframe to a cross-site frame with a frame, and navigate _that_ // frame to a cross-site, cookie-setting endpoint, and verify that the cookie @@ -245,7 +190,8 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, // is still cross-site. NavigateNestedFrameTo("b.com", "/set-cookie?thirdparty=2;SameSite=None;Secure"); - ExpectCookiesOnHost("b.com", "thirdparty=2"); + storage::test::ExpectCookiesOnHost(browser()->profile(), GetURL("b.com"), + "thirdparty=2"); // Navigate iframe to a cross-site frame with a frame, and navigate _that_ // frame to a cross-site, cookie-setting endpoint, and verify that the cookie @@ -253,7 +199,8 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NavigateFrameTo("c.com", "/iframe.html"); NavigateNestedFrameTo("b.com", "/set-cookie?thirdparty=3;SameSite=None;Secure"); - ExpectCookiesOnHost("b.com", "thirdparty=3"); + storage::test::ExpectCookiesOnHost(browser()->profile(), GetURL("b.com"), + "thirdparty=3"); } // This test does the same navigations as the test above, so we can be assured @@ -269,7 +216,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, // Navigate iframe to a cross-site, cookie-setting endpoint, and verify that // the cookie is not set: NavigateFrameTo("b.com", "/set-cookie?thirdparty=1;SameSite=None;Secure"); - ExpectCookiesOnHost("b.com", ""); + storage::test::ExpectCookiesOnHost(browser()->profile(), GetURL("b.com"), ""); // Navigate iframe to a cross-site frame with a frame, and navigate _that_ // frame to a cross-site, cookie-setting endpoint, and verify that the cookie @@ -277,7 +224,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("b.com", "/set-cookie?thirdparty=2;SameSite=None;Secure"); - ExpectCookiesOnHost("b.com", ""); + storage::test::ExpectCookiesOnHost(browser()->profile(), GetURL("b.com"), ""); // Navigate iframe to a cross-site frame with a frame, and navigate _that_ // frame to a cross-site, cookie-setting endpoint, and verify that the cookie @@ -285,7 +232,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NavigateFrameTo("c.com", "/iframe.html"); NavigateNestedFrameTo("b.com", "/set-cookie?thirdparty=3;SameSite=None;Secure"); - ExpectCookiesOnHost("b.com", ""); + storage::test::ExpectCookiesOnHost(browser()->profile(), GetURL("b.com"), ""); } IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, @@ -295,7 +242,8 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, // Set a cookie on `b.com`. content::SetCookie(browser()->profile(), https_server_.GetURL("b.com", "/"), "thirdparty=1;SameSite=None;Secure"); - ExpectCookiesOnHost("b.com", "thirdparty=1"); + storage::test::ExpectCookiesOnHost(browser()->profile(), GetURL("b.com"), + "thirdparty=1"); NavigateToPageWithFrame("a.com"); @@ -330,7 +278,8 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, // Set a cookie on `b.com`. content::SetCookie(browser()->profile(), https_server_.GetURL("b.com", "/"), "thirdparty=1;SameSite=None;Secure"); - ExpectCookiesOnHost("b.com", "thirdparty=1"); + storage::test::ExpectCookiesOnHost(browser()->profile(), GetURL("b.com"), + "thirdparty=1"); NavigateToPageWithFrame("a.com"); @@ -361,13 +310,15 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, // Set a cookie on `b.com`. content::SetCookie(browser()->profile(), https_server_.GetURL("b.com", "/"), "thirdparty=1;SameSite=None;Secure"); - ExpectCookiesOnHost("b.com", "thirdparty=1"); + storage::test::ExpectCookiesOnHost(browser()->profile(), GetURL("b.com"), + "thirdparty=1"); // Set a cookie on othersite.com. content::SetCookie(browser()->profile(), https_server_.GetURL("othersite.com", "/"), "thirdparty=other;SameSite=None;Secure"); - ExpectCookiesOnHost("othersite.com", "thirdparty=other"); + storage::test::ExpectCookiesOnHost( + browser()->profile(), GetURL("othersite.com"), "thirdparty=other"); // Allow all requests to b.com to have cookies. // On the other hand, othersite.com does not have an exception set for it. @@ -416,7 +367,8 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, // Set a cookie on `b.com`. content::SetCookie(browser()->profile(), https_server_.GetURL("b.com", "/"), "thirdparty=1;SameSite=None;Secure"); - ExpectCookiesOnHost("b.com", "thirdparty=1"); + storage::test::ExpectCookiesOnHost(browser()->profile(), GetURL("b.com"), + "thirdparty=1"); // Allow all requests on the top frame domain a.com to have cookies. auto cookie_settings = @@ -473,15 +425,15 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, ThirdPartyIFrameStorage) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetFrame(), false); - SetStorageForFrame(GetFrame()); - ExpectStorageForFrame(GetFrame(), true); + storage::test::ExpectStorageForFrame(GetFrame(), false); + storage::test::SetStorageForFrame(GetFrame()); + storage::test::ExpectStorageForFrame(GetFrame(), true); SetBlockThirdPartyCookies(true); NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetFrame(), false); + storage::test::ExpectStorageForFrame(GetFrame(), false); // Allow all requests to b.com to access storage. auto cookie_settings = @@ -493,14 +445,14 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, ThirdPartyIFrameStorage) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetFrame(), true); + storage::test::ExpectStorageForFrame(GetFrame(), true); // Remove ALLOW setting. cookie_settings->ResetCookieSetting(b_url); NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetFrame(), false); + storage::test::ExpectStorageForFrame(GetFrame(), false); // Allow all third-parties on a.com to access storage. cookie_settings->SetThirdPartyCookieSetting( @@ -508,7 +460,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, ThirdPartyIFrameStorage) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetFrame(), true); + storage::test::ExpectStorageForFrame(GetFrame(), true); } IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NestedThirdPartyIFrameStorage) { @@ -516,16 +468,16 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NestedThirdPartyIFrameStorage) { NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("c.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetNestedFrame(), false); - SetStorageForFrame(GetNestedFrame()); - ExpectStorageForFrame(GetNestedFrame(), true); + storage::test::ExpectStorageForFrame(GetNestedFrame(), false); + storage::test::SetStorageForFrame(GetNestedFrame()); + storage::test::ExpectStorageForFrame(GetNestedFrame(), true); SetBlockThirdPartyCookies(true); NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("c.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetNestedFrame(), false); + storage::test::ExpectStorageForFrame(GetNestedFrame(), false); // Allow all requests to b.com to access storage. auto cookie_settings = @@ -538,7 +490,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NestedThirdPartyIFrameStorage) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("c.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetNestedFrame(), true); + storage::test::ExpectStorageForFrame(GetNestedFrame(), true); // Remove ALLOW setting. cookie_settings->ResetCookieSetting(c_url); @@ -546,7 +498,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NestedThirdPartyIFrameStorage) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("c.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetNestedFrame(), false); + storage::test::ExpectStorageForFrame(GetNestedFrame(), false); // Allow all third-parties on a.com to access storage. cookie_settings->SetThirdPartyCookieSetting( @@ -555,7 +507,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NestedThirdPartyIFrameStorage) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("c.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetNestedFrame(), true); + storage::test::ExpectStorageForFrame(GetNestedFrame(), true); } IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NestedFirstPartyIFrameStorage) { @@ -563,16 +515,16 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NestedFirstPartyIFrameStorage) { NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("a.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetNestedFrame(), false); - SetStorageForFrame(GetNestedFrame()); - ExpectStorageForFrame(GetNestedFrame(), true); + storage::test::ExpectStorageForFrame(GetNestedFrame(), false); + storage::test::SetStorageForFrame(GetNestedFrame()); + storage::test::ExpectStorageForFrame(GetNestedFrame(), true); SetBlockThirdPartyCookies(true); NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("a.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetNestedFrame(), false); + storage::test::ExpectStorageForFrame(GetNestedFrame(), false); // Allow all requests to b.com to access storage. auto cookie_settings = @@ -584,7 +536,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NestedFirstPartyIFrameStorage) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("a.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetNestedFrame(), true); + storage::test::ExpectStorageForFrame(GetNestedFrame(), true); // Remove ALLOW setting. cookie_settings->ResetCookieSetting(a_url); @@ -592,7 +544,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NestedFirstPartyIFrameStorage) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("a.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetNestedFrame(), false); + storage::test::ExpectStorageForFrame(GetNestedFrame(), false); // Allow all third-parties on a.com to access storage. cookie_settings->SetThirdPartyCookieSetting( @@ -601,7 +553,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, NestedFirstPartyIFrameStorage) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("a.com", "/browsing_data/site_data.html"); - ExpectStorageForFrame(GetNestedFrame(), true); + storage::test::ExpectStorageForFrame(GetNestedFrame(), true); } // Test third-party cookie blocking of features that allow to communicate @@ -610,20 +562,20 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, MultiTabTest) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/browsing_data/site_data.html"); - ExpectCrossTabInfoForFrame(GetFrame(), false); - SetCrossTabInfoForFrame(GetFrame()); - ExpectCrossTabInfoForFrame(GetFrame(), true); + storage::test::ExpectCrossTabInfoForFrame(GetFrame(), false); + storage::test::SetCrossTabInfoForFrame(GetFrame()); + storage::test::ExpectCrossTabInfoForFrame(GetFrame(), true); // Create a second tab to test communication between tabs. NavigateToNewTabWithFrame("a.com"); NavigateFrameTo("b.com", "/browsing_data/site_data.html"); - ExpectCrossTabInfoForFrame(GetFrame(), true); + storage::test::ExpectCrossTabInfoForFrame(GetFrame(), true); SetBlockThirdPartyCookies(true); NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/browsing_data/site_data.html"); - ExpectCrossTabInfoForFrame(GetFrame(), false); + storage::test::ExpectCrossTabInfoForFrame(GetFrame(), false); // Allow all requests to b.com to access cookies. auto cookie_settings = @@ -635,14 +587,14 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, MultiTabTest) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/browsing_data/site_data.html"); - ExpectCrossTabInfoForFrame(GetFrame(), true); + storage::test::ExpectCrossTabInfoForFrame(GetFrame(), true); // Remove ALLOW setting. cookie_settings->ResetCookieSetting(b_url); NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/browsing_data/site_data.html"); - ExpectCrossTabInfoForFrame(GetFrame(), false); + storage::test::ExpectCrossTabInfoForFrame(GetFrame(), false); // Allow all third-parties on a.com to access cookies. cookie_settings->SetThirdPartyCookieSetting( @@ -650,7 +602,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, MultiTabTest) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/browsing_data/site_data.html"); - ExpectCrossTabInfoForFrame(GetFrame(), true); + storage::test::ExpectCrossTabInfoForFrame(GetFrame(), true); } // Same as MultiTabTest but with a nested frame on a.com inside a b.com frame. @@ -661,22 +613,22 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, MultiTabNestedTest) { NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("a.com", "/browsing_data/site_data.html"); - ExpectCrossTabInfoForFrame(GetNestedFrame(), false); - SetCrossTabInfoForFrame(GetNestedFrame()); - ExpectCrossTabInfoForFrame(GetNestedFrame(), true); + storage::test::ExpectCrossTabInfoForFrame(GetNestedFrame(), false); + storage::test::SetCrossTabInfoForFrame(GetNestedFrame()); + storage::test::ExpectCrossTabInfoForFrame(GetNestedFrame(), true); // Create a second tab to test communication between tabs. NavigateToNewTabWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("a.com", "/browsing_data/site_data.html"); - ExpectCrossTabInfoForFrame(GetNestedFrame(), true); + storage::test::ExpectCrossTabInfoForFrame(GetNestedFrame(), true); SetBlockThirdPartyCookies(true); NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("a.com", "/browsing_data/site_data.html"); - ExpectCrossTabInfoForFrame(GetNestedFrame(), false); + storage::test::ExpectCrossTabInfoForFrame(GetNestedFrame(), false); // Allow all requests to a.com to access cookies. auto cookie_settings = @@ -688,7 +640,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, MultiTabNestedTest) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("a.com", "/browsing_data/site_data.html"); - ExpectCrossTabInfoForFrame(GetNestedFrame(), true); + storage::test::ExpectCrossTabInfoForFrame(GetNestedFrame(), true); // Remove ALLOW setting. cookie_settings->ResetCookieSetting(a_url); @@ -696,7 +648,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, MultiTabNestedTest) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("a.com", "/browsing_data/site_data.html"); - ExpectCrossTabInfoForFrame(GetNestedFrame(), false); + storage::test::ExpectCrossTabInfoForFrame(GetNestedFrame(), false); // Allow all third-parties on a.com to access cookies. cookie_settings->SetThirdPartyCookieSetting( @@ -705,7 +657,7 @@ IN_PROC_BROWSER_TEST_F(CookiePolicyBrowserTest, MultiTabNestedTest) { NavigateToPageWithFrame("a.com"); NavigateFrameTo("b.com", "/iframe.html"); NavigateNestedFrameTo("a.com", "/browsing_data/site_data.html"); - ExpectCrossTabInfoForFrame(GetNestedFrame(), true); + storage::test::ExpectCrossTabInfoForFrame(GetNestedFrame(), true); } } // namespace diff --git a/chromium/chrome/browser/net/dns_over_https_browsertest.cc b/chromium/chrome/browser/net/dns_over_https_browsertest.cc index 4ae5b153e3e..0d4ce20c7d3 100644 --- a/chromium/chrome/browser/net/dns_over_https_browsertest.cc +++ b/chromium/chrome/browser/net/dns_over_https_browsertest.cc @@ -3,6 +3,9 @@ // found in the LICENSE file. #include "base/test/scoped_feature_list.h" +#include "chrome/browser/net/secure_dns_config.h" +#include "chrome/browser/net/stub_resolver_config_reader.h" +#include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_features.h" #include "chrome/test/base/in_process_browser_test.h" @@ -10,7 +13,7 @@ #include "content/public/common/content_features.h" #include "content/public/test/browser_test.h" #include "content/public/test/test_navigation_observer.h" -#include "net/dns/public/doh_provider_list.h" +#include "net/dns/public/doh_provider_entry.h" #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" @@ -29,10 +32,9 @@ struct DohParameter { std::vector<DohParameter> GetDohServerTestCases() { std::vector<DohParameter> doh_test_cases; - const auto& doh_providers = net::GetDohProviderList(); - for (const auto& doh_provider : doh_providers) { - doh_test_cases.emplace_back(doh_provider.provider, - doh_provider.dns_over_https_template, true); + for (const auto* entry : net::DohProviderEntry::GetList()) { + doh_test_cases.emplace_back(entry->provider, entry->dns_over_https_template, + true); } // Negative test-case doh_test_cases.emplace_back("NegativeTestExampleCom", @@ -64,6 +66,13 @@ class DohBrowserTest : public InProcessBrowserTest, }; IN_PROC_BROWSER_TEST_P(DohBrowserTest, MANUAL_ExternalDohServers) { + SecureDnsConfig secure_dns_config = + SystemNetworkContextManager::GetStubResolverConfigReader() + ->GetSecureDnsConfiguration( + false /* force_check_parental_controls_for_automatic_mode */); + // Ensure that DoH is enabled in secure mode + EXPECT_EQ(net::DnsConfig::SecureDnsMode::SECURE, secure_dns_config.mode()); + content::TestNavigationObserver nav_observer( browser()->tab_strip_model()->GetActiveWebContents(), 1); EXPECT_TRUE(ui_test_utils::NavigateToURL(browser(), test_url_)); diff --git a/chromium/chrome/browser/net/dns_probe_browsertest.cc b/chromium/chrome/browser/net/dns_probe_browsertest.cc index b6f1bbf6687..c73735d92b3 100644 --- a/chromium/chrome/browser/net/dns_probe_browsertest.cc +++ b/chromium/chrome/browser/net/dns_probe_browsertest.cc @@ -8,7 +8,6 @@ #include "base/bind.h" #include "base/path_service.h" #include "base/run_loop.h" -#include "base/task/post_task.h" #include "base/threading/thread_restrictions.h" #include "base/time/default_tick_clock.h" #include "build/build_config.h" @@ -73,7 +72,7 @@ namespace { // base::PostTask returns a bool, it can't directly be posted to // another thread. void RunClosureOnUIThread(const base::Closure& closure) { - base::PostTask(FROM_HERE, {BrowserThread::UI}, closure); + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, closure); } // Wraps DnsProbeService and delays probes until someone calls @@ -424,8 +423,8 @@ class DnsProbeBrowserTest : public InProcessBrowserTest { DnsProbeBrowserTest::DnsProbeBrowserTest() : helper_(new DnsProbeBrowserTestIOThreadHelper()), - active_browser_(NULL), - monitored_tab_helper_(NULL) { + active_browser_(nullptr), + monitored_tab_helper_(nullptr) { NavigationCorrectionTabObserver::SetAllowEnableCorrectionsForTesting(true); } @@ -441,8 +440,8 @@ void DnsProbeBrowserTest::SetUpOnMainThread() { browser()->profile()->GetPrefs()->SetBoolean( embedder_support::kAlternateErrorPagesEnabled, true); - base::PostTask(FROM_HERE, {BrowserThread::IO}, - BindOnce(&DnsProbeBrowserTestIOThreadHelper::SetUpOnIOThread, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, BindOnce(&DnsProbeBrowserTestIOThreadHelper::SetUpOnIOThread, Unretained(helper_))); ASSERT_TRUE(embedded_test_server()->Start()); @@ -455,8 +454,8 @@ void DnsProbeBrowserTest::SetUpOnMainThread() { } void DnsProbeBrowserTest::TearDownOnMainThread() { - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, BindOnce( &DnsProbeBrowserTestIOThreadHelper::CleanUpOnIOThreadAndDeleteHelper, Unretained(helper_))); @@ -521,16 +520,16 @@ void DnsProbeBrowserTest::SetFakeHostResolverResults( void DnsProbeBrowserTest::SetCorrectionServiceBroken(bool broken) { int net_error = broken ? net::ERR_NAME_NOT_RESOLVED : net::OK; - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, BindOnce(&DnsProbeBrowserTestIOThreadHelper::SetCorrectionServiceNetError, Unretained(helper_), net_error)); } void DnsProbeBrowserTest::SetCorrectionServiceDelayRequests( bool delay_requests) { - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, BindOnce( &DnsProbeBrowserTestIOThreadHelper::SetCorrectionServiceDelayRequests, Unretained(helper_), delay_requests)); @@ -538,8 +537,8 @@ void DnsProbeBrowserTest::SetCorrectionServiceDelayRequests( void DnsProbeBrowserTest::WaitForDelayedRequestDestruction() { base::RunLoop run_loop; - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, BindOnce( &DnsProbeBrowserTestIOThreadHelper::SetRequestDestructionCallback, Unretained(helper_), diff --git a/chromium/chrome/browser/net/errorpage_browsertest.cc b/chromium/chrome/browser/net/errorpage_browsertest.cc index d7f97d43a70..08da4073684 100644 --- a/chromium/chrome/browser/net/errorpage_browsertest.cc +++ b/chromium/chrome/browser/net/errorpage_browsertest.cc @@ -22,6 +22,8 @@ #include "base/strings/utf_string_conversions.h" #include "base/synchronization/lock.h" #include "base/task/post_task.h" +#include "base/test/test_timeouts.h" +#include "base/threading/platform_thread.h" #include "base/threading/thread_restrictions.h" #include "base/values.h" #include "build/build_config.h" @@ -52,6 +54,7 @@ #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/browsing_data_remover.h" +#include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_handle.h" #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_types.h" @@ -69,7 +72,6 @@ #include "net/base/filename_util.h" #include "net/base/net_errors.h" #include "net/dns/mock_host_resolver.h" -#include "net/http/failing_http_transaction_factory.h" #include "net/http/http_cache.h" #include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/http_request.h" @@ -343,8 +345,8 @@ class DNSErrorPageTest : public ErrorPageTest { EXPECT_EQ(origin, "null"); // Send RequestCreated so that anyone blocking on // WaitForRequests can continue. - base::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&DNSErrorPageTest::RequestCreated, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&DNSErrorPageTest::RequestCreated, base::Unretained(owner))); content::URLLoaderInterceptor::WriteResponse( "chrome/test/data/mock-link-doctor.json", @@ -1117,6 +1119,41 @@ IN_PROC_BROWSER_TEST_F(ErrorPageAutoReloadTest, IgnoresSameDocumentNavigation) { EXPECT_EQ(3, interceptor_requests()); } +// Make sure that an error page that is providing it's own HTML has auto-reloads +// disabled. +IN_PROC_BROWSER_TEST_F(ErrorPageAutoReloadTest, + CustomErrorPageDoesNotAutoReload) { + ASSERT_TRUE(embedded_test_server()->Start()); + GURL test_url = embedded_test_server()->base_url(); + // Navigate to the test site without installing the interceptor so it + // succeeds. + ui_test_utils::NavigateToURL(browser(), test_url); + // Install an interceptor so we can check there was no reload. + InstallInterceptor(test_url, 10); + // Trigger a custom error page and wait for it to load. + content::WebContents* web_contents = + browser()->tab_strip_model()->GetActiveWebContents(); + content::TestNavigationObserver error_observer(web_contents); + web_contents->GetController().LoadPostCommitErrorPage( + web_contents->GetMainFrame(), test_url, "error html", + net::ERR_CONNECTION_RESET); + // Wait for the custom error page to load. + error_observer.Wait(); + // Wait for a short time (since the first reload would happen immediately + // after the error loads), after that we should see no interceptor requests or + // failures for reloads, since this error page shouldn't reload. + base::PlatformThread::Sleep(TestTimeouts::tiny_timeout()); + EXPECT_EQ(0, interceptor_failures()); + EXPECT_EQ(0, interceptor_requests()); + + // Navigate to the page manually, this will trigger a regular error page, make + // sure autoreloads are enabled at this point. + ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), test_url, + 2); + EXPECT_EQ(2, interceptor_failures()); + EXPECT_EQ(2, interceptor_requests()); +} + // A test fixture that returns ERR_ADDRESS_UNREACHABLE for all navigation // correction requests. ERR_NAME_NOT_RESOLVED is more typical, but need to use // a different error for the correction service and the original page to diff --git a/chromium/chrome/browser/net/net_error_tab_helper.cc b/chromium/chrome/browser/net/net_error_tab_helper.cc index 7f17b1aaa04..3477bb6fbec 100644 --- a/chromium/chrome/browser/net/net_error_tab_helper.cc +++ b/chromium/chrome/browser/net/net_error_tab_helper.cc @@ -71,19 +71,6 @@ void NetErrorTabHelper::RenderFrameCreated( CanShowNetworkDiagnosticsDialog(web_contents())); } -void NetErrorTabHelper::DidStartNavigation( - content::NavigationHandle* navigation_handle) { - if (!navigation_handle->IsInMainFrame()) - return; - - if (navigation_handle->IsErrorPage() && - PageTransitionCoreTypeIs(navigation_handle->GetPageTransition(), - ui::PAGE_TRANSITION_RELOAD)) { - error_page::RecordEvent( - error_page::NETWORK_ERROR_PAGE_BROWSER_INITIATED_RELOAD); - } -} - void NetErrorTabHelper::DidFinishNavigation( content::NavigationHandle* navigation_handle) { if (!navigation_handle->IsInMainFrame()) @@ -112,31 +99,33 @@ void NetErrorTabHelper::DidFinishNavigation( } } -bool NetErrorTabHelper::OnMessageReceived( - const IPC::Message& message, - content::RenderFrameHost* render_frame_host) { - if (render_frame_host != web_contents()->GetMainFrame()) - return false; #if BUILDFLAG(ENABLE_OFFLINE_PAGES) - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(NetErrorTabHelper, message) - IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DownloadPageLater, - OnDownloadPageLater) - IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetIsShowingDownloadButtonInErrorPage, - OnSetIsShowingDownloadButtonInErrorPage) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - - return handled; -#else - return false; -#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) +void NetErrorTabHelper::DownloadPageLater() { + // Makes sure that this is coming from an error page. + content::NavigationEntry* entry = + web_contents()->GetController().GetLastCommittedEntry(); + if (!entry || entry->GetPageType() != content::PAGE_TYPE_ERROR) + return; + + // Only download the page for HTTP/HTTPS URLs. + GURL url(entry->GetVirtualURL()); + if (!url.SchemeIsHTTPOrHTTPS()) + return; + + DownloadPageLaterHelper(url); } +void NetErrorTabHelper::SetIsShowingDownloadButtonInErrorPage( + bool showing_download_button) { + is_showing_download_button_in_error_page_ = showing_download_button; +} +#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) + NetErrorTabHelper::NetErrorTabHelper(WebContents* contents) : WebContentsObserver(contents), network_diagnostics_receivers_(contents, this), network_easter_egg_receivers_(contents, this), + net_error_page_support_(contents, this), is_error_page_(false), dns_error_active_(false), dns_error_page_committed_(false), @@ -190,28 +179,6 @@ void NetErrorTabHelper::OnDnsProbeFinished(DnsProbeStatus result) { SendInfo(); } -#if BUILDFLAG(ENABLE_OFFLINE_PAGES) -void NetErrorTabHelper::OnDownloadPageLater() { - // Makes sure that this is coming from an error page. - content::NavigationEntry* entry = - web_contents()->GetController().GetLastCommittedEntry(); - if (!entry || entry->GetPageType() != content::PAGE_TYPE_ERROR) - return; - - // Only download the page for HTTP/HTTPS URLs. - GURL url(entry->GetVirtualURL()); - if (!url.SchemeIsHTTPOrHTTPS()) - return; - - DownloadPageLaterHelper(url); -} - -void NetErrorTabHelper::OnSetIsShowingDownloadButtonInErrorPage( - bool is_showing_download_button) { - is_showing_download_button_in_error_page_ = is_showing_download_button; -} -#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) - // static void NetErrorTabHelper::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable* prefs) { diff --git a/chromium/chrome/browser/net/net_error_tab_helper.h b/chromium/chrome/browser/net/net_error_tab_helper.h index 5ff174b969f..7062c1da29b 100644 --- a/chromium/chrome/browser/net/net_error_tab_helper.h +++ b/chromium/chrome/browser/net/net_error_tab_helper.h @@ -12,6 +12,7 @@ #include "base/macros.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/net/dns_probe_service.h" +#include "chrome/common/net/net_error_page_support.mojom.h" #include "chrome/common/network_diagnostics.mojom.h" #include "chrome/common/network_easter_egg.mojom.h" #include "components/error_page/common/net_error_info.h" @@ -34,6 +35,7 @@ namespace chrome_browser_net { class NetErrorTabHelper : public content::WebContentsObserver, public content::WebContentsUserData<NetErrorTabHelper>, + public chrome::mojom::NetErrorPageSupport, public chrome::mojom::NetworkDiagnostics, public chrome::mojom::NetworkEasterEgg { public: @@ -68,12 +70,15 @@ class NetErrorTabHelper // content::WebContentsObserver implementation. void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; - void DidStartNavigation( - content::NavigationHandle* navigation_handle) override; void DidFinishNavigation( content::NavigationHandle* navigation_handle) override; - bool OnMessageReceived(const IPC::Message& message, - content::RenderFrameHost* render_frame_host) override; + + // chrome::mojom::NetErrorPageSupport: +#if BUILDFLAG(ENABLE_OFFLINE_PAGES) + void DownloadPageLater() override; + void SetIsShowingDownloadButtonInErrorPage( + bool showing_download_button) override; +#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) protected: // |contents| is the WebContents of the tab this NetErrorTabHelper is @@ -92,11 +97,6 @@ class NetErrorTabHelper return network_diagnostics_receivers_; } -#if BUILDFLAG(ENABLE_OFFLINE_PAGES) - void OnDownloadPageLater(); - void OnSetIsShowingDownloadButtonInErrorPage(bool is_showing_download_button); -#endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) - private: friend class content::WebContentsUserData<NetErrorTabHelper>; @@ -126,6 +126,8 @@ class NetErrorTabHelper network_diagnostics_receivers_; content::WebContentsFrameReceiverSet<chrome::mojom::NetworkEasterEgg> network_easter_egg_receivers_; + content::WebContentsFrameReceiverSet<chrome::mojom::NetErrorPageSupport> + net_error_page_support_; // True if the last provisional load that started was for an error page. bool is_error_page_; diff --git a/chromium/chrome/browser/net/net_error_tab_helper_unittest.cc b/chromium/chrome/browser/net/net_error_tab_helper_unittest.cc index fef66fcfe7f..cf5dc2537e6 100644 --- a/chromium/chrome/browser/net/net_error_tab_helper_unittest.cc +++ b/chromium/chrome/browser/net/net_error_tab_helper_unittest.cc @@ -45,7 +45,7 @@ class TestNetErrorTabHelper : public NetErrorTabHelper { int mock_sent_count() const { return mock_sent_count_; } #if BUILDFLAG(ENABLE_OFFLINE_PAGES) - using NetErrorTabHelper::OnDownloadPageLater; + using NetErrorTabHelper::DownloadPageLater; const GURL& download_page_later_url() const { return download_page_later_url_; @@ -169,7 +169,7 @@ class NetErrorTabHelperTest : public ChromeRenderViewHostTestHarness { bool succeeded) { GURL url(url_string); LoadURL(url, succeeded); - tab_helper()->OnDownloadPageLater(); + tab_helper()->DownloadPageLater(); EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked()); } #endif // BUILDFLAG(ENABLE_OFFLINE_PAGES) @@ -370,7 +370,7 @@ TEST_F(NetErrorTabHelperTest, NoDiagnosticsForNonHttpSchemes) { TEST_F(NetErrorTabHelperTest, DownloadPageLater) { GURL url("http://somewhere:123/"); LoadURL(url, false /*succeeded*/); - tab_helper()->OnDownloadPageLater(); + tab_helper()->DownloadPageLater(); EXPECT_EQ(url, tab_helper()->download_page_later_url()); EXPECT_EQ(1, tab_helper()->times_download_page_later_invoked()); } @@ -378,7 +378,7 @@ TEST_F(NetErrorTabHelperTest, DownloadPageLater) { TEST_F(NetErrorTabHelperTest, NoDownloadPageLaterOnNonErrorPage) { GURL url("http://somewhere:123/"); LoadURL(url, true /*succeeded*/); - tab_helper()->OnDownloadPageLater(); + tab_helper()->DownloadPageLater(); EXPECT_EQ(0, tab_helper()->times_download_page_later_invoked()); } diff --git a/chromium/chrome/browser/net/network_context_configuration_browsertest.cc b/chromium/chrome/browser/net/network_context_configuration_browsertest.cc index e297441ad05..f40e582ca2c 100644 --- a/chromium/chrome/browser/net/network_context_configuration_browsertest.cc +++ b/chromium/chrome/browser/net/network_context_configuration_browsertest.cc @@ -434,7 +434,7 @@ class NetworkContextConfigurationBrowserTest case NetworkContextType::kOnDiskAppWithIncognitoProfile: // Incognito actually uses the non-incognito prefs, so this should end // up being the same pref store as in the KProfile case. - return browser()->profile()->GetOffTheRecordProfile()->GetPrefs(); + return browser()->profile()->GetPrimaryOTRProfile()->GetPrefs(); } } @@ -463,7 +463,7 @@ class NetworkContextConfigurationBrowserTest case NetworkContextType::kIncognitoProfile: case NetworkContextType::kOnDiskAppWithIncognitoProfile: ProfileNetworkContextServiceFactory::GetForContext( - browser()->profile()->GetOffTheRecordProfile()) + browser()->profile()->GetPrimaryOTRProfile()) ->FlushProxyConfigMonitorForTesting(); break; } @@ -633,8 +633,8 @@ class NetworkContextConfigurationBrowserTest url, net::CookieOptions::MakeAllInclusive(), base::BindOnce( [](std::string* cookies_out, base::RunLoop* run_loop, - const net::CookieStatusList& cookies, - const net::CookieStatusList& excluded_cookies) { + const net::CookieAccessResultList& cookies, + const net::CookieAccessResultList& excluded_cookies) { *cookies_out = net::CanonicalCookie::BuildCookieLine(cookies); run_loop->Quit(); }, @@ -1386,17 +1386,26 @@ IN_PROC_BROWSER_TEST_P(NetworkContextConfigurationBrowserTest, FlushNetworkInterface(); std::string accept_language2, user_agent2; ASSERT_TRUE(FetchHeaderEcho("accept-language", &accept_language2)); - EXPECT_EQ(system ? kNoAcceptLanguage : "uk", accept_language2); + if (GetProfile()->IsOffTheRecord()) { + EXPECT_EQ(system ? kNoAcceptLanguage : "en-US,en;q=0.9", accept_language2); + } else { + EXPECT_EQ(system ? kNoAcceptLanguage : "uk", accept_language2); + } ASSERT_TRUE(FetchHeaderEcho("user-agent", &user_agent2)); EXPECT_EQ(::GetUserAgent(), user_agent2); // Try a more complicated one, with multiple languages. browser()->profile()->GetPrefs()->SetString(language::prefs::kAcceptLanguages, - "uk, en_US"); + "uk, en-US"); FlushNetworkInterface(); std::string accept_language3, user_agent3; ASSERT_TRUE(FetchHeaderEcho("accept-language", &accept_language3)); - EXPECT_EQ(system ? kNoAcceptLanguage : "uk,en_US;q=0.9", accept_language3); + if (GetProfile()->IsOffTheRecord()) { + EXPECT_EQ(system ? kNoAcceptLanguage : "en-US,en;q=0.9", accept_language3); + } else { + EXPECT_EQ(system ? kNoAcceptLanguage : "uk,en-US;q=0.9,en;q=0.8", + accept_language3); + } ASSERT_TRUE(FetchHeaderEcho("user-agent", &user_agent3)); EXPECT_EQ(::GetUserAgent(), user_agent3); } diff --git a/chromium/chrome/browser/net/network_quality_estimator_prefs_browsertest.cc b/chromium/chrome/browser/net/network_quality_estimator_prefs_browsertest.cc index d2b15b52a4e..dbebc7d6f1e 100644 --- a/chromium/chrome/browser/net/network_quality_estimator_prefs_browsertest.cc +++ b/chromium/chrome/browser/net/network_quality_estimator_prefs_browsertest.cc @@ -20,13 +20,13 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process_impl.h" #include "chrome/browser/chrome_content_browser_client.h" -#include "chrome/browser/metrics/subprocess_metrics_provider.h" #include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/url_constants.h" #include "chrome/test/base/in_process_browser_test.h" +#include "components/metrics/content/subprocess_metrics_provider.h" #include "components/prefs/json_pref_store.h" #include "components/prefs/pref_service.h" #include "content/public/browser/browser_context.h" @@ -71,7 +71,7 @@ void RetryForHistogramUntilCountReached(base::HistogramTester* histogram_tester, if (total_count >= count) return; content::FetchHistogramsFromChildProcesses(); - SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); + metrics::SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); base::RunLoop().RunUntilIdle(); } } @@ -195,6 +195,8 @@ IN_PROC_BROWSER_TEST_F(NetworkQualityEstimatorPrefsBrowserTest, mojo::PendingRemote<network::mojom::NetworkContext> network_context; network::mojom::NetworkContextParamsPtr context_params = network::mojom::NetworkContextParams::New(); + context_params->cert_verifier_params = content::GetCertVerifierParams( + network::mojom::CertVerifierCreationParams::New()); context_params->http_server_properties_path = browser()->profile()->GetPath().Append( FILE_PATH_LITERAL("Temp Network Persistent State")); diff --git a/chromium/chrome/browser/net/network_quality_tracker_browsertest.cc b/chromium/chrome/browser/net/network_quality_tracker_browsertest.cc index b1bb02b14b0..64281e9daa9 100644 --- a/chromium/chrome/browser/net/network_quality_tracker_browsertest.cc +++ b/chromium/chrome/browser/net/network_quality_tracker_browsertest.cc @@ -7,7 +7,6 @@ #include "base/deferred_sequenced_task_runner.h" #include "base/macros.h" #include "base/run_loop.h" -#include "base/task/post_task.h" #include "base/test/scoped_feature_list.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process_impl.h" @@ -17,6 +16,7 @@ #include "chrome/browser/ui/browser.h" #include "chrome/test/base/in_process_browser_test.h" #include "content/public/browser/browser_task_traits.h" +#include "content/public/browser/browser_thread.h" #include "content/public/browser/network_service_instance.h" #include "content/public/browser/storage_partition.h" #include "content/public/common/network_service_util.h" @@ -122,7 +122,7 @@ class NetworkQualityTrackerBrowserTest : public InProcessBrowserTest { void SimulateNetworkQualityChange(net::EffectiveConnectionType type) { if (!content::IsOutOfProcessNetworkService()) { scoped_refptr<base::SequencedTaskRunner> task_runner = - base::CreateSequencedTaskRunner({content::BrowserThread::IO}); + content::GetIOThreadTaskRunner({}); if (content::IsInProcessNetworkService()) task_runner = content::GetNetworkTaskRunner(); task_runner->PostTask( diff --git a/chromium/chrome/browser/net/network_request_metrics_browsertest.cc b/chromium/chrome/browser/net/network_request_metrics_browsertest.cc index ae08cdc870e..c002cd77d7e 100644 --- a/chromium/chrome/browser/net/network_request_metrics_browsertest.cc +++ b/chromium/chrome/browser/net/network_request_metrics_browsertest.cc @@ -17,7 +17,6 @@ #include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/thread_restrictions.h" #include "chrome/browser/download/download_prefs.h" -#include "chrome/browser/metrics/subprocess_metrics_provider.h" #include "chrome/browser/predictors/loading_predictor_config.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" @@ -26,6 +25,7 @@ #include "chrome/common/pref_names.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" +#include "components/metrics/content/subprocess_metrics_provider.h" #include "components/prefs/pref_service.h" #include "content/public/browser/web_contents_observer.h" #include "content/public/test/browser_test.h" @@ -181,7 +181,7 @@ class NetworkRequestMetricsBrowserTest NetworkAccessed network_accessed) { // Some metrics may come from the renderer. This call ensures that those // metrics are available. - SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); + metrics::SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); if (GetParam() == RequestType::kMainFrame) { histograms_->ExpectTotalCount("Net.ErrorCodesForImages2", 0); @@ -268,7 +268,7 @@ class NetworkRequestMetricsBrowserTest void CheckHistogramsAfterMainFrameInterruption() { // Some metrics may come from the renderer. This call ensures that those // metrics are available. - SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); + metrics::SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); if (GetParam() == RequestType::kMainFrame) { // Can't check Net.ErrorCodesForSubresources3, due to the favicon, which @@ -511,7 +511,7 @@ IN_PROC_BROWSER_TEST_P(NetworkRequestMetricsBrowserTest, Download) { // Some metrics may come from the renderer. This call ensures that those // metrics are available. - SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); + metrics::SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); if (GetParam() == RequestType::kMainFrame) { histograms()->ExpectTotalCount("Net.ErrorCodesForImages2", 0); diff --git a/chromium/chrome/browser/net/nss_context.cc b/chromium/chrome/browser/net/nss_context.cc index 67aa6bf89ef..d328c9d82c4 100644 --- a/chromium/chrome/browser/net/nss_context.cc +++ b/chromium/chrome/browser/net/nss_context.cc @@ -7,7 +7,6 @@ #include "base/bind.h" #include "base/sequenced_task_runner.h" #include "base/single_thread_task_runner.h" -#include "base/task/post_task.h" #include "base/threading/thread_task_runner_handle.h" #include "chrome/browser/profiles/profile.h" #include "content/public/browser/browser_task_traits.h" @@ -52,8 +51,8 @@ void GetNSSCertDatabaseForProfile( const base::Callback<void(net::NSSCertDatabase*)>& callback) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - base::PostTask( - FROM_HERE, {BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&GetCertDBOnIOThread, profile->GetResourceContext(), base::ThreadTaskRunnerHandle::Get(), callback)); } diff --git a/chromium/chrome/browser/net/nss_context_chromeos_browsertest.cc b/chromium/chrome/browser/net/nss_context_chromeos_browsertest.cc index 833a109b11d..beab33cf71b 100644 --- a/chromium/chrome/browser/net/nss_context_chromeos_browsertest.cc +++ b/chromium/chrome/browser/net/nss_context_chromeos_browsertest.cc @@ -8,7 +8,6 @@ #include "base/bind.h" #include "base/run_loop.h" -#include "base/task/post_task.h" #include "chrome/browser/chromeos/login/login_manager_test.h" #include "chrome/browser/chromeos/login/test/login_manager_mixin.h" #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" @@ -39,8 +38,8 @@ class DBTester { // Returns true if the database was retrieved successfully. bool DoGetDBTests() { base::RunLoop run_loop; - base::PostTask( - FROM_HERE, {content::BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&DBTester::GetDBAndDoTestsOnIOThread, base::Unretained(this), profile_->GetResourceContext(), run_loop.QuitClosure())); @@ -51,8 +50,8 @@ class DBTester { // Test retrieving the database again, should be called after DoGetDBTests. void DoGetDBAgainTests() { base::RunLoop run_loop; - base::PostTask( - FROM_HERE, {content::BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&DBTester::DoGetDBAgainTestsOnIOThread, base::Unretained(this), profile_->GetResourceContext(), run_loop.QuitClosure())); @@ -92,7 +91,7 @@ class DBTester { EXPECT_EQ(db->GetPublicSlot().get(), db->GetPrivateSlot().get()); } - base::PostTask(FROM_HERE, {content::BrowserThread::UI}, done_callback); + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, done_callback); } void DoGetDBAgainTestsOnIOThread(content::ResourceContext* context, @@ -104,7 +103,7 @@ class DBTester { // Should return the same db as before. EXPECT_EQ(db_, db); - base::PostTask(FROM_HERE, {content::BrowserThread::UI}, done_callback); + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, done_callback); } Profile* profile_; diff --git a/chromium/chrome/browser/net/probe_message.cc b/chromium/chrome/browser/net/probe_message.cc index 4ab7e3e28ee..597aee11228 100644 --- a/chromium/chrome/browser/net/probe_message.cc +++ b/chromium/chrome/browser/net/probe_message.cc @@ -8,6 +8,7 @@ #include <string> +#include "base/check_op.h" #include "base/logging.h" namespace chrome_browser_net { diff --git a/chromium/chrome/browser/net/profile_network_context_service.cc b/chromium/chrome/browser/net/profile_network_context_service.cc index 75a5ee19235..b409f1bd146 100644 --- a/chromium/chrome/browser/net/profile_network_context_service.cc +++ b/chromium/chrome/browser/net/profile_network_context_service.cc @@ -7,14 +7,15 @@ #include <string> #include "base/bind.h" +#include "base/check_op.h" #include "base/command_line.h" #include "base/feature_list.h" #include "base/files/file_path.h" #include "base/files/file_util.h" -#include "base/logging.h" #include "base/metrics/field_trial.h" #include "base/metrics/field_trial_params.h" #include "base/metrics/histogram_macros.h" +#include "base/notreached.h" #include "base/strings/string_split.h" #include "base/task/post_task.h" #include "base/task/thread_pool.h" @@ -35,6 +36,7 @@ #include "components/certificate_transparency/pref_names.h" #include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/language/core/browser/pref_names.h" +#include "components/language/core/common/locale_util.h" #include "components/metrics/metrics_pref_names.h" #include "components/pref_registry/pref_registry_syncable.h" #include "components/prefs/pref_registry_simple.h" @@ -111,9 +113,7 @@ std::vector<std::string> TranslateStringArray(const base::ListValue* list) { std::string ComputeAcceptLanguageFromPref(const std::string& language_pref) { std::string accept_languages_str = - base::FeatureList::IsEnabled(features::kUseNewAcceptLanguageHeader) - ? net::HttpUtil::ExpandLanguageList(language_pref) - : language_pref; + net::HttpUtil::ExpandLanguageList(language_pref); return net::HttpUtil::GenerateAcceptLanguageHeader(accept_languages_str); } @@ -166,10 +166,16 @@ void InitializeCorsExtraSafelistedRequestHeaderNamesForProfile( // TODO(https://crbug.com/458508): Currently, this is determined by OR of the // feature flag and policy. Next steps would be changing the feature value to // false after enough heads up and then removing the feature. -bool IsAmbientAuthAllowedForProfile(const Profile* profile) { +bool IsAmbientAuthAllowedForProfile(Profile* profile) { if (profile->IsRegularProfile()) return true; + // Non-primary OTR profiles are not used to create browser windows and are + // only technical means for a task that does not need to leave state after + // it's completed. + if (!profile->IsPrimaryOTRProfile()) + return true; + PrefService* local_state = g_browser_process->local_state(); DCHECK(local_state); DCHECK(local_state->FindPreference( @@ -197,6 +203,53 @@ bool IsAmbientAuthAllowedForProfile(const Profile* profile) { return false; } +void UpdateCookieSettings(Profile* profile) { + ContentSettingsForOneType settings; + HostContentSettingsMapFactory::GetForProfile(profile)->GetSettingsForOneType( + ContentSettingsType::COOKIES, std::string(), &settings); + content::BrowserContext::ForEachStoragePartition( + profile, base::BindRepeating( + [](ContentSettingsForOneType settings, + content::StoragePartition* storage_partition) { + storage_partition->GetCookieManagerForBrowserProcess() + ->SetContentSettings(settings); + }, + settings)); +} + +void UpdateLegacyCookieSettings(Profile* profile) { + ContentSettingsForOneType settings; + HostContentSettingsMapFactory::GetForProfile(profile)->GetSettingsForOneType( + ContentSettingsType::LEGACY_COOKIE_ACCESS, std::string(), &settings); + content::BrowserContext::ForEachStoragePartition( + profile, base::BindRepeating( + [](ContentSettingsForOneType settings, + content::StoragePartition* storage_partition) { + storage_partition->GetCookieManagerForBrowserProcess() + ->SetContentSettingsForLegacyCookieAccess(settings); + }, + settings)); +} + +void UpdateStorageAccessSettings(Profile* profile) { + if (base::FeatureList::IsEnabled(blink::features::kStorageAccessAPI)) { + ContentSettingsForOneType settings; + HostContentSettingsMapFactory::GetForProfile(profile) + ->GetSettingsForOneType(ContentSettingsType::STORAGE_ACCESS, + std::string(), &settings); + + content::BrowserContext::ForEachStoragePartition( + profile, base::BindRepeating( + [](ContentSettingsForOneType settings, + content::StoragePartition* storage_partition) { + storage_partition->GetCookieManagerForBrowserProcess() + ->SetStorageAccessGrantSettings(settings, + base::DoNothing()); + }, + settings)); + } +} + } // namespace ProfileNetworkContextService::ProfileNetworkContextService(Profile* profile) @@ -280,8 +333,8 @@ void ProfileNetworkContextService::ConfigureNetworkContextParams( FROM_HERE, {base::TaskPriority::BEST_EFFORT, base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, - base::BindOnce(base::IgnoreResult(&base::DeleteFile), media_cache_path, - true /* recursive */)); + base::BindOnce(base::GetDeletePathRecursivelyCallback(), + media_cache_path)); } } @@ -360,6 +413,10 @@ void ProfileNetworkContextService::OnThirdPartyCookieBlockingChanged( } std::string ProfileNetworkContextService::ComputeAcceptLanguage() const { + if (profile_->IsOffTheRecord()) { + return ComputeAcceptLanguageFromPref( + g_browser_process->GetApplicationLocale()); + } return ComputeAcceptLanguageFromPref(pref_accept_language_.GetValue()); } @@ -474,6 +531,11 @@ ProfileNetworkContextService::CreateCookieManagerParams( auto out = network::mojom::CookieManagerParams::New(); out->block_third_party_cookies = cookie_settings.ShouldBlockThirdPartyCookies(); + // This allows cookies to be sent on https requests from chrome:// pages, + // ignoring SameSite attribute rules. For example, this is needed for browser + // UI to interact with SameSite cookies on accounts.google.com, which are used + // for logging into Cloud Print from chrome://print, for displaying a list + // of available accounts on the NTP (chrome://new-tab-page), etc. out->secure_origin_cookies_allowed_schemes.push_back( content::kChromeUIScheme); #if BUILDFLAG(ENABLE_EXTENSIONS) @@ -855,41 +917,22 @@ void ProfileNetworkContextService::OnContentSettingChanged( const ContentSettingsPattern& secondary_pattern, ContentSettingsType content_type, const std::string& resource_identifier) { - if (content_type != ContentSettingsType::COOKIES && - content_type != ContentSettingsType::LEGACY_COOKIE_ACCESS && - content_type != ContentSettingsType::DEFAULT) { - return; - } - - if (content_type == ContentSettingsType::COOKIES || - content_type == ContentSettingsType::DEFAULT) { - ContentSettingsForOneType cookies_settings; - HostContentSettingsMapFactory::GetForProfile(profile_) - ->GetSettingsForOneType(ContentSettingsType::COOKIES, std::string(), - &cookies_settings); - content::BrowserContext::ForEachStoragePartition( - profile_, base::BindRepeating( - [](ContentSettingsForOneType settings, - content::StoragePartition* storage_partition) { - storage_partition->GetCookieManagerForBrowserProcess() - ->SetContentSettings(settings); - }, - cookies_settings)); - } - - if (content_type == ContentSettingsType::LEGACY_COOKIE_ACCESS || - content_type == ContentSettingsType::DEFAULT) { - ContentSettingsForOneType legacy_cookie_access_settings; - HostContentSettingsMapFactory::GetForProfile(profile_) - ->GetSettingsForOneType(ContentSettingsType::LEGACY_COOKIE_ACCESS, - std::string(), &legacy_cookie_access_settings); - content::BrowserContext::ForEachStoragePartition( - profile_, base::BindRepeating( - [](ContentSettingsForOneType settings, - content::StoragePartition* storage_partition) { - storage_partition->GetCookieManagerForBrowserProcess() - ->SetContentSettingsForLegacyCookieAccess(settings); - }, - legacy_cookie_access_settings)); + switch (content_type) { + case ContentSettingsType::COOKIES: + UpdateCookieSettings(profile_); + break; + case ContentSettingsType::LEGACY_COOKIE_ACCESS: + UpdateLegacyCookieSettings(profile_); + break; + case ContentSettingsType::STORAGE_ACCESS: + UpdateStorageAccessSettings(profile_); + break; + case ContentSettingsType::DEFAULT: + UpdateCookieSettings(profile_); + UpdateLegacyCookieSettings(profile_); + UpdateStorageAccessSettings(profile_); + break; + default: + return; } } diff --git a/chromium/chrome/browser/net/profile_network_context_service_browsertest.cc b/chromium/chrome/browser/net/profile_network_context_service_browsertest.cc index 5bd46dd35db..0b5d8377d2a 100644 --- a/chromium/chrome/browser/net/profile_network_context_service_browsertest.cc +++ b/chromium/chrome/browser/net/profile_network_context_service_browsertest.cc @@ -3,12 +3,16 @@ // found in the LICENSE file. #include <algorithm> +#include <memory> #include <string> #include <vector> +#include "base/bind.h" +#include "base/check_op.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/files/scoped_temp_dir.h" +#include "base/optional.h" #include "base/stl_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_piece.h" @@ -21,12 +25,13 @@ #include "base/threading/thread_restrictions.h" #include "build/build_config.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/metrics/subprocess_metrics_provider.h" #include "chrome/browser/net/profile_network_context_service.h" #include "chrome/browser/net/profile_network_context_service_factory.h" #include "chrome/browser/net/profile_network_context_service_test_utils.h" +#include "chrome/browser/net/system_network_context_manager.h" #include "chrome/browser/policy/policy_test_utils.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_features.h" @@ -35,13 +40,16 @@ #include "chrome/common/pref_names.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" +#include "components/metrics/content/subprocess_metrics_provider.h" #include "components/policy/core/common/policy_map.h" #include "components/policy/policy_constants.h" #include "components/prefs/pref_service.h" +#include "content/public/browser/network_service_instance.h" #include "content/public/browser/storage_partition.h" #include "content/public/common/content_features.h" #include "content/public/test/browser_test.h" #include "content/public/test/simple_url_loader_test_helper.h" +#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/system/data_pipe_utils.h" #include "net/base/features.h" #include "net/base/load_flags.h" @@ -51,6 +59,8 @@ #include "net/test/embedded_test_server/http_response.h" #include "net/test/embedded_test_server/request_handler_util.h" #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" +#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom.h" +#include "services/cert_verifier/test_cert_verifier_service_factory.h" #include "services/network/public/cpp/cors/cors.h" #include "services/network/public/cpp/features.h" #include "services/network/public/mojom/network_context.mojom.h" @@ -164,7 +174,7 @@ void CheckCacheResetStatus(base::HistogramTester* histograms, bool reset) { // has been loaded prior to testing the histograms. while (!histograms->GetBucketCount("HttpCache.HardReset", reset)) { content::FetchHistogramsFromChildProcesses(); - SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); + metrics::SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(5)); } @@ -296,10 +306,14 @@ class AmbientAuthenticationTestWithPolicy service->GetInteger(prefs::kAmbientAuthenticationInPrivateModesEnabled); Profile* regular_profile = browser()->profile(); - Profile* incognito_profile = regular_profile->GetOffTheRecordProfile(); + Profile* incognito_profile = regular_profile->GetPrimaryOTRProfile(); + Profile* non_primary_otr_profile = regular_profile->GetOffTheRecordProfile( + Profile::OTRProfileID("Test::AmbientAuthentication")); EXPECT_TRUE(AmbientAuthenticationTestHelper::IsAmbientAuthAllowedForProfile( regular_profile)); + EXPECT_TRUE(AmbientAuthenticationTestHelper::IsAmbientAuthAllowedForProfile( + non_primary_otr_profile)); EXPECT_EQ(AmbientAuthenticationTestHelper::IsAmbientAuthAllowedForProfile( incognito_profile), AmbientAuthenticationTestHelper::IsIncognitoAllowedInFeature( @@ -440,19 +454,88 @@ IN_PROC_BROWSER_TEST_F(ProfileNetworkContextServiceDiskCacheBrowsertest, } #if BUILDFLAG(BUILTIN_CERT_VERIFIER_FEATURE_SUPPORTED) +namespace { +void UnblockOnProfileCreation(base::RunLoop* run_loop, + Profile* profile, + Profile::CreateStatus status) { + if (status == Profile::CREATE_STATUS_INITIALIZED) + run_loop->Quit(); +} +} // namespace + class ProfileNetworkContextServiceCertVerifierBuiltinFeaturePolicyTest : public policy::PolicyTest, public testing::WithParamInterface<bool> { public: void SetUpInProcessBrowserTestFixture() override { - scoped_feature_list_.InitWithFeatureState( - net::features::kCertVerifierBuiltinFeature, - /*enabled=*/GetParam()); + std::vector<base::Feature> enabled_features, disabled_features; + if (use_builtin_cert_verifier()) { + enabled_features.push_back(net::features::kCertVerifierBuiltinFeature); + } else { + disabled_features.push_back(net::features::kCertVerifierBuiltinFeature); + } + if (enable_cert_verifier_service()) { + enabled_features.push_back(network::features::kCertVerifierService); + test_cert_verifier_service_factory_.emplace(); + content::SetCertVerifierServiceFactoryForTesting( + &test_cert_verifier_service_factory_.value()); + } else { + disabled_features.push_back(network::features::kCertVerifierService); + } + scoped_feature_list_.InitWithFeatures(enabled_features, disabled_features); policy::PolicyTest::SetUpInProcessBrowserTestFixture(); } + void TearDownInProcessBrowserTestFixture() override { + content::SetCertVerifierServiceFactoryForTesting(nullptr); + } + + void SetUpOnMainThread() override { + if (enable_cert_verifier_service()) { + test_cert_verifier_service_factory_->ReleaseAllCertVerifierParams(); + } + } + + void ExpectUseBuiltinCertVerifierCorrectUsingCertVerifierService( + network::mojom::CertVerifierCreationParams::CertVerifierImpl + use_builtin_cert_verifier) { + ASSERT_TRUE(enable_cert_verifier_service()); + ASSERT_TRUE(test_cert_verifier_service_factory_); + EXPECT_EQ(1ul, test_cert_verifier_service_factory_->num_captured_params()); + EXPECT_EQ(use_builtin_cert_verifier, + test_cert_verifier_service_factory_->GetParamsAtIndex(0) + ->creation_params->use_builtin_cert_verifier); + // Send it to the actual CertVerifierServiceFactory. + test_cert_verifier_service_factory_->ReleaseNextCertVerifierParams(); + } + + Profile* CreateNewProfile() { + ProfileManager* profile_manager = g_browser_process->profile_manager(); + base::FilePath new_path = + profile_manager->GenerateNextProfileDirectoryPath(); + base::RunLoop run_loop; + profile_manager->CreateProfileAsync( + new_path, base::BindRepeating(&UnblockOnProfileCreation, &run_loop), + base::string16(), std::string()); + run_loop.Run(); + return profile_manager->GetProfileByPath(new_path); + } + + bool use_builtin_cert_verifier() const { return GetParam(); } + bool enable_cert_verifier_service() const { + return enable_cert_verifier_service_; + } + void set_enable_cert_verifier_service(bool enable_cv_service) { + enable_cert_verifier_service_ = enable_cv_service; + } + private: base::test::ScopedFeatureList scoped_feature_list_; + bool enable_cert_verifier_service_ = false; + + // Used if enable_cert_verifier_service() returns true. + base::Optional<cert_verifier::TestCertVerifierServiceFactoryImpl> + test_cert_verifier_service_factory_; }; IN_PROC_BROWSER_TEST_P( @@ -468,10 +551,11 @@ IN_PROC_BROWSER_TEST_P( /*in_memory=*/false, empty_relative_partition_path, &network_context_params, &cert_verifier_creation_params); - EXPECT_EQ(GetParam() ? network::mojom::CertVerifierCreationParams:: - CertVerifierImpl::kBuiltin - : network::mojom::CertVerifierCreationParams:: - CertVerifierImpl::kSystem, + EXPECT_EQ(use_builtin_cert_verifier() + ? network::mojom::CertVerifierCreationParams:: + CertVerifierImpl::kBuiltin + : network::mojom::CertVerifierCreationParams:: + CertVerifierImpl::kSystem, cert_verifier_creation_params.use_builtin_cert_verifier); } @@ -515,6 +599,68 @@ INSTANTIATE_TEST_SUITE_P( All, ProfileNetworkContextServiceCertVerifierBuiltinFeaturePolicyTest, ::testing::Bool()); + +class + ProfileNetworkContextServiceCertVerifierBuiltinFeaturePolicyTestWithService + : public ProfileNetworkContextServiceCertVerifierBuiltinFeaturePolicyTest { + public: + ProfileNetworkContextServiceCertVerifierBuiltinFeaturePolicyTestWithService() { + set_enable_cert_verifier_service(true); + } + + ~ProfileNetworkContextServiceCertVerifierBuiltinFeaturePolicyTestWithService() + override = default; +}; + +IN_PROC_BROWSER_TEST_P( + ProfileNetworkContextServiceCertVerifierBuiltinFeaturePolicyTestWithService, + Test) { + { + content::BrowserContext::GetDefaultStoragePartition(CreateNewProfile()) + ->GetNetworkContext(); + + ExpectUseBuiltinCertVerifierCorrectUsingCertVerifierService( + use_builtin_cert_verifier() + ? network::mojom::CertVerifierCreationParams::CertVerifierImpl:: + kBuiltin + : network::mojom::CertVerifierCreationParams::CertVerifierImpl:: + kSystem); + } + +#if BUILDFLAG(BUILTIN_CERT_VERIFIER_POLICY_SUPPORTED) + // If the BuiltinCertificateVerifierEnabled policy is set it should override + // the feature flag. + policy::PolicyMap policies; + SetPolicy(&policies, policy::key::kBuiltinCertificateVerifierEnabled, + std::make_unique<base::Value>(true)); + UpdateProviderPolicy(policies); + + { + content::BrowserContext::GetDefaultStoragePartition(CreateNewProfile()) + ->GetNetworkContext(); + + ExpectUseBuiltinCertVerifierCorrectUsingCertVerifierService( + network::mojom::CertVerifierCreationParams::CertVerifierImpl::kBuiltin); + } + + SetPolicy(&policies, policy::key::kBuiltinCertificateVerifierEnabled, + std::make_unique<base::Value>(false)); + UpdateProviderPolicy(policies); + + { + content::BrowserContext::GetDefaultStoragePartition(CreateNewProfile()) + ->GetNetworkContext(); + + ExpectUseBuiltinCertVerifierCorrectUsingCertVerifierService( + network::mojom::CertVerifierCreationParams::CertVerifierImpl::kSystem); + } +#endif // BUILDFLAG(BUILTIN_CERT_VERIFIER_POLICY_SUPPORTED) +} + +INSTANTIATE_TEST_SUITE_P( + All, + ProfileNetworkContextServiceCertVerifierBuiltinFeaturePolicyTestWithService, + ::testing::Bool()); #endif // BUILDFLAG(BUILTIN_CERT_VERIFIER_FEATURE_SUPPORTED) enum class CorsTestMode { diff --git a/chromium/chrome/browser/net/referrer_policy_policy_handler_unittest.cc b/chromium/chrome/browser/net/referrer_policy_policy_handler_unittest.cc index afad0b0a15c..60035614c07 100644 --- a/chromium/chrome/browser/net/referrer_policy_policy_handler_unittest.cc +++ b/chromium/chrome/browser/net/referrer_policy_policy_handler_unittest.cc @@ -20,8 +20,7 @@ namespace policy { class ReferrerPolicyPolicyHandlerTest : public testing::Test { protected: - void SetPolicyValue(const std::string& policy, - std::unique_ptr<base::Value> value) { + void SetPolicyValue(const std::string& policy, base::Value value) { policies_.Set(policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_PLATFORM, std::move(value), nullptr); } @@ -57,8 +56,7 @@ TEST_F(ReferrerPolicyPolicyHandlerTest, NotSet) { // Sanity check tests to ensure the policy errors have the correct name. TEST_F(ReferrerPolicyPolicyHandlerTest, WrongType) { // Do anything that causes a policy error. - SetPolicyValue(key::kForceLegacyDefaultReferrerPolicy, - std::make_unique<base::Value>(1)); + SetPolicyValue(key::kForceLegacyDefaultReferrerPolicy, base::Value(1)); CheckAndApplyPolicySettings(); @@ -68,16 +66,14 @@ TEST_F(ReferrerPolicyPolicyHandlerTest, WrongType) { } TEST_F(ReferrerPolicyPolicyHandlerTest, ValueTrue) { - SetPolicyValue(key::kForceLegacyDefaultReferrerPolicy, - std::make_unique<base::Value>(true)); + SetPolicyValue(key::kForceLegacyDefaultReferrerPolicy, base::Value(true)); CheckAndApplyPolicySettings(); EXPECT_TRUE(content::Referrer::ShouldForceLegacyDefaultReferrerPolicy()); } TEST_F(ReferrerPolicyPolicyHandlerTest, ValueFalse) { - SetPolicyValue(key::kForceLegacyDefaultReferrerPolicy, - std::make_unique<base::Value>(false)); + SetPolicyValue(key::kForceLegacyDefaultReferrerPolicy, base::Value(false)); CheckAndApplyPolicySettings(); EXPECT_FALSE(content::Referrer::ShouldForceLegacyDefaultReferrerPolicy()); diff --git a/chromium/chrome/browser/net/secure_dns_config.h b/chromium/chrome/browser/net/secure_dns_config.h index f9d4ca156a4..3a65827ad8f 100644 --- a/chromium/chrome/browser/net/secure_dns_config.h +++ b/chromium/chrome/browser/net/secure_dns_config.h @@ -18,6 +18,8 @@ struct DnsOverHttpsServerConfig; // Representation of a complete Secure DNS configuration. class SecureDnsConfig { public: + // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.net + // GENERATED_JAVA_CLASS_NAME_OVERRIDE: SecureDnsManagementMode // Forced management description types. We will check for the override cases // in the order they are listed in the enum. enum class ManagementMode { diff --git a/chromium/chrome/browser/net/secure_dns_util.cc b/chromium/chrome/browser/net/secure_dns_util.cc index e1c342e3a14..d34c70398b4 100644 --- a/chromium/chrome/browser/net/secure_dns_util.cc +++ b/chromium/chrome/browser/net/secure_dns_util.cc @@ -8,12 +8,15 @@ #include <string> #include "base/feature_list.h" +#include "base/metrics/histogram_macros.h" #include "base/strings/string_split.h" #include "chrome/common/chrome_features.h" +#include "components/country_codes/country_codes.h" #include "components/embedder_support/pref_names.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/pref_service.h" #include "net/dns/dns_config_overrides.h" +#include "net/dns/public/doh_provider_entry.h" #include "net/dns/public/util.h" #include "net/third_party/uri_template/uri_template.h" #include "url/gurl.h" @@ -26,6 +29,37 @@ namespace { const char kAlternateErrorPagesBackup[] = "alternate_error_pages.backup"; +void IncrementDropdownHistogram(net::DohProviderIdForHistogram id, + const std::string& doh_template, + base::StringPiece old_template, + base::StringPiece new_template) { + if (doh_template == old_template) { + UMA_HISTOGRAM_ENUMERATION("Net.DNS.UI.DropdownSelectionEvent.Unselected", + id); + } else if (doh_template == new_template) { + UMA_HISTOGRAM_ENUMERATION("Net.DNS.UI.DropdownSelectionEvent.Selected", id); + } else { + UMA_HISTOGRAM_ENUMERATION("Net.DNS.UI.DropdownSelectionEvent.Ignored", id); + } +} + +bool EntryIsForCountry(const net::DohProviderEntry* entry, int country_id) { + if (entry->display_globally) { + return true; + } + const auto& countries = entry->display_countries; + bool matches = std::any_of(countries.begin(), countries.end(), + [country_id](const std::string& country_code) { + return country_codes::CountryStringToCountryID( + country_code) == country_id; + }); + if (matches) { + DCHECK(!entry->ui_name.empty()); + DCHECK(!entry->privacy_policy.empty()); + } + return matches; +} + } // namespace void RegisterProbesSettingBackupPref(PrefRegistrySimple* registry) { @@ -68,6 +102,35 @@ void MigrateProbesSettingToOrFromBackup(PrefService* prefs) { } } +net::DohProviderEntry::List ProvidersForCountry( + const net::DohProviderEntry::List& providers, + int country_id) { + net::DohProviderEntry::List local_providers; + std::copy_if(providers.begin(), providers.end(), + std::back_inserter(local_providers), + [country_id](const auto* entry) { + return EntryIsForCountry(entry, country_id); + }); + return local_providers; +} + +std::vector<std::string> GetDisabledProviders() { + return SplitString(features::kDnsOverHttpsDisabledProvidersParam.Get(), ",", + base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); +} + +net::DohProviderEntry::List RemoveDisabledProviders( + const net::DohProviderEntry::List& providers, + const std::vector<string>& disabled_providers) { + net::DohProviderEntry::List filtered_providers; + std::copy_if(providers.begin(), providers.end(), + std::back_inserter(filtered_providers), + [&disabled_providers](const auto* entry) { + return !base::Contains(disabled_providers, entry->provider); + }); + return filtered_providers; +} + std::vector<base::StringPiece> SplitGroup(base::StringPiece group) { // Templates in a group are whitespace-separated. return SplitStringPiece(group, " ", base::TRIM_WHITESPACE, @@ -83,6 +146,28 @@ bool IsValidGroup(base::StringPiece group) { }); } +void UpdateDropdownHistograms( + const std::vector<const net::DohProviderEntry*>& providers, + base::StringPiece old_template, + base::StringPiece new_template) { + for (const auto* entry : providers) { + IncrementDropdownHistogram(entry->provider_id_for_histogram.value(), + entry->dns_over_https_template, old_template, + new_template); + } + // An empty template indicates a custom provider. + IncrementDropdownHistogram(net::DohProviderIdForHistogram::kCustom, + std::string(), old_template, new_template); +} + +void UpdateValidationHistogram(bool valid) { + UMA_HISTOGRAM_BOOLEAN("Net.DNS.UI.ValidationAttemptSuccess", valid); +} + +void UpdateProbeHistogram(bool success) { + UMA_HISTOGRAM_BOOLEAN("Net.DNS.UI.ProbeAttemptSuccess", success); +} + void ApplyTemplate(net::DnsConfigOverrides* overrides, base::StringPiece server_template) { std::string server_method; diff --git a/chromium/chrome/browser/net/secure_dns_util.h b/chromium/chrome/browser/net/secure_dns_util.h index 98ec18fe744..8e6509ffcaf 100644 --- a/chromium/chrome/browser/net/secure_dns_util.h +++ b/chromium/chrome/browser/net/secure_dns_util.h @@ -8,6 +8,7 @@ #include <vector> #include "base/strings/string_piece.h" +#include "net/dns/public/doh_provider_entry.h" namespace net { struct DnsConfigOverrides; @@ -20,6 +21,22 @@ namespace chrome_browser_net { namespace secure_dns { +// Returns the subset of |providers| that are marked for use in the specified +// country. +net::DohProviderEntry::List ProvidersForCountry( + const net::DohProviderEntry::List& providers, + int country_id); + +// Returns the names of providers that have been remotely disabled, for use with +// RemoveDisabledProviders(). +std::vector<std::string> GetDisabledProviders(); + +// Returns the subset of |providers| for which |DohProviderEntry::provider| is +// not listed in |disabled_providers|. +net::DohProviderEntry::List RemoveDisabledProviders( + const net::DohProviderEntry::List& providers, + const std::vector<std::string>& disabled_providers); + // Implements the whitespace-delimited group syntax for DoH templates. std::vector<base::StringPiece> SplitGroup(base::StringPiece group); @@ -28,6 +45,16 @@ std::vector<base::StringPiece> SplitGroup(base::StringPiece group); // stored preferences. bool IsValidGroup(base::StringPiece group); +// When the selected template changes, call this function to update the +// Selected, Unselected, and Ignored histograms for all the included providers, +// and also for the custom provider option. If the old or new selection is the +// custom provider option, pass an empty string as the template. +void UpdateDropdownHistograms(const net::DohProviderEntry::List& providers, + base::StringPiece old_template, + base::StringPiece new_template); +void UpdateValidationHistogram(bool valid); +void UpdateProbeHistogram(bool success); + // Modifies |overrides| to use the DoH server specified by |server_template|. void ApplyTemplate(net::DnsConfigOverrides* overrides, base::StringPiece server_template); diff --git a/chromium/chrome/browser/net/secure_dns_util_unittest.cc b/chromium/chrome/browser/net/secure_dns_util_unittest.cc index d99da3b6e93..b68a7206096 100644 --- a/chromium/chrome/browser/net/secure_dns_util_unittest.cc +++ b/chromium/chrome/browser/net/secure_dns_util_unittest.cc @@ -6,12 +6,15 @@ #include <memory> +#include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_feature_list.h" #include "chrome/common/chrome_features.h" +#include "components/country_codes/country_codes.h" #include "components/embedder_support/pref_names.h" #include "components/prefs/pref_registry_simple.h" #include "components/prefs/testing_pref_service.h" #include "net/dns/dns_config_overrides.h" +#include "net/dns/public/doh_provider_entry.h" #include "testing/gmock/include/gmock/gmock-matchers.h" #include "testing/gtest/include/gtest/gtest.h" @@ -27,7 +30,7 @@ const char kAlternateErrorPagesBackup[] = "alternate_error_pages.backup"; namespace secure_dns { -class DNSUtilTest : public testing::Test { +class SecureDnsUtilTest : public testing::Test { public: void SetUp() override { DisableRedesign(); } @@ -37,13 +40,17 @@ class DNSUtilTest : public testing::Test { features::kPrivacySettingsRedesign, base::FieldTrialParams()); } - void DisableRedesign() { scoped_feature_list_.Reset(); } + void DisableRedesign() { + scoped_feature_list_.Reset(); + scoped_feature_list_.InitAndDisableFeature( + features::kPrivacySettingsRedesign); + } private: base::test::ScopedFeatureList scoped_feature_list_; }; -TEST_F(DNSUtilTest, MigrateProbesPref) { +TEST_F(SecureDnsUtilTest, MigrateProbesPref) { TestingPrefServiceSimple prefs; prefs.registry()->RegisterBooleanPref( embedder_support::kAlternateErrorPagesEnabled, true); @@ -150,14 +157,14 @@ TEST_F(DNSUtilTest, MigrateProbesPref) { EXPECT_FALSE(backup_pref->HasUserSetting()); } -TEST(DNSUtil, SplitGroup) { +TEST(SecureDnsUtil, SplitGroup) { EXPECT_THAT(SplitGroup("a"), ElementsAre("a")); EXPECT_THAT(SplitGroup("a b"), ElementsAre("a", "b")); EXPECT_THAT(SplitGroup("a \tb\nc"), ElementsAre("a", "b\nc")); EXPECT_THAT(SplitGroup(" \ta b\n"), ElementsAre("a", "b")); } -TEST(DNSUtil, IsValidGroup) { +TEST(SecureDnsUtil, IsValidGroup) { EXPECT_TRUE(IsValidGroup("")); EXPECT_TRUE(IsValidGroup("https://valid")); EXPECT_TRUE(IsValidGroup("https://valid https://valid2")); @@ -168,7 +175,7 @@ TEST(DNSUtil, IsValidGroup) { EXPECT_FALSE(IsValidGroup("invalid invalid2")); } -TEST(DNSUtil, ApplyDohTemplatePost) { +TEST(SecureDnsUtil, ApplyDohTemplatePost) { std::string post_template("https://valid"); net::DnsConfigOverrides overrides; ApplyTemplate(&overrides, post_template); @@ -178,7 +185,7 @@ TEST(DNSUtil, ApplyDohTemplatePost) { {post_template, true /* use_post */})))); } -TEST(DNSUtil, ApplyDohTemplateGet) { +TEST(SecureDnsUtil, ApplyDohTemplateGet) { std::string get_template("https://valid/{?dns}"); net::DnsConfigOverrides overrides; ApplyTemplate(&overrides, get_template); @@ -188,6 +195,105 @@ TEST(DNSUtil, ApplyDohTemplateGet) { {get_template, false /* use_post */})))); } +net::DohProviderEntry::List GetProvidersForTesting() { + static const auto global1 = net::DohProviderEntry::ConstructForTesting( + "Provider_Global1", net::DohProviderIdForHistogram(-1), {} /*ip_strs */, + {} /* dot_hostnames */, "https://global1.provider/dns-query{?dns}", + "Global Provider 1" /* ui_name */, + "https://global1.provider/privacy_policy/" /* privacy_policy */, + true /* display_globally */, {} /* display_countries */); + static const auto no_display = net::DohProviderEntry::ConstructForTesting( + "Provider_NoDisplay", net::DohProviderIdForHistogram(-2), {} /*ip_strs */, + {} /* dot_hostnames */, "https://nodisplay.provider/dns-query{?dns}", + "No Display Provider" /* ui_name */, + "https://nodisplay.provider/privacy_policy/" /* privacy_policy */, + false /* display_globally */, {} /* display_countries */); + static const auto ee_fr = net::DohProviderEntry::ConstructForTesting( + "Provider_EE_FR", net::DohProviderIdForHistogram(-3), {} /*ip_strs */, + {} /* dot_hostnames */, "https://ee.fr.provider/dns-query{?dns}", + "EE/FR Provider" /* ui_name */, + "https://ee.fr.provider/privacy_policy/" /* privacy_policy */, + false /* display_globally */, {"EE", "FR"} /* display_countries */); + static const auto fr = net::DohProviderEntry::ConstructForTesting( + "Provider_FR", net::DohProviderIdForHistogram(-4), {} /*ip_strs */, + {} /* dot_hostnames */, "https://fr.provider/dns-query{?dns}", + "FR Provider" /* ui_name */, + "https://fr.provider/privacy_policy/" /* privacy_policy */, + false /* display_globally */, {"FR"} /* display_countries */); + static const auto global2 = net::DohProviderEntry::ConstructForTesting( + "Provider_Global2", net::DohProviderIdForHistogram(-5), {} /*ip_strs */, + {} /* dot_hostnames */, "https://global2.provider/dns-query{?dns}", + "Global Provider 2" /* ui_name */, + "https://global2.provider/privacy_policy/" /* privacy_policy */, + true /* display_globally */, {} /* display_countries */); + return {&global1, &no_display, &ee_fr, &fr, &global2}; +} + +TEST(SecureDnsUtil, LocalProviders) { + const auto providers = GetProvidersForTesting(); + + const auto fr_providers = ProvidersForCountry( + providers, country_codes::CountryStringToCountryID("FR")); + EXPECT_THAT(fr_providers, ElementsAre(providers[0], providers[2], + providers[3], providers[4])); + + const auto ee_providers = ProvidersForCountry( + providers, country_codes::CountryStringToCountryID("EE")); + EXPECT_THAT(ee_providers, + ElementsAre(providers[0], providers[2], providers[4])); + + const auto us_providers = ProvidersForCountry( + providers, country_codes::CountryStringToCountryID("US")); + EXPECT_THAT(us_providers, ElementsAre(providers[0], providers[4])); + + const auto unknown_providers = + ProvidersForCountry(providers, country_codes::kCountryIDUnknown); + EXPECT_THAT(unknown_providers, ElementsAre(providers[0], providers[4])); +} + +TEST(SecureDnsUtil, DisabledProviders) { + base::test::ScopedFeatureList scoped_features; + scoped_features.InitAndEnableFeatureWithParameters( + features::kDnsOverHttps, + {{"DisabledProviders", "Provider_Global2, , Provider_EE_FR,Unexpected"}}); + EXPECT_THAT(GetDisabledProviders(), + ElementsAre("Provider_Global2", "Provider_EE_FR", "Unexpected")); +} + +TEST(SecureDnsUtil, RemoveDisabled) { + const auto providers = GetProvidersForTesting(); + const auto filtered_providers = RemoveDisabledProviders( + providers, {"Provider_Global2", "", "Provider_EE_FR", "Unexpected"}); + EXPECT_THAT(filtered_providers, + ElementsAre(providers[0], providers[1], providers[3])); +} + +TEST(SecureDnsUtil, UpdateDropdownHistograms) { + base::HistogramTester histograms; + + const auto providers = GetProvidersForTesting(); + UpdateDropdownHistograms(providers, providers[4]->dns_over_https_template, + providers[0]->dns_over_https_template); + + const std::string kUmaBase = "Net.DNS.UI.DropdownSelectionEvent"; + histograms.ExpectTotalCount(kUmaBase + ".Ignored", 4u); + histograms.ExpectTotalCount(kUmaBase + ".Selected", 1u); + histograms.ExpectTotalCount(kUmaBase + ".Unselected", 1u); +} + +TEST(SecureDnsUtil, UpdateDropdownHistogramsCustom) { + base::HistogramTester histograms; + + const auto providers = GetProvidersForTesting(); + UpdateDropdownHistograms(providers, std::string(), + providers[2]->dns_over_https_template); + + const std::string kUmaBase = "Net.DNS.UI.DropdownSelectionEvent"; + histograms.ExpectTotalCount(kUmaBase + ".Ignored", 4u); + histograms.ExpectTotalCount(kUmaBase + ".Selected", 1u); + histograms.ExpectTotalCount(kUmaBase + ".Unselected", 1u); +} + } // namespace secure_dns } // namespace chrome_browser_net diff --git a/chromium/chrome/browser/net/storage_test_utils.cc b/chromium/chrome/browser/net/storage_test_utils.cc new file mode 100644 index 00000000000..d2a26814fc8 --- /dev/null +++ b/chromium/chrome/browser/net/storage_test_utils.cc @@ -0,0 +1,102 @@ +// Copyright (c) 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/net/storage_test_utils.h" + +#include "content/public/test/browser_test_utils.h" + +namespace storage { +namespace test { + +const std::vector<std::string> kStorageTypes{ + "Cookie", "LocalStorage", "FileSystem", "SessionStorage", "IndexedDb", + "WebSql", "CacheStorage", "ServiceWorker", "CookieStore"}; + +const std::vector<std::string> kCrossTabCommunicationTypes{ + "SharedWorker", + "WebLock", +}; + +constexpr char kRequestStorageAccess[] = + "document.requestStorageAccess().then(" + " () => { window.domAutomationController.send(true); }," + " () => { window.domAutomationController.send(false); }," + ");"; + +constexpr char kHasStorageAccess[] = + "document.hasStorageAccess().then(" + " (result) => { window.domAutomationController.send(result); }," + " () => { window.domAutomationController.send(false); }," + ");"; + +void ExpectFrameContent(content::RenderFrameHost* frame, + const std::string& expected) { + std::string content; + ASSERT_TRUE(ExecuteScriptAndExtractString( + frame, "window.domAutomationController.send(document.body.textContent)", + &content)); + EXPECT_EQ(expected, content); +} + +void ExpectCookiesOnHost(content::BrowserContext* context, + const GURL& host_url, + const std::string& expected) { + EXPECT_EQ(expected, content::GetCookies(context, host_url)); +} + +void SetStorageForFrame(content::RenderFrameHost* frame) { + for (const auto& data_type : kStorageTypes) { + bool data = false; + EXPECT_TRUE(content::ExecuteScriptAndExtractBool( + frame, "set" + data_type + "()", &data)); + EXPECT_TRUE(data) << data_type; + } +} + +void ExpectStorageForFrame(content::RenderFrameHost* frame, bool expected) { + for (const auto& data_type : kStorageTypes) { + bool data = false; + EXPECT_TRUE(content::ExecuteScriptAndExtractBool( + frame, "has" + data_type + "();", &data)); + EXPECT_EQ(expected, data) << data_type; + } +} + +void SetCrossTabInfoForFrame(content::RenderFrameHost* frame) { + for (const auto& data_type : kCrossTabCommunicationTypes) { + bool data = false; + EXPECT_TRUE(content::ExecuteScriptAndExtractBool( + frame, "set" + data_type + "()", &data)); + EXPECT_TRUE(data) << data_type; + } +} + +void ExpectCrossTabInfoForFrame(content::RenderFrameHost* frame, + bool expected) { + for (const auto& data_type : kCrossTabCommunicationTypes) { + bool data = false; + EXPECT_TRUE(content::ExecuteScriptAndExtractBool( + frame, "has" + data_type + "();", &data)); + EXPECT_EQ(expected, data) << data_type; + } +} + +void RequestStorageAccessForFrame(content::RenderFrameHost* frame, + bool should_resolve) { + bool data = false; + EXPECT_TRUE(content::ExecuteScriptAndExtractBool(frame, kRequestStorageAccess, + &data)); + EXPECT_EQ(should_resolve, data) << "document.requestStorageAccess()"; +} + +void CheckStorageAccessForFrame(content::RenderFrameHost* frame, + bool access_expected) { + bool data = false; + EXPECT_TRUE( + content::ExecuteScriptAndExtractBool(frame, kHasStorageAccess, &data)); + EXPECT_EQ(access_expected, data) << "document.hasStorageAccess()"; +} + +} // namespace test +} // namespace storage diff --git a/chromium/chrome/browser/net/storage_test_utils.h b/chromium/chrome/browser/net/storage_test_utils.h new file mode 100644 index 00000000000..b997843b400 --- /dev/null +++ b/chromium/chrome/browser/net/storage_test_utils.h @@ -0,0 +1,51 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_NET_STORAGE_TEST_UTILS_H_ +#define CHROME_BROWSER_NET_STORAGE_TEST_UTILS_H_ + +#include <string> + +class GURL; + +namespace content { +class BrowserContext; +class RenderFrameHost; +} // namespace content + +namespace storage { +namespace test { + +// Helper to validate a given frame contains the |expected| contents as their +// document body. +void ExpectFrameContent(content::RenderFrameHost* frame, + const std::string& expected); +// Helper to validate a given for a given |context| and |host_url| that +// |expected| cookies are present. +void ExpectCookiesOnHost(content::BrowserContext* context, + const GURL& host_url, + const std::string& expected); + +// Helpers to set and check various types of storage on a given frame. Typically +// used on page like //chrome/test/data/browsing_data/site_data.html +void SetStorageForFrame(content::RenderFrameHost* frame); +void ExpectStorageForFrame(content::RenderFrameHost* frame, bool expected); + +// Helpers to set and check various types of cross tab info for a given frame. +// Typically used on page like //chrome/test/data/browsing_data/site_data.html +void SetCrossTabInfoForFrame(content::RenderFrameHost* frame); +void ExpectCrossTabInfoForFrame(content::RenderFrameHost* frame, bool expected); + +// Helper to request storage access for a frame using +// document.requestStorageAccess() +void RequestStorageAccessForFrame(content::RenderFrameHost* frame, + bool should_resolve); +// Helper to validate if a frame currently has storage access using +// document.hasStorageAccess() +void CheckStorageAccessForFrame(content::RenderFrameHost* frame, + bool access_expected); + +} // namespace test +} // namespace storage +#endif // CHROME_BROWSER_NET_STORAGE_TEST_UTILS_H_ diff --git a/chromium/chrome/browser/net/stub_resolver_config_reader.cc b/chromium/chrome/browser/net/stub_resolver_config_reader.cc index 37e70c07c4c..fd6f5bfa473 100644 --- a/chromium/chrome/browser/net/stub_resolver_config_reader.cc +++ b/chromium/chrome/browser/net/stub_resolver_config_reader.cc @@ -36,6 +36,7 @@ #if defined(OS_ANDROID) #include "base/android/build_info.h" +#include "chrome/browser/enterprise/util/android_enterprise_info.h" #endif #if defined(OS_WIN) @@ -172,8 +173,17 @@ StubResolverConfigReader::StubResolverConfigReader(PrefService* local_state, FROM_HERE, kParentalControlsCheckDelay, base::BindOnce(&StubResolverConfigReader::OnParentalControlsDelayTimer, base::Unretained(this))); + +#if defined(OS_ANDROID) + chrome::enterprise_util::AndroidEnterpriseInfo::GetInstance() + ->GetAndroidEnterpriseInfoState(base::BindOnce( + &StubResolverConfigReader::OnAndroidOwnedStateCheckComplete, + weak_factory_.GetWeakPtr())); +#endif } +StubResolverConfigReader::~StubResolverConfigReader() = default; + // static void StubResolverConfigReader::RegisterPrefs(PrefRegistrySimple* registry) { // Register the DnsClient and DoH preferences. The feature list has not been @@ -201,14 +211,25 @@ void StubResolverConfigReader::UpdateNetworkService(bool record_metrics) { } bool StubResolverConfigReader::ShouldDisableDohForManaged() { -#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) - if (g_browser_process->browser_policy_connector()->HasMachineLevelPolicies()) +// This function ignores cloud policies which are loaded on a per-profile basis. +#if defined(OS_ANDROID) + // Check for MDM/management/owner apps. android_has_owner_ is true if either a + // device or policy owner app is discovered by + // GetAndroidEnterpriseInfoState(). If android_has_owner_ is nullopt, take a + // value of false so that we don't disable DoH during the async check. + + // Because Android policies can only be loaded with owner apps this is + // sufficient to check for the prescences of policies as well. + if (android_has_owner_.value_or(false)) return true; -#endif -#if defined(OS_WIN) +#elif defined(OS_WIN) if (base::IsMachineExternallyManaged()) return true; #endif +#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) + if (g_browser_process->browser_policy_connector()->HasMachineLevelPolicies()) + return true; +#endif return false; } @@ -242,6 +263,8 @@ SecureDnsConfig StubResolverConfigReader::GetAndUpdateConfiguration( bool force_check_parental_controls_for_automatic_mode, bool record_metrics, bool update_network_service) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + net::DnsConfig::SecureDnsMode secure_dns_mode; SecureDnsModeDetailsForHistogram mode_details; SecureDnsConfig::ManagementMode forced_management_mode = @@ -367,3 +390,15 @@ SecureDnsConfig StubResolverConfigReader::GetAndUpdateConfiguration( return SecureDnsConfig(secure_dns_mode, std::move(dns_over_https_servers), forced_management_mode); } + +#if defined(OS_ANDROID) +void StubResolverConfigReader::OnAndroidOwnedStateCheckComplete( + bool has_profile_owner, + bool has_device_owner) { + DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); + android_has_owner_ = has_profile_owner || has_device_owner; + // update the network service if the actual result is "true" to save time. + if (android_has_owner_.value()) + UpdateNetworkService(false /* record_metrics */); +} +#endif diff --git a/chromium/chrome/browser/net/stub_resolver_config_reader.h b/chromium/chrome/browser/net/stub_resolver_config_reader.h index 3aedabd184e..d69b3b301c7 100644 --- a/chromium/chrome/browser/net/stub_resolver_config_reader.h +++ b/chromium/chrome/browser/net/stub_resolver_config_reader.h @@ -6,11 +6,17 @@ #define CHROME_BROWSER_NET_STUB_RESOLVER_CONFIG_READER_H_ #include "base/optional.h" +#include "base/sequence_checker.h" #include "base/time/time.h" #include "base/timer/timer.h" +#include "build/build_config.h" #include "components/prefs/pref_change_registrar.h" #include "services/network/public/mojom/host_resolver.mojom-forward.h" +#if defined(OS_ANDROID) +#include "base/memory/weak_ptr.h" +#endif + class PrefRegistrySimple; class PrefService; class SecureDnsConfig; @@ -28,7 +34,7 @@ class StubResolverConfigReader { StubResolverConfigReader(const StubResolverConfigReader&) = delete; StubResolverConfigReader& operator=(const StubResolverConfigReader&) = delete; - virtual ~StubResolverConfigReader() = default; + virtual ~StubResolverConfigReader(); static void RegisterPrefs(PrefRegistrySimple* registry); @@ -51,16 +57,23 @@ class StubResolverConfigReader { // Updates the network service with the current configuration. void UpdateNetworkService(bool record_metrics); - // Returns true if there are any active machine level policies or if the - // machine is domain joined. This special logic is used to disable DoH by - // default for Desktop platforms (the enterprise policy field - // default_for_enterprise_users only applies to ChromeOS). We don't attempt - // enterprise detection on Android at this time. + // Returns true if there are any active machine level policies, if the + // machine is domain joined (Windows), or any device or profile owner apps are + // installed (Android). This special logic is used to disable DoH by default + // for Desktop platforms and Android. ChromeOS is handled by the enterprise + // policy field "default_for_enterprise_users". virtual bool ShouldDisableDohForManaged(); // Returns true if there are parental controls detected on the device. virtual bool ShouldDisableDohForParentalControls(); +#if defined(OS_ANDROID) + // Updates the android owned state and network service if the device/prfile is + // owned. + void OnAndroidOwnedStateCheckComplete(bool has_profile_owner, + bool has_device_owner); +#endif + private: void OnParentalControlsDelayTimer(); @@ -81,7 +94,20 @@ class StubResolverConfigReader { // expiration of the delay timer or because of a forced check. bool parental_controls_checked_ = false; + // This object lives on the UI thread, but it's possible for it to be created + // before BrowserMainLoop::CreateThreads() is called which would cause a + // DCHECK for the UI thread to fail (as the UI thread hasn't been + // named yet). Using a sequence checker works around this. + SEQUENCE_CHECKER(sequence_checker_); + PrefChangeRegistrar pref_change_registrar_; + +#if defined(OS_ANDROID) + // Whether or not an Android device or profile is owned. + // A nullopt indicates this value has not been determined yet. + base::Optional<bool> android_has_owner_ = base::nullopt; + base::WeakPtrFactory<StubResolverConfigReader> weak_factory_{this}; +#endif }; #endif // CHROME_BROWSER_NET_STUB_RESOLVER_CONFIG_READER_H_ diff --git a/chromium/chrome/browser/net/system_network_context_manager.cc b/chromium/chrome/browser/net/system_network_context_manager.cc index bb3b12d4667..2163341048b 100644 --- a/chromium/chrome/browser/net/system_network_context_manager.cc +++ b/chromium/chrome/browser/net/system_network_context_manager.cc @@ -46,7 +46,6 @@ #include "components/version_info/version_info.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" -#include "content/public/browser/cors_exempt_headers.h" #include "content/public/browser/network_context_client_base.h" #include "content/public/browser/network_service_instance.h" #include "content/public/common/content_features.h" @@ -56,14 +55,17 @@ #include "content/public/common/user_agent.h" #include "crypto/sha2.h" #include "mojo/public/cpp/bindings/pending_remote.h" +#include "mojo/public/cpp/bindings/receiver_set.h" #include "mojo/public/cpp/bindings/self_owned_receiver.h" #include "net/base/features.h" #include "net/net_buildflags.h" #include "net/third_party/uri_template/uri_template.h" +#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom.h" #include "services/network/network_service.h" #include "services/network/public/cpp/cross_thread_pending_shared_url_loader_factory.h" #include "services/network/public/cpp/features.h" #include "services/network/public/cpp/shared_url_loader_factory.h" +#include "services/network/public/mojom/cert_verifier_service.mojom.h" #include "services/network/public/mojom/network_context.mojom.h" #include "services/proxy_resolver/public/mojom/proxy_resolver.mojom.h" #include "third_party/blink/public/common/features.h" @@ -273,6 +275,7 @@ SystemNetworkContextManager::GetURLLoaderFactory() { params->process_id = network::mojom::kBrowserProcessId; params->is_corb_enabled = false; params->is_trusted = true; + url_loader_factory_.reset(); GetContext()->CreateURLLoaderFactory( url_loader_factory_.BindNewPipeAndPassReceiver(), std::move(params)); @@ -473,8 +476,6 @@ void SystemNetworkContextManager::OnNetworkServiceCreated( if (max_connections_per_proxy != -1) network_service->SetMaxConnectionsPerProxy(max_connections_per_proxy); - // The system NetworkContext must be created first, since it sets - // |primary_network_context| to true. network_service_network_context_.reset(); network_service->CreateNetworkContext( network_service_network_context_.BindNewPipeAndPassReceiver(), @@ -539,7 +540,6 @@ void SystemNetworkContextManager::AddSSLConfigToNetworkContextParams( void SystemNetworkContextManager::ConfigureDefaultNetworkContextParams( network::mojom::NetworkContextParams* network_context_params, network::mojom::CertVerifierCreationParams* cert_verifier_creation_params) { - content::UpdateCorsExemptHeader(network_context_params); variations::UpdateCorsExemptHeaderForVariations(network_context_params); GoogleURLLoaderThrottle::UpdateCorsExemptHeader(network_context_params); @@ -648,8 +648,8 @@ SystemNetworkContextManager::CreateDefaultNetworkContextParams() { network::mojom::CertVerifierCreationParams::New(); ConfigureDefaultNetworkContextParams(network_context_params.get(), cert_verifier_creation_params.get()); - network_context_params->cert_verifier_creation_params = - std::move(cert_verifier_creation_params); + network_context_params->cert_verifier_params = + content::GetCertVerifierParams(std::move(cert_verifier_creation_params)); return network_context_params; } @@ -710,8 +710,6 @@ SystemNetworkContextManager::CreateNetworkContextParams() { base::FeatureList::IsEnabled(features::kFtpProtocol); #endif - network_context_params->primary_network_context = true; - proxy_config_monitor_.AddToNetworkContextParams(network_context_params.get()); return network_context_params; diff --git a/chromium/chrome/browser/net/system_network_context_manager.h b/chromium/chrome/browser/net/system_network_context_manager.h index 38ddec6c873..daaad39c801 100644 --- a/chromium/chrome/browser/net/system_network_context_manager.h +++ b/chromium/chrome/browser/net/system_network_context_manager.h @@ -9,6 +9,7 @@ #include <string> #include <vector> +#include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/optional.h" @@ -123,9 +124,12 @@ class SystemNetworkContextManager { network::mojom::CertVerifierCreationParams* cert_verifier_creation_params); - // Same as ConfigureDefaultNetworkContextParams() but returns a newly - // allocated network::mojom::NetworkContextParams with the - // CertVerifierCreationParams already placed into the NetworkContextParams. + // Performs the same function as ConfigureDefaultNetworkContextParams(), and + // then returns a newly allocated network::mojom::NetworkContextParams with + // some modifications: if the CertVerifierService is enabled, the new + // NetworkContextParams will contain a CertVerifierServiceRemoteParams. + // Otherwise the newly configured CertVerifierCreationParams is placed + // directly into the NetworkContextParams. network::mojom::NetworkContextParamsPtr CreateDefaultNetworkContextParams(); // Returns a shared global NetExportFileWriter instance, used by net-export. @@ -160,6 +164,10 @@ class SystemNetworkContextManager { } private: + FRIEND_TEST_ALL_PREFIXES( + SystemNetworkContextServiceCertVerifierBuiltinFeaturePolicyTest, + Test); + class URLLoaderFactoryForSystem; // Constructor. |pref_service| must out live this object. diff --git a/chromium/chrome/browser/net/system_network_context_manager_browsertest.cc b/chromium/chrome/browser/net/system_network_context_manager_browsertest.cc index f1b01f338ac..ae771b3c86e 100644 --- a/chromium/chrome/browser/net/system_network_context_manager_browsertest.cc +++ b/chromium/chrome/browser/net/system_network_context_manager_browsertest.cc @@ -21,8 +21,11 @@ #include "chrome/test/base/in_process_browser_test.h" #include "components/prefs/pref_service.h" #include "components/version_info/version_info.h" +#include "content/public/browser/network_service_instance.h" #include "content/public/common/user_agent.h" #include "content/public/test/browser_test.h" +#include "services/cert_verifier/test_cert_verifier_service_factory.h" +#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/network_service_buildflags.h" #include "services/network/public/mojom/network_context.mojom.h" #include "services/network/public/mojom/network_service.mojom.h" @@ -325,9 +328,9 @@ class SystemNetworkContextManagerReferrersFeatureBrowsertest // value of the kEnableReferrers pref. IN_PROC_BROWSER_TEST_P(SystemNetworkContextManagerReferrersFeatureBrowsertest, TestDefaultReferrerReflectsFeatureValue) { - ASSERT_TRUE(!!g_browser_process); + ASSERT_TRUE(g_browser_process); PrefService* local_state = g_browser_process->local_state(); - ASSERT_TRUE(!!local_state); + ASSERT_TRUE(local_state); EXPECT_NE(local_state->GetBoolean(prefs::kEnableReferrers), GetParam()); } @@ -458,57 +461,136 @@ INSTANTIATE_TEST_SUITE_P( #if BUILDFLAG(BUILTIN_CERT_VERIFIER_FEATURE_SUPPORTED) class SystemNetworkContextServiceCertVerifierBuiltinFeaturePolicyTest : public policy::PolicyTest, - public testing::WithParamInterface<bool> { + public testing::WithParamInterface<std::tuple<bool, bool>> { public: + SystemNetworkContextServiceCertVerifierBuiltinFeaturePolicyTest() { + bool use_builtin_cert_verifier; + std::tie(use_builtin_cert_verifier, enable_cert_verification_service_) = + GetParam(); + cert_verifier_impl_ = use_builtin_cert_verifier + ? network::mojom::CertVerifierCreationParams:: + CertVerifierImpl::kBuiltin + : network::mojom::CertVerifierCreationParams:: + CertVerifierImpl::kSystem; + } + void SetUpInProcessBrowserTestFixture() override { - scoped_feature_list_.InitWithFeatureState( - net::features::kCertVerifierBuiltinFeature, - /*enabled=*/GetParam()); + std::vector<base::Feature> enabled_features, disabled_features; + if (cert_verifier_impl_ == network::mojom::CertVerifierCreationParams:: + CertVerifierImpl::kBuiltin) { + enabled_features.push_back(net::features::kCertVerifierBuiltinFeature); + } else { + disabled_features.push_back(net::features::kCertVerifierBuiltinFeature); + } + if (enable_cert_verification_service_) { + enabled_features.push_back(network::features::kCertVerifierService); + test_cert_verifier_service_factory_.emplace(); + content::SetCertVerifierServiceFactoryForTesting( + &test_cert_verifier_service_factory_.value()); + } else { + disabled_features.push_back(network::features::kCertVerifierService); + } + scoped_feature_list_.InitWithFeatures(enabled_features, disabled_features); policy::PolicyTest::SetUpInProcessBrowserTestFixture(); } + void TearDownInProcessBrowserTestFixture() override { + content::SetCertVerifierServiceFactoryForTesting(nullptr); + } + + void SetUpOnMainThread() override { + if (enable_cert_verification_service_) { + test_cert_verifier_service_factory_->ReleaseAllCertVerifierParams(); + } + } + + void ExpectUseBuiltinCertVerifierCorrect( + network::mojom::NetworkContextParamsPtr& network_context_params_ptr, + network::mojom::CertVerifierCreationParams::CertVerifierImpl + use_builtin_cert_verifier) { + ASSERT_TRUE(network_context_params_ptr); + ASSERT_TRUE(network_context_params_ptr->cert_verifier_params); + if (enable_cert_verification_service_) { + EXPECT_TRUE( + network_context_params_ptr->cert_verifier_params->is_remote_params()); + ASSERT_TRUE(test_cert_verifier_service_factory_); + ASSERT_EQ(1ul, + test_cert_verifier_service_factory_->num_captured_params()); + ASSERT_TRUE(test_cert_verifier_service_factory_->GetParamsAtIndex(0) + ->creation_params); + EXPECT_EQ(use_builtin_cert_verifier, + test_cert_verifier_service_factory_->GetParamsAtIndex(0) + ->creation_params->use_builtin_cert_verifier); + // Send it to the actual CertVerifierServiceFactory. + test_cert_verifier_service_factory_->ReleaseNextCertVerifierParams(); + } else { + ASSERT_TRUE(network_context_params_ptr->cert_verifier_params + ->is_creation_params()); + EXPECT_EQ(use_builtin_cert_verifier, + network_context_params_ptr->cert_verifier_params + ->get_creation_params() + ->use_builtin_cert_verifier); + } + } + + network::mojom::CertVerifierCreationParams::CertVerifierImpl + cert_verifier_impl() const { + return cert_verifier_impl_; + } + private: + network::mojom::CertVerifierCreationParams::CertVerifierImpl + cert_verifier_impl_; + bool enable_cert_verification_service_; base::test::ScopedFeatureList scoped_feature_list_; + + // Used if |enable_cert_verification_service_| set to true. + base::Optional<cert_verifier::TestCertVerifierServiceFactoryImpl> + test_cert_verifier_service_factory_; }; IN_PROC_BROWSER_TEST_P( SystemNetworkContextServiceCertVerifierBuiltinFeaturePolicyTest, Test) { + network::mojom::NetworkContextParamsPtr network_context_params_ptr; + // If no BuiltinCertificateVerifierEnabled policy is set, the // use_builtin_cert_verifier param should be set from the feature flag. - EXPECT_EQ(GetParam() ? network::mojom::CertVerifierCreationParams:: - CertVerifierImpl::kBuiltin - : network::mojom::CertVerifierCreationParams:: - CertVerifierImpl::kSystem, - g_browser_process->system_network_context_manager() - ->CreateDefaultNetworkContextParams() - ->cert_verifier_creation_params->use_builtin_cert_verifier); + network_context_params_ptr = + g_browser_process->system_network_context_manager() + ->CreateDefaultNetworkContextParams(); + ExpectUseBuiltinCertVerifierCorrect(network_context_params_ptr, + cert_verifier_impl()); #if BUILDFLAG(BUILTIN_CERT_VERIFIER_POLICY_SUPPORTED) - // If the BuiltinCertificateVerifierEnabled policy is set it should override - // the feature flag. + // If the BuiltinCertificateVerifierEnabled policy is set it should + // override the feature flag. policy::PolicyMap policies; SetPolicy(&policies, policy::key::kBuiltinCertificateVerifierEnabled, std::make_unique<base::Value>(true)); UpdateProviderPolicy(policies); - EXPECT_EQ( - network::mojom::CertVerifierCreationParams::CertVerifierImpl::kBuiltin, + + network_context_params_ptr = g_browser_process->system_network_context_manager() - ->CreateDefaultNetworkContextParams() - ->cert_verifier_creation_params->use_builtin_cert_verifier); + ->CreateDefaultNetworkContextParams(); + ExpectUseBuiltinCertVerifierCorrect( + network_context_params_ptr, + network::mojom::CertVerifierCreationParams::CertVerifierImpl::kBuiltin); SetPolicy(&policies, policy::key::kBuiltinCertificateVerifierEnabled, std::make_unique<base::Value>(false)); UpdateProviderPolicy(policies); - EXPECT_EQ( - network::mojom::CertVerifierCreationParams::CertVerifierImpl::kSystem, + + network_context_params_ptr = g_browser_process->system_network_context_manager() - ->CreateDefaultNetworkContextParams() - ->cert_verifier_creation_params->use_builtin_cert_verifier); + ->CreateDefaultNetworkContextParams(); + ExpectUseBuiltinCertVerifierCorrect( + network_context_params_ptr, + network::mojom::CertVerifierCreationParams::CertVerifierImpl::kSystem); #endif // BUILDFLAG(BUILTIN_CERT_VERIFIER_POLICY_SUPPORTED) } INSTANTIATE_TEST_SUITE_P( All, SystemNetworkContextServiceCertVerifierBuiltinFeaturePolicyTest, - ::testing::Bool()); + ::testing::Combine(::testing::Bool(), ::testing::Bool())); #endif // BUILDFLAG(BUILTIN_CERT_VERIFIER_FEATURE_SUPPORTED) diff --git a/chromium/chrome/browser/net/trial_comparison_cert_verifier_browsertest.cc b/chromium/chrome/browser/net/trial_comparison_cert_verifier_browsertest.cc index 1c431c79806..10ec923fc43 100644 --- a/chromium/chrome/browser/net/trial_comparison_cert_verifier_browsertest.cc +++ b/chromium/chrome/browser/net/trial_comparison_cert_verifier_browsertest.cc @@ -5,13 +5,13 @@ #include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_feature_list.h" #include "build/build_config.h" -#include "chrome/browser/metrics/subprocess_metrics_provider.h" #include "chrome/browser/net/trial_comparison_cert_verifier_controller.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/common/chrome_features.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" +#include "components/metrics/content/subprocess_metrics_provider.h" #include "components/safe_browsing/core/common/safe_browsing_prefs.h" #include "content/public/test/browser_test.h" #include "net/base/features.h" @@ -33,7 +33,7 @@ IN_PROC_BROWSER_TEST_F(TrialComparisonCertVerifierTest, TrialDisabled) { base::HistogramTester histograms; ui_test_utils::NavigateToURL(browser(), https_test_server_.GetURL("/title1.html")); - SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); + metrics::SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); histograms.ExpectTotalCount("Net.CertVerifier_Job_Latency", 1); histograms.ExpectTotalCount("Net.CertVerifier_Job_Latency_TrialPrimary", 0); } @@ -65,21 +65,21 @@ IN_PROC_BROWSER_TEST_F(TrialComparisonCertVerifierFeatureEnabledTest, base::HistogramTester histograms; ui_test_utils::NavigateToURL(browser(), https_test_server_.GetURL("/title1.html")); - SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); + metrics::SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); histograms.ExpectTotalCount("Net.CertVerifier_Job_Latency", 1); histograms.ExpectTotalCount("Net.CertVerifier_Job_Latency_TrialPrimary", 0); } IN_PROC_BROWSER_TEST_F(TrialComparisonCertVerifierFeatureEnabledTest, TrialEnabledPrefEnabled) { - safe_browsing::SetExtendedReportingPref(browser()->profile()->GetPrefs(), - true); + safe_browsing::SetExtendedReportingPrefForTests( + browser()->profile()->GetPrefs(), true); ASSERT_TRUE(https_test_server_.Start()); base::HistogramTester histograms; ui_test_utils::NavigateToURL(browser(), https_test_server_.GetURL("/title1.html")); - SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); + metrics::SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); histograms.ExpectTotalCount("Net.CertVerifier_Job_Latency", 1); #if BUILDFLAG(BUILTIN_CERT_VERIFIER_FEATURE_SUPPORTED) if (base::FeatureList::IsEnabled( @@ -121,14 +121,14 @@ class TrialComparisonCertVerifierFeatureOverridenByBuiltinVerifierTest IN_PROC_BROWSER_TEST_F( TrialComparisonCertVerifierFeatureOverridenByBuiltinVerifierTest, TrialEnabledPrefEnabledBuiltVerifierEnabled) { - safe_browsing::SetExtendedReportingPref(browser()->profile()->GetPrefs(), - true); + safe_browsing::SetExtendedReportingPrefForTests( + browser()->profile()->GetPrefs(), true); ASSERT_TRUE(https_test_server_.Start()); base::HistogramTester histograms; ui_test_utils::NavigateToURL(browser(), https_test_server_.GetURL("/title1.html")); - SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); + metrics::SubprocessMetricsProvider::MergeHistogramDeltasForTesting(); histograms.ExpectTotalCount("Net.CertVerifier_Job_Latency", 1); // If both the dual cert verifier trial feature and the builtin verifier // feature are enabled, the dual cert verifier trial should not be used. diff --git a/chromium/chrome/browser/net/trial_comparison_cert_verifier_controller_unittest.cc b/chromium/chrome/browser/net/trial_comparison_cert_verifier_controller_unittest.cc index 83417a3c335..8fa14070863 100644 --- a/chromium/chrome/browser/net/trial_comparison_cert_verifier_controller_unittest.cc +++ b/chromium/chrome/browser/net/trial_comparison_cert_verifier_controller_unittest.cc @@ -234,7 +234,7 @@ TEST_F(TrialComparisonCertVerifierControllerTest, NothingEnabled) { // Enable the SBER pref, shouldn't matter since it's a non-official build and // field trial isn't enabled. - safe_browsing::SetExtendedReportingPref(pref_service(), true); + safe_browsing::SetExtendedReportingPrefForTests(pref_service(), true); // Trial still not allowed, and OnTrialConfigUpdated should not be called // either. @@ -257,7 +257,7 @@ TEST_F(TrialComparisonCertVerifierControllerTest, CreateController(); EXPECT_FALSE(trial_controller().IsAllowed()); - safe_browsing::SetExtendedReportingPref(pref_service(), true); + safe_browsing::SetExtendedReportingPrefForTests(pref_service(), true); // Trial still not allowed, and OnTrialConfigUpdated should not be called // either. @@ -288,7 +288,7 @@ TEST_F(TrialComparisonCertVerifierControllerTest, // In a real official build, expect the trial config to be updated. EXPECT_CALL(mock_config_client(), OnTrialConfigUpdated(true)).Times(1); #endif - safe_browsing::SetExtendedReportingPref(pref_service(), true); + safe_browsing::SetExtendedReportingPrefForTests(pref_service(), true); #if defined(OFFICIAL_BUILD) && BUILDFLAG(GOOGLE_CHROME_BRANDING) // In a real official build, expect the trial to be allowed now. (Don't @@ -326,7 +326,7 @@ TEST_F(TrialComparisonCertVerifierControllerTest, OfficialBuildTrialEnabled) { // Enable the SBER pref, which should trigger the OnTrialConfigUpdated // callback. EXPECT_CALL(mock_config_client(), OnTrialConfigUpdated(true)).Times(1); - safe_browsing::SetExtendedReportingPref(pref_service(), true); + safe_browsing::SetExtendedReportingPrefForTests(pref_service(), true); // Trial should now be allowed. EXPECT_TRUE(trial_controller().IsAllowed()); @@ -378,7 +378,7 @@ TEST_F(TrialComparisonCertVerifierControllerTest, OfficialBuildTrialEnabled) { // Disable the SBER pref again, which should trigger the OnTrialConfigUpdated // callback. EXPECT_CALL(mock_config_client(), OnTrialConfigUpdated(false)).Times(1); - safe_browsing::SetExtendedReportingPref(pref_service(), false); + safe_browsing::SetExtendedReportingPrefForTests(pref_service(), false); // Not allowed now. EXPECT_FALSE(trial_controller().IsAllowed()); @@ -422,7 +422,7 @@ TEST_F(TrialComparisonCertVerifierControllerTest, // callback. EXPECT_CALL(mock_config_client(), OnTrialConfigUpdated(true)).Times(1); EXPECT_CALL(mock_config_client_2, OnTrialConfigUpdated(true)).Times(1); - safe_browsing::SetExtendedReportingPref(pref_service(), true); + safe_browsing::SetExtendedReportingPrefForTests(pref_service(), true); // Trial should now be allowed. EXPECT_TRUE(trial_controller().IsAllowed()); @@ -482,7 +482,7 @@ TEST_F(TrialComparisonCertVerifierControllerTest, // callback. EXPECT_CALL(mock_config_client(), OnTrialConfigUpdated(false)).Times(1); EXPECT_CALL(mock_config_client_2, OnTrialConfigUpdated(false)).Times(1); - safe_browsing::SetExtendedReportingPref(pref_service(), false); + safe_browsing::SetExtendedReportingPrefForTests(pref_service(), false); // Not allowed now. EXPECT_FALSE(trial_controller().IsAllowed()); @@ -515,7 +515,7 @@ TEST_F(TrialComparisonCertVerifierControllerTest, // Enable the SBER pref, which should trigger the OnTrialConfigUpdated // callback. EXPECT_CALL(mock_config_client(), OnTrialConfigUpdated(true)).Times(1); - safe_browsing::SetExtendedReportingPref(pref_service(), true); + safe_browsing::SetExtendedReportingPrefForTests(pref_service(), true); // Trial should now be allowed. EXPECT_TRUE(trial_controller().IsAllowed()); @@ -544,12 +544,12 @@ TEST_F(TrialComparisonCertVerifierControllerTest, scoped_feature_ = std::make_unique<base::test::ScopedFeatureList>(); scoped_feature_->InitAndEnableFeature( features::kCertDualVerificationTrialFeature); - CreateController(profile()->GetOffTheRecordProfile()); + CreateController(profile()->GetPrimaryOTRProfile()); EXPECT_FALSE(trial_controller().IsAllowed()); // Enable the SBER pref, shouldn't matter since it's an incognito profile. - safe_browsing::SetExtendedReportingPref(pref_service(), true); + safe_browsing::SetExtendedReportingPrefForTests(pref_service(), true); // Trial still not allowed, and OnTrialConfigUpdated should not be called // either. diff --git a/chromium/chrome/browser/net/variations_http_headers_browsertest.cc b/chromium/chrome/browser/net/variations_http_headers_browsertest.cc index 4b55712c322..d96eaa2a7a1 100644 --- a/chromium/chrome/browser/net/variations_http_headers_browsertest.cc +++ b/chromium/chrome/browser/net/variations_http_headers_browsertest.cc @@ -18,13 +18,19 @@ #include "chrome/browser/chrome_browser_main.h" #include "chrome/browser/chrome_browser_main_extra_parts.h" #include "chrome/browser/net/system_network_context_manager.h" +#include "chrome/browser/optimization_guide/optimization_guide_keyed_service.h" +#include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h" +#include "chrome/browser/predictors/predictors_features.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/signin/identity_manager_factory.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_commands.h" #include "chrome/common/chrome_paths.h" #include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/ui_test_utils.h" #include "components/network_session_configurator/common/network_switches.h" +#include "components/optimization_guide/optimization_guide_features.h" +#include "components/optimization_guide/proto/hints.pb.h" #include "components/signin/public/identity_manager/identity_test_utils.h" #include "components/variations/net/variations_http_headers.h" #include "components/variations/variations_http_header_provider.h" @@ -134,6 +140,15 @@ class VariationsHttpHeadersBrowserTest : public InProcessBrowserTest { GURL GetExampleUrl() const { return GetExampleUrlWithPath("/landing.html"); } + void WaitForRequest(const GURL& url) { + auto it = received_headers_.find(url); + if (it != received_headers_.end()) + return; + base::RunLoop loop; + done_callbacks_.emplace(url, loop.QuitClosure()); + loop.Run(); + } + // Returns whether a given |header| has been received for a |url|. If // |url| has not been observed, fails an EXPECT and returns false. bool HasReceivedHeader(const GURL& url, const std::string& header) const { @@ -282,6 +297,9 @@ class VariationsHttpHeadersBrowserTest : public InProcessBrowserTest { // Stores the observed HTTP Request headers. std::map<GURL, net::test_server::HttpRequest::HeaderMap> received_headers_; + // For waiting for requests. + std::map<GURL, base::OnceClosure> done_callbacks_; + DISALLOW_COPY_AND_ASSIGN(VariationsHttpHeadersBrowserTest); }; @@ -304,6 +322,10 @@ VariationsHttpHeadersBrowserTest::RequestHandler( // Memorize the request headers for this URL for later verification. received_headers_[original_url] = request.headers; + auto iter = done_callbacks_.find(original_url); + if (iter != done_callbacks_.end()) { + std::move(iter->second).Run(); + } // Set up a test server that redirects according to the // following redirect chain: @@ -584,3 +606,83 @@ IN_PROC_BROWSER_TEST_F(VariationsHttpHeadersBrowserTest, WorkerScriptTest("/workers/create_dedicated_worker.html", "/workers/import_scripts_dedicated_worker.js"); } + +namespace { + +// A test fixture for testing prefetches from the Loading Predictor. +class VariationsHttpHeadersBrowserTestWithOptimizationGuide + : public VariationsHttpHeadersBrowserTest { + public: + VariationsHttpHeadersBrowserTestWithOptimizationGuide() { + std::vector<base::test::ScopedFeatureList::FeatureAndParams> enabled = { + {features::kLoadingPredictorPrefetch, {}}, + {features::kLoadingPredictorUseOptimizationGuide, + {{"use_predictions_for_preconnect", "true"}}}, + {optimization_guide::features::kOptimizationHints, {}}}; + std::vector<base::Feature> disabled = { + features::kLoadingPredictorUseLocalPredictions}; + feature_list_.InitWithFeaturesAndParameters(enabled, disabled); + } + + std::unique_ptr<content::TestNavigationManager> NavigateToURLAsync( + const GURL& url) { + chrome::NewTab(browser()); + content::WebContents* tab = + browser()->tab_strip_model()->GetActiveWebContents(); + DCHECK(tab); + auto observer = std::make_unique<content::TestNavigationManager>(tab, url); + tab->GetController().LoadURL(url, content::Referrer(), + ui::PAGE_TRANSITION_TYPED, std::string()); + return observer; + } + + void SetUpOptimizationHint( + const GURL& url, + const std::vector<std::string>& predicted_subresource_urls) { + auto* optimization_guide_keyed_service = + OptimizationGuideKeyedServiceFactory::GetForProfile( + browser()->profile()); + ASSERT_TRUE(optimization_guide_keyed_service); + + optimization_guide::proto::LoadingPredictorMetadata + loading_predictor_metadata; + for (const auto& subresource_url : predicted_subresource_urls) { + loading_predictor_metadata.add_subresources()->set_url(subresource_url); + } + + optimization_guide::OptimizationMetadata optimization_metadata; + optimization_metadata.set_loading_predictor_metadata( + loading_predictor_metadata); + optimization_guide_keyed_service->AddHintForTesting( + url, optimization_guide::proto::LOADING_PREDICTOR, + optimization_metadata); + } + + private: + base::test::ScopedFeatureList feature_list_; +}; + +} // namespace + +// Verify in an integration test that that the variations header (X-Client-Data) +// is correctly attached to prefetch requests from the Loading Predictor. +IN_PROC_BROWSER_TEST_F(VariationsHttpHeadersBrowserTestWithOptimizationGuide, + Prefetch) { + GURL url = server()->GetURL("test.com", "/simple_page.html"); + GURL google_url = GetGoogleSubresourceUrl(); + GURL non_google_url = GetExampleUrl(); + + // Set up optimization hints. + std::vector<std::string> hints = {google_url.spec(), non_google_url.spec()}; + SetUpOptimizationHint(url, hints); + + // Navigate. + auto observer = NavigateToURLAsync(url); + EXPECT_TRUE(observer->WaitForRequestStart()); + WaitForRequest(google_url); + WaitForRequest(non_google_url); + + // Expect header on google urls only. + EXPECT_TRUE(HasReceivedHeader(google_url, "X-Client-Data")); + EXPECT_FALSE(HasReceivedHeader(non_google_url, "X-Client-Data")); +} diff --git a/chromium/chrome/browser/net/websocket_browsertest.cc b/chromium/chrome/browser/net/websocket_browsertest.cc index e96355ca123..d6bd99c4b14 100644 --- a/chromium/chrome/browser/net/websocket_browsertest.cc +++ b/chromium/chrome/browser/net/websocket_browsertest.cc @@ -409,8 +409,6 @@ class ExpectInvalidUtf8Client : public network::mojom::WebSocketClient { NOTREACHED(); } - void AddSendFlowControlQuota(int64_t quota) override {} - void OnDropChannel(bool was_clean, uint16_t code, const std::string& reason) override { |