summaryrefslogtreecommitdiffstats
path: root/components/suggestions
diff options
context:
space:
mode:
authormathp <mathp@chromium.org>2015-01-19 15:20:09 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-19 23:21:09 +0000
commit25cc193f2c398442782e28d105d0cebfa4b89017 (patch)
tree554c9eb3082c427020a3dd24d9c2370f473bbffb /components/suggestions
parentf7b92d86c032da9ae1ae71b0f9d5bbde9900a132 (diff)
downloadchromium_src-25cc193f2c398442782e28d105d0cebfa4b89017.zip
chromium_src-25cc193f2c398442782e28d105d0cebfa4b89017.tar.gz
chromium_src-25cc193f2c398442782e28d105d0cebfa4b89017.tar.bz2
[SuggestionsService] Add Variations check for enabling the service
No longer by default for M41. BUG=450035 TBR=mgiuca Review URL: https://codereview.chromium.org/855973002 Cr-Commit-Position: refs/heads/master@{#312153}
Diffstat (limited to 'components/suggestions')
-rw-r--r--components/suggestions/suggestions_service.cc9
-rw-r--r--components/suggestions/suggestions_service.h4
-rw-r--r--components/suggestions/suggestions_service_unittest.cc26
3 files changed, 34 insertions, 5 deletions
diff --git a/components/suggestions/suggestions_service.cc b/components/suggestions/suggestions_service.cc
index bb47aa1..9c6f2c8 100644
--- a/components/suggestions/suggestions_service.cc
+++ b/components/suggestions/suggestions_service.cc
@@ -91,6 +91,7 @@ const int kSchedulingMaxDelaySec = 5 * 60;
const char kSuggestionsFieldTrialName[] = "ChromeSuggestions";
const char kSuggestionsFieldTrialControlParam[] = "control";
const char kSuggestionsFieldTrialStateEnabled[] = "enabled";
+const char kSuggestionsFieldTrialStateParam[] = "state";
// TODO(mathp): Put this in TemplateURL.
const char kSuggestionsURL[] = "https://www.google.com/chromesuggestions?t=2";
@@ -118,9 +119,15 @@ SuggestionsService::SuggestionsService(
SuggestionsService::~SuggestionsService() {}
// static
+bool SuggestionsService::IsEnabled() {
+ return GetExperimentParam(kSuggestionsFieldTrialStateParam) ==
+ kSuggestionsFieldTrialStateEnabled;
+}
+
+// static
bool SuggestionsService::IsControlGroup() {
return GetExperimentParam(kSuggestionsFieldTrialControlParam) ==
- kSuggestionsFieldTrialStateEnabled;
+ kSuggestionsFieldTrialStateEnabled;
}
void SuggestionsService::FetchSuggestionsData(
diff --git a/components/suggestions/suggestions_service.h b/components/suggestions/suggestions_service.h
index 16c1d60..f4ebfe0 100644
--- a/components/suggestions/suggestions_service.h
+++ b/components/suggestions/suggestions_service.h
@@ -40,6 +40,7 @@ class SuggestionsStore;
extern const char kSuggestionsFieldTrialName[];
extern const char kSuggestionsFieldTrialControlParam[];
extern const char kSuggestionsFieldTrialStateEnabled[];
+extern const char kSuggestionsFieldTrialStateParam[];
extern const char kSuggestionsURL[];
extern const char kSuggestionsBlacklistURLPrefix[];
@@ -60,6 +61,9 @@ class SuggestionsService : public KeyedService, public net::URLFetcherDelegate {
scoped_ptr<BlacklistStore> blacklist_store);
~SuggestionsService() override;
+ // Whether this service is enabled.
+ static bool IsEnabled();
+
// Whether the user is part of a control group.
static bool IsControlGroup();
diff --git a/components/suggestions/suggestions_service_unittest.cc b/components/suggestions/suggestions_service_unittest.cc
index a2e12e3..c6253c7 100644
--- a/components/suggestions/suggestions_service_unittest.cc
+++ b/components/suggestions/suggestions_service_unittest.cc
@@ -199,8 +199,7 @@ class SuggestionsServiceTest : public testing::Test {
io_message_loop_.message_loop_proxy());
}
- // Enables the control group in the "ChromeSuggestions.Group1" field trial.
- void EnableFieldTrialControlGroup() {
+ void EnableFieldTrial(bool control_group) {
// Clear the existing |field_trial_list_| to avoid firing a DCHECK.
field_trial_list_.reset(NULL);
field_trial_list_.reset(
@@ -208,8 +207,12 @@ class SuggestionsServiceTest : public testing::Test {
variations::testing::ClearAllVariationParams();
std::map<std::string, std::string> params;
- params[kSuggestionsFieldTrialControlParam] =
+ params[kSuggestionsFieldTrialStateParam] =
kSuggestionsFieldTrialStateEnabled;
+ if (control_group) {
+ params[kSuggestionsFieldTrialControlParam] =
+ kSuggestionsFieldTrialStateEnabled;
+ }
variations::AssociateVariationParams(kSuggestionsFieldTrialName, "Group1",
params);
field_trial_ = base::FieldTrialList::CreateFieldTrial(
@@ -347,21 +350,25 @@ class SuggestionsServiceTest : public testing::Test {
};
TEST_F(SuggestionsServiceTest, IsControlGroup) {
+ EnableFieldTrial(false);
EXPECT_FALSE(SuggestionsService::IsControlGroup());
- EnableFieldTrialControlGroup();
+ EnableFieldTrial(true);
EXPECT_TRUE(SuggestionsService::IsControlGroup());
}
TEST_F(SuggestionsServiceTest, FetchSuggestionsData) {
+ EnableFieldTrial(false);
FetchSuggestionsDataHelper(INITIALIZED_ENABLED_HISTORY);
}
TEST_F(SuggestionsServiceTest, FetchSuggestionsDataSyncNotInitializedEnabled) {
+ EnableFieldTrial(false);
FetchSuggestionsDataHelper(NOT_INITIALIZED_ENABLED);
}
TEST_F(SuggestionsServiceTest, FetchSuggestionsDataSyncDisabled) {
+ EnableFieldTrial(false);
scoped_ptr<SuggestionsService> suggestions_service(
CreateSuggestionsServiceWithMocks());
EXPECT_TRUE(suggestions_service != NULL);
@@ -380,6 +387,7 @@ TEST_F(SuggestionsServiceTest, FetchSuggestionsDataSyncDisabled) {
}
TEST_F(SuggestionsServiceTest, IssueRequestIfNoneOngoingError) {
+ EnableFieldTrial(false);
scoped_ptr<SuggestionsService> suggestions_service(
CreateSuggestionsServiceWithMocks());
EXPECT_TRUE(suggestions_service != NULL);
@@ -399,6 +407,7 @@ TEST_F(SuggestionsServiceTest, IssueRequestIfNoneOngoingError) {
}
TEST_F(SuggestionsServiceTest, IssueRequestIfNoneOngoingResponseNotOK) {
+ EnableFieldTrial(false);
scoped_ptr<SuggestionsService> suggestions_service(
CreateSuggestionsServiceWithMocks());
EXPECT_TRUE(suggestions_service != NULL);
@@ -427,6 +436,7 @@ TEST_F(SuggestionsServiceTest, IssueRequestIfNoneOngoingResponseNotOK) {
}
TEST_F(SuggestionsServiceTest, BlacklistURL) {
+ EnableFieldTrial(false);
scoped_ptr<SuggestionsService> suggestions_service(
CreateSuggestionsServiceWithMocks());
EXPECT_TRUE(suggestions_service != NULL);
@@ -470,6 +480,7 @@ TEST_F(SuggestionsServiceTest, BlacklistURL) {
}
TEST_F(SuggestionsServiceTest, BlacklistURLFails) {
+ EnableFieldTrial(false);
scoped_ptr<SuggestionsService> suggestions_service(
CreateSuggestionsServiceWithMocks());
EXPECT_TRUE(suggestions_service != NULL);
@@ -485,6 +496,7 @@ TEST_F(SuggestionsServiceTest, BlacklistURLFails) {
// Initial blacklist request fails, triggering a second which succeeds.
TEST_F(SuggestionsServiceTest, BlacklistURLRequestFails) {
+ EnableFieldTrial(false);
scoped_ptr<SuggestionsService> suggestions_service(
CreateSuggestionsServiceWithMocks());
EXPECT_TRUE(suggestions_service != NULL);
@@ -541,6 +553,7 @@ TEST_F(SuggestionsServiceTest, BlacklistURLRequestFails) {
}
TEST_F(SuggestionsServiceTest, UndoBlacklistURL) {
+ EnableFieldTrial(false);
scoped_ptr<SuggestionsService> suggestions_service(
CreateSuggestionsServiceWithMocks());
EXPECT_TRUE(suggestions_service != NULL);
@@ -577,14 +590,17 @@ TEST_F(SuggestionsServiceTest, UndoBlacklistURL) {
TEST_F(SuggestionsServiceTest, UndoBlacklistURLFailsIfNotInBlacklist) {
+ EnableFieldTrial(false);
UndoBlacklistURLFailsHelper(true);
}
TEST_F(SuggestionsServiceTest, UndoBlacklistURLFailsIfAlreadyCandidate) {
+ EnableFieldTrial(false);
UndoBlacklistURLFailsHelper(false);
}
TEST_F(SuggestionsServiceTest, GetBlacklistedUrl) {
+ EnableFieldTrial(false);
scoped_ptr<GURL> request_url;
scoped_ptr<net::FakeURLFetcher> fetcher;
GURL retrieved_url;
@@ -610,6 +626,7 @@ TEST_F(SuggestionsServiceTest, GetBlacklistedUrl) {
}
TEST_F(SuggestionsServiceTest, UpdateBlacklistDelay) {
+ EnableFieldTrial(false);
scoped_ptr<SuggestionsService> suggestions_service(
CreateSuggestionsServiceWithMocks());
base::TimeDelta initial_delay = suggestions_service->blacklist_delay();
@@ -628,6 +645,7 @@ TEST_F(SuggestionsServiceTest, UpdateBlacklistDelay) {
}
TEST_F(SuggestionsServiceTest, CheckDefaultTimeStamps) {
+ EnableFieldTrial(false);
scoped_ptr<SuggestionsService> suggestions_service(
CreateSuggestionsServiceWithMocks());
SuggestionsProfile suggestions =