Commit da04c6e1 authored by David Van Cleve's avatar David Van Cleve Committed by Commit Bot

Adds feature disabling referrers by default

This CL adds a new feature, kNoReferrers, to subsume the functionality
of the --no-referrers switch.  When the feature is *true*, the
kEnableReferrers pref will have its default value set to *false*.  This
is the current effect of setting the --no-referrers switch.

A separate CL, crrev.com/c/1808144, is in progress to remove the switch
itself.

This is one of a series of changes adding
functionality to run a Finch experiment exploring different
levels of referrer policy and caps.

R=creis, mmenke

depending on the value of the feature.

Test: Added browser test to confirm that the pref is set correctly
Bug: 1004486
Change-Id: If250cf4f29523328e540aa23672436071fbbb10a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1806080
Commit-Queue: Matt Menke <mmenke@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699349}
parent 035bf351
...@@ -476,6 +476,9 @@ SystemNetworkContextManager::SystemNetworkContextManager( ...@@ -476,6 +476,9 @@ SystemNetworkContextManager::SystemNetworkContextManager(
pref_change_registrar_.Add(prefs::kKerberosEnabled, auth_pref_callback); pref_change_registrar_.Add(prefs::kKerberosEnabled, auth_pref_callback);
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
local_state_->SetDefaultPrefValue(
prefs::kEnableReferrers,
base::Value(!base::FeatureList::IsEnabled(features::kNoReferrers)));
enable_referrers_.Init( enable_referrers_.Init(
prefs::kEnableReferrers, local_state_, prefs::kEnableReferrers, local_state_,
base::BindRepeating(&SystemNetworkContextManager::UpdateReferrersEnabled, base::BindRepeating(&SystemNetworkContextManager::UpdateReferrersEnabled,
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/user_agent.h" #include "content/public/common/user_agent.h"
#include "services/network/public/cpp/network_service_buildflags.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_context.mojom.h"
...@@ -295,6 +294,36 @@ INSTANTIATE_TEST_SUITE_P(, ...@@ -295,6 +294,36 @@ INSTANTIATE_TEST_SUITE_P(,
SystemNetworkContextManagerStubResolverBrowsertest, SystemNetworkContextManagerStubResolverBrowsertest,
::testing::Bool()); ::testing::Bool());
class SystemNetworkContextManagerReferrersFeatureBrowsertest
: public SystemNetworkContextManagerBrowsertest,
public testing::WithParamInterface<bool> {
public:
SystemNetworkContextManagerReferrersFeatureBrowsertest() {
scoped_feature_list_.InitWithFeatureState(features::kNoReferrers,
GetParam());
}
~SystemNetworkContextManagerReferrersFeatureBrowsertest() override {}
void SetUpOnMainThread() override {}
private:
base::test::ScopedFeatureList scoped_feature_list_;
};
// Tests that toggling the kNoReferrers feature correctly changes the default
// value of the kEnableReferrers pref.
IN_PROC_BROWSER_TEST_P(SystemNetworkContextManagerReferrersFeatureBrowsertest,
TestDefaultReferrerReflectsFeatureValue) {
ASSERT_TRUE(!!g_browser_process);
PrefService* local_state = g_browser_process->local_state();
ASSERT_TRUE(!!local_state);
EXPECT_NE(local_state->GetBoolean(prefs::kEnableReferrers), GetParam());
}
INSTANTIATE_TEST_SUITE_P(,
SystemNetworkContextManagerReferrersFeatureBrowsertest,
::testing::Bool());
class SystemNetworkContextManagerFreezeQUICUaBrowsertest class SystemNetworkContextManagerFreezeQUICUaBrowsertest
: public SystemNetworkContextManagerBrowsertest, : public SystemNetworkContextManagerBrowsertest,
public testing::WithParamInterface<bool> { public testing::WithParamInterface<bool> {
......
...@@ -513,6 +513,11 @@ const base::Feature kNewNetErrorPageUI{"NewNetErrorPageUI", ...@@ -513,6 +513,11 @@ const base::Feature kNewNetErrorPageUI{"NewNetErrorPageUI",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
#endif // OS_ANDROID #endif // OS_ANDROID
// When kNoReferrers is enabled, most HTTP requests will provide empty
// referrers instead of their ordinary behavior.
const base::Feature kNoReferrers{"NoReferrers",
base::FEATURE_DISABLED_BY_DEFAULT};
#if defined(OS_POSIX) #if defined(OS_POSIX)
// Enables NTLMv2, which implicitly disables NTLMv1. // Enables NTLMv2, which implicitly disables NTLMv1.
const base::Feature kNtlmV2Enabled{"NtlmV2Enabled", const base::Feature kNtlmV2Enabled{"NtlmV2Enabled",
......
...@@ -331,6 +331,8 @@ extern const base::Feature kNativeNotifications; ...@@ -331,6 +331,8 @@ extern const base::Feature kNativeNotifications;
COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kNewNetErrorPageUI; COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kNewNetErrorPageUI;
#endif #endif
COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kNoReferrers;
#if defined(OS_POSIX) #if defined(OS_POSIX)
COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kNtlmV2Enabled; COMPONENT_EXPORT(CHROME_FEATURES) extern const base::Feature kNtlmV2Enabled;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment