Commit c450408f authored by Cathy Li's avatar Cathy Li Committed by Commit Bot

[Explore Sites]: Add feature parameters to explore sites flag

Bug: 867488
Change-Id: Ibb67a81cfef555e93128ae395fe6a9f0081a45ed
Reviewed-on: https://chromium-review.googlesource.com/1157183
Commit-Queue: Cathy Li <chili@chromium.org>
Reviewed-by: default avatarDmitry Titov <dimich@chromium.org>
Reviewed-by: default avatarJustin DeWitt <dewittj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580303}
parent 3c5a7b67
...@@ -2097,6 +2097,8 @@ jumbo_split_static_library("browser") { ...@@ -2097,6 +2097,8 @@ jumbo_split_static_library("browser") {
"android/explore_sites/catalog.h", "android/explore_sites/catalog.h",
"android/explore_sites/explore_sites_bridge.cc", "android/explore_sites/explore_sites_bridge.cc",
"android/explore_sites/explore_sites_bridge.h", "android/explore_sites/explore_sites_bridge.h",
"android/explore_sites/explore_sites_feature.cc",
"android/explore_sites/explore_sites_feature.h",
"android/explore_sites/ntp_json_fetcher.cc", "android/explore_sites/ntp_json_fetcher.cc",
"android/explore_sites/ntp_json_fetcher.h", "android/explore_sites/ntp_json_fetcher.h",
"android/explore_sites/url_util.cc", "android/explore_sites/url_util.cc",
......
...@@ -144,6 +144,7 @@ ...@@ -144,6 +144,7 @@
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "chrome/browser/android/chrome_feature_list.h" #include "chrome/browser/android/chrome_feature_list.h"
#include "chrome/browser/android/download/new_net_error_page_feature.h" #include "chrome/browser/android/download/new_net_error_page_feature.h"
#include "chrome/browser/android/explore_sites/explore_sites_feature.h"
#else // OS_ANDROID #else // OS_ANDROID
#include "chrome/browser/media/router/media_router_feature.h" #include "chrome/browser/media/router/media_router_feature.h"
#include "ui/message_center/public/cpp/features.h" #include "ui/message_center/public/cpp/features.h"
...@@ -1206,6 +1207,12 @@ const FeatureEntry::FeatureVariation kNewNetErrorPageUIVariations[] = { ...@@ -1206,6 +1207,12 @@ const FeatureEntry::FeatureVariation kNewNetErrorPageUIVariations[] = {
{"Content Preview", &kNewNetErrorPageUIContentPreview, 1, nullptr}, {"Content Preview", &kNewNetErrorPageUIContentPreview, 1, nullptr},
{"Content Preview + Auto download", &kNewNetErrorPageUIContentPreviewAutoDL, {"Content Preview + Auto download", &kNewNetErrorPageUIContentPreviewAutoDL,
1, nullptr}}; 1, nullptr}};
const FeatureEntry::FeatureParam kExploreSitesExperimental = {
chrome::android::explore_sites::kExploreSitesVariationParameterName,
chrome::android::explore_sites::kExploreSitesVariationExperimental};
const FeatureEntry::FeatureVariation kExploreSitesVariations[] = {
{"Experimental", &kExploreSitesExperimental, 1, nullptr}};
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
// RECORDING USER METRICS FOR FLAGS: // RECORDING USER METRICS FOR FLAGS:
...@@ -1380,7 +1387,9 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -1380,7 +1387,9 @@ const FeatureEntry kFeatureEntries[] = {
FEATURE_VALUE_TYPE(chrome::android::kContextualSearchUnityIntegration)}, FEATURE_VALUE_TYPE(chrome::android::kContextualSearchUnityIntegration)},
{"explore-sites", flag_descriptions::kExploreSitesName, {"explore-sites", flag_descriptions::kExploreSitesName,
flag_descriptions::kExploreSitesDescription, kOsAndroid, flag_descriptions::kExploreSitesDescription, kOsAndroid,
FEATURE_VALUE_TYPE(chrome::android::kExploreSites)}, FEATURE_WITH_PARAMS_VALUE_TYPE(chrome::android::kExploreSites,
kExploreSitesVariations,
"ExploreSites")},
#endif // OS_ANDROID #endif // OS_ANDROID
{"show-autofill-type-predictions", {"show-autofill-type-predictions",
flag_descriptions::kShowAutofillTypePredictionsName, flag_descriptions::kShowAutofillTypePredictionsName,
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/android/explore_sites/explore_sites_feature.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "chrome/browser/android/chrome_feature_list.h"
namespace chrome {
namespace android {
namespace explore_sites {
const char kExploreSitesVariationParameterName[] = "variation";
const char kExploreSitesVariationExperimental[] = "experiment";
ExploreSitesVariation GetExploreSitesVariation() {
if (base::FeatureList::IsEnabled(kExploreSites)) {
if (base::GetFieldTrialParamValueByFeature(
kExploreSites, kExploreSitesVariationParameterName) ==
kExploreSitesVariationExperimental) {
return ExploreSitesVariation::EXPERIMENT;
}
return ExploreSitesVariation::ENABLED;
}
return ExploreSitesVariation::DISABLED;
}
} // namespace explore_sites
} // namespace android
} // namespace chrome
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ANDROID_EXPLORE_SITES_EXPLORE_SITES_FEATURE_H_
#define CHROME_BROWSER_ANDROID_EXPLORE_SITES_EXPLORE_SITES_FEATURE_H_
namespace chrome {
namespace android {
namespace explore_sites {
extern const char kExploreSitesVariationParameterName[];
extern const char kExploreSitesVariationExperimental[];
enum class ExploreSitesVariation { ENABLED, EXPERIMENT, DISABLED };
ExploreSitesVariation GetExploreSitesVariation();
} // namespace explore_sites
} // namespace android
} // namespace chrome
#endif // CHROME_BROWSER_ANDROID_EXPLORE_SITES_EXPLORE_SITES_FEATURE_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/android/explore_sites/explore_sites_feature.h"
#include <map>
#include <string>
#include "base/feature_list.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/android/chrome_feature_list.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chrome {
namespace android {
namespace explore_sites {
TEST(ExploreSitesFeatureTest, ExploreSitesEnabled) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(kExploreSites);
EXPECT_EQ(ExploreSitesVariation::ENABLED, GetExploreSitesVariation());
}
TEST(ExploreSitesFeatureTest, ExploreSitesDisabled) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndDisableFeature(kExploreSites);
EXPECT_EQ(ExploreSitesVariation::DISABLED, GetExploreSitesVariation());
}
TEST(ExploreSitesFeatureTest, ExploreSitesEnabledWithExperiment) {
std::map<std::string, std::string> parameters;
parameters[kExploreSitesVariationParameterName] =
kExploreSitesVariationExperimental;
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeatureWithParameters(kExploreSites,
parameters);
EXPECT_EQ(ExploreSitesVariation::EXPERIMENT, GetExploreSitesVariation());
}
TEST(ExploreSitesFeatureTest, ExploreSitesEnabledWithBogus) {
const char bogusParamValue[] = "bogus";
std::map<std::string, std::string> parameters;
parameters[kExploreSitesVariationParameterName] = bogusParamValue;
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeatureWithParameters(kExploreSites,
parameters);
EXPECT_EQ(ExploreSitesVariation::ENABLED, GetExploreSitesVariation());
}
} // namespace explore_sites
} // namespace android
} // namespace chrome
...@@ -2304,6 +2304,7 @@ test("unit_tests") { ...@@ -2304,6 +2304,7 @@ test("unit_tests") {
"../browser/android/contextualsearch/contextual_search_field_trial_unittest.cc", "../browser/android/contextualsearch/contextual_search_field_trial_unittest.cc",
"../browser/android/digital_asset_links/digital_asset_links_handler_unittest.cc", "../browser/android/digital_asset_links/digital_asset_links_handler_unittest.cc",
"../browser/android/download/download_manager_service_unittest.cc", "../browser/android/download/download_manager_service_unittest.cc",
"../browser/android/explore_sites/explore_sites_feature_unittest.cc",
"../browser/android/explore_sites/ntp_json_fetcher_unittest.cc", "../browser/android/explore_sites/ntp_json_fetcher_unittest.cc",
"../browser/android/history_report/data_observer_unittest.cc", "../browser/android/history_report/data_observer_unittest.cc",
"../browser/android/history_report/delta_file_backend_leveldb_unittest.cc", "../browser/android/history_report/delta_file_backend_leveldb_unittest.cc",
......
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