Remove NtpModulesFirstRunExperience C++ backend.
Also following the removal process for the following prefs
- kNtpModulesFreVisible
- kNtpModulesFirstShownTime
- kNtpModulesShownCount
OBSOLETE_HISTOGRAMS=No longer needed.
Fixed: 352803677
Change-Id: Id728a5aa37ca4c2f6473b33363ae8e16d1412ac6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5704408
Reviewed-by: Tibor Goldschwendt <[email protected]>
Reviewed-by: Chris Bookholt <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Commit-Queue: Demetrios Papadopoulos <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1327800}
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 250bed4..13c07ca 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -1082,9 +1082,14 @@
inline constexpr char kFirstRunStudyGroup[] = "browser.first_run_study_group";
#endif
-// Deprecated 07/2024
#if !BUILDFLAG(IS_ANDROID)
+// Deprecated 07/2024
constexpr char kNtpRecipesDismissedTasks[] = "NewTabPage.DismissedRecipeTasks";
+
+// Deprecated 07/2024
+constexpr char kNtpModulesFirstShownTime[] = "NewTabPage.ModulesFirstShownTime";
+constexpr char kNtpModulesFreVisible[] = "NewTabPage.ModulesFreVisible";
+constexpr char kNtpModulesShownCount[] = "NewTabPage.ModulesShownCount";
#endif
// Register local state used only for migration (clearing or moving to a new
@@ -1512,9 +1517,14 @@
// Deprecated 06/2024.
registry->RegisterBooleanPref(kDefaultSearchProviderChoicePending, false);
- // Deprecated 07/2024
#if !BUILDFLAG(IS_ANDROID)
+ // Deprecated 07/2024
registry->RegisterListPref(kNtpRecipesDismissedTasks);
+
+ // Deprecated 07/2024
+ registry->RegisterBooleanPref(kNtpModulesFreVisible, true);
+ registry->RegisterIntegerPref(kNtpModulesShownCount, 0);
+ registry->RegisterTimePref(kNtpModulesFirstShownTime, base::Time());
#endif
}
@@ -2857,9 +2867,14 @@
// Added 06/2024.
profile_prefs->ClearPref(kDefaultSearchProviderChoicePending);
- // Added 07/2024.
#if !BUILDFLAG(IS_ANDROID)
+ // Added 07/2024.
profile_prefs->ClearPref(kNtpRecipesDismissedTasks);
+
+ // Added 07/2024.
+ profile_prefs->ClearPref(kNtpModulesFirstShownTime);
+ profile_prefs->ClearPref(kNtpModulesFreVisible);
+ profile_prefs->ClearPref(kNtpModulesShownCount);
#endif
// Please don't delete the following line. It is used by PRESUBMIT.py.
// END_MIGRATE_OBSOLETE_PROFILE_PREFS
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom b/chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom
index e67d487a..6b6fcc6 100644
--- a/chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom
+++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page.mojom
@@ -302,14 +302,6 @@
// Returns the order of modules or an empty array if the user has not
// reordered them before.
GetModulesOrder() => (array<string> module_ids);
- // Increment the number of times the user has seen modules.
- IncrementModulesShownCount();
- // If |visible| Modular NTP Desktop v1 First Run Experience will be shown.
- SetModulesFreVisible(bool visible);
- // Triggers a call to |SetModulesFreVisibility|.
- UpdateModulesFreVisibility();
- // Log user's FRE |optInStatus|.
- LogModulesFreOptInStatus(OptInStatus opt_in_status);
// Shows or hides the customize chrome in unified side panel.
SetCustomizeChromeSidePanelVisible(bool visible,
CustomizeChromeSection section);
@@ -363,8 +355,6 @@
// Disables the modules in |ids|. If |all|, disables all modules and passes an
// empty list for |ids|.
SetDisabledModules(bool all, array<string> ids);
- // Sets Modular NTP Desktop v1 First Run Experience's visibility to |visible|.
- SetModulesFreVisibility(bool visible);
// Sets NTP homepage promo.
SetPromo(Promo? promo);
// Shows a toast with information about Chrome Webstore themes.
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
index fa9deefc..fc4fc92 100644
--- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
+++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.cc
@@ -87,7 +87,6 @@
namespace {
const int64_t kMaxDownloadBytes = 1024 * 1024;
-const int64_t kMaxModuleFreImpressions = 8;
constexpr char kDisableInteraction[] = "disable";
constexpr char kDismissInteraction[] = "dismiss";
@@ -537,9 +536,6 @@
registry->RegisterListPref(prefs::kNtpDisabledModules);
registry->RegisterListPref(prefs::kNtpModulesOrder);
registry->RegisterBooleanPref(prefs::kNtpModulesVisible, true);
- registry->RegisterIntegerPref(prefs::kNtpModulesShownCount, 0);
- registry->RegisterTimePref(prefs::kNtpModulesFirstShownTime, base::Time());
- registry->RegisterBooleanPref(prefs::kNtpModulesFreVisible, true);
registry->RegisterIntegerPref(prefs::kNtpCustomizeChromeButtonOpenCount, 0);
registry->RegisterDictionaryPref(prefs::kNtpModulesInteractedCountDict);
registry->RegisterDictionaryPref(prefs::kNtpModulesLoadedCountDict);
@@ -848,71 +844,6 @@
std::move(callback).Run(std::move(module_ids));
}
-void NewTabPageHandler::IncrementModulesShownCount() {
- const auto ntp_modules_shown_count =
- profile_->GetPrefs()->GetInteger(prefs::kNtpModulesShownCount);
-
- if (ntp_modules_shown_count == 0) {
- profile_->GetPrefs()->SetTime(prefs::kNtpModulesFirstShownTime,
- base::Time::Now());
- }
- profile_->GetPrefs()->SetInteger(prefs::kNtpModulesShownCount,
- ntp_modules_shown_count + 1);
-}
-
-void NewTabPageHandler::SetModulesFreVisible(bool visible) {
- profile_->GetPrefs()->SetBoolean(prefs::kNtpModulesFreVisible, visible);
- page_->SetModulesFreVisibility(visible);
-}
-
-void NewTabPageHandler::UpdateModulesFreVisibility() {
- const auto ntp_modules_shown_count =
- profile_->GetPrefs()->GetInteger(prefs::kNtpModulesShownCount);
- const auto ntp_modules_first_shown_time =
- profile_->GetPrefs()->GetTime(prefs::kNtpModulesFirstShownTime);
- auto ntp_modules_fre_visible =
- profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible);
-
- if (ntp_modules_fre_visible &&
- (ntp_modules_shown_count == kMaxModuleFreImpressions ||
- (!ntp_modules_first_shown_time.is_null() &&
- (base::Time::Now() - ntp_modules_first_shown_time) == base::Days(1)))) {
- LogModulesFreOptInStatus(new_tab_page::mojom::OptInStatus::kImplicitOptIn);
- }
-
- // Hide Modular NTP Desktop v1 First Run Experience after
- // |kMaxModuleFreImpressions| impressions or 1 day, whichever comes first.
- if (ntp_modules_shown_count >= kMaxModuleFreImpressions ||
- (!ntp_modules_first_shown_time.is_null() &&
- (base::Time::Now() - ntp_modules_first_shown_time) > base::Days(1))) {
- ntp_modules_fre_visible = false;
- SetModulesFreVisible(ntp_modules_fre_visible);
- } else {
- page_->SetModulesFreVisibility(ntp_modules_fre_visible);
- }
-}
-
-void NewTabPageHandler::LogModulesFreOptInStatus(
- new_tab_page::mojom::OptInStatus opt_in_status) {
- const auto ntp_modules_shown_count =
- profile_->GetPrefs()->GetInteger(prefs::kNtpModulesShownCount);
- switch (opt_in_status) {
- case new_tab_page::mojom::OptInStatus::kExplicitOptIn:
- base::UmaHistogramExactLinear("NewTabPage.Modules.FreExplicitOptIn",
- ntp_modules_shown_count,
- kMaxModuleFreImpressions);
- break;
- case new_tab_page::mojom::OptInStatus::kImplicitOptIn:
- base::UmaHistogramBoolean("NewTabPage.Modules.FreImplicitOptIn", true);
- break;
-
- case new_tab_page::mojom::OptInStatus::kOptOut:
- base::UmaHistogramExactLinear("NewTabPage.Modules.FreOptOut",
- ntp_modules_shown_count,
- kMaxModuleFreImpressions);
- }
-}
-
void NewTabPageHandler::SetCustomizeChromeSidePanelVisible(
bool visible,
new_tab_page::mojom::CustomizeChromeSection section) {
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h
index 8965edd3..db2993f7 100644
--- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h
+++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler.h
@@ -135,11 +135,6 @@
void GetModulesIdNames(GetModulesIdNamesCallback callback) override;
void SetModulesOrder(const std::vector<std::string>& module_ids) override;
void GetModulesOrder(GetModulesOrderCallback callback) override;
- void IncrementModulesShownCount() override;
- void SetModulesFreVisible(bool visible) override;
- void UpdateModulesFreVisibility() override;
- void LogModulesFreOptInStatus(
- new_tab_page::mojom::OptInStatus opt_in_status) override;
void SetCustomizeChromeSidePanelVisible(
bool visible,
new_tab_page::mojom::CustomizeChromeSection section) override;
diff --git a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc
index 83e42e4..b4894d2 100644
--- a/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc
+++ b/chrome/browser/ui/webui/new_tab_page/new_tab_page_handler_unittest.cc
@@ -703,22 +703,6 @@
std::string(NewTabPageHandler::kModuleRestoredHistogram) +
".kaleidoscope",
1);
-
- // NewTabPage.Modules.FreOptIn and NewTabPage.Modules.FreOptOut log how many
- // times the FRE is shown, so we increment the shown count to make sure the
- // histogram is logging correctly
- handler_->IncrementModulesShownCount();
- handler_->LogModulesFreOptInStatus(
- new_tab_page::mojom::OptInStatus::kExplicitOptIn);
- histogram_tester_.ExpectTotalCount("NewTabPage.Modules.FreExplicitOptIn", 1);
- ASSERT_EQ(1, histogram_tester_.GetBucketCount(
- "NewTabPage.Modules.FreExplicitOptIn", 1));
-
- handler_->IncrementModulesShownCount();
- handler_->LogModulesFreOptInStatus(new_tab_page::mojom::OptInStatus::kOptOut);
- histogram_tester_.ExpectTotalCount("NewTabPage.Modules.FreOptOut", 1);
- ASSERT_EQ(
- 1, histogram_tester_.GetBucketCount("NewTabPage.Modules.FreOptOut", 2));
}
TEST_F(NewTabPageHandlerTest, GetAnimatedDoodle) {
@@ -986,87 +970,6 @@
}
}
-TEST_F(NewTabPageHandlerTest, UpdateNtpModulesFreVisibility) {
- bool expected_visibility = true;
- profile_->GetPrefs()->SetBoolean(prefs::kNtpModulesFreVisible,
- expected_visibility);
-
- EXPECT_EQ(profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible),
- expected_visibility);
-
- expected_visibility = false;
- EXPECT_CALL(mock_page_, SetModulesFreVisibility)
- .Times(1)
- .WillOnce(testing::Invoke(
- [&](bool arg) { EXPECT_EQ(expected_visibility, arg); }));
-
- handler_->SetModulesFreVisible(expected_visibility);
-
- EXPECT_EQ(profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible),
- expected_visibility);
-
- mock_page_.FlushForTesting();
-}
-
-TEST_F(NewTabPageHandlerTest, IncrementModulesShownCount) {
- EXPECT_EQ(profile_->GetPrefs()->GetInteger(prefs::kNtpModulesShownCount), 0);
- EXPECT_EQ(profile_->GetPrefs()->GetTime(prefs::kNtpModulesFirstShownTime),
- base::Time());
-
- handler_->IncrementModulesShownCount();
-
- EXPECT_EQ(profile_->GetPrefs()->GetInteger(prefs::kNtpModulesShownCount), 1);
- EXPECT_NE(profile_->GetPrefs()->GetTime(prefs::kNtpModulesFirstShownTime),
- base::Time());
-
- mock_page_.FlushForTesting();
-}
-
-TEST_F(NewTabPageHandlerTest,
- UpdateModulesFreVisibilityUsingModulesShownCount) {
- handler_->SetModulesFreVisible(true);
- profile_->GetPrefs()->SetInteger(prefs::kNtpModulesShownCount, 7);
-
- handler_->UpdateModulesFreVisibility();
-
- EXPECT_EQ(profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible),
- true);
-
- profile_->GetPrefs()->SetInteger(prefs::kNtpModulesShownCount, 8);
-
- handler_->UpdateModulesFreVisibility();
-
- EXPECT_EQ(profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible),
- false);
- histogram_tester_.ExpectTotalCount("NewTabPage.Modules.FreImplicitOptIn", 1);
- ASSERT_EQ(1, histogram_tester_.GetBucketCount(
- "NewTabPage.Modules.FreImplicitOptIn", true));
-
- mock_page_.FlushForTesting();
-}
-
-TEST_F(NewTabPageHandlerTest,
- UpdateModulesFreVisibilityUsingModulesFirstShownTime) {
- handler_->SetModulesFreVisible(true);
- profile_->GetPrefs()->SetTime(prefs::kNtpModulesFirstShownTime,
- base::Time::Now());
-
- handler_->UpdateModulesFreVisibility();
-
- EXPECT_EQ(profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible),
- true);
-
- profile_->GetPrefs()->SetTime(prefs::kNtpModulesFirstShownTime,
- base::Time::Now() - base::Days(2));
-
- handler_->UpdateModulesFreVisibility();
-
- EXPECT_EQ(profile_->GetPrefs()->GetBoolean(prefs::kNtpModulesFreVisible),
- false);
-
- mock_page_.FlushForTesting();
-}
-
TEST_F(NewTabPageHandlerTest, SetModuleDisabledTriggersPageCall) {
handler_->SetModuleDisabled("drive", true);
EXPECT_CALL(mock_page_, SetDisabledModules).Times(1);