[unified-consent] Remove consent bump internals
Remove consent bump internals. This includes:
- API + tests from UnifiedConsentService
- Metrics
- Feature state and flags
Bug: 906026
Change-Id: Ibc12bee6ea661061530e321fe9c9e45363792f9d
Reviewed-on: https://chromium-review.googlesource.com/c/1355162
Reviewed-by: Jochen Eisinger <[email protected]>
Reviewed-by: Brian White <[email protected]>
Reviewed-by: David Roger <[email protected]>
Commit-Queue: Thomas Tangl <[email protected]>
Cr-Commit-Position: refs/heads/master@{#612621}
diff --git a/components/unified_consent/feature.cc b/components/unified_consent/feature.cc
index 19b47f9..7f87d77 100644
--- a/components/unified_consent/feature.cc
+++ b/components/unified_consent/feature.cc
@@ -4,39 +4,14 @@
#include "components/unified_consent/feature.h"
-#include "base/feature_list.h"
-#include "base/metrics/field_trial_params.h"
-#include "components/sync/driver/sync_driver_switches.h"
-
namespace unified_consent {
-// base::Feature definitions.
+// base::Feature definition.
const base::Feature kUnifiedConsent{"UnifiedConsent",
base::FEATURE_DISABLED_BY_DEFAULT};
-const char kUnifiedConsentShowBumpParameter[] = "show_consent_bump";
-const base::Feature kForceUnifiedConsentBump{"ForceUnifiedConsentBump",
- base::FEATURE_DISABLED_BY_DEFAULT};
-
-namespace {
-UnifiedConsentFeatureState GetUnifiedConsentFeatureState() {
- if (!base::FeatureList::IsEnabled(kUnifiedConsent))
- return UnifiedConsentFeatureState::kDisabled;
-
- std::string show_bump = base::GetFieldTrialParamValueByFeature(
- kUnifiedConsent, kUnifiedConsentShowBumpParameter);
- return show_bump.empty() ? UnifiedConsentFeatureState::kEnabledNoBump
- : UnifiedConsentFeatureState::kEnabledWithBump;
-}
-} // namespace
bool IsUnifiedConsentFeatureEnabled() {
- return GetUnifiedConsentFeatureState() !=
- UnifiedConsentFeatureState::kDisabled;
-}
-
-bool IsUnifiedConsentFeatureWithBumpEnabled() {
- return GetUnifiedConsentFeatureState() ==
- UnifiedConsentFeatureState::kEnabledWithBump;
+ return base::FeatureList::IsEnabled(kUnifiedConsent);
}
} // namespace unified_consent
diff --git a/components/unified_consent/feature.h b/components/unified_consent/feature.h
index 21bd42d..bd59685 100644
--- a/components/unified_consent/feature.h
+++ b/components/unified_consent/feature.h
@@ -9,30 +9,12 @@
namespace unified_consent {
-// State of the "Unified Consent" feature.
-enum class UnifiedConsentFeatureState {
- // Unified consent is disabled.
- kDisabled,
- // Unified consent is enabled, but the bump is not shown.
- kEnabledNoBump,
- // Unified consent is enabled and the bump is shown.
- kEnabledWithBump
-};
-
-// Improved and unified consent for privacy-related features.
+// Single consent for Google services in Chrome.
extern const base::Feature kUnifiedConsent;
-extern const char kUnifiedConsentShowBumpParameter[];
-extern const base::Feature kForceUnifiedConsentBump;
-// Returns true if the unified consent feature state is kEnabledNoBump or
-// kEnabledWithBump. Note that the bump may not be enabled, even if this returns
-// true. To check if the bump is enabled, use
-// IsUnifiedConsentFeatureWithBumpEnabled().
+// Returns true if the unified consent feature state is enabled.
bool IsUnifiedConsentFeatureEnabled();
-// Returns true if the unified consent feature state is kEnabledWithBump.
-bool IsUnifiedConsentFeatureWithBumpEnabled();
-
} // namespace unified_consent
#endif // COMPONENTS_UNIFIED_CONSENT_FEATURE_H_
diff --git a/components/unified_consent/feature_unittest.cc b/components/unified_consent/feature_unittest.cc
index 60cc2f7..534e985 100644
--- a/components/unified_consent/feature_unittest.cc
+++ b/components/unified_consent/feature_unittest.cc
@@ -13,26 +13,15 @@
TEST(UnifiedConsentFeatureTest, FeatureState) {
// Unified consent is disabled by default.
EXPECT_FALSE(IsUnifiedConsentFeatureEnabled());
- EXPECT_FALSE(IsUnifiedConsentFeatureWithBumpEnabled());
{
ScopedUnifiedConsent scoped_disabled(UnifiedConsentFeatureState::kDisabled);
EXPECT_FALSE(IsUnifiedConsentFeatureEnabled());
- EXPECT_FALSE(IsUnifiedConsentFeatureWithBumpEnabled());
}
{
- ScopedUnifiedConsent scoped_no_bump(
- UnifiedConsentFeatureState::kEnabledNoBump);
+ ScopedUnifiedConsent scoped_enabled(UnifiedConsentFeatureState::kEnabled);
EXPECT_TRUE(IsUnifiedConsentFeatureEnabled());
- EXPECT_FALSE(IsUnifiedConsentFeatureWithBumpEnabled());
- }
-
- {
- ScopedUnifiedConsent scoped_bump(
- UnifiedConsentFeatureState::kEnabledWithBump);
- EXPECT_TRUE(IsUnifiedConsentFeatureEnabled());
- EXPECT_TRUE(IsUnifiedConsentFeatureWithBumpEnabled());
}
}
diff --git a/components/unified_consent/pref_names.cc b/components/unified_consent/pref_names.cc
index 21f394c..e242092 100644
--- a/components/unified_consent/pref_names.cc
+++ b/components/unified_consent/pref_names.cc
@@ -13,11 +13,6 @@
const char kAllUnifiedConsentServicesWereEnabled[] =
"unified_consent.all_services_were_enabled";
-// Boolean indicating whether all criteria is met for the consent bump to be
-// shown.
-const char kShouldShowUnifiedConsentBump[] =
- "unified_consent.consent_bump.should_show";
-
// Integer indicating the migration state of unified consent, defined in
// unified_consent::MigrationState.
const char kUnifiedConsentMigrationState[] = "unified_consent.migration_state";
diff --git a/components/unified_consent/pref_names.h b/components/unified_consent/pref_names.h
index c717732..534f9d14b 100644
--- a/components/unified_consent/pref_names.h
+++ b/components/unified_consent/pref_names.h
@@ -9,7 +9,6 @@
namespace prefs {
extern const char kAllUnifiedConsentServicesWereEnabled[];
-extern const char kShouldShowUnifiedConsentBump[];
extern const char kUnifiedConsentMigrationState[];
extern const char kUrlKeyedAnonymizedDataCollectionEnabled[];
diff --git a/components/unified_consent/scoped_unified_consent.cc b/components/unified_consent/scoped_unified_consent.cc
index a6076bf..d1eef04 100644
--- a/components/unified_consent/scoped_unified_consent.cc
+++ b/components/unified_consent/scoped_unified_consent.cc
@@ -11,6 +11,7 @@
#include "base/bind.h"
#include "base/feature_list.h"
#include "base/logging.h"
+#include "components/unified_consent/feature.h"
namespace unified_consent {
@@ -19,16 +20,9 @@
case UnifiedConsentFeatureState::kDisabled:
unified_consent_feature_list_.InitAndDisableFeature(kUnifiedConsent);
break;
- case UnifiedConsentFeatureState::kEnabledNoBump:
+ case UnifiedConsentFeatureState::kEnabled:
unified_consent_feature_list_.InitAndEnableFeature(kUnifiedConsent);
break;
- case UnifiedConsentFeatureState::kEnabledWithBump: {
- std::map<std::string, std::string> feature_params;
- feature_params[kUnifiedConsentShowBumpParameter] = "true";
- unified_consent_feature_list_.InitAndEnableFeatureWithParameters(
- kUnifiedConsent, feature_params);
- break;
- }
}
}
diff --git a/components/unified_consent/scoped_unified_consent.h b/components/unified_consent/scoped_unified_consent.h
index b7b4fc1..f4bce38 100644
--- a/components/unified_consent/scoped_unified_consent.h
+++ b/components/unified_consent/scoped_unified_consent.h
@@ -9,10 +9,17 @@
#include "base/macros.h"
#include "base/test/scoped_feature_list.h"
-#include "components/unified_consent/feature.h"
namespace unified_consent {
+// State of the "Unified Consent" feature.
+enum class UnifiedConsentFeatureState {
+ // Unified consent is disabled.
+ kDisabled,
+ // Unified consent is enabled.
+ kEnabled,
+};
+
// Changes the unified consent feature state while it is in scope. Useful for
// tests.
// Also enables the feature |switches::kSyncUserConsentSeparateType| as
diff --git a/components/unified_consent/unified_consent_metrics.cc b/components/unified_consent/unified_consent_metrics.cc
index 0ecc8801..9a76647 100644
--- a/components/unified_consent/unified_consent_metrics.cc
+++ b/components/unified_consent/unified_consent_metrics.cc
@@ -10,9 +10,6 @@
namespace {
-// Histogram name for the consent bump action.
-const char kConsentBumpActionMetricName[] = "UnifiedConsent.ConsentBump.Action";
-
// Histogram recorded at startup to log which Google services are enabled.
const char kSyncAndGoogleServicesSettingsHistogram[] =
"UnifiedConsent.SyncAndGoogleServicesSettings";
@@ -23,17 +20,6 @@
namespace metrics {
-void RecordConsentBumpMetric(UnifiedConsentBumpAction action) {
- UMA_HISTOGRAM_ENUMERATION(
- kConsentBumpActionMetricName, action,
- UnifiedConsentBumpAction::kUnifiedConsentBumpActionMoreOptionsMax);
-}
-
-void RecordConsentBumpEligibility(bool eligible) {
- UMA_HISTOGRAM_BOOLEAN("UnifiedConsent.ConsentBump.EligibleAtStartup",
- eligible);
-}
-
void RecordSettingsHistogram(UnifiedConsentServiceClient* service_client,
PrefService* pref_service) {
bool metric_recorded = false;
diff --git a/components/unified_consent/unified_consent_metrics.h b/components/unified_consent/unified_consent_metrics.h
index b0e55a9a8e..aaf73a9 100644
--- a/components/unified_consent/unified_consent_metrics.h
+++ b/components/unified_consent/unified_consent_metrics.h
@@ -11,43 +11,6 @@
namespace metrics {
-// Histogram enum: UnifiedConsentBumpAction.
-enum class UnifiedConsentBumpAction : int {
- kUnifiedConsentBumpActionDefaultOptIn = 0,
- kUnifiedConsentBumpActionMoreOptionsOptIn,
- kUnifiedConsentBumpActionMoreOptionsReviewSettings,
- kUnifiedConsentBumpActionMoreOptionsNoChanges,
- kUnifiedConsentBumpActionMoreOptionsMax,
-};
-
-// Used in histograms. Do not change existing values, append new values at the
-// end.
-enum class ConsentBumpSuppressReason {
- // There is no suppress reason. The consent bump was shown.
- kNone,
- // The user wasn't signed in during the migration.
- kNotSignedIn,
- // The user wasn't syncing everything during the migration.
- kSyncEverythingOff,
- // The user didn't have all on-by-default privacy settings enabled during
- // migration.
- kPrivacySettingOff,
- kSettingsOptIn,
- // The user was eligible for seeing the consent bump, but then signed out.
- kUserSignedOut,
- kSyncPaused,
- // The user was eligible for seeing the consent bump, but turned an individual
- // sync data type off.
- kUserTurnedSyncDatatypeOff,
- // The user was eligible for seeing the consent bump, but turned an
- // on-by-default privacy setting off.
- kUserTurnedPrivacySettingOff,
- // The user has a custom passphrase tied to their sync account.
- kCustomPassphrase,
-
- kMaxValue = kCustomPassphrase
-};
-
// Google services that can be toggled in user settings.
// Used in histograms. Do not change existing values, append new values at the
// end.
@@ -63,13 +26,6 @@
kMaxValue = kAllServicesWereEnabled
};
-// Records histogram action for the unified consent bump.
-void RecordConsentBumpMetric(UnifiedConsentBumpAction action);
-
-// Records whether the user is eligible for the consent bump. This method should
-// be called at startup.
-void RecordConsentBumpEligibility(bool eligible);
-
// Records settings entries in the kSyncAndGoogleServicesSettingsHistogram.
// kNone is recorded when none of the settings is enabled.
void RecordSettingsHistogram(UnifiedConsentServiceClient* service_client,
diff --git a/components/unified_consent/unified_consent_service.cc b/components/unified_consent/unified_consent_service.cc
index ed27965..1ccfff8 100644
--- a/components/unified_consent/unified_consent_service.cc
+++ b/components/unified_consent/unified_consent_service.cc
@@ -37,9 +37,6 @@
if (GetMigrationState() == MigrationState::kNotInitialized)
MigrateProfileToUnifiedConsent();
- // Check if this profile is still eligible for the consent bump.
- CheckConsentBumpEligibility();
-
identity_manager_->AddObserver(this);
sync_service_->AddObserver(this);
}
@@ -54,7 +51,6 @@
registry->RegisterIntegerPref(
prefs::kUnifiedConsentMigrationState,
static_cast<int>(MigrationState::kNotInitialized));
- registry->RegisterBooleanPref(prefs::kShouldShowUnifiedConsentBump, false);
registry->RegisterBooleanPref(prefs::kAllUnifiedConsentServicesWereEnabled,
false);
}
@@ -86,7 +82,6 @@
// Clear all unified consent prefs.
user_pref_service->ClearPref(prefs::kUrlKeyedAnonymizedDataCollectionEnabled);
user_pref_service->ClearPref(prefs::kUnifiedConsentMigrationState);
- user_pref_service->ClearPref(prefs::kShouldShowUnifiedConsentBump);
user_pref_service->ClearPref(prefs::kAllUnifiedConsentServicesWereEnabled);
}
@@ -99,10 +94,6 @@
SetMigrationState(MigrationState::kCompleted);
}
- if (ShouldShowConsentBump())
- RecordConsentBumpSuppressReason(
- metrics::ConsentBumpSuppressReason::kSettingsOptIn);
-
// Enable all Google services except sync.
pref_service_->SetBoolean(prefs::kUrlKeyedAnonymizedDataCollectionEnabled,
true);
@@ -117,44 +108,6 @@
pref_service_->SetBoolean(prefs::kAllUnifiedConsentServicesWereEnabled, true);
}
-bool UnifiedConsentService::ShouldShowConsentBump() {
- if (base::FeatureList::IsEnabled(kForceUnifiedConsentBump) &&
- identity_manager_->HasPrimaryAccount()) {
- return true;
- }
- return pref_service_->GetBoolean(prefs::kShouldShowUnifiedConsentBump);
-}
-
-void UnifiedConsentService::MarkConsentBumpShown() {
- // Record suppress reason kNone, which means that it was shown. This also sets
- // the |kShouldShowConsentBump| pref to false.
- RecordConsentBumpSuppressReason(metrics::ConsentBumpSuppressReason::kNone);
-}
-
-void UnifiedConsentService::RecordConsentBumpSuppressReason(
- metrics::ConsentBumpSuppressReason suppress_reason) {
- UMA_HISTOGRAM_ENUMERATION("UnifiedConsent.ConsentBump.SuppressReason",
- suppress_reason);
-
- switch (suppress_reason) {
- case metrics::ConsentBumpSuppressReason::kNone:
- case metrics::ConsentBumpSuppressReason::kNotSignedIn:
- case metrics::ConsentBumpSuppressReason::kSyncEverythingOff:
- case metrics::ConsentBumpSuppressReason::kPrivacySettingOff:
- case metrics::ConsentBumpSuppressReason::kSettingsOptIn:
- case metrics::ConsentBumpSuppressReason::kUserSignedOut:
- case metrics::ConsentBumpSuppressReason::kUserTurnedSyncDatatypeOff:
- case metrics::ConsentBumpSuppressReason::kUserTurnedPrivacySettingOff:
- case metrics::ConsentBumpSuppressReason::kCustomPassphrase:
- pref_service_->SetBoolean(prefs::kShouldShowUnifiedConsentBump, false);
- break;
- case metrics::ConsentBumpSuppressReason::kSyncPaused:
- // Consent bump should be shown when sync is active again.
- DCHECK(ShouldShowConsentBump());
- break;
- }
-}
-
void UnifiedConsentService::Shutdown() {
identity_manager_->RemoveObserver(this);
sync_service_->RemoveObserver(this);
@@ -178,10 +131,6 @@
// When the user signs out, the migration is complete.
SetMigrationState(MigrationState::kCompleted);
}
-
- if (ShouldShowConsentBump())
- RecordConsentBumpSuppressReason(
- metrics::ConsentBumpSuppressReason::kUserSignedOut);
}
void UnifiedConsentService::OnStateChanged(syncer::SyncService* sync) {
@@ -192,14 +141,6 @@
if (GetMigrationState() == MigrationState::kInProgressWaitForSyncInit)
UpdateSettingsForMigration();
-
- if (sync_service_->GetUserSettings()->IsUsingSecondaryPassphrase()) {
- if (ShouldShowConsentBump()) {
- // Do not show the consent bump when the user has a custom passphrase.
- RecordConsentBumpSuppressReason(
- metrics::ConsentBumpSuppressReason::kCustomPassphrase);
- }
- }
}
MigrationState UnifiedConsentService::GetMigrationState() {
@@ -220,25 +161,9 @@
DCHECK_EQ(GetMigrationState(), MigrationState::kNotInitialized);
if (!identity_manager_->HasPrimaryAccount()) {
- RecordConsentBumpSuppressReason(
- metrics::ConsentBumpSuppressReason::kNotSignedIn);
SetMigrationState(MigrationState::kCompleted);
return;
}
- bool is_syncing_everything =
- sync_service_->GetUserSettings()->IsSyncEverythingEnabled();
-
- if (!is_syncing_everything) {
- RecordConsentBumpSuppressReason(
- metrics::ConsentBumpSuppressReason::kSyncEverythingOff);
- } else if (!AreAllOnByDefaultPrivacySettingsOn()) {
- RecordConsentBumpSuppressReason(
- metrics::ConsentBumpSuppressReason::kPrivacySettingOff);
- } else {
- // When the user was syncing everything, and all on-by-default privacy
- // settings were on, the consent bump should be shown.
- pref_service_->SetBoolean(prefs::kShouldShowUnifiedConsentBump, true);
- }
UpdateSettingsForMigration();
}
@@ -262,33 +187,4 @@
SetMigrationState(MigrationState::kCompleted);
}
-bool UnifiedConsentService::AreAllOnByDefaultPrivacySettingsOn() {
- for (auto service : {Service::kAlternateErrorPages,
- Service::kMetricsReporting, Service::kNetworkPrediction,
- Service::kSafeBrowsing, Service::kSearchSuggest}) {
- if (service_client_->GetServiceState(service) == ServiceState::kDisabled)
- return false;
- }
- return true;
-}
-
-void UnifiedConsentService::CheckConsentBumpEligibility() {
- // Only check eligility if the user was eligible before.
- if (!ShouldShowConsentBump()) {
- metrics::RecordConsentBumpEligibility(false);
- return;
- }
-
- if (!sync_service_->GetUserSettings()->GetChosenDataTypes().HasAll(
- syncer::UserSelectableTypes())) {
- RecordConsentBumpSuppressReason(
- metrics::ConsentBumpSuppressReason::kUserTurnedSyncDatatypeOff);
- } else if (!AreAllOnByDefaultPrivacySettingsOn()) {
- RecordConsentBumpSuppressReason(
- metrics::ConsentBumpSuppressReason::kUserTurnedPrivacySettingOff);
- }
- metrics::RecordConsentBumpEligibility(
- pref_service_->GetBoolean(prefs::kShouldShowUnifiedConsentBump));
-}
-
} // namespace unified_consent
diff --git a/components/unified_consent/unified_consent_service.h b/components/unified_consent/unified_consent_service.h
index 9f927c2..018d032f 100644
--- a/components/unified_consent/unified_consent_service.h
+++ b/components/unified_consent/unified_consent_service.h
@@ -65,17 +65,6 @@
// in this method.
void EnableGoogleServices();
- // Returns true if all criteria is met to show the consent bump.
- bool ShouldShowConsentBump();
- // Marks the consent bump as shown. Any future calls to
- // |ShouldShowConsentBump| are guaranteed to return false.
- void MarkConsentBumpShown();
- // Records the consent bump suppress reason and updates the state whether the
- // consent bump should be shown. Note: In some cases, e.g. sync paused,
- // |ShouldShowConsentBump| will still return true.
- void RecordConsentBumpSuppressReason(
- metrics::ConsentBumpSuppressReason suppress_reason);
-
// KeyedService:
void Shutdown() override;
@@ -92,24 +81,13 @@
// Migration helpers.
MigrationState GetMigrationState();
void SetMigrationState(MigrationState migration_state);
- // Called when the unified consent service is created. This sets the
- // |kShouldShowUnifiedConsentBump| pref to true if the user is eligible and
- // calls |UpdateSettingsForMigration| at the end.
+ // Called when the unified consent service is created.
void MigrateProfileToUnifiedConsent();
// Updates the settings preferences for the migration when the sync engine is
// initialized. When it is not, this function will be called again from
// |OnStateChanged| when the sync engine is initialized.
void UpdateSettingsForMigration();
- // Checks if all on-by-default non-personalized services are on.
- bool AreAllOnByDefaultPrivacySettingsOn();
-
- // This method is called on startup to check the eligibility criteria for
- // showing the consent bump. The check is only done when the profile was
- // eligible before. If the user is not eligible anymore, the
- // kShouldShowUnifiedConsentBump pref is set to false.
- void CheckConsentBumpEligibility();
-
std::unique_ptr<UnifiedConsentServiceClient> service_client_;
PrefService* pref_service_;
identity::IdentityManager* identity_manager_;
diff --git a/components/unified_consent/unified_consent_service_unittest.cc b/components/unified_consent/unified_consent_service_unittest.cc
index 48454eb..efa4227 100644
--- a/components/unified_consent/unified_consent_service_unittest.cc
+++ b/components/unified_consent/unified_consent_service_unittest.cc
@@ -131,7 +131,7 @@
void CreateConsentService(bool client_services_on_by_default = false) {
if (!scoped_unified_consent_) {
SetUnifiedConsentFeatureState(
- unified_consent::UnifiedConsentFeatureState::kEnabledWithBump);
+ unified_consent::UnifiedConsentFeatureState::kEnabled);
}
auto client =
@@ -176,10 +176,6 @@
return true;
}
- bool AreAllOnByDefaultPrivacySettingsOn() {
- return consent_service_->AreAllOnByDefaultPrivacySettingsOn();
- }
-
unified_consent::MigrationState GetMigrationState() {
int migration_state_int =
pref_service_.GetInteger(prefs::kUnifiedConsentMigrationState);
@@ -232,92 +228,6 @@
EXPECT_TRUE(AreAllGoogleServicesEnabled());
}
-#if !defined(OS_CHROMEOS)
-TEST_F(UnifiedConsentServiceTest, Migration_SyncingEverythingAndAllServicesOn) {
- base::HistogramTester histogram_tester;
-
- // Create inconsistent state.
- identity_test_environment_.SetPrimaryAccount("testaccount");
- sync_service_.GetUserSettings()->SetChosenDataTypes(
- true, syncer::UserSelectableTypes());
- EXPECT_TRUE(sync_service_.GetUserSettings()->IsSyncEverythingEnabled());
- sync_service_.SetTransportState(
- syncer::SyncService::TransportState::INITIALIZING);
- EXPECT_FALSE(sync_service_.IsSyncFeatureActive());
-
- CreateConsentService(true /* client_services_on_by_default */);
- EXPECT_TRUE(AreAllGoogleServicesEnabled());
- // After the creation of the consent service, the profile started to migrate
- // (but waiting for sync init) and |ShouldShowConsentBump| should return true.
- EXPECT_EQ(GetMigrationState(),
- unified_consent::MigrationState::kInProgressWaitForSyncInit);
- EXPECT_TRUE(consent_service_->ShouldShowConsentBump());
-
- // When sync is active, the migration should continue and finish.
- sync_service_.SetTransportState(syncer::SyncService::TransportState::ACTIVE);
- sync_service_.FireStateChanged();
- base::RunLoop().RunUntilIdle();
-
- // No metric for the consent bump suppress reason should have been recorded at
- // this point.
- histogram_tester.ExpectTotalCount("UnifiedConsent.ConsentBump.SuppressReason",
- 0);
-
- // When the user signs out, the migration state changes to completed and the
- // consent bump doesn't need to be shown anymore.
- identity_test_environment_.ClearPrimaryAccount();
- EXPECT_EQ(GetMigrationState(), unified_consent::MigrationState::kCompleted);
- EXPECT_FALSE(consent_service_->ShouldShowConsentBump());
- // A metric for the consent bump suppress reason should have been recorded at
- // this point.
- histogram_tester.ExpectBucketCount(
- "UnifiedConsent.ConsentBump.SuppressReason",
- metrics::ConsentBumpSuppressReason::kUserSignedOut, 1);
-}
-
-TEST_F(UnifiedConsentServiceTest, Migration_SyncingEverythingAndServicesOff) {
- base::HistogramTester histogram_tester;
-
- // Create inconsistent state.
- identity_test_environment_.SetPrimaryAccount("testaccount");
- sync_service_.GetUserSettings()->SetChosenDataTypes(
- true, syncer::UserSelectableTypes());
- EXPECT_TRUE(sync_service_.GetUserSettings()->IsSyncEverythingEnabled());
- EXPECT_TRUE(sync_service_.IsSyncFeatureActive());
-
- CreateConsentService();
- EXPECT_FALSE(AreAllOnByDefaultPrivacySettingsOn());
- // After the creation of the consent service, the profile is migrated and
- // |ShouldShowConsentBump| should return false.
- EXPECT_EQ(GetMigrationState(), unified_consent::MigrationState::kCompleted);
- EXPECT_FALSE(consent_service_->ShouldShowConsentBump());
-
- // A metric for the consent bump suppress reason should have been recorded at
- // this point.
- histogram_tester.ExpectBucketCount(
- "UnifiedConsent.ConsentBump.SuppressReason",
- metrics::ConsentBumpSuppressReason::kPrivacySettingOff, 1);
-}
-#endif // !defined(OS_CHROMEOS)
-
-TEST_F(UnifiedConsentServiceTest, Migration_NotSyncingEverything) {
- base::HistogramTester histogram_tester;
-
- identity_test_environment_.SetPrimaryAccount("testaccount");
- sync_service_.GetUserSettings()->SetChosenDataTypes(
- false, syncer::UserSelectableTypes());
- EXPECT_FALSE(sync_service_.GetUserSettings()->IsSyncEverythingEnabled());
-
- CreateConsentService();
- // When the user is not syncing everything the migration is completed after
- // the creation of the consent service.
- EXPECT_EQ(GetMigrationState(), unified_consent::MigrationState::kCompleted);
- // The suppress reason for not showing the consent bump should be recorded.
- histogram_tester.ExpectBucketCount(
- "UnifiedConsent.ConsentBump.SuppressReason",
- metrics::ConsentBumpSuppressReason::kSyncEverythingOff, 1);
-}
-
TEST_F(UnifiedConsentServiceTest, Migration_UpdateSettings) {
// Create user that syncs history and has no custom passphrase.
identity_test_environment_.SetPrimaryAccount("testaccount");
@@ -377,13 +287,9 @@
base::HistogramTester histogram_tester;
CreateConsentService();
- // Since there were not inconsistencies, the migration is completed after the
+ // The user is signed out, so the migration is completed after the
// creation of the consent service.
EXPECT_EQ(GetMigrationState(), unified_consent::MigrationState::kCompleted);
- // The suppress reason for not showing the consent bump should be recorded.
- histogram_tester.ExpectBucketCount(
- "UnifiedConsent.ConsentBump.SuppressReason",
- metrics::ConsentBumpSuppressReason::kNotSignedIn, 1);
}
#endif // !defined(OS_CHROMEOS)
@@ -420,143 +326,4 @@
service_client_->GetServiceState(Service::kContextualSearch));
}
-TEST_F(UnifiedConsentServiceTest, ConsentBump_EligibleOnSecondStartup) {
- base::HistogramTester histogram_tester;
-
- identity_test_environment_.SetPrimaryAccount("testaccount");
- sync_service_.GetUserSettings()->SetChosenDataTypes(
- true, syncer::UserSelectableTypes());
- syncer::SyncPrefs sync_prefs(&pref_service_);
- EXPECT_TRUE(sync_service_.GetUserSettings()->IsSyncEverythingEnabled());
-
- // First time creation of the service migrates the profile and initializes the
- // consent bump pref.
- CreateConsentService(true /* client_services_on_by_default */);
- EXPECT_TRUE(AreAllGoogleServicesEnabled());
- EXPECT_TRUE(consent_service_->ShouldShowConsentBump());
- histogram_tester.ExpectTotalCount("UnifiedConsent.ConsentBump.SuppressReason",
- 0);
- histogram_tester.ExpectUniqueSample(
- "UnifiedConsent.ConsentBump.EligibleAtStartup", true, 1);
-
- // Simulate shutdown.
- consent_service_->Shutdown();
- consent_service_.reset();
-
- // After the second startup, the user should still be eligible.
- CreateConsentService(true /* client_services_on_by_default */);
- EXPECT_TRUE(AreAllGoogleServicesEnabled());
- EXPECT_TRUE(consent_service_->ShouldShowConsentBump());
- histogram_tester.ExpectTotalCount("UnifiedConsent.ConsentBump.SuppressReason",
- 0);
- histogram_tester.ExpectUniqueSample(
- "UnifiedConsent.ConsentBump.EligibleAtStartup", true, 2);
-}
-
-TEST_F(UnifiedConsentServiceTest,
- ConsentBump_NotEligibleOnSecondStartup_DisabledSyncDatatype) {
- base::HistogramTester histogram_tester;
-
- identity_test_environment_.SetPrimaryAccount("testaccount");
- sync_service_.GetUserSettings()->SetChosenDataTypes(
- true, syncer::UserSelectableTypes());
- syncer::SyncPrefs sync_prefs(&pref_service_);
- EXPECT_TRUE(sync_service_.GetUserSettings()->IsSyncEverythingEnabled());
-
- // First time creation of the service migrates the profile and initializes the
- // consent bump pref.
- CreateConsentService(true /* client_services_on_by_default */);
- EXPECT_TRUE(AreAllGoogleServicesEnabled());
- EXPECT_TRUE(consent_service_->ShouldShowConsentBump());
- histogram_tester.ExpectTotalCount("UnifiedConsent.ConsentBump.SuppressReason",
- 0);
- histogram_tester.ExpectUniqueSample(
- "UnifiedConsent.ConsentBump.EligibleAtStartup", true, 1);
-
- // Simulate shutdown.
- consent_service_->Shutdown();
- consent_service_.reset();
-
- // User disables BOOKMARKS.
- auto data_types = sync_service_.GetPreferredDataTypes();
- data_types.RetainAll(syncer::UserSelectableTypes());
- data_types.Remove(syncer::BOOKMARKS);
- sync_service_.GetUserSettings()->SetChosenDataTypes(false, data_types);
-
- // After the second startup, the user should not be eligible anymore.
- CreateConsentService(true /* client_services_on_by_default */);
- EXPECT_FALSE(consent_service_->ShouldShowConsentBump());
- histogram_tester.ExpectBucketCount(
- "UnifiedConsent.ConsentBump.SuppressReason",
- metrics::ConsentBumpSuppressReason::kUserTurnedSyncDatatypeOff, 1);
- histogram_tester.ExpectBucketCount(
- "UnifiedConsent.ConsentBump.EligibleAtStartup", true, 1);
- histogram_tester.ExpectBucketCount(
- "UnifiedConsent.ConsentBump.EligibleAtStartup", false, 1);
-}
-
-TEST_F(UnifiedConsentServiceTest,
- ConsentBump_NotEligibleOnSecondStartup_DisabledPrivacySetting) {
- base::HistogramTester histogram_tester;
-
- identity_test_environment_.SetPrimaryAccount("testaccount");
- sync_service_.GetUserSettings()->SetChosenDataTypes(
- true, syncer::UserSelectableTypes());
- syncer::SyncPrefs sync_prefs(&pref_service_);
- EXPECT_TRUE(sync_service_.GetUserSettings()->IsSyncEverythingEnabled());
-
- // First time creation of the service migrates the profile and initializes the
- // consent bump pref.
- CreateConsentService(true /* client_services_on_by_default */);
- EXPECT_TRUE(AreAllGoogleServicesEnabled());
- EXPECT_TRUE(consent_service_->ShouldShowConsentBump());
- histogram_tester.ExpectTotalCount("UnifiedConsent.ConsentBump.SuppressReason",
- 0);
- // Simulate shutdown.
- consent_service_->Shutdown();
- consent_service_.reset();
-
- // Disable privacy setting.
- service_client_->SetServiceEnabled(Service::kSafeBrowsing, false);
-
- // After the second startup, the user should not be eligible anymore.
- CreateConsentService(false /* client_services_on_by_default */);
- EXPECT_FALSE(consent_service_->ShouldShowConsentBump());
- histogram_tester.ExpectBucketCount(
- "UnifiedConsent.ConsentBump.SuppressReason",
- metrics::ConsentBumpSuppressReason::kUserTurnedPrivacySettingOff, 1);
-}
-
-TEST_F(UnifiedConsentServiceTest, ConsentBump_SuppressedWithCustomPassphrase) {
- base::HistogramTester histogram_tester;
-
- // Setup sync account with custom passphrase, such that it would be eligible
- // for the consent bump without custom passphrase.
- identity_test_environment_.SetPrimaryAccount("testaccount");
- sync_service_.GetUserSettings()->SetChosenDataTypes(
- true, syncer::UserSelectableTypes());
- sync_service_.SetIsUsingSecondaryPassphrase(true);
- syncer::SyncPrefs sync_prefs(&pref_service_);
- EXPECT_TRUE(sync_service_.GetUserSettings()->IsSyncEverythingEnabled());
- sync_service_.SetTransportState(
- syncer::SyncService::TransportState::INITIALIZING);
- EXPECT_FALSE(sync_service_.IsEngineInitialized());
-
- // Before sync is initialized, the user is eligible for seeing the consent
- // bump.
- CreateConsentService(true /* client_services_on_by_default */);
- EXPECT_TRUE(AreAllGoogleServicesEnabled());
- EXPECT_TRUE(consent_service_->ShouldShowConsentBump());
-
- // When sync is initialized, it fires the observer in the consent service.
- // This will suppress the consent bump.
- sync_service_.SetTransportState(syncer::SyncService::TransportState::ACTIVE);
- EXPECT_TRUE(sync_service_.IsEngineInitialized());
- sync_service_.FireStateChanged();
- EXPECT_FALSE(consent_service_->ShouldShowConsentBump());
- histogram_tester.ExpectUniqueSample(
- "UnifiedConsent.ConsentBump.SuppressReason",
- metrics::ConsentBumpSuppressReason::kCustomPassphrase, 1);
-}
-
} // namespace unified_consent
diff --git a/components/unified_consent/url_keyed_data_collection_consent_helper_unittest.cc b/components/unified_consent/url_keyed_data_collection_consent_helper_unittest.cc
index 7624aa1..893ae47a 100644
--- a/components/unified_consent/url_keyed_data_collection_consent_helper_unittest.cc
+++ b/components/unified_consent/url_keyed_data_collection_consent_helper_unittest.cc
@@ -67,7 +67,7 @@
TEST_F(UrlKeyedDataCollectionConsentHelperTest,
AnonymizedDataCollection_UnifiedConsentEnabled) {
ScopedUnifiedConsent scoped_unified_consent(
- UnifiedConsentFeatureState::kEnabledNoBump);
+ UnifiedConsentFeatureState::kEnabled);
std::unique_ptr<UrlKeyedDataCollectionConsentHelper> helper =
UrlKeyedDataCollectionConsentHelper::
NewAnonymizedDataCollectionConsentHelper(&pref_service_,
@@ -124,7 +124,7 @@
TEST_F(UrlKeyedDataCollectionConsentHelperTest,
PersonalizedDataCollection_UnifiedConsentEnabled) {
ScopedUnifiedConsent scoped_unified_consent(
- UnifiedConsentFeatureState::kEnabledNoBump);
+ UnifiedConsentFeatureState::kEnabled);
std::unique_ptr<UrlKeyedDataCollectionConsentHelper> helper =
UrlKeyedDataCollectionConsentHelper::
NewPersonalizedDataCollectionConsentHelper(&sync_service_);
@@ -170,7 +170,7 @@
}
{
ScopedUnifiedConsent scoped_unified_consent(
- UnifiedConsentFeatureState::kEnabledNoBump);
+ UnifiedConsentFeatureState::kEnabled);
std::unique_ptr<UrlKeyedDataCollectionConsentHelper> helper =
UrlKeyedDataCollectionConsentHelper::
NewPersonalizedDataCollectionConsentHelper(