Commit 192819ea authored by Andy Paicu's avatar Andy Paicu Committed by Commit Bot

Add a minimum display period before the flash banner expires on navigation

When using pinned tabs, the banner will immediately disappear because
of the navigation to the pinned tab's address. This ensures that there
is a minimum display period before the banner expires on navigations.

Bug: 1001333
Change-Id: Idabc5a972696068f3ce7d5a9f70ee0ca95d4c0f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925063
Commit-Queue: Andy Paicu <andypaicu@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720922}
parent 593748ae
......@@ -30,6 +30,10 @@ namespace {
constexpr base::TimeDelta kMessageCooldown = base::TimeDelta::FromDays(14);
// This duration is the same as the "default browser" banner's duration.
constexpr base::TimeDelta kMinimumDurationBeforeExpiryOnNavigation =
base::TimeDelta::FromSeconds(8);
bool IsFlashDeprecationWarningCooldownActive(Profile* profile) {
base::Time last_dismissal =
profile->GetPrefs()->GetTime(prefs::kPluginsDeprecationInfobarLastShown);
......@@ -90,7 +94,7 @@ bool FlashDeprecationInfoBarDelegate::ShouldDisplayFlashDeprecation(
FlashDeprecationInfoBarDelegate::FlashDeprecationInfoBarDelegate(
Profile* profile)
: profile_(profile) {}
: profile_(profile), display_start_(base::Time::Now()) {}
infobars::InfoBarDelegate::InfoBarIdentifier
FlashDeprecationInfoBarDelegate::GetIdentifier() const {
......@@ -139,3 +143,11 @@ GURL FlashDeprecationInfoBarDelegate::GetLinkURL() const {
void FlashDeprecationInfoBarDelegate::InfoBarDismissed() {
ActivateFlashDeprecationWarningCooldown(profile_);
}
bool FlashDeprecationInfoBarDelegate::ShouldExpire(
const NavigationDetails& details) const {
bool minimum_duration_elapsed = base::Time::Now() - display_start_ >
kMinimumDurationBeforeExpiryOnNavigation;
return minimum_duration_elapsed &&
ConfirmInfoBarDelegate::ShouldExpire(details);
}
......@@ -10,6 +10,10 @@
class Profile;
class InfoBarService;
namespace base {
class Time;
}
class FlashDeprecationInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
static void Create(InfoBarService* infobar_service, Profile* profile);
......@@ -19,7 +23,6 @@ class FlashDeprecationInfoBarDelegate : public ConfirmInfoBarDelegate {
static bool ShouldDisplayFlashDeprecation(Profile* profile);
explicit FlashDeprecationInfoBarDelegate(Profile* profile);
~FlashDeprecationInfoBarDelegate() override = default;
// ConfirmInfobarDelegate:
infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
......@@ -31,9 +34,16 @@ class FlashDeprecationInfoBarDelegate : public ConfirmInfoBarDelegate {
base::string16 GetLinkText() const override;
GURL GetLinkURL() const override;
void InfoBarDismissed() override;
bool ShouldExpire(const NavigationDetails& details) const override;
private:
// The profile associated with this infobar.
Profile* const profile_;
// The time at which the banner has started to be displayed. Used to determine
// if the banner should expire on navigation, based on how long it has been
// visible.
base::Time display_start_;
};
#endif // CHROME_BROWSER_PLUGINS_FLASH_DEPRECATION_INFOBAR_DELEGATE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment