[DownloadBubble] Remove last download time pref
This removes the last download time pref and updates code relying on it
to use the time supplied by DownloadBubbleUpdateService::GetDisplayInfo
instead. This updates the algorithm for calculating the last downloaded
time in the display info, by recording the time when a download is
updated and becomes no longer in-progress. We assume that when a
download is updated to a not-in-progress state, no further updates will
be sent aside from cancellation. In particular, this takes the time when
a download is marked insecure or dangerous (as they are considered not
in-progress).
This is done because:
1. The original reason for persisting the last downloaded time between
browser sessions is no longer relevant, because the download toolbar
button is no longer shown upon browser startup for performance
reasons. (The pref was added in crrev.com/c/3472822.)
2. Reading the pref on every single update may be expensive and doesn't
make a difference most of the time.
The resulting behavior change is that, in the case where a download
finished less than an hour ago in a previous Chrome session and the user
downloads another file (causing the toolbar button to be shown), we will
no longer schedule the toolbar button disappearance for 1 hr after the
original download, but will instead schedule it for 1 hr after the last
download finished *in the current browser session*.
Bug: 1482991
Change-Id: Iff1c2feed2b3f047cd8c952c51d2ff8dec0f7772
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4922235
Reviewed-by: Xinghui Lu <[email protected]>
Commit-Queue: Lily Chen <[email protected]>
Reviewed-by: Gabriel Charette <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1208381}
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index daf90c5..aefc80b 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -903,39 +903,36 @@
const char kPrivacySandboxM1Unrestricted[] = "privacy_sandbox.m1.unrestricted";
#if BUILDFLAG(IS_WIN)
const char kSwReporter[] = "software_reporter";
-inline constexpr char kChromeCleaner[] = "chrome_cleaner";
-inline constexpr char kSettingsResetPrompt[] = "settings_reset_prompt";
+const char kChromeCleaner[] = "chrome_cleaner";
+const char kSettingsResetPrompt[] = "settings_reset_prompt";
#endif
// A boolean specifying whether the new download bubble UI is enabled. If it is
// set to false, the old download shelf UI will be shown instead.
-inline constexpr char kDownloadBubbleEnabled[] = "download_bubble_enabled";
+const char kDownloadBubbleEnabled[] = "download_bubble_enabled";
// Deprecated 09/2023.
#if BUILDFLAG(IS_CHROMEOS_ASH)
-constexpr char kGestureEducationNotificationShown[] =
+const char kGestureEducationNotificationShown[] =
"ash.gesture_education.notification_shown";
// Note that this very name is used outside ChromeOS Ash, where it isn't
// deprecated.
-constexpr char kSyncInitialSyncFeatureSetupCompleteOnAsh[] =
+const char kSyncInitialSyncFeatureSetupCompleteOnAsh[] =
"sync.has_setup_completed";
#endif
// Deprecated 09/2023.
-// Synced boolean that indicates if a user has manually toggled the settings
-// associated with the PrivacySandboxSettings feature.
-inline constexpr char kPrivacySandboxManuallyControlled[] =
+const char kPrivacySandboxManuallyControlled[] =
"privacy_sandbox.manually_controlled";
// Deprecated 09/2023.
-// Boolean value indicating whether the regular prefs were migrated to UPM
-// settings for syncing users.
#if BUILDFLAG(IS_ANDROID)
const char kSettingsMigratedToUPM[] = "profile.settings_migrated_to_upm";
#endif
// Deprecated 10/2023.
-inline constexpr char kSyncRequested[] = "sync.requested";
+const char kSyncRequested[] = "sync.requested";
+const char kDownloadLastCompleteTime[] = "download.last_complete_time";
// Deprecated 10/2023.
#if BUILDFLAG(IS_CHROMEOS_ASH)
@@ -1321,6 +1318,7 @@
registry->RegisterStringPref(kLastSuccessfulDomainPref, std::string());
registry->RegisterBooleanPref(kShouldAttemptReenable, true);
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
+ registry->RegisterTimePref(kDownloadLastCompleteTime, base::Time());
}
void ClearSyncRequestedPrefAndMaybeMigrate(PrefService* profile_prefs) {