[Merchant Trust] Add country and locale checks
The feature is only enabled if the user's country and locale match the
values specified in the feature parameters.
Change-Id: I764738991d720dfa609a01ed4df31d7f9a083be1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6059921
Code-Coverage: [email protected] <[email protected]>
Reviewed-by: Olesia Marukhno <[email protected]>
Commit-Queue: Nicola Tommasi <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1391502}
diff --git a/components/page_info/core/features.cc b/components/page_info/core/features.cc
index 2425f13..41fda60 100644
--- a/components/page_info/core/features.cc
+++ b/components/page_info/core/features.cc
@@ -10,6 +10,7 @@
#include "base/containers/fixed_flat_set.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
+#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "ui/base/l10n/l10n_util.h"
@@ -59,5 +60,23 @@
const base::FeatureParam<bool> kMerchantTrustEnabledWithSampleData{
&kMerchantTrust, kMerchantTrustEnabledWithSampleDataName, false};
+const char kMerchantTrustEnabledForCountry[] = "us";
+const char kMerchantTrustEnabledForLocale[] = "en-us";
+
+const char kMerchantTrustForceShowUIForTestingName[] =
+ "force-show-ui-for-testing";
+const base::FeatureParam<bool> kMerchantTrustForceShowUIForTesting{
+ &kMerchantTrust, kMerchantTrustForceShowUIForTestingName, false};
+
+extern bool IsMerchantTrustFeatureEnabled(const std::string& country_code,
+ const std::string& locale) {
+ if (kMerchantTrustForceShowUIForTesting.Get()) {
+ return true;
+ }
+
+ return base::FeatureList::IsEnabled(kMerchantTrust) &&
+ base::ToLowerASCII(country_code) == kMerchantTrustEnabledForCountry &&
+ base::ToLowerASCII(locale) == kMerchantTrustEnabledForLocale;
+}
} // namespace page_info