Commit cce73dd2 authored by Caitlin Fischer's avatar Caitlin Fischer Committed by Commit Bot

Add IDCollectionKeys and the RestrictGoogleWebVisibility feature.

The feature is disabled by default.

Also, rename two existing IDCollectionKeys.

This change paves the way for limiting the set of experiment IDs
included in X-Client-Data headers sent in third-party contexts.

Bug: 1094303
Change-Id: Ib535b0b8657aeb82570c552b31d722bd30168019
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363467
Commit-Queue: Caitlin Fischer <caitlinfischer@google.com>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800310}
parent 9f607b92
...@@ -49,9 +49,9 @@ std::set<variations::VariationID> GetSnippetsExperiments() { ...@@ -49,9 +49,9 @@ std::set<variations::VariationID> GetSnippetsExperiments() {
continue; continue;
for (variations::IDCollectionKey key : for (variations::IDCollectionKey key :
{variations::GOOGLE_WEB_PROPERTIES, {variations::GOOGLE_WEB_PROPERTIES_ANY_CONTEXT,
variations::GOOGLE_WEB_PROPERTIES_SIGNED_IN, variations::GOOGLE_WEB_PROPERTIES_SIGNED_IN,
variations::GOOGLE_WEB_PROPERTIES_TRIGGER}) { variations::GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT}) {
const variations::VariationID id = variations::GetGoogleVariationID( const variations::VariationID id = variations::GetGoogleVariationID(
key, trial->trial_name(), trial->group_name()); key, trial->trial_name(), trial->group_name());
if (id != variations::EMPTY_ID) { if (id != variations::EMPTY_ID) {
......
...@@ -1062,7 +1062,7 @@ void AutofillDownloadManager::InitActiveExperiments() { ...@@ -1062,7 +1062,7 @@ void AutofillDownloadManager::InitActiveExperiments() {
delete active_experiments_; delete active_experiments_;
active_experiments_ = new std::vector<variations::VariationID>( active_experiments_ = new std::vector<variations::VariationID>(
variations_ids_provider->GetVariationsVector( variations_ids_provider->GetVariationsVector(
variations::GOOGLE_WEB_PROPERTIES_TRIGGER)); variations::GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT));
base::EraseIf(*active_experiments_, [](variations::VariationID id) { base::EraseIf(*active_experiments_, [](variations::VariationID id) {
return !IsAutofillExperimentId(id); return !IsAutofillExperimentId(id);
}); });
......
...@@ -120,7 +120,7 @@ class PaymentsClientTest : public testing::Test { ...@@ -120,7 +120,7 @@ class PaymentsClientTest : public testing::Test {
const std::string& group_name, const std::string& group_name,
int variation_id) { int variation_id) {
variations::AssociateGoogleVariationID( variations::AssociateGoogleVariationID(
variations::GOOGLE_WEB_PROPERTIES, trial_name, group_name, variations::GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, trial_name, group_name,
static_cast<variations::VariationID>(variation_id)); static_cast<variations::VariationID>(variation_id));
base::FieldTrialList::CreateFieldTrial(trial_name, group_name)->group(); base::FieldTrialList::CreateFieldTrial(trial_name, group_name)->group();
} }
......
...@@ -77,7 +77,7 @@ class FeedbackUploaderDispatchTest : public ::testing::Test { ...@@ -77,7 +77,7 @@ class FeedbackUploaderDispatchTest : public ::testing::Test {
const std::string& group_name, const std::string& group_name,
int variation_id) { int variation_id) {
variations::AssociateGoogleVariationID( variations::AssociateGoogleVariationID(
variations::GOOGLE_WEB_PROPERTIES, trial_name, group_name, variations::GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, trial_name, group_name,
static_cast<variations::VariationID>(variation_id)); static_cast<variations::VariationID>(variation_id));
base::FieldTrialList::CreateFieldTrial(trial_name, group_name)->group(); base::FieldTrialList::CreateFieldTrial(trial_name, group_name)->group();
} }
......
...@@ -52,9 +52,9 @@ class DocumentSuggestionsServiceTest : public testing::Test { ...@@ -52,9 +52,9 @@ class DocumentSuggestionsServiceTest : public testing::Test {
// Set up a variation. // Set up a variation.
variations::VariationsIdsProvider::GetInstance()->ResetForTesting(); variations::VariationsIdsProvider::GetInstance()->ResetForTesting();
variations::AssociateGoogleVariationID(variations::GOOGLE_WEB_PROPERTIES, variations::AssociateGoogleVariationID(
"trial name", "group name", variations::GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, "trial name",
kVariationID); "group name", kVariationID);
base::FieldTrialList::CreateFieldTrial("trial name", "group name")->group(); base::FieldTrialList::CreateFieldTrial("trial name", "group name")->group();
} }
DocumentSuggestionsServiceTest(const DocumentSuggestionsServiceTest&) = DocumentSuggestionsServiceTest(const DocumentSuggestionsServiceTest&) =
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/singleton.h" #include "base/memory/singleton.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_param_associator.h" #include "base/metrics/field_trial_param_associator.h"
#include "base/metrics/field_trial_params.h" #include "base/metrics/field_trial_params.h"
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
...@@ -18,6 +17,13 @@ ...@@ -18,6 +17,13 @@
namespace variations { namespace variations {
namespace internal {
const base::Feature kRestrictGoogleWebVisibility{
"RestrictGoogleWebVisibility", base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace internal
namespace { namespace {
// The internal singleton accessor for the map, used to keep it thread-safe. // The internal singleton accessor for the map, used to keep it thread-safe.
...@@ -31,41 +37,43 @@ class GroupMapAccessor { ...@@ -31,41 +37,43 @@ class GroupMapAccessor {
return base::Singleton<GroupMapAccessor>::get(); return base::Singleton<GroupMapAccessor>::get();
} }
// Note that this normally only sets the ID for a group the first time, unless // Ensures that |group_identifier| is associated with only one non-trigger,
// |force| is set to true, in which case it will always override it. // trigger, or signed-in key.
void AssociateID(IDCollectionKey key, void ValidateID(IDCollectionKey key,
const ActiveGroupId& group_identifier, const ActiveGroupId& group_identifier,
const VariationID id, const VariationID id) {
const bool force) { static_assert(ID_COLLECTION_COUNT == 6,
static_assert(4 == ID_COLLECTION_COUNT,
"If you add a new collection key, add handling code here!"); "If you add a new collection key, add handling code here!");
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
// Ensure that at most one of the trigger/non-trigger/signed-in web property
// IDs are set.
if (key == GOOGLE_WEB_PROPERTIES || key == GOOGLE_WEB_PROPERTIES_TRIGGER ||
key == GOOGLE_WEB_PROPERTIES_SIGNED_IN) {
if (key != GOOGLE_WEB_PROPERTIES)
DCHECK_EQ(EMPTY_ID, GetID(GOOGLE_WEB_PROPERTIES, group_identifier));
if (key != GOOGLE_WEB_PROPERTIES_TRIGGER) {
DCHECK_EQ(EMPTY_ID,
GetID(GOOGLE_WEB_PROPERTIES_TRIGGER, group_identifier));
}
if (key != GOOGLE_WEB_PROPERTIES_SIGNED_IN) {
DCHECK_EQ(EMPTY_ID,
GetID(GOOGLE_WEB_PROPERTIES_SIGNED_IN, group_identifier));
}
}
// Validate that all collections with this |group_identifier| have the same
// associated ID.
for (int i = 0; i < ID_COLLECTION_COUNT; ++i) { for (int i = 0; i < ID_COLLECTION_COUNT; ++i) {
IDCollectionKey other_key = static_cast<IDCollectionKey>(i); IDCollectionKey other_key = static_cast<IDCollectionKey>(i);
if (other_key == key) if (key == other_key)
continue; continue;
VariationID other_id = GetID(other_key, group_identifier); VariationID other_id = GetID(other_key, group_identifier);
// For a GOOGLE_APP key, validate that all other collections with this
// |group_identifier| have the same associated ID.
if (key == GOOGLE_APP) {
DCHECK(other_id == EMPTY_ID || other_id == id); DCHECK(other_id == EMPTY_ID || other_id == id);
continue;
}
// The ID should not be registered under a different non-GOOGLE_APP
// IDCollectionKey.
if (other_key != GOOGLE_APP)
DCHECK_EQ(EMPTY_ID, other_id);
}
#endif // DCHECK_IS_ON()
} }
#endif
// Note that this normally only sets the ID for a group the first time, unless
// |force| is set to true, in which case it will always override it.
void AssociateID(IDCollectionKey key,
const ActiveGroupId& group_identifier,
const VariationID id,
const bool force) {
ValidateID(key, group_identifier, id);
base::AutoLock scoped_lock(lock_); base::AutoLock scoped_lock(lock_);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "base/metrics/field_trial.h"
#include "components/variations/active_field_trials.h" #include "components/variations/active_field_trials.h"
// This file provides various helpers that extend the functionality around // This file provides various helpers that extend the functionality around
...@@ -36,18 +37,22 @@ ...@@ -36,18 +37,22 @@
// std::string value = GetVariationParamValue("trial", "param_x"); // std::string value = GetVariationParamValue("trial", "param_x");
// // use |value|, which will be "" if it does not exist // // use |value|, which will be "" if it does not exist
// //
// VariationID id = GetGoogleVariationID(GOOGLE_WEB_PROPERTIES, "trial", // VariationID id = GetGoogleVariationID(
// "group1"); // GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, "trial", "group1");
// if (id != variations::EMPTY_ID) { // if (id != variations::EMPTY_ID) {
// // use |id| // // use |id|
// } // }
namespace base {
struct Feature;
} // namespace base
namespace variations { namespace variations {
namespace internal {
// A feature that supports more finely-grained control over the transmission of
// VariationIDs to Google web properties by allowing some VariationIDs to not be
// transmitted in all contexts. See IsFirstPartyContext() in
// variations_http_headers.cc for more details.
extern const base::Feature kRestrictGoogleWebVisibility;
} // namespace internal
typedef int VariationID; typedef int VariationID;
const VariationID EMPTY_ID = 0; const VariationID EMPTY_ID = 0;
...@@ -55,16 +60,26 @@ const VariationID EMPTY_ID = 0; ...@@ -55,16 +60,26 @@ const VariationID EMPTY_ID = 0;
// A key into the Associate/Get methods for VariationIDs. This is used to create // A key into the Associate/Get methods for VariationIDs. This is used to create
// separate ID associations for separate parties interested in VariationIDs. // separate ID associations for separate parties interested in VariationIDs.
enum IDCollectionKey { enum IDCollectionKey {
// This collection is used by Google web properties, transmitted through the // The IDs in this collection are used by Google web properties and are
// X-Client-Data header. // transmitted via the X-Client-Data header. These IDs are transmitted in
GOOGLE_WEB_PROPERTIES, // first- and third-party contexts.
GOOGLE_WEB_PROPERTIES_ANY_CONTEXT,
// Used when kRestrictGoogleWebVisibility is enabled. The IDs in this
// collection are used by Google web properties and are transmitted via the
// X-Client-Data header. These IDs are transmitted in first-party contexts.
GOOGLE_WEB_PROPERTIES_FIRST_PARTY,
// This collection is used by Google web properties for signed in users only, // This collection is used by Google web properties for signed in users only,
// transmitted through the X-Client-Data header. // transmitted through the X-Client-Data header.
GOOGLE_WEB_PROPERTIES_SIGNED_IN, GOOGLE_WEB_PROPERTIES_SIGNED_IN,
// This collection is used by Google web properties for IDs that trigger // The IDs in this collection are used by Google web properties to trigger
// server side experimental behavior, transmitted through the // server-side experimental behavior and are transmitted via the X-Client-Data
// X-Client-Data header. // header. These IDs are transmitted in first- and third-party contexts.
GOOGLE_WEB_PROPERTIES_TRIGGER, GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT,
// Used when kRestrictGoogleWebVisibility is enabled. The IDs in this
// collection are used by Google web properties to trigger server-side
// experimental behavior and are transmitted via the X-Client-Data header.
// These IDs are transmitted in first-party contexts.
GOOGLE_WEB_PROPERTIES_TRIGGER_FIRST_PARTY,
// This collection is used by the Google App and is passed at the time // This collection is used by the Google App and is passed at the time
// the cross-app communication is triggered. // the cross-app communication is triggered.
GOOGLE_APP, GOOGLE_APP,
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/metrics/field_trial.h" #include "base/metrics/field_trial.h"
#include "base/test/scoped_feature_list.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace variations { namespace variations {
...@@ -56,7 +57,11 @@ TEST_F(VariationsAssociatedDataTest, DisableImmediately) { ...@@ -56,7 +57,11 @@ TEST_F(VariationsAssociatedDataTest, DisableImmediately) {
CreateFieldTrial("trial", 100, "default", &default_group_number)); CreateFieldTrial("trial", 100, "default", &default_group_number));
ASSERT_EQ(default_group_number, trial->group()); ASSERT_EQ(default_group_number, trial->group());
ASSERT_EQ(EMPTY_ID, GetIDForTrial(GOOGLE_WEB_PROPERTIES, trial.get()));
for (int i = 0; i < ID_COLLECTION_COUNT; ++i) {
ASSERT_EQ(EMPTY_ID,
GetIDForTrial(static_cast<IDCollectionKey>(i), trial.get()));
}
} }
// Test that successfully associating the FieldTrial with some ID, and then // Test that successfully associating the FieldTrial with some ID, and then
...@@ -70,13 +75,13 @@ TEST_F(VariationsAssociatedDataTest, DisableAfterInitialization) { ...@@ -70,13 +75,13 @@ TEST_F(VariationsAssociatedDataTest, DisableAfterInitialization) {
CreateFieldTrial("trial", 100, default_name, nullptr)); CreateFieldTrial("trial", 100, default_name, nullptr));
trial->AppendGroup(non_default_name, 100); trial->AppendGroup(non_default_name, 100);
AssociateGoogleVariationID(GOOGLE_WEB_PROPERTIES, trial->trial_name(), AssociateGoogleVariationID(GOOGLE_APP, trial->trial_name(), default_name,
default_name, TEST_VALUE_A); TEST_VALUE_A);
AssociateGoogleVariationID(GOOGLE_WEB_PROPERTIES, trial->trial_name(), AssociateGoogleVariationID(GOOGLE_APP, trial->trial_name(), non_default_name,
non_default_name, TEST_VALUE_B); TEST_VALUE_B);
trial->Disable(); trial->Disable();
ASSERT_EQ(default_name, trial->group_name()); ASSERT_EQ(default_name, trial->group_name());
ASSERT_EQ(TEST_VALUE_A, GetIDForTrial(GOOGLE_WEB_PROPERTIES, trial.get())); ASSERT_EQ(TEST_VALUE_A, GetIDForTrial(GOOGLE_APP, trial.get()));
} }
// Test various successful association cases. // Test various successful association cases.
...@@ -88,15 +93,14 @@ TEST_F(VariationsAssociatedDataTest, AssociateGoogleVariationID) { ...@@ -88,15 +93,14 @@ TEST_F(VariationsAssociatedDataTest, AssociateGoogleVariationID) {
int winner_group = trial_true->AppendGroup(winner, 10); int winner_group = trial_true->AppendGroup(winner, 10);
// Set GoogleVariationIDs so we can verify that they were chosen correctly. // Set GoogleVariationIDs so we can verify that they were chosen correctly.
AssociateGoogleVariationID(GOOGLE_WEB_PROPERTIES, trial_true->trial_name(), AssociateGoogleVariationID(GOOGLE_APP, trial_true->trial_name(),
default_name1, TEST_VALUE_A); default_name1, TEST_VALUE_A);
AssociateGoogleVariationID(GOOGLE_WEB_PROPERTIES, trial_true->trial_name(), AssociateGoogleVariationID(GOOGLE_APP, trial_true->trial_name(), winner,
winner, TEST_VALUE_B); TEST_VALUE_B);
EXPECT_EQ(winner_group, trial_true->group()); EXPECT_EQ(winner_group, trial_true->group());
EXPECT_EQ(winner, trial_true->group_name()); EXPECT_EQ(winner, trial_true->group_name());
EXPECT_EQ(TEST_VALUE_B, EXPECT_EQ(TEST_VALUE_B, GetIDForTrial(GOOGLE_APP, trial_true.get()));
GetIDForTrial(GOOGLE_WEB_PROPERTIES, trial_true.get()));
const std::string default_name2 = "default2"; const std::string default_name2 = "default2";
scoped_refptr<base::FieldTrial> trial_false( scoped_refptr<base::FieldTrial> trial_false(
...@@ -104,14 +108,13 @@ TEST_F(VariationsAssociatedDataTest, AssociateGoogleVariationID) { ...@@ -104,14 +108,13 @@ TEST_F(VariationsAssociatedDataTest, AssociateGoogleVariationID) {
const std::string loser = "ALoser"; const std::string loser = "ALoser";
const int loser_group = trial_false->AppendGroup(loser, 0); const int loser_group = trial_false->AppendGroup(loser, 0);
AssociateGoogleVariationID(GOOGLE_WEB_PROPERTIES, trial_false->trial_name(), AssociateGoogleVariationID(GOOGLE_APP, trial_false->trial_name(),
default_name2, TEST_VALUE_A); default_name2, TEST_VALUE_A);
AssociateGoogleVariationID(GOOGLE_WEB_PROPERTIES, trial_false->trial_name(), AssociateGoogleVariationID(GOOGLE_APP, trial_false->trial_name(), loser,
loser, TEST_VALUE_B); TEST_VALUE_B);
EXPECT_NE(loser_group, trial_false->group()); EXPECT_NE(loser_group, trial_false->group());
EXPECT_EQ(TEST_VALUE_A, EXPECT_EQ(TEST_VALUE_A, GetIDForTrial(GOOGLE_APP, trial_false.get()));
GetIDForTrial(GOOGLE_WEB_PROPERTIES, trial_false.get()));
} }
// Test that not associating a FieldTrial with any IDs ensure that the empty ID // Test that not associating a FieldTrial with any IDs ensure that the empty ID
...@@ -128,25 +131,23 @@ TEST_F(VariationsAssociatedDataTest, NoAssociation) { ...@@ -128,25 +131,23 @@ TEST_F(VariationsAssociatedDataTest, NoAssociation) {
// have a valid VariationID associated with it. // have a valid VariationID associated with it.
EXPECT_EQ(winner_group, no_id_trial->group()); EXPECT_EQ(winner_group, no_id_trial->group());
EXPECT_EQ(winner, no_id_trial->group_name()); EXPECT_EQ(winner, no_id_trial->group_name());
EXPECT_EQ(EMPTY_ID, GetIDForTrial(GOOGLE_WEB_PROPERTIES, no_id_trial.get())); for (int i = 0; i < ID_COLLECTION_COUNT; ++i) {
ASSERT_EQ(EMPTY_ID, GetIDForTrial(static_cast<IDCollectionKey>(i),
no_id_trial.get()));
}
} }
// Ensure that the AssociateGoogleVariationIDForce works as expected. // Ensure that the AssociateGoogleVariationIDForce works as expected.
TEST_F(VariationsAssociatedDataTest, ForceAssociation) { TEST_F(VariationsAssociatedDataTest, ForceAssociation) {
EXPECT_EQ(EMPTY_ID, EXPECT_EQ(EMPTY_ID, GetGoogleVariationID(GOOGLE_APP, "trial", "group"));
GetGoogleVariationID(GOOGLE_WEB_PROPERTIES, "trial", "group"));
AssociateGoogleVariationID(GOOGLE_WEB_PROPERTIES, "trial", "group", AssociateGoogleVariationID(GOOGLE_APP, "trial", "group", TEST_VALUE_A);
TEST_VALUE_A); EXPECT_EQ(TEST_VALUE_A, GetGoogleVariationID(GOOGLE_APP, "trial", "group"));
EXPECT_EQ(TEST_VALUE_A, AssociateGoogleVariationID(GOOGLE_APP, "trial", "group", TEST_VALUE_B);
GetGoogleVariationID(GOOGLE_WEB_PROPERTIES, "trial", "group")); EXPECT_EQ(TEST_VALUE_A, GetGoogleVariationID(GOOGLE_APP, "trial", "group"));
AssociateGoogleVariationID(GOOGLE_WEB_PROPERTIES, "trial", "group",
TEST_VALUE_B); AssociateGoogleVariationIDForce(GOOGLE_APP, "trial", "group", TEST_VALUE_B);
EXPECT_EQ(TEST_VALUE_A, EXPECT_EQ(TEST_VALUE_B, GetGoogleVariationID(GOOGLE_APP, "trial", "group"));
GetGoogleVariationID(GOOGLE_WEB_PROPERTIES, "trial", "group"));
AssociateGoogleVariationIDForce(GOOGLE_WEB_PROPERTIES, "trial", "group",
TEST_VALUE_B);
EXPECT_EQ(TEST_VALUE_B,
GetGoogleVariationID(GOOGLE_WEB_PROPERTIES, "trial", "group"));
} }
} // namespace variations } // namespace variations
...@@ -79,15 +79,17 @@ class VariationsIdCollectionTest : public ::testing::Test { ...@@ -79,15 +79,17 @@ class VariationsIdCollectionTest : public ::testing::Test {
}; };
TEST_F(VariationsIdCollectionTest, VariousSetupAndFinalization) { TEST_F(VariationsIdCollectionTest, VariousSetupAndFinalization) {
SetupAndFinalizeTrial(kTrial1, GOOGLE_WEB_PROPERTIES, kVariation1); SetupAndFinalizeTrial(kTrial1, GOOGLE_WEB_PROPERTIES_ANY_CONTEXT,
SetupTrial(kTrial2, GOOGLE_WEB_PROPERTIES, kVariation2); kVariation1);
ResetCollection(GOOGLE_WEB_PROPERTIES); SetupTrial(kTrial2, GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, kVariation2);
ResetCollection(GOOGLE_WEB_PROPERTIES_ANY_CONTEXT);
EXPECT_EQ(Set({kVariation1}), collection()->GetIds()); EXPECT_EQ(Set({kVariation1}), collection()->GetIds());
EXPECT_EQ(Vec({}), GetNewIds()); EXPECT_EQ(Vec({}), GetNewIds());
FinalizeTrial(kTrial2); FinalizeTrial(kTrial2);
SetupAndFinalizeTrial(kTrial3, GOOGLE_WEB_PROPERTIES, kVariation3); SetupAndFinalizeTrial(kTrial3, GOOGLE_WEB_PROPERTIES_ANY_CONTEXT,
kVariation3);
EXPECT_EQ(Set({kVariation1, kVariation2, kVariation3}), EXPECT_EQ(Set({kVariation1, kVariation2, kVariation3}),
collection()->GetIds()); collection()->GetIds());
...@@ -95,9 +97,11 @@ TEST_F(VariationsIdCollectionTest, VariousSetupAndFinalization) { ...@@ -95,9 +97,11 @@ TEST_F(VariationsIdCollectionTest, VariousSetupAndFinalization) {
} }
TEST_F(VariationsIdCollectionTest, VariousKeys) { TEST_F(VariationsIdCollectionTest, VariousKeys) {
SetupAndFinalizeTrial(kTrial1, GOOGLE_WEB_PROPERTIES, kVariation1); SetupAndFinalizeTrial(kTrial1, GOOGLE_WEB_PROPERTIES_ANY_CONTEXT,
kVariation1);
SetupAndFinalizeTrial(kTrial2, GOOGLE_WEB_PROPERTIES_SIGNED_IN, kVariation2); SetupAndFinalizeTrial(kTrial2, GOOGLE_WEB_PROPERTIES_SIGNED_IN, kVariation2);
SetupAndFinalizeTrial(kTrial3, GOOGLE_WEB_PROPERTIES_TRIGGER, kVariation3); SetupAndFinalizeTrial(kTrial3, GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT,
kVariation3);
ResetCollection(GOOGLE_WEB_PROPERTIES_SIGNED_IN); ResetCollection(GOOGLE_WEB_PROPERTIES_SIGNED_IN);
EXPECT_EQ(Set({kVariation2}), collection()->GetIds()); EXPECT_EQ(Set({kVariation2}), collection()->GetIds());
...@@ -105,14 +109,14 @@ TEST_F(VariationsIdCollectionTest, VariousKeys) { ...@@ -105,14 +109,14 @@ TEST_F(VariationsIdCollectionTest, VariousKeys) {
} }
TEST_F(VariationsIdCollectionTest, MultipleFinalization) { TEST_F(VariationsIdCollectionTest, MultipleFinalization) {
ResetCollection(GOOGLE_WEB_PROPERTIES); ResetCollection(GOOGLE_WEB_PROPERTIES_ANY_CONTEXT);
collection()->OnFieldTrialGroupFinalized(kTrial1, kGroup); collection()->OnFieldTrialGroupFinalized(kTrial1, kGroup);
EXPECT_EQ(Set({}), collection()->GetIds()); EXPECT_EQ(Set({}), collection()->GetIds());
EXPECT_EQ(Vec({}), GetNewIds()); EXPECT_EQ(Vec({}), GetNewIds());
// Even though OnFieldTrialGroupFinalized is called, the VariationID lookup // Even though OnFieldTrialGroupFinalized is called, the VariationID lookup
// should still fail and it should be gracefully handled. // should still fail and it should be gracefully handled.
SetupTrial(kTrial2, GOOGLE_WEB_PROPERTIES, kVariation1); SetupTrial(kTrial2, GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, kVariation1);
collection()->OnFieldTrialGroupFinalized(kTrial1, kGroup); collection()->OnFieldTrialGroupFinalized(kTrial1, kGroup);
EXPECT_EQ(Set({}), collection()->GetIds()); EXPECT_EQ(Set({}), collection()->GetIds());
EXPECT_EQ(Vec({}), GetNewIds()); EXPECT_EQ(Vec({}), GetNewIds());
......
...@@ -79,7 +79,7 @@ std::string VariationsIdsProvider::GetGoogleAppVariationsString() { ...@@ -79,7 +79,7 @@ std::string VariationsIdsProvider::GetGoogleAppVariationsString() {
} }
std::string VariationsIdsProvider::GetVariationsString() { std::string VariationsIdsProvider::GetVariationsString() {
return GetVariationsString(GOOGLE_WEB_PROPERTIES); return GetVariationsString(GOOGLE_WEB_PROPERTIES_ANY_CONTEXT);
} }
std::vector<VariationID> VariationsIdsProvider::GetVariationsVector( std::vector<VariationID> VariationsIdsProvider::GetVariationsVector(
...@@ -90,9 +90,9 @@ std::vector<VariationID> VariationsIdsProvider::GetVariationsVector( ...@@ -90,9 +90,9 @@ std::vector<VariationID> VariationsIdsProvider::GetVariationsVector(
std::vector<VariationID> std::vector<VariationID>
VariationsIdsProvider::GetVariationsVectorForWebPropertiesKeys() { VariationsIdsProvider::GetVariationsVectorForWebPropertiesKeys() {
const std::set<IDCollectionKey> web_properties_keys{ const std::set<IDCollectionKey> web_properties_keys{
variations::GOOGLE_WEB_PROPERTIES, variations::GOOGLE_WEB_PROPERTIES_ANY_CONTEXT,
variations::GOOGLE_WEB_PROPERTIES_SIGNED_IN, variations::GOOGLE_WEB_PROPERTIES_SIGNED_IN,
variations::GOOGLE_WEB_PROPERTIES_TRIGGER}; variations::GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT};
return GetVariationsVectorImpl(web_properties_keys); return GetVariationsVectorImpl(web_properties_keys);
} }
...@@ -153,9 +153,10 @@ void VariationsIdsProvider::OnFieldTrialGroupFinalized( ...@@ -153,9 +153,10 @@ void VariationsIdsProvider::OnFieldTrialGroupFinalized(
const std::string& group_name) { const std::string& group_name) {
base::AutoLock scoped_lock(lock_); base::AutoLock scoped_lock(lock_);
const size_t old_size = variation_ids_set_.size(); const size_t old_size = variation_ids_set_.size();
CacheVariationsId(trial_name, group_name, GOOGLE_WEB_PROPERTIES); CacheVariationsId(trial_name, group_name, GOOGLE_WEB_PROPERTIES_ANY_CONTEXT);
CacheVariationsId(trial_name, group_name, GOOGLE_WEB_PROPERTIES_SIGNED_IN); CacheVariationsId(trial_name, group_name, GOOGLE_WEB_PROPERTIES_SIGNED_IN);
CacheVariationsId(trial_name, group_name, GOOGLE_WEB_PROPERTIES_TRIGGER); CacheVariationsId(trial_name, group_name,
GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT);
CacheVariationsId(trial_name, group_name, GOOGLE_APP); CacheVariationsId(trial_name, group_name, GOOGLE_APP);
if (variation_ids_set_.size() != old_size) if (variation_ids_set_.size() != old_size)
UpdateVariationIDsHeaderValue(); UpdateVariationIDsHeaderValue();
...@@ -167,11 +168,11 @@ void VariationsIdsProvider::OnSyntheticTrialsChanged( ...@@ -167,11 +168,11 @@ void VariationsIdsProvider::OnSyntheticTrialsChanged(
synthetic_variation_ids_set_.clear(); synthetic_variation_ids_set_.clear();
for (const SyntheticTrialGroup& group : groups) { for (const SyntheticTrialGroup& group : groups) {
VariationID id = VariationID id = GetGoogleVariationIDFromHashes(
GetGoogleVariationIDFromHashes(GOOGLE_WEB_PROPERTIES, group.id); GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, group.id);
if (id != EMPTY_ID) { if (id != EMPTY_ID) {
synthetic_variation_ids_set_.insert( synthetic_variation_ids_set_.insert(
VariationIDEntry(id, GOOGLE_WEB_PROPERTIES)); VariationIDEntry(id, GOOGLE_WEB_PROPERTIES_ANY_CONTEXT));
} }
id = GetGoogleVariationIDFromHashes(GOOGLE_WEB_PROPERTIES_SIGNED_IN, id = GetGoogleVariationIDFromHashes(GOOGLE_WEB_PROPERTIES_SIGNED_IN,
group.id); group.id);
...@@ -200,11 +201,11 @@ void VariationsIdsProvider::InitVariationIDsCacheIfNeeded() { ...@@ -200,11 +201,11 @@ void VariationsIdsProvider::InitVariationIDsCacheIfNeeded() {
for (const auto& entry : initial_groups) { for (const auto& entry : initial_groups) {
CacheVariationsId(entry.trial_name, entry.group_name, CacheVariationsId(entry.trial_name, entry.group_name,
GOOGLE_WEB_PROPERTIES); GOOGLE_WEB_PROPERTIES_ANY_CONTEXT);
CacheVariationsId(entry.trial_name, entry.group_name, CacheVariationsId(entry.trial_name, entry.group_name,
GOOGLE_WEB_PROPERTIES_SIGNED_IN); GOOGLE_WEB_PROPERTIES_SIGNED_IN);
CacheVariationsId(entry.trial_name, entry.group_name, CacheVariationsId(entry.trial_name, entry.group_name,
GOOGLE_WEB_PROPERTIES_TRIGGER); GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT);
CacheVariationsId(entry.trial_name, entry.group_name, GOOGLE_APP); CacheVariationsId(entry.trial_name, entry.group_name, GOOGLE_APP);
} }
UpdateVariationIDsHeaderValue(); UpdateVariationIDsHeaderValue();
...@@ -251,15 +252,19 @@ std::string VariationsIdsProvider::GenerateBase64EncodedProto( ...@@ -251,15 +252,19 @@ std::string VariationsIdsProvider::GenerateBase64EncodedProto(
if (is_signed_in) if (is_signed_in)
proto.add_variation_id(entry.first); proto.add_variation_id(entry.first);
break; break;
case GOOGLE_WEB_PROPERTIES: case GOOGLE_WEB_PROPERTIES_ANY_CONTEXT:
proto.add_variation_id(entry.first); proto.add_variation_id(entry.first);
break; break;
case GOOGLE_WEB_PROPERTIES_TRIGGER: case GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT:
proto.add_trigger_variation_id(entry.first); proto.add_trigger_variation_id(entry.first);
break; break;
case GOOGLE_APP: case GOOGLE_APP:
// These IDs should not be added into Google Web headers. // These IDs should not be added into Google Web headers.
break; break;
case GOOGLE_WEB_PROPERTIES_FIRST_PARTY:
case GOOGLE_WEB_PROPERTIES_TRIGGER_FIRST_PARTY:
// TODO(crbug/1094303): Add support for the above IDCollectionKeys.
break;
case ID_COLLECTION_COUNT: case ID_COLLECTION_COUNT:
// This case included to get full enum coverage for switch, so that // This case included to get full enum coverage for switch, so that
// new enums introduce compiler warnings. Nothing to do for this. // new enums introduce compiler warnings. Nothing to do for this.
...@@ -310,8 +315,8 @@ bool VariationsIdsProvider::AddVariationIdsToSet( ...@@ -310,8 +315,8 @@ bool VariationsIdsProvider::AddVariationIdsToSet(
return false; return false;
} }
target_set->insert(VariationIDEntry( target_set->insert(VariationIDEntry(
variation_id, variation_id, trigger_id ? GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT
trigger_id ? GOOGLE_WEB_PROPERTIES_TRIGGER : GOOGLE_WEB_PROPERTIES)); : GOOGLE_WEB_PROPERTIES_ANY_CONTEXT));
} }
return true; return true;
} }
......
...@@ -165,11 +165,11 @@ TEST_F(VariationsIdsProviderTest, OnFieldTrialGroupFinalized) { ...@@ -165,11 +165,11 @@ TEST_F(VariationsIdsProviderTest, OnFieldTrialGroupFinalized) {
const std::string default_name = "default"; const std::string default_name = "default";
scoped_refptr<base::FieldTrial> trial_1(CreateTrialAndAssociateId( scoped_refptr<base::FieldTrial> trial_1(CreateTrialAndAssociateId(
"t1", default_name, GOOGLE_WEB_PROPERTIES, 123)); "t1", default_name, GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, 123));
ASSERT_EQ(default_name, trial_1->group_name()); ASSERT_EQ(default_name, trial_1->group_name());
scoped_refptr<base::FieldTrial> trial_2(CreateTrialAndAssociateId( scoped_refptr<base::FieldTrial> trial_2(CreateTrialAndAssociateId(
"t2", default_name, GOOGLE_WEB_PROPERTIES_TRIGGER, 456)); "t2", default_name, GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT, 456));
ASSERT_EQ(default_name, trial_2->group_name()); ASSERT_EQ(default_name, trial_2->group_name());
scoped_refptr<base::FieldTrial> trial_3(CreateTrialAndAssociateId( scoped_refptr<base::FieldTrial> trial_3(CreateTrialAndAssociateId(
...@@ -208,8 +208,8 @@ TEST_F(VariationsIdsProviderTest, OnFieldTrialGroupFinalized) { ...@@ -208,8 +208,8 @@ TEST_F(VariationsIdsProviderTest, OnFieldTrialGroupFinalized) {
TEST_F(VariationsIdsProviderTest, GetGoogleAppVariationsString) { TEST_F(VariationsIdsProviderTest, GetGoogleAppVariationsString) {
// All GOOGLE_WEB_PROPERTIES(_X) ids shouldn't be included. // All GOOGLE_WEB_PROPERTIES(_X) ids shouldn't be included.
CreateTrialAndAssociateId("t1", "g1", GOOGLE_WEB_PROPERTIES, 123); CreateTrialAndAssociateId("t1", "g1", GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, 123);
CreateTrialAndAssociateId("t2", "g2", GOOGLE_WEB_PROPERTIES, 124); CreateTrialAndAssociateId("t2", "g2", GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, 124);
CreateTrialAndAssociateId("t3", "g3", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 125); CreateTrialAndAssociateId("t3", "g3", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 125);
// GOOGLE_APP ids should be included. // GOOGLE_APP ids should be included.
...@@ -221,8 +221,8 @@ TEST_F(VariationsIdsProviderTest, GetGoogleAppVariationsString) { ...@@ -221,8 +221,8 @@ TEST_F(VariationsIdsProviderTest, GetGoogleAppVariationsString) {
} }
TEST_F(VariationsIdsProviderTest, GetVariationsString) { TEST_F(VariationsIdsProviderTest, GetVariationsString) {
CreateTrialAndAssociateId("t1", "g1", GOOGLE_WEB_PROPERTIES, 123); CreateTrialAndAssociateId("t1", "g1", GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, 123);
CreateTrialAndAssociateId("t2", "g2", GOOGLE_WEB_PROPERTIES, 124); CreateTrialAndAssociateId("t2", "g2", GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, 124);
// SIGNED_IN ids shouldn't be included. // SIGNED_IN ids shouldn't be included.
CreateTrialAndAssociateId("t3", "g3", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 125); CreateTrialAndAssociateId("t3", "g3", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 125);
// GOOGLE_APP ids shouldn't be included. // GOOGLE_APP ids shouldn't be included.
...@@ -234,10 +234,12 @@ TEST_F(VariationsIdsProviderTest, GetVariationsString) { ...@@ -234,10 +234,12 @@ TEST_F(VariationsIdsProviderTest, GetVariationsString) {
} }
TEST_F(VariationsIdsProviderTest, GetVariationsVector) { TEST_F(VariationsIdsProviderTest, GetVariationsVector) {
CreateTrialAndAssociateId("t1", "g1", GOOGLE_WEB_PROPERTIES, 121); CreateTrialAndAssociateId("t1", "g1", GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, 121);
CreateTrialAndAssociateId("t2", "g2", GOOGLE_WEB_PROPERTIES, 122); CreateTrialAndAssociateId("t2", "g2", GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, 122);
CreateTrialAndAssociateId("t3", "g3", GOOGLE_WEB_PROPERTIES_TRIGGER, 123); CreateTrialAndAssociateId("t3", "g3",
CreateTrialAndAssociateId("t4", "g4", GOOGLE_WEB_PROPERTIES_TRIGGER, 124); GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT, 123);
CreateTrialAndAssociateId("t4", "g4",
GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT, 124);
CreateTrialAndAssociateId("t5", "g5", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 125); CreateTrialAndAssociateId("t5", "g5", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 125);
CreateTrialAndAssociateId("t6", "g6", GOOGLE_APP, 126); CreateTrialAndAssociateId("t6", "g6", GOOGLE_APP, 126);
...@@ -245,9 +247,10 @@ TEST_F(VariationsIdsProviderTest, GetVariationsVector) { ...@@ -245,9 +247,10 @@ TEST_F(VariationsIdsProviderTest, GetVariationsVector) {
provider.ForceVariationIds({"100", "200", "t101"}, ""); provider.ForceVariationIds({"100", "200", "t101"}, "");
EXPECT_EQ((std::vector<VariationID>{100, 121, 122, 200}), EXPECT_EQ((std::vector<VariationID>{100, 121, 122, 200}),
provider.GetVariationsVector(GOOGLE_WEB_PROPERTIES)); provider.GetVariationsVector(GOOGLE_WEB_PROPERTIES_ANY_CONTEXT));
EXPECT_EQ((std::vector<VariationID>{101, 123, 124}), EXPECT_EQ(
provider.GetVariationsVector(GOOGLE_WEB_PROPERTIES_TRIGGER)); (std::vector<VariationID>{101, 123, 124}),
provider.GetVariationsVector(GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT));
EXPECT_EQ((std::vector<VariationID>{125}), EXPECT_EQ((std::vector<VariationID>{125}),
provider.GetVariationsVector(GOOGLE_WEB_PROPERTIES_SIGNED_IN)); provider.GetVariationsVector(GOOGLE_WEB_PROPERTIES_SIGNED_IN));
EXPECT_EQ((std::vector<VariationID>{126}), EXPECT_EQ((std::vector<VariationID>{126}),
...@@ -255,8 +258,9 @@ TEST_F(VariationsIdsProviderTest, GetVariationsVector) { ...@@ -255,8 +258,9 @@ TEST_F(VariationsIdsProviderTest, GetVariationsVector) {
} }
TEST_F(VariationsIdsProviderTest, GetVariationsVectorForWebPropertiesKeys) { TEST_F(VariationsIdsProviderTest, GetVariationsVectorForWebPropertiesKeys) {
CreateTrialAndAssociateId("t1", "g1", GOOGLE_WEB_PROPERTIES, 121); CreateTrialAndAssociateId("t1", "g1", GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, 121);
CreateTrialAndAssociateId("t2", "g2", GOOGLE_WEB_PROPERTIES_TRIGGER, 122); CreateTrialAndAssociateId("t2", "g2",
GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT, 122);
CreateTrialAndAssociateId("t3", "g3", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 123); CreateTrialAndAssociateId("t3", "g3", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 123);
CreateTrialAndAssociateId("t4", "g4", GOOGLE_APP, 124); // Will be excluded. CreateTrialAndAssociateId("t4", "g4", GOOGLE_APP, 124); // Will be excluded.
VariationsIdsProvider provider; VariationsIdsProvider provider;
...@@ -266,10 +270,12 @@ TEST_F(VariationsIdsProviderTest, GetVariationsVectorForWebPropertiesKeys) { ...@@ -266,10 +270,12 @@ TEST_F(VariationsIdsProviderTest, GetVariationsVectorForWebPropertiesKeys) {
} }
TEST_F(VariationsIdsProviderTest, GetVariationsVectorImpl) { TEST_F(VariationsIdsProviderTest, GetVariationsVectorImpl) {
CreateTrialAndAssociateId("t1", "g1", GOOGLE_WEB_PROPERTIES, 121); CreateTrialAndAssociateId("t1", "g1", GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, 121);
CreateTrialAndAssociateId("t2", "g2", GOOGLE_WEB_PROPERTIES, 122); CreateTrialAndAssociateId("t2", "g2", GOOGLE_WEB_PROPERTIES_ANY_CONTEXT, 122);
CreateTrialAndAssociateId("t3", "g3", GOOGLE_WEB_PROPERTIES_TRIGGER, 123); CreateTrialAndAssociateId("t3", "g3",
CreateTrialAndAssociateId("t4", "g4", GOOGLE_WEB_PROPERTIES_TRIGGER, 124); GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT, 123);
CreateTrialAndAssociateId("t4", "g4",
GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT, 124);
CreateTrialAndAssociateId("t5", "g5", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 125); CreateTrialAndAssociateId("t5", "g5", GOOGLE_WEB_PROPERTIES_SIGNED_IN, 125);
CreateTrialAndAssociateId("t6", "g6", GOOGLE_WEB_PROPERTIES_SIGNED_IN, CreateTrialAndAssociateId("t6", "g6", GOOGLE_WEB_PROPERTIES_SIGNED_IN,
124); // Note: Duplicate. 124); // Note: Duplicate.
...@@ -280,10 +286,12 @@ TEST_F(VariationsIdsProviderTest, GetVariationsVectorImpl) { ...@@ -280,10 +286,12 @@ TEST_F(VariationsIdsProviderTest, GetVariationsVectorImpl) {
EXPECT_EQ((std::vector<VariationID>{100, 101, 121, 122, 123, 124, 200}), EXPECT_EQ((std::vector<VariationID>{100, 101, 121, 122, 123, 124, 200}),
provider.GetVariationsVectorImpl( provider.GetVariationsVectorImpl(
{GOOGLE_WEB_PROPERTIES, GOOGLE_WEB_PROPERTIES_TRIGGER})); {GOOGLE_WEB_PROPERTIES_ANY_CONTEXT,
GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT}));
EXPECT_EQ((std::vector<VariationID>{101, 123, 124, 125}), EXPECT_EQ((std::vector<VariationID>{101, 123, 124, 125}),
provider.GetVariationsVectorImpl({GOOGLE_WEB_PROPERTIES_SIGNED_IN, provider.GetVariationsVectorImpl(
GOOGLE_WEB_PROPERTIES_TRIGGER})); {GOOGLE_WEB_PROPERTIES_SIGNED_IN,
GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT}));
EXPECT_EQ((std::vector<VariationID>{124, 125, 126}), EXPECT_EQ((std::vector<VariationID>{124, 125, 126}),
provider.GetVariationsVectorImpl( provider.GetVariationsVectorImpl(
{GOOGLE_APP, GOOGLE_WEB_PROPERTIES_SIGNED_IN})); {GOOGLE_APP, GOOGLE_WEB_PROPERTIES_SIGNED_IN}));
......
...@@ -42,16 +42,16 @@ void RegisterVariationIds(const Study_Experiment& experiment, ...@@ -42,16 +42,16 @@ void RegisterVariationIds(const Study_Experiment& experiment,
if (experiment.has_google_web_experiment_id()) { if (experiment.has_google_web_experiment_id()) {
const VariationID variation_id = const VariationID variation_id =
static_cast<VariationID>(experiment.google_web_experiment_id()); static_cast<VariationID>(experiment.google_web_experiment_id());
AssociateGoogleVariationIDForce(GOOGLE_WEB_PROPERTIES, AssociateGoogleVariationIDForce(GOOGLE_WEB_PROPERTIES_ANY_CONTEXT,
trial_name, trial_name, experiment.name(),
experiment.name(),
variation_id); variation_id);
} }
if (experiment.has_google_web_trigger_experiment_id()) { if (experiment.has_google_web_trigger_experiment_id()) {
const VariationID variation_id = const VariationID variation_id =
static_cast<VariationID>(experiment.google_web_trigger_experiment_id()); static_cast<VariationID>(experiment.google_web_trigger_experiment_id());
AssociateGoogleVariationIDForce(GOOGLE_WEB_PROPERTIES_TRIGGER, trial_name, AssociateGoogleVariationIDForce(GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT,
experiment.name(), variation_id); trial_name, experiment.name(),
variation_id);
} }
if (experiment.has_google_app_experiment_id()) { if (experiment.has_google_app_experiment_id()) {
......
...@@ -177,8 +177,8 @@ TEST_F(VariationsSeedProcessorTest, AllowForceGroupAndVariationId) { ...@@ -177,8 +177,8 @@ TEST_F(VariationsSeedProcessorTest, AllowForceGroupAndVariationId) {
EXPECT_EQ(kFlagGroup1Name, EXPECT_EQ(kFlagGroup1Name,
base::FieldTrialList::FindFullName(kFlagStudyName)); base::FieldTrialList::FindFullName(kFlagStudyName));
VariationID id = GetGoogleVariationID(GOOGLE_WEB_PROPERTIES, kFlagStudyName, VariationID id = GetGoogleVariationID(GOOGLE_WEB_PROPERTIES_ANY_CONTEXT,
kFlagGroup1Name); kFlagStudyName, kFlagGroup1Name);
EXPECT_EQ(kExperimentId, id); EXPECT_EQ(kExperimentId, id);
} }
...@@ -593,8 +593,8 @@ TEST_F(VariationsSeedProcessorTest, ForcingFlagAlreadyForced) { ...@@ -593,8 +593,8 @@ TEST_F(VariationsSeedProcessorTest, ForcingFlagAlreadyForced) {
// Check that params and experiment ids correspond. // Check that params and experiment ids correspond.
EXPECT_EQ("y", GetVariationParamValue(study.name(), "x")); EXPECT_EQ("y", GetVariationParamValue(study.name(), "x"));
VariationID id = GetGoogleVariationID(GOOGLE_WEB_PROPERTIES, kFlagStudyName, VariationID id = GetGoogleVariationID(GOOGLE_WEB_PROPERTIES_ANY_CONTEXT,
kNonFlagGroupName); kFlagStudyName, kNonFlagGroupName);
EXPECT_EQ(kExperimentId, id); EXPECT_EQ(kExperimentId, id);
} }
......
...@@ -699,16 +699,16 @@ NSString* SerializedPref(const PrefService::Preference* pref) { ...@@ -699,16 +699,16 @@ NSString* SerializedPref(const PrefService::Preference* pref) {
+ (BOOL)isVariationEnabled:(int)variationID { + (BOOL)isVariationEnabled:(int)variationID {
variations::VariationsIdsProvider* provider = variations::VariationsIdsProvider* provider =
variations::VariationsIdsProvider::GetInstance(); variations::VariationsIdsProvider::GetInstance();
std::vector<variations::VariationID> ids = std::vector<variations::VariationID> ids = provider->GetVariationsVector(
provider->GetVariationsVector(variations::GOOGLE_WEB_PROPERTIES); variations::GOOGLE_WEB_PROPERTIES_ANY_CONTEXT);
return std::find(ids.begin(), ids.end(), variationID) != ids.end(); return std::find(ids.begin(), ids.end(), variationID) != ids.end();
} }
+ (BOOL)isTriggerVariationEnabled:(int)variationID { + (BOOL)isTriggerVariationEnabled:(int)variationID {
variations::VariationsIdsProvider* provider = variations::VariationsIdsProvider* provider =
variations::VariationsIdsProvider::GetInstance(); variations::VariationsIdsProvider::GetInstance();
std::vector<variations::VariationID> ids = std::vector<variations::VariationID> ids = provider->GetVariationsVector(
provider->GetVariationsVector(variations::GOOGLE_WEB_PROPERTIES_TRIGGER); variations::GOOGLE_WEB_PROPERTIES_TRIGGER_ANY_CONTEXT);
return std::find(ids.begin(), ids.end(), variationID) != ids.end(); return std::find(ids.begin(), ids.end(), variationID) != ids.end();
} }
......
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