Skip to content

Commit

Permalink
[IP Protection] Add chrome://flags entry to disable feature
Browse files Browse the repository at this point in the history
Fixed: 1491882
Change-Id: I8d5a5feabd10356f80394c87eaadf196a23d3dfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4936101
Reviewed-by: Brianna Goldstein <brgoldstein@google.com>
Commit-Queue: Andrew Williams <awillia@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1209599}
  • Loading branch information
recvfrom authored and Chromium LUCI CQ committed Oct 13, 2023
1 parent 8164856 commit dd84030
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 3 deletions.
2 changes: 2 additions & 0 deletions chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,8 @@ static_library("browser") {
"ip_protection/ip_protection_config_provider.h",
"ip_protection/ip_protection_config_provider_factory.cc",
"ip_protection/ip_protection_config_provider_factory.h",
"ip_protection/ip_protection_switches.cc",
"ip_protection/ip_protection_switches.h",
"k_anonymity_service/k_anonymity_service_client.cc",
"k_anonymity_service/k_anonymity_service_client.h",
"k_anonymity_service/k_anonymity_service_factory.cc",
Expand Down
12 changes: 12 additions & 0 deletions chrome/browser/about_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "chrome/browser/file_system_access/file_system_access_features.h"
#include "chrome/browser/flag_descriptions.h"
#include "chrome/browser/follow/follow_features.h"
#include "chrome/browser/ip_protection/ip_protection_switches.h"
#include "chrome/browser/login_detection/login_detection_util.h"
#include "chrome/browser/media/router/discovery/access_code/access_code_cast_constants.h"
#include "chrome/browser/media/router/discovery/access_code/access_code_cast_feature.h"
Expand Down Expand Up @@ -1171,6 +1172,12 @@ const FeatureEntry::Choice kForceTextDirectionChoices[] = {
switches::kForceDirectionRTL},
};

const FeatureEntry::Choice kIpProtectionProxyOptOutChoices[] = {
{flag_descriptions::kIpProtectionProxyOptOutChoiceDefault, "", ""},
{flag_descriptions::kIpProtectionProxyOptOutChoiceOptOut,
switches::kDisableIpProtectionProxy, ""},
};

#if BUILDFLAG(IS_CHROMEOS_ASH)
const FeatureEntry::Choice kSchedulerConfigurationChoices[] = {
{flags_ui::kGenericExperimentChoiceDefault, "", ""},
Expand Down Expand Up @@ -10802,6 +10809,11 @@ const FeatureEntry kFeatureEntries[] = {
FEATURE_VALUE_TYPE(
password_manager::features::kForgotPasswordFormSupport)},

{"ip-protection-proxy-opt-out",
flag_descriptions::kIpProtectionProxyOptOutName,
flag_descriptions::kIpProtectionProxyOptOutDescription, kOsAll,
MULTI_VALUE_TYPE(kIpProtectionProxyOptOutChoices)},

#if BUILDFLAG(IS_ANDROID)
{"autofill-enable-android-n-key-for-fido-authentication",
flag_descriptions::kAutofillEnableAndroidNKeyForFidoAuthenticationName,
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/flag-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5154,6 +5154,11 @@
"owners": [ "djean", "bling-flags@google.com" ],
"expiry_milestone": 120
},
{
"name": "ip-protection-proxy-opt-out",
"owners": [ "awillia", "//chrome/browser/ip_protection/OWNERS" ],
"expiry_milestone": 128
},
{
"name": "iph-extensions-menu-feature",
"owners": [
Expand Down
9 changes: 9 additions & 0 deletions chrome/browser/flag_descriptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,15 @@ const char kInstantHotspotRebrandName[] = "Instant Hotspot Improvements";
const char kInstantHotspotRebrandDescription[] =
"Enables Instant Hotspot rebrand/feature improvements.";

const char kIpProtectionProxyOptOutName[] = "Disable IP Protection Proxy";
const char kIpProtectionProxyOptOutDescription[] =
"When disabled, prevents use of the IP Protection proxy. This is intended "
"to help with diagnosing any issues that could be caused by the feature "
"being enabled. For the current status of this feature, see: "
"https://chromestatus.com/feature/5111460239245312";
const char kIpProtectionProxyOptOutChoiceDefault[] = "Default";
const char kIpProtectionProxyOptOutChoiceOptOut[] = "Disabled";

const char kJapaneseOSSettingsName[] = "Japanese OS Settings Page";
const char kJapaneseOSSettingsDescription[] =
"Enable OS Settings Page for Japanese input methods";
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/flag_descriptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,11 @@ extern const char kIndexedDBCompressValuesWithSnappyDescription[];
extern const char kIndexedDBDefaultDurabilityRelaxed[];
extern const char kIndexedDBDefaultDurabilityRelaxedDescription[];

extern const char kIpProtectionProxyOptOutName[];
extern const char kIpProtectionProxyOptOutDescription[];
extern const char kIpProtectionProxyOptOutChoiceDefault[];
extern const char kIpProtectionProxyOptOutChoiceOptOut[];

extern const char kJapaneseOSSettingsName[];
extern const char kJapaneseOSSettingsDescription[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

#include "chrome/browser/ip_protection/ip_protection_config_provider_factory.h"

#include "base/command_line.h"
#include "chrome/browser/ip_protection/ip_protection_config_provider.h"
#include "chrome/browser/ip_protection/ip_protection_switches.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_selections.h"
#include "chrome/browser/signin/identity_manager_factory.h"
Expand All @@ -27,7 +29,9 @@ IpProtectionConfigProviderFactory::GetInstance() {

// static
ProfileSelections IpProtectionConfigProviderFactory::CreateProfileSelections() {
if (!base::FeatureList::IsEnabled(net::features::kEnableIpProtectionProxy)) {
if (!base::FeatureList::IsEnabled(net::features::kEnableIpProtectionProxy) ||
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableIpProtectionProxy)) {
return ProfileSelections::BuildNoProfilesSelected();
}
// IP Protection usage requires that a Gaia account is available when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

#include "chrome/browser/ip_protection/ip_protection_config_provider_factory.h"

#include "base/strings/string_util.h"
#include "base/test/scoped_command_line.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/ip_protection/ip_protection_config_provider.h"
#include "chrome/browser/ip_protection/ip_protection_switches.h"
#include "chrome/browser/profiles/profile_test_util.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/test/base/testing_profile.h"
Expand All @@ -23,16 +26,32 @@ class ScopedInitFeature {
private:
base::test::ScopedFeatureList feature_list_;
};

class ScopedInitCommandLine {
public:
explicit ScopedInitCommandLine(base::StringPiece command_line_switch) {
if (!command_line_switch.empty()) {
command_line_.GetProcessCommandLine()->AppendSwitch(command_line_switch);
}
}

private:
base::test::ScopedCommandLine command_line_;
};
} // namespace

class IpProtectionConfigProviderFactoryTest : public testing::Test {
protected:
explicit IpProtectionConfigProviderFactoryTest(bool feature_enabled = true)
explicit IpProtectionConfigProviderFactoryTest(
bool feature_enabled = true,
const char* command_line_switch = "")
// Note that the order of initialization is important here - we want to
// set the value of the feature before anything else since it's used by
// the `IpProtectionConfigProviderFactory` logic.
// the `IpProtectionConfigProviderFactory` logic. Same for the command
// line switch, if specified.
: scoped_feature_(net::features::kEnableIpProtectionProxy,
feature_enabled),
scoped_command_line_(command_line_switch),
profile_selections_(IpProtectionConfigProviderFactory::GetInstance(),
IpProtectionConfigProviderFactory::
CreateProfileSelectionsForTesting()) {}
Expand All @@ -47,6 +66,7 @@ class IpProtectionConfigProviderFactoryTest : public testing::Test {
TestingProfile* profile() { return profile_.get(); }

ScopedInitFeature scoped_feature_;
ScopedInitCommandLine scoped_command_line_;
profiles::testing::ScopedProfileSelectionsForFactoryTesting
profile_selections_;
content::BrowserTaskEnvironment task_environment_;
Expand Down Expand Up @@ -89,3 +109,19 @@ TEST_F(IpProtectionConfigProviderFactoryFeatureDisabledTest,
IpProtectionConfigProviderFactory::GetForProfile(profile());
ASSERT_FALSE(service);
}

class IpProtectionConfigProviderFactoryOptOutEnabled
: public IpProtectionConfigProviderFactoryTest {
public:
IpProtectionConfigProviderFactoryOptOutEnabled()
: IpProtectionConfigProviderFactoryTest(
/*feature_enabled=*/true,
/*command_line_switch=*/switches::kDisableIpProtectionProxy) {}
};

TEST_F(IpProtectionConfigProviderFactoryOptOutEnabled,
ServiceCreationFailsWhenUserOptedOut) {
IpProtectionConfigProvider* service =
IpProtectionConfigProviderFactory::GetForProfile(profile());
ASSERT_FALSE(service);
}
11 changes: 11 additions & 0 deletions chrome/browser/ip_protection/ip_protection_switches.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ip_protection/ip_protection_switches.h"

namespace switches {

const char kDisableIpProtectionProxy[] = "disable-ip-privacy-proxy";

} // namespace switches
16 changes: 16 additions & 0 deletions chrome/browser/ip_protection/ip_protection_switches.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_IP_PROTECTION_IP_PROTECTION_SWITCHES_H_
#define CHROME_BROWSER_IP_PROTECTION_IP_PROTECTION_SWITCHES_H_

namespace switches {

// Disable IP Protection proxy, for use with a corresponding chrome://flags
// entry in case of breakage or when debugging.
extern const char kDisableIpProtectionProxy[];

} // namespace switches

#endif // CHROME_BROWSER_IP_PROTECTION_IP_PROTECTION_SWITCHES_H_
1 change: 1 addition & 0 deletions tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64149,6 +64149,7 @@ from previous Chrome versions.
<int value="-497571337" label="SkipUndecryptablePasswords:enabled"/>
<int value="-496989565"
label="DesktopPWAsFlashAppNameInsteadOfOrigin:disabled"/>
<int value="-496879081" label="disable-ip-privacy-proxy"/>
<int value="-496119023" label="WebXR:enabled"/>
<int value="-495991146" label="CustomizeChromeSidePanel:disabled"/>
<int value="-495585885" label="enable-spdy-proxy-dev-auth-origin"/>
Expand Down

0 comments on commit dd84030

Please sign in to comment.