Create feature kMostVisitedTilesImprovedSuggestions with a client side
finch trial.

This feature exists for an M109 iOS-only experiment to test better
default MVT suggestions based on Bling usage data.

This flag is checked against in PopularSites::GetPopularSitesURL(...)
and overrides the popular sites URL with
suggested_sites_US_2023q1_mvt_experiment_arm1.json or
suggested_sites_US_2023q1_mvt_experiment_arm2.json depending on the
experimental arm, if any.

NOTE: This change should be reviewed alongside cl/486703603, which adds
IOSPopularSitesImprovedSuggestions to the synthetic trials.

Change-Id: I5ddd28c22bbbab2803efc4a36d2839a9fe609e25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3995350
Reviewed-by: Tibor Goldschwendt <[email protected]>
Reviewed-by: Chris Lu <[email protected]>
Commit-Queue: Benjamin Williams <[email protected]>
Reviewed-by: Sylvain Defresne <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1071145}
diff --git a/components/ntp_tiles/features.cc b/components/ntp_tiles/features.cc
index d35052b..8b29a14 100644
--- a/components/ntp_tiles/features.cc
+++ b/components/ntp_tiles/features.cc
@@ -5,6 +5,7 @@
 #include "components/ntp_tiles/features.h"
 
 #include "base/feature_list.h"
+#include "base/metrics/field_trial_params.h"
 #include "build/build_config.h"
 #include "ui/base/ui_base_features.h"
 
@@ -12,6 +13,9 @@
 
 const char kPopularSitesFieldTrialName[] = "NTPPopularSites";
 
+const char kIOSPopularSitesExcludePopularAppsParam[] =
+    "IOSPopularSitesExcludePopularAppsParam";
+
 BASE_FEATURE(kPopularSitesBakedInContentFeature,
              "NTPPopularSitesBakedInContent",
              base::FEATURE_ENABLED_BY_DEFAULT);
@@ -24,4 +28,21 @@
              "UsePopularSitesSuggestions",
              base::FEATURE_ENABLED_BY_DEFAULT);
 
+BASE_FEATURE(kIOSPopularSitesImprovedSuggestions,
+             "IOSPopularSitesImprovedSuggestions",
+             base::FEATURE_DISABLED_BY_DEFAULT);
+
+IOSDefaultPopularSitesExperimentBehavior
+GetDefaultPopularSitesExperimentType() {
+  if (base::FeatureList::IsEnabled(kIOSPopularSitesImprovedSuggestions)) {
+    return base::GetFieldTrialParamByFeatureAsBool(
+               kIOSPopularSitesImprovedSuggestions,
+               kIOSPopularSitesExcludePopularAppsParam, /*default_value=*/false)
+               ? IOSDefaultPopularSitesExperimentBehavior::kExcludePopularApps
+               : IOSDefaultPopularSitesExperimentBehavior::kIncludePopularApps;
+  }
+
+  return IOSDefaultPopularSitesExperimentBehavior::kDefault;
+}
+
 }  // namespace ntp_tiles