Skip to content

Commit

Permalink
Add new experiment configuration for Attribution Reporting
Browse files Browse the repository at this point in the history
This CL introduces a new RTE trial feature which enabled Attribution
Reporting, Fledge, and Topics.

With this change multiple RTE features will use the same OT trial name,
however we want to ensure they can still be individually enabled/
disabled via feature specific base::Features. We add new logic to
further restrict what features can be registered from a given trial
name for this reason.

In order for the pre-existing Fledge and Topics RTEF to work
correctly with the origin trial infrastructure, we remove their
base::Features mappings, and introduce a new base::Feature
PrivacySandboxAdStackOverride which allows force enabling via flags.

A separate override about:flag is enabled which overrides the RTE
features and ensures that privacy sandbox settings are skipped to
allow for local testing with the new experiment configuration
(which would otherwise not be possible).

Note: With this new experiment config, Attribution Reporting will
no longer be using a user subset exclusion origin trial, so
corresponding tests are removed.

Bug: 1309791
Change-Id: I00dfde8c6154accfbc88d96dfffdcba702edca83
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3527133
Reviewed-by: Josh Karlin <jkarlin@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Russ Hamilton <behamilton@google.com>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: Paul Jensen <pauljensen@chromium.org>
Reviewed-by: Theodore Olsauskas-Warren <sauski@google.com>
Reviewed-by: Andrew Paseltiner <apaseltiner@chromium.org>
Reviewed-by: Yao Xiao <yaoxia@chromium.org>
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Reviewed-by: Dominic Farolino <dom@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: John Delaney <johnidel@chromium.org>
Cr-Commit-Position: refs/heads/main@{#985142}
  • Loading branch information
John Delaney authored and Chromium LUCI CQ committed Mar 25, 2022
1 parent 693d487 commit 1d6e4b5
Show file tree
Hide file tree
Showing 46 changed files with 453 additions and 315 deletions.
Expand Up @@ -48,8 +48,9 @@
// enable-experimental-web-platform-features turns on the overall ConversionMeasurement Blink
// feature.
// conversions-debug-mode will send reports with no delay or noise.
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
"enable-experimental-web-platform-features", "conversions-debug-mode"})
@CommandLineFlags.
Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE, "enable-experimental-web-platform-features",
"enable-blink-test-features", "conversions-debug-mode"})
@Features.EnableFeatures(ChromeFeatureList.APP_TO_WEB_ATTRIBUTION)
public class AttributionProviderIntegrationTest {
private static final String EVENT_ID = "12345";
Expand Down
10 changes: 10 additions & 0 deletions chrome/browser/about_flags.cc
Expand Up @@ -7141,6 +7141,16 @@ const FeatureEntry kFeatureEntries[] = {
"disable-dialog-for-testing/true/show-sample-data/true,"
"EnableFetchingAccountCapabilities")},

{"privacy-sandbox-ads-apis",
flag_descriptions::kPrivacySandboxAdsAPIsOverrideName,
flag_descriptions::kPrivacySandboxAdsAPIsOverrideDescription, kOsAll,
// Use a command-line parameter instead of a FEATURE_VALUE_TYPE to enable
// multiple related features when they are available.
SINGLE_VALUE_TYPE_AND_VALUE(switches::kEnableFeatures,
"PrivacySandboxAdsAPIsOverride"
"Fledge,BrowsingTopics,ConversionMeasurement"
"OverridePrivacySandboxSettingsLocalTesting")},

{"animated-image-resume", flag_descriptions::kAnimatedImageResumeName,
flag_descriptions::kAnimatedImageResumeDescription, kOsAll,
FEATURE_VALUE_TYPE(features::kAnimatedImageResume)},
Expand Down
Expand Up @@ -31,6 +31,7 @@ class ChromeAttributionBrowserTest : public InProcessBrowserTest {
// Sets up the blink runtime feature for ConversionMeasurement.
command_line->AppendSwitch(
switches::kEnableExperimentalWebPlatformFeatures);
command_line->AppendSwitch(switches::kEnableBlinkTestFeatures);
}

void SetUpOnMainThread() override {
Expand Down

This file was deleted.

Expand Up @@ -9,6 +9,7 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/browsing_topics/browsing_topics_service.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_test.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/request_handler_util.h"
Expand Down Expand Up @@ -90,7 +91,8 @@ class BrowsingTopicsBrowserTest : public BrowsingTopicsBrowserTestBase {
public:
BrowsingTopicsBrowserTest() {
scoped_feature_list_.InitWithFeatures(
/*enabled_features=*/{blink::features::kBrowsingTopics},
/*enabled_features=*/{blink::features::kBrowsingTopics,
features::kPrivacySandboxAdsAPIsOverride},
/*disabled_features=*/{});
}

Expand Down
Expand Up @@ -185,7 +185,8 @@ class DeclarativeNetRequestBrowserTest
/*enabled_features=*/
{blink::features::kInterestGroupStorage,
blink::features::kAdInterestGroupAPI, blink::features::kFledge,
blink::features::kFencedFrames},
blink::features::kFencedFrames,
features::kPrivacySandboxAdsAPIsOverride},
/*disabled_features=*/
{});
net::test_server::RegisterDefaultHandlers(embedded_test_server());
Expand Down
8 changes: 8 additions & 0 deletions chrome/browser/flag-metadata.json
Expand Up @@ -4863,6 +4863,14 @@
"chrome-friendly-settings@google.com"],
"expiry_milestone": 104
},
{
"name": "privacy-sandbox-ads-apis",
"owners": [
"johnidel",
"jkarlin",
"pauljensen"],
"expiry_milestone": 104
},
{
"name": "privacy-sandbox-v3-android",
"owners": [
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/flag_descriptions.cc
Expand Up @@ -2130,6 +2130,11 @@ const char kPrivacyGuide2Description[] =
"Enables UI updates for Privacy Guide. This requires #privacy-guide to "
"also be enabled";

const char kPrivacySandboxAdsAPIsOverrideName[] = "Privacy Sandbox Ads APIs";
const char kPrivacySandboxAdsAPIsOverrideDescription[] =
"Enables Privacy Sandbox APIs: Attribtuion Reporting, Fledge, Topics and "
"their associated features.";

const char kPrivacySandboxV3Name[] = "Privacy Sandbox V3";
const char kPrivacySandboxV3Description[] =
"Enables an updated Privacy Sandbox UI. Also enables some related "
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/flag_descriptions.h
Expand Up @@ -1200,6 +1200,9 @@ extern const char kPrivacyGuideDescription[];
extern const char kPrivacyGuide2Name[];
extern const char kPrivacyGuide2Description[];

extern const char kPrivacySandboxAdsAPIsOverrideName[];
extern const char kPrivacySandboxAdsAPIsOverrideDescription[];

extern const char kPrivacySandboxV3Name[];
extern const char kPrivacySandboxV3Description[];

Expand Down
Expand Up @@ -15,6 +15,7 @@
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/prefs/pref_service.h"
#include "content/public/common/content_features.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"
Expand All @@ -28,7 +29,8 @@ class InterestGroupPermissionsBrowserTest : public InProcessBrowserTest {
scoped_feature_list_.InitWithFeatures(
/*enabled_features=*/
{blink::features::kInterestGroupStorage,
blink::features::kAdInterestGroupAPI, blink::features::kFledge},
blink::features::kAdInterestGroupAPI, blink::features::kFledge,
features::kPrivacySandboxAdsAPIsOverride},
/*disabled_features=*/
{blink::features::kFencedFrames});
}
Expand Down Expand Up @@ -202,7 +204,7 @@ class InterestGroupOffBrowserTest : public InterestGroupPermissionsBrowserTest {
scoped_feature_list_.InitWithFeatures(
{blink::features::kInterestGroupStorage},
{blink::features::kAdInterestGroupAPI, blink::features::kFledge,
blink::features::kParakeet});
blink::features::kParakeet, features::kPrivacySandboxAdsAPIsOverride});
}
base::test::ScopedFeatureList scoped_feature_list_;
};
Expand All @@ -222,7 +224,8 @@ class InterestGroupFledgeOnBrowserTest
public:
InterestGroupFledgeOnBrowserTest() {
scoped_feature_list_.InitWithFeatures(
{blink::features::kInterestGroupStorage, blink::features::kFledge},
{blink::features::kInterestGroupStorage, blink::features::kFledge,
features::kPrivacySandboxAdsAPIsOverride},
{blink::features::kAdInterestGroupAPI, blink::features::kParakeet});
}
base::test::ScopedFeatureList scoped_feature_list_;
Expand All @@ -245,7 +248,8 @@ class InterestGroupParakeetOnBrowserTest
InterestGroupParakeetOnBrowserTest() {
scoped_feature_list_.InitWithFeatures(
{blink::features::kInterestGroupStorage, blink::features::kParakeet},
{blink::features::kAdInterestGroupAPI, blink::features::kFledge});
{blink::features::kAdInterestGroupAPI, blink::features::kFledge,
features::kPrivacySandboxAdsAPIsOverride});
}
base::test::ScopedFeatureList scoped_feature_list_;
};
Expand All @@ -269,7 +273,8 @@ class InterestGroupAPIOnBrowserTest
scoped_feature_list_.InitWithFeatures(
{blink::features::kInterestGroupStorage,
blink::features::kAdInterestGroupAPI},
{blink::features::kParakeet, blink::features::kFledge});
{blink::features::kParakeet, blink::features::kFledge,
features::kPrivacySandboxAdsAPIsOverride});
}
base::test::ScopedFeatureList scoped_feature_list_;
};
Expand Down
1 change: 0 additions & 1 deletion chrome/test/BUILD.gn
Expand Up @@ -1590,7 +1590,6 @@ if (!is_android) {
"../browser/apps/platform_apps/platform_app_navigation_redirector_browsertest.cc",
"../browser/apps/platform_apps/service_worker_browsertest.cc",
"../browser/attribution_reporting/chrome_attribution_browsertest.cc",
"../browser/attribution_reporting/conversions_usage_restriction_trial_browsertest.cc",
"../browser/autocomplete/autocomplete_browsertest.cc",
"../browser/autofill/autofill_autocomplete_browsertest.cc",
"../browser/autofill/autofill_browsertest.cc",
Expand Down
4 changes: 4 additions & 0 deletions components/privacy_sandbox/privacy_sandbox_features.cc
Expand Up @@ -21,4 +21,8 @@ const base::FeatureParam<bool>
const base::FeatureParam<bool> kPrivacySandboxSettings3ShowSampleDataForTesting{
&kPrivacySandboxSettings3, "show-sample-data", false};

const base::Feature kOverridePrivacySandboxSettingsLocalTesting{
"OverridePrivacySandboxSettingsLocalTesting",
base::FEATURE_DISABLED_BY_DEFAULT};

} // namespace privacy_sandbox
2 changes: 2 additions & 0 deletions components/privacy_sandbox/privacy_sandbox_features.h
Expand Up @@ -27,6 +27,8 @@ extern const base::FeatureParam<bool>
extern const base::FeatureParam<bool>
kPrivacySandboxSettings3ShowSampleDataForTesting;

extern const base::Feature kOverridePrivacySandboxSettingsLocalTesting;

} // namespace privacy_sandbox

#endif // COMPONENTS_PRIVACY_SANDBOX_PRIVACY_SANDBOX_FEATURES_H_
15 changes: 14 additions & 1 deletion components/privacy_sandbox/privacy_sandbox_settings.cc
Expand Up @@ -343,18 +343,31 @@ bool PrivacySandboxSettings::IsPrivacySandboxEnabled() const {
if (delegate_->IsPrivacySandboxRestricted())
return false;

// For Measurement and Relevance APIs, we explicitly do not require the
// underlying pref to be enabled if there is a local flag enabling the APIs to
// allow for local testing.
bool should_override_setting_for_local_testing = base::FeatureList::IsEnabled(
privacy_sandbox::kOverridePrivacySandboxSettingsLocalTesting);

// Which preference is consulted is dependent on whether release 3 of the
// settings is available.
if (base::FeatureList::IsEnabled(privacy_sandbox::kPrivacySandboxSettings3)) {
// For Privacy Sandbox Settings 3, APIs are disabled in incognito.
if (incognito_profile_)
return false;

// For Privacy Sadnbox Settings 3, APIs may be restricted via the delegate.
if (should_override_setting_for_local_testing) {
return true;
}

// For Privacy Sandbox Settings 3, APIs may be restricted via the delegate.
// The V2 pref was introduced with the 3rd Privacy Sandbox release.
return pref_service_->GetBoolean(prefs::kPrivacySandboxApisEnabledV2);
}

if (should_override_setting_for_local_testing)
return true;

return pref_service_->GetBoolean(prefs::kPrivacySandboxApisEnabled);
}

Expand Down
34 changes: 33 additions & 1 deletion components/privacy_sandbox/privacy_sandbox_settings_unittest.cc
Expand Up @@ -93,9 +93,11 @@ class PrivacySandboxSettingsTest : public testing::TestWithParam<bool> {
return &browser_task_environment_;
}

protected:
base::test::ScopedFeatureList feature_list_;

private:
content::BrowserTaskEnvironment browser_task_environment_;
base::test::ScopedFeatureList feature_list_;
raw_ptr<privacy_sandbox_test_util::MockPrivacySandboxSettingsDelegate>
mock_delegate_;
sync_preferences::TestingPrefServiceSyncable prefs_;
Expand Down Expand Up @@ -886,4 +888,34 @@ INSTANTIATE_TEST_SUITE_P(PrivacySandboxSettingsMockDelegateTestInstance,
PrivacySandboxSettingsMockDelegateTest,
testing::Bool());

class PrivacySandboxSettingLocalOverrideTest
: public PrivacySandboxSettingsTest {
void InitializeFeaturesBeforeStart() override {
if (GetParam()) {
feature_list_.InitWithFeatures(
{privacy_sandbox::kPrivacySandboxSettings3,
privacy_sandbox::kOverridePrivacySandboxSettingsLocalTesting},
/*disabled_features=*/{});
} else {
feature_list_.InitWithFeatures(
{privacy_sandbox::kPrivacySandboxSettings3},
{privacy_sandbox::kOverridePrivacySandboxSettingsLocalTesting});
}
}
};

TEST_P(PrivacySandboxSettingLocalOverrideTest, FollowsOverrideBehavior) {
// When the Release 3 flag is enabled, APIs should always be disabled in
// incognito. The Release 3 flag is set based on the test param.
privacy_sandbox_settings()->SetPrivacySandboxEnabled(false);
if (GetParam())
EXPECT_TRUE(privacy_sandbox_settings()->IsPrivacySandboxEnabled());
else
EXPECT_FALSE(privacy_sandbox_settings()->IsPrivacySandboxEnabled());
}

INSTANTIATE_TEST_SUITE_P(PrivacySandboxSettingLocalOverrideTestInstance,
PrivacySandboxSettingLocalOverrideTest,
testing::Bool());

} // namespace privacy_sandbox
Expand Up @@ -154,6 +154,7 @@ class AttributionsBrowserTest : public ContentBrowserTest {
// Sets up the blink runtime feature for ConversionMeasurement.
command_line->AppendSwitch(
switches::kEnableExperimentalWebPlatformFeatures);
command_line->AppendSwitch(switches::kEnableBlinkTestFeatures);
}

void SetUpOnMainThread() override {
Expand Down

0 comments on commit 1d6e4b5

Please sign in to comment.