AboutThisSite: Enable PFINGS by default on Android
Bug: b/271425975
Change-Id: I7172711a6976d5e6b15cad1406dbe4d6b5de7216
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4341748
Commit-Queue: Christian Dullweber <[email protected]>
Reviewed-by: Filipa Senra <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1118016}
diff --git a/components/page_info/core/about_this_site_service_unittest.cc b/components/page_info/core/about_this_site_service_unittest.cc
index 98332e0..536dd17c 100644
--- a/components/page_info/core/about_this_site_service_unittest.cc
+++ b/components/page_info/core/about_this_site_service_unittest.cc
@@ -140,12 +140,25 @@
// Tests the language specific feature check.
TEST_P(AboutThisSiteServiceTest, FeatureCheck) {
- EXPECT_TRUE(page_info::IsAboutThisSiteFeatureEnabled("en-US"));
- EXPECT_TRUE(page_info::IsAboutThisSiteFeatureEnabled("en-GB"));
- EXPECT_TRUE(page_info::IsAboutThisSiteFeatureEnabled("en"));
+ const char* enabled[]{"en-US", "en-UK", "en"};
+ const char* disabled[]{"da", "id", "zh-TW", "ja"};
+ const char* enabled_on_android[]{"pt", "pt-BR", "pt-PT", "fr", "fr-CA", "it",
+ "nl", "de", "de-DE", "es", "es-419"};
- EXPECT_FALSE(page_info::IsAboutThisSiteFeatureEnabled("de-DE"));
- EXPECT_FALSE(page_info::IsAboutThisSiteFeatureEnabled("de"));
+ for (const char* lang : enabled) {
+ EXPECT_TRUE(page_info::IsAboutThisSiteFeatureEnabled(lang));
+ }
+ for (const char* lang : disabled) {
+ EXPECT_FALSE(page_info::IsAboutThisSiteFeatureEnabled(lang));
+ }
+
+ for (const char* lang : enabled_on_android) {
+#if BUILDFLAG(IS_ANDROID)
+ EXPECT_TRUE(page_info::IsAboutThisSiteFeatureEnabled(lang));
+#else
+ EXPECT_FALSE(page_info::IsAboutThisSiteFeatureEnabled(lang));
+#endif
+ }
}
// Tests that incorrect proto messages are discarded.
diff --git a/components/page_info/core/features.cc b/components/page_info/core/features.cc
index 7438ddf..c107a39 100644
--- a/components/page_info/core/features.cc
+++ b/components/page_info/core/features.cc
@@ -4,6 +4,7 @@
#include "components/page_info/core/features.h"
+#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/metrics/field_trial_params.h"
#include "build/build_config.h"
@@ -20,10 +21,18 @@
base::FEATURE_DISABLED_BY_DEFAULT);
#endif
+const char* pfings[]{"pt", "fr", "it", "nl", "de", "es"};
+
extern bool IsAboutThisSiteFeatureEnabled(const std::string& locale) {
- if (l10n_util::GetLanguage(locale) == "en") {
+ std::string lang = l10n_util::GetLanguage(locale);
+ if (lang == "en") {
return base::FeatureList::IsEnabled(kPageInfoAboutThisSiteEn);
} else {
+#if BUILDFLAG(IS_ANDROID)
+ if (base::Contains(pfings, lang)) {
+ return base::FeatureList::IsEnabled(kPageInfoAboutThisSiteEn);
+ }
+#endif
return base::FeatureList::IsEnabled(kPageInfoAboutThisSiteNonEn);
}
}
diff --git a/components/page_info/core/features.h b/components/page_info/core/features.h
index cd044e5..c04ebfe 100644
--- a/components/page_info/core/features.h
+++ b/components/page_info/core/features.h
@@ -26,7 +26,11 @@
// Enables the "About this site" section in Page Info.
extern bool IsAboutThisSiteFeatureEnabled(const std::string& locale);
+
+// Controls the feature for English and other languages that are enabled by
+// default. Use IsAboutThisSiteFeatureEnabled() to check a specific language.
BASE_DECLARE_FEATURE(kPageInfoAboutThisSiteEn);
+// Controls the feature for languages that are not enabled by default yet.
BASE_DECLARE_FEATURE(kPageInfoAboutThisSiteNonEn);
// Enables the "About this site" section for non-MSBB users.