Commit 8601ea33 authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[unified-consent] Enable Unified Consent in fieldtrial_testing_config

Bug: 811351
Change-Id: Id46b66bef4483cf2e34a42771fca6838109673ef
Reviewed-on: https://chromium-review.googlesource.com/1225987
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarMarkus Heintz <markusheintz@chromium.org>
Reviewed-by: default avatarRobert Kaplow (sloooow) <rkaplow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593505}
parent 6b9a7f12
...@@ -3805,7 +3805,7 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -3805,7 +3805,7 @@ const FeatureEntry kFeatureEntries[] = {
flag_descriptions::kUnifiedConsentDescription, kOsAll, flag_descriptions::kUnifiedConsentDescription, kOsAll,
FEATURE_WITH_PARAMS_VALUE_TYPE(unified_consent::kUnifiedConsent, FEATURE_WITH_PARAMS_VALUE_TYPE(unified_consent::kUnifiedConsent,
kUnifiedConsentVariations, kUnifiedConsentVariations,
"UnifiedConsentVariations")}, "UnifiedConsent")},
{"force-unified-consent-bump", {"force-unified-consent-bump",
flag_descriptions::kForceUnifiedConsentBumpName, flag_descriptions::kForceUnifiedConsentBumpName,
......
...@@ -9,8 +9,10 @@ ...@@ -9,8 +9,10 @@
#include "chrome/browser/history/web_history_service_factory.h" #include "chrome/browser/history/web_history_service_factory.h"
#include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/test/integration/profile_sync_service_harness.h"
#include "chrome/browser/sync/test/integration/sync_test.h" #include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/unified_consent/unified_consent_service_factory.h"
#include "chrome/browser/web_data_service_factory.h" #include "chrome/browser/web_data_service_factory.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h" #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
...@@ -23,6 +25,7 @@ ...@@ -23,6 +25,7 @@
#include "components/history/core/browser/web_history_service.h" #include "components/history/core/browser/web_history_service.h"
#include "components/history/core/test/fake_web_history_service.h" #include "components/history/core/test/fake_web_history_service.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/unified_consent/unified_consent_service.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
using browsing_data::BrowsingDataCounter; using browsing_data::BrowsingDataCounter;
...@@ -116,6 +119,20 @@ IN_PROC_BROWSER_TEST_F(SyncAwareCounterTest, AutofillCounter) { ...@@ -116,6 +119,20 @@ IN_PROC_BROWSER_TEST_F(SyncAwareCounterTest, AutofillCounter) {
WaitForCounting(); WaitForCounting();
EXPECT_TRUE(IsSyncEnabled()); EXPECT_TRUE(IsSyncEnabled());
// When the unified consent was given, it needs to be revoked here before
// the sync_everything flag can be set to false below. This restarts the
// counter.
unified_consent::UnifiedConsentService* consent_service =
UnifiedConsentServiceFactory::GetForProfile(profile);
if (consent_service && consent_service->IsUnifiedConsentGiven()) {
consent_service->SetUnifiedConsentGiven(false);
ASSERT_TRUE(
GetClient(kFirstProfileIndex)
->AwaitSyncSetupCompletion(/*skip_passphrase_verification=*/false));
WaitForCounting();
ASSERT_TRUE(sync_service->GetActiveDataTypes().Has(syncer::AUTOFILL));
}
// We stop syncing autofill in particular. This restarts the counter. // We stop syncing autofill in particular. This restarts the counter.
syncer::ModelTypeSet everything_except_autofill = syncer::ModelTypeSet everything_except_autofill =
syncer::UserSelectableTypes(); syncer::UserSelectableTypes();
...@@ -178,6 +195,20 @@ IN_PROC_BROWSER_TEST_F(SyncAwareCounterTest, PasswordCounter) { ...@@ -178,6 +195,20 @@ IN_PROC_BROWSER_TEST_F(SyncAwareCounterTest, PasswordCounter) {
WaitForCounting(); WaitForCounting();
EXPECT_TRUE(IsSyncEnabled()); EXPECT_TRUE(IsSyncEnabled());
// When the unified consent was given, it needs to be revoked here before
// the sync_everything flag can be set to false below. This restarts the
// counter.
unified_consent::UnifiedConsentService* consent_service =
UnifiedConsentServiceFactory::GetForProfile(profile);
if (consent_service && consent_service->IsUnifiedConsentGiven()) {
consent_service->SetUnifiedConsentGiven(false);
ASSERT_TRUE(
GetClient(kFirstProfileIndex)
->AwaitSyncSetupCompletion(/*skip_passphrase_verification=*/false));
WaitForCounting();
ASSERT_TRUE(sync_service->GetPreferredDataTypes().Has(syncer::PASSWORDS));
}
// We stop syncing passwords in particular. This restarts the counter. // We stop syncing passwords in particular. This restarts the counter.
syncer::ModelTypeSet everything_except_passwords = syncer::ModelTypeSet everything_except_passwords =
syncer::UserSelectableTypes(); syncer::UserSelectableTypes();
...@@ -248,6 +279,21 @@ IN_PROC_BROWSER_TEST_F(SyncAwareCounterTest, HistoryCounter) { ...@@ -248,6 +279,21 @@ IN_PROC_BROWSER_TEST_F(SyncAwareCounterTest, HistoryCounter) {
WaitForCounting(); WaitForCounting();
EXPECT_TRUE(IsSyncEnabled()); EXPECT_TRUE(IsSyncEnabled());
// When the unified consent was given, it needs to be revoked here before
// the sync_everything flag can be set to false below. This restarts the
// counter.
unified_consent::UnifiedConsentService* consent_service =
UnifiedConsentServiceFactory::GetForProfile(profile);
if (consent_service && consent_service->IsUnifiedConsentGiven()) {
consent_service->SetUnifiedConsentGiven(false);
ASSERT_TRUE(
GetClient(kFirstProfileIndex)
->AwaitSyncSetupCompletion(/*skip_passphrase_verification=*/false));
WaitForCounting();
ASSERT_TRUE(sync_service->GetActiveDataTypes().Has(
syncer::HISTORY_DELETE_DIRECTIVES));
}
// We stop syncing history deletion in particular. This restarts the counter. // We stop syncing history deletion in particular. This restarts the counter.
syncer::ModelTypeSet everything_except_history = syncer::ModelTypeSet everything_except_history =
syncer::UserSelectableTypes(); syncer::UserSelectableTypes();
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "components/sync/base/model_type.h" #include "components/sync/base/model_type.h"
#include "components/sync/base/sync_prefs.h" #include "components/sync/base/sync_prefs.h"
#include "components/sync/driver/sync_driver_switches.h" #include "components/sync/driver/sync_driver_switches.h"
#include "components/unified_consent/feature.h"
using base::FeatureList; using base::FeatureList;
using syncer::ModelType; using syncer::ModelType;
...@@ -26,8 +27,6 @@ using syncer::UserSelectableTypes; ...@@ -26,8 +27,6 @@ using syncer::UserSelectableTypes;
namespace { namespace {
const bool kUserEventsSeparatePrefGroup = false;
// Some types show up in multiple groups. This means that there are at least two // Some types show up in multiple groups. This means that there are at least two
// user selectable groups that will cause these types to become enabled. This // user selectable groups that will cause these types to become enabled. This
// affects our tests because we cannot assume that before enabling a multi type // affects our tests because we cannot assume that before enabling a multi type
...@@ -42,7 +41,8 @@ ModelTypeSet MultiGroupTypes(const SyncPrefs& sync_prefs, ...@@ -42,7 +41,8 @@ ModelTypeSet MultiGroupTypes(const SyncPrefs& sync_prefs,
// elsewhere in the file). // elsewhere in the file).
for (ModelType st : selectable_types) { for (ModelType st : selectable_types) {
const ModelTypeSet grouped_types = sync_prefs.ResolvePrefGroups( const ModelTypeSet grouped_types = sync_prefs.ResolvePrefGroups(
registered_types, ModelTypeSet(st), kUserEventsSeparatePrefGroup); registered_types, ModelTypeSet(st),
unified_consent::IsUnifiedConsentFeatureEnabled());
for (ModelType gt : grouped_types) { for (ModelType gt : grouped_types) {
if (seen.Has(gt)) { if (seen.Has(gt)) {
multi.Put(gt); multi.Put(gt);
...@@ -109,10 +109,10 @@ class EnableDisableSingleClientTest : public SyncTest { ...@@ -109,10 +109,10 @@ class EnableDisableSingleClientTest : public SyncTest {
} }
ModelTypeSet ResolveGroup(ModelType type) { ModelTypeSet ResolveGroup(ModelType type) {
return Difference( return Difference(sync_prefs_->ResolvePrefGroups(
sync_prefs_->ResolvePrefGroups(registered_types_, ModelTypeSet(type), registered_types_, ModelTypeSet(type),
kUserEventsSeparatePrefGroup), unified_consent::IsUnifiedConsentFeatureEnabled()),
ProxyTypes()); ProxyTypes());
} }
ModelTypeSet WithoutMultiTypes(const ModelTypeSet& input) { ModelTypeSet WithoutMultiTypes(const ModelTypeSet& input) {
......
...@@ -530,7 +530,13 @@ bool ProfileSyncServiceHarness::EnableSyncForAllDatatypes() { ...@@ -530,7 +530,13 @@ bool ProfileSyncServiceHarness::EnableSyncForAllDatatypes() {
return false; return false;
} }
service()->OnUserChoseDatatypes(true, syncer::UserSelectableTypes()); if (unified_consent::IsUnifiedConsentFeatureEnabled()) {
// Setting unified consent given to true will enable all sync data types.
UnifiedConsentServiceFactory::GetForProfile(profile_)
->SetUnifiedConsentGiven(true);
} else {
service()->OnUserChoseDatatypes(true, syncer::UserSelectableTypes());
}
if (AwaitSyncSetupCompletion(/*skip_passphrase_verification=*/false)) { if (AwaitSyncSetupCompletion(/*skip_passphrase_verification=*/false)) {
DVLOG(1) << "EnableSyncForAllDatatypes(): Enabled sync for all datatypes " DVLOG(1) << "EnableSyncForAllDatatypes(): Enabled sync for all datatypes "
<< "on " << profile_debug_name_ << "."; << "on " << profile_debug_name_ << ".";
......
...@@ -17,6 +17,9 @@ cr.define('settings_people_page', function() { ...@@ -17,6 +17,9 @@ cr.define('settings_people_page', function() {
easyUnlockAllowed: false, easyUnlockAllowed: false,
// Force Dice off. Dice is tested in the DiceUITest suite. // Force Dice off. Dice is tested in the DiceUITest suite.
diceEnabled: false, diceEnabled: false,
// Force Unified Consent off. Unified Consent is tested in the
// UnifiedConsentUITest suite.
unifiedConsentEnabled: false,
}); });
}); });
......
...@@ -4563,6 +4563,23 @@ ...@@ -4563,6 +4563,23 @@
] ]
} }
], ],
"UnifiedConsent": [
{
"platforms": [
"linux",
"mac",
"windows"
],
"experiments": [
{
"name": "Enabled2",
"enable_features": [
"UnifiedConsent"
]
}
]
}
],
"UpdateMenuItem": [ "UpdateMenuItem": [
{ {
"platforms": [ "platforms": [
......
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