Revert "Added cooldown after dimssing the flash warning message"
This reverts commit 4aaa9f29d8fe5eac55b8632fa8fcb05a68d9005b.
As Flash's deprecation is near, we are resuming per session prompting about the deprecation.
Bug: 995969
Change-Id: I76632c2ace65d95fafaaea9224f02586f53c6841
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390656
Commit-Queue: Ravjit Singh Uppal <ravjit@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Balazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805443}
diff --git a/chrome/browser/plugins/flash_deprecation_infobar_delegate.cc b/chrome/browser/plugins/flash_deprecation_infobar_delegate.cc
index dbca32d..78dab2f5 100644
--- a/chrome/browser/plugins/flash_deprecation_infobar_delegate.cc
+++ b/chrome/browser/plugins/flash_deprecation_infobar_delegate.cc
@@ -4,21 +4,15 @@
#include "chrome/browser/plugins/flash_deprecation_infobar_delegate.h"
-#include <memory>
-
#include "base/feature_list.h"
-#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/plugins/plugin_utils.h"
-#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_features.h"
-#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/infobars/core/infobar.h"
-#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/l10n/l10n_util.h"
@@ -26,48 +20,39 @@
#include "url/url_constants.h"
// static
-void FlashDeprecationInfoBarDelegate::Create(InfoBarService* infobar_service,
- Profile* profile) {
+void FlashDeprecationInfoBarDelegate::Create(
+ InfoBarService* infobar_service,
+ HostContentSettingsMap* host_content_settings_map) {
infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
- std::make_unique<FlashDeprecationInfoBarDelegate>(profile)));
+ std::make_unique<FlashDeprecationInfoBarDelegate>(
+ host_content_settings_map)));
}
// static
bool FlashDeprecationInfoBarDelegate::ShouldDisplayFlashDeprecation(
- Profile* profile) {
+ HostContentSettingsMap* host_content_settings_map) {
+ DCHECK(host_content_settings_map);
+
if (!base::FeatureList::IsEnabled(features::kFlashDeprecationWarning))
return false;
- // Generally, display the infobar if the Flash setting is anything other than
- // BLOCK.
- HostContentSettingsMap* host_content_settings_map =
- HostContentSettingsMapFactory::GetForProfile(profile);
- DCHECK(host_content_settings_map);
bool is_managed = false;
ContentSetting flash_setting =
PluginUtils::UnsafeGetRawDefaultFlashContentSetting(
host_content_settings_map, &is_managed);
- if (flash_setting == CONTENT_SETTING_BLOCK)
- return false;
- // However, if the user can't do anything about their browser's Flash
- // behavior, there's no point to showing a Flash deprecation warning infobar.
+ // If the user can't do anything about their browser's Flash behavior,
+ // there's no point to showing a Flash deprecation warning infobar.
if (is_managed)
return false;
- // Also limit how frequently the infobar is shown. Users should be
- // periodically reminded that they need to take action, but if they couldn't
- // take action and turn off flash it's unlikely they will able to the next
- // time they start a session. The message becomes more annoying than
- // informative in that case.
- const base::Time last_dismissal =
- profile->GetPrefs()->GetTime(prefs::kPluginsDeprecationInfobarLastShown);
- return (base::Time::Now() - last_dismissal) > base::TimeDelta::FromDays(3);
+ // Display the infobar if the Flash setting is anything other than BLOCK.
+ return flash_setting != CONTENT_SETTING_BLOCK;
}
FlashDeprecationInfoBarDelegate::FlashDeprecationInfoBarDelegate(
- Profile* profile)
- : profile_(profile) {}
+ HostContentSettingsMap* host_content_settings_map)
+ : host_content_settings_map_(host_content_settings_map) {}
infobars::InfoBarDelegate::InfoBarIdentifier
FlashDeprecationInfoBarDelegate::GetIdentifier() const {
@@ -87,20 +72,6 @@
"https://www.blog.google/products/chrome/saying-goodbye-flash-chrome/");
}
-bool FlashDeprecationInfoBarDelegate::ShouldExpire(
- const NavigationDetails& details) const {
- // This duration is the same as the "default browser" banner's duration.
- const bool minimum_duration_elapsed =
- (base::Time::Now() - display_start_) > base::TimeDelta::FromSeconds(8);
- return minimum_duration_elapsed &&
- ConfirmInfoBarDelegate::ShouldExpire(details);
-}
-
-void FlashDeprecationInfoBarDelegate::InfoBarDismissed() {
- profile_->GetPrefs()->SetTime(prefs::kPluginsDeprecationInfobarLastShown,
- base::Time::Now());
-}
-
base::string16 FlashDeprecationInfoBarDelegate::GetMessageText() const {
return l10n_util::GetStringUTF16(IDS_PLUGIN_FLASH_DEPRECATION_PROMPT);
}
@@ -115,12 +86,11 @@
}
bool FlashDeprecationInfoBarDelegate::Accept() {
- HostContentSettingsMap* host_content_settings_map =
- HostContentSettingsMapFactory::GetForProfile(profile_);
- // Can be null in tests.
- if (host_content_settings_map) {
- host_content_settings_map->SetDefaultContentSetting(
- ContentSettingsType::PLUGINS, CONTENT_SETTING_DEFAULT);
- }
+ // Can be nullptr in tests.
+ if (!host_content_settings_map_)
+ return true;
+
+ host_content_settings_map_->SetDefaultContentSetting(
+ ContentSettingsType::PLUGINS, CONTENT_SETTING_DEFAULT);
return true;
}
diff --git a/chrome/browser/plugins/flash_deprecation_infobar_delegate.h b/chrome/browser/plugins/flash_deprecation_infobar_delegate.h
index 61b2a1f..94862d7 100644
--- a/chrome/browser/plugins/flash_deprecation_infobar_delegate.h
+++ b/chrome/browser/plugins/flash_deprecation_infobar_delegate.h
@@ -8,39 +8,35 @@
#include "base/time/time.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
-class Profile;
+class HostContentSettingsMap;
class InfoBarService;
class FlashDeprecationInfoBarDelegate : public ConfirmInfoBarDelegate {
public:
- static void Create(InfoBarService* infobar_service, Profile* profile);
+ static void Create(InfoBarService* infobar_service,
+ HostContentSettingsMap* host_content_settings_map);
// Returns true if we should display a deprecation warning for
// |host_content_settings_map|.
- static bool ShouldDisplayFlashDeprecation(Profile* profile);
+ static bool ShouldDisplayFlashDeprecation(
+ HostContentSettingsMap* host_content_settings_map);
- explicit FlashDeprecationInfoBarDelegate(Profile* profile);
+ explicit FlashDeprecationInfoBarDelegate(
+ HostContentSettingsMap* host_content_settings_map);
+ ~FlashDeprecationInfoBarDelegate() override = default;
// ConfirmInfobarDelegate:
infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
const gfx::VectorIcon& GetVectorIcon() const override;
base::string16 GetLinkText() const override;
GURL GetLinkURL() const override;
- bool ShouldExpire(const NavigationDetails& details) const override;
- void InfoBarDismissed() override;
base::string16 GetMessageText() const override;
int GetButtons() const override;
base::string16 GetButtonLabel(InfoBarButton button) const override;
bool Accept() 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_ = base::Time::Now();
+ HostContentSettingsMap* const host_content_settings_map_;
};
#endif // CHROME_BROWSER_PLUGINS_FLASH_DEPRECATION_INFOBAR_DELEGATE_H_
diff --git a/chrome/browser/plugins/plugin_prefs_factory.cc b/chrome/browser/plugins/plugin_prefs_factory.cc
index 64515a3..be93714 100644
--- a/chrome/browser/plugins/plugin_prefs_factory.cc
+++ b/chrome/browser/plugins/plugin_prefs_factory.cc
@@ -5,7 +5,6 @@
#include "chrome/browser/plugins/plugin_prefs_factory.h"
#include "base/path_service.h"
-#include "base/time/time.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
@@ -65,8 +64,6 @@
registry->RegisterBooleanPref(
prefs::kPluginsAlwaysOpenPdfExternally, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
- registry->RegisterTimePref(prefs::kPluginsDeprecationInfobarLastShown,
- base::Time());
}
content::BrowserContext* PluginPrefsFactory::GetBrowserContextToUse(
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 95c645a..113900f 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -472,6 +472,10 @@
// Deprecated 9/2020
const char kBlockThirdPartyCookies[] = "profile.block_third_party_cookies";
+// Deprecated 9/2020
+const char kPluginsDeprecationInfobarLastShown[] =
+ "plugins.deprecation_infobar_last_shown";
+
// Register local state used only for migration (clearing or moving to a new
// key).
void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
@@ -530,6 +534,8 @@
registry->RegisterDictionaryPref(kObservedSessionTime);
registry->RegisterBooleanPref(kBlockThirdPartyCookies, false);
+
+ registry->RegisterTimePref(kPluginsDeprecationInfobarLastShown, base::Time());
}
} // namespace
@@ -1108,4 +1114,7 @@
// Added 9/2020
profile_prefs->ClearPref(kBlockThirdPartyCookies);
+
+ // Added 9/2020
+ profile_prefs->ClearPref(kPluginsDeprecationInfobarLastShown);
}
diff --git a/chrome/browser/ui/startup/startup_browser_creator_impl.cc b/chrome/browser/ui/startup/startup_browser_creator_impl.cc
index baee6546..47ddd90a 100644
--- a/chrome/browser/ui/startup/startup_browser_creator_impl.cc
+++ b/chrome/browser/ui/startup/startup_browser_creator_impl.cc
@@ -928,9 +928,12 @@
#endif
#if BUILDFLAG(ENABLE_PLUGINS)
+ auto* host_content_settings_map =
+ HostContentSettingsMapFactory::GetForProfile(profile_);
if (FlashDeprecationInfoBarDelegate::ShouldDisplayFlashDeprecation(
- profile_)) {
- FlashDeprecationInfoBarDelegate::Create(infobar_service, profile_);
+ host_content_settings_map)) {
+ FlashDeprecationInfoBarDelegate::Create(infobar_service,
+ host_content_settings_map);
}
#endif
}
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 9a33364..6a574167 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -1151,11 +1151,6 @@
const char kPluginsResourceCacheUpdate[] = "plugins.resource_cache_update";
#endif
-// Last time the flash deprecation message was dismissed. Used to ensure a
-// cooldown period passes before the deprecation message is displayed again.
-const char kPluginsDeprecationInfobarLastShown[] =
- "plugins.deprecation_infobar_last_shown";
-
// Int64 containing the internal value of the time at which the default browser
// infobar was last dismissed by the user.
const char kDefaultBrowserLastDeclined[] =
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 02c47660..ee20312 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -377,7 +377,6 @@
extern const char kPluginsMetadata[];
extern const char kPluginsResourceCacheUpdate[];
#endif
-extern const char kPluginsDeprecationInfobarLastShown[];
extern const char kDefaultBrowserLastDeclined[];
extern const char kResetCheckDefaultBrowser[];
extern const char kDefaultBrowserSettingEnabled[];