Commit 6e38836f authored by Ravjit Singh Uppal's avatar Ravjit Singh Uppal Committed by Commit Bot

Revert "Added cooldown after dimssing the flash warning message"

This reverts commit 4aaa9f29.

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: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805443}
parent 60018458
...@@ -4,21 +4,15 @@ ...@@ -4,21 +4,15 @@
#include "chrome/browser/plugins/flash_deprecation_infobar_delegate.h" #include "chrome/browser/plugins/flash_deprecation_infobar_delegate.h"
#include <memory>
#include "base/feature_list.h" #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/infobars/infobar_service.h"
#include "chrome/browser/plugins/plugin_utils.h" #include "chrome/browser/plugins/plugin_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/content_settings/core/browser/host_content_settings_map.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.h"
#include "components/content_settings/core/common/content_settings_types.h" #include "components/content_settings/core/common/content_settings_types.h"
#include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar.h"
#include "components/prefs/pref_service.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "components/vector_icons/vector_icons.h" #include "components/vector_icons/vector_icons.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -26,48 +20,39 @@ ...@@ -26,48 +20,39 @@
#include "url/url_constants.h" #include "url/url_constants.h"
// static // static
void FlashDeprecationInfoBarDelegate::Create(InfoBarService* infobar_service, void FlashDeprecationInfoBarDelegate::Create(
Profile* profile) { InfoBarService* infobar_service,
HostContentSettingsMap* host_content_settings_map) {
infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
std::make_unique<FlashDeprecationInfoBarDelegate>(profile))); std::make_unique<FlashDeprecationInfoBarDelegate>(
host_content_settings_map)));
} }
// static // static
bool FlashDeprecationInfoBarDelegate::ShouldDisplayFlashDeprecation( bool FlashDeprecationInfoBarDelegate::ShouldDisplayFlashDeprecation(
Profile* profile) { HostContentSettingsMap* host_content_settings_map) {
DCHECK(host_content_settings_map);
if (!base::FeatureList::IsEnabled(features::kFlashDeprecationWarning)) if (!base::FeatureList::IsEnabled(features::kFlashDeprecationWarning))
return false; 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; bool is_managed = false;
ContentSetting flash_setting = ContentSetting flash_setting =
PluginUtils::UnsafeGetRawDefaultFlashContentSetting( PluginUtils::UnsafeGetRawDefaultFlashContentSetting(
host_content_settings_map, &is_managed); 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 // If the user can't do anything about their browser's Flash behavior,
// behavior, there's no point to showing a Flash deprecation warning infobar. // there's no point to showing a Flash deprecation warning infobar.
if (is_managed) if (is_managed)
return false; return false;
// Also limit how frequently the infobar is shown. Users should be // Display the infobar if the Flash setting is anything other than BLOCK.
// periodically reminded that they need to take action, but if they couldn't return flash_setting != CONTENT_SETTING_BLOCK;
// 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);
} }
FlashDeprecationInfoBarDelegate::FlashDeprecationInfoBarDelegate( FlashDeprecationInfoBarDelegate::FlashDeprecationInfoBarDelegate(
Profile* profile) HostContentSettingsMap* host_content_settings_map)
: profile_(profile) {} : host_content_settings_map_(host_content_settings_map) {}
infobars::InfoBarDelegate::InfoBarIdentifier infobars::InfoBarDelegate::InfoBarIdentifier
FlashDeprecationInfoBarDelegate::GetIdentifier() const { FlashDeprecationInfoBarDelegate::GetIdentifier() const {
...@@ -87,20 +72,6 @@ GURL FlashDeprecationInfoBarDelegate::GetLinkURL() const { ...@@ -87,20 +72,6 @@ GURL FlashDeprecationInfoBarDelegate::GetLinkURL() const {
"https://www.blog.google/products/chrome/saying-goodbye-flash-chrome/"); "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 { base::string16 FlashDeprecationInfoBarDelegate::GetMessageText() const {
return l10n_util::GetStringUTF16(IDS_PLUGIN_FLASH_DEPRECATION_PROMPT); return l10n_util::GetStringUTF16(IDS_PLUGIN_FLASH_DEPRECATION_PROMPT);
} }
...@@ -115,12 +86,11 @@ base::string16 FlashDeprecationInfoBarDelegate::GetButtonLabel( ...@@ -115,12 +86,11 @@ base::string16 FlashDeprecationInfoBarDelegate::GetButtonLabel(
} }
bool FlashDeprecationInfoBarDelegate::Accept() { bool FlashDeprecationInfoBarDelegate::Accept() {
HostContentSettingsMap* host_content_settings_map = // Can be nullptr in tests.
HostContentSettingsMapFactory::GetForProfile(profile_); if (!host_content_settings_map_)
// Can be null in tests. return true;
if (host_content_settings_map) {
host_content_settings_map->SetDefaultContentSetting( host_content_settings_map_->SetDefaultContentSetting(
ContentSettingsType::PLUGINS, CONTENT_SETTING_DEFAULT); ContentSettingsType::PLUGINS, CONTENT_SETTING_DEFAULT);
}
return true; return true;
} }
...@@ -8,39 +8,35 @@ ...@@ -8,39 +8,35 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "components/infobars/core/confirm_infobar_delegate.h" #include "components/infobars/core/confirm_infobar_delegate.h"
class Profile; class HostContentSettingsMap;
class InfoBarService; class InfoBarService;
class FlashDeprecationInfoBarDelegate : public ConfirmInfoBarDelegate { class FlashDeprecationInfoBarDelegate : public ConfirmInfoBarDelegate {
public: 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 // Returns true if we should display a deprecation warning for
// |host_content_settings_map|. // |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: // ConfirmInfobarDelegate:
infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
const gfx::VectorIcon& GetVectorIcon() const override; const gfx::VectorIcon& GetVectorIcon() const override;
base::string16 GetLinkText() const override; base::string16 GetLinkText() const override;
GURL GetLinkURL() const override; GURL GetLinkURL() const override;
bool ShouldExpire(const NavigationDetails& details) const override;
void InfoBarDismissed() override;
base::string16 GetMessageText() const override; base::string16 GetMessageText() const override;
int GetButtons() const override; int GetButtons() const override;
base::string16 GetButtonLabel(InfoBarButton button) const override; base::string16 GetButtonLabel(InfoBarButton button) const override;
bool Accept() override; bool Accept() override;
private: private:
// The profile associated with this infobar. HostContentSettingsMap* const host_content_settings_map_;
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();
}; };
#endif // CHROME_BROWSER_PLUGINS_FLASH_DEPRECATION_INFOBAR_DELEGATE_H_ #endif // CHROME_BROWSER_PLUGINS_FLASH_DEPRECATION_INFOBAR_DELEGATE_H_
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "chrome/browser/plugins/plugin_prefs_factory.h" #include "chrome/browser/plugins/plugin_prefs_factory.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/time/time.h"
#include "chrome/browser/plugins/plugin_prefs.h" #include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -65,8 +64,6 @@ void PluginPrefsFactory::RegisterProfilePrefs( ...@@ -65,8 +64,6 @@ void PluginPrefsFactory::RegisterProfilePrefs(
registry->RegisterBooleanPref( registry->RegisterBooleanPref(
prefs::kPluginsAlwaysOpenPdfExternally, false, prefs::kPluginsAlwaysOpenPdfExternally, false,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterTimePref(prefs::kPluginsDeprecationInfobarLastShown,
base::Time());
} }
content::BrowserContext* PluginPrefsFactory::GetBrowserContextToUse( content::BrowserContext* PluginPrefsFactory::GetBrowserContextToUse(
......
...@@ -472,6 +472,10 @@ const char kObservedSessionTime[] = "profile.observed_session_time"; ...@@ -472,6 +472,10 @@ const char kObservedSessionTime[] = "profile.observed_session_time";
// Deprecated 9/2020 // Deprecated 9/2020
const char kBlockThirdPartyCookies[] = "profile.block_third_party_cookies"; 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 // Register local state used only for migration (clearing or moving to a new
// key). // key).
void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) { void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
...@@ -530,6 +534,8 @@ void RegisterProfilePrefsForMigration( ...@@ -530,6 +534,8 @@ void RegisterProfilePrefsForMigration(
registry->RegisterDictionaryPref(kObservedSessionTime); registry->RegisterDictionaryPref(kObservedSessionTime);
registry->RegisterBooleanPref(kBlockThirdPartyCookies, false); registry->RegisterBooleanPref(kBlockThirdPartyCookies, false);
registry->RegisterTimePref(kPluginsDeprecationInfobarLastShown, base::Time());
} }
} // namespace } // namespace
...@@ -1108,4 +1114,7 @@ void MigrateObsoleteProfilePrefs(Profile* profile) { ...@@ -1108,4 +1114,7 @@ void MigrateObsoleteProfilePrefs(Profile* profile) {
// Added 9/2020 // Added 9/2020
profile_prefs->ClearPref(kBlockThirdPartyCookies); profile_prefs->ClearPref(kBlockThirdPartyCookies);
// Added 9/2020
profile_prefs->ClearPref(kPluginsDeprecationInfobarLastShown);
} }
...@@ -928,9 +928,12 @@ void StartupBrowserCreatorImpl::AddInfoBarsIfNecessary( ...@@ -928,9 +928,12 @@ void StartupBrowserCreatorImpl::AddInfoBarsIfNecessary(
#endif #endif
#if BUILDFLAG(ENABLE_PLUGINS) #if BUILDFLAG(ENABLE_PLUGINS)
auto* host_content_settings_map =
HostContentSettingsMapFactory::GetForProfile(profile_);
if (FlashDeprecationInfoBarDelegate::ShouldDisplayFlashDeprecation( if (FlashDeprecationInfoBarDelegate::ShouldDisplayFlashDeprecation(
profile_)) { host_content_settings_map)) {
FlashDeprecationInfoBarDelegate::Create(infobar_service, profile_); FlashDeprecationInfoBarDelegate::Create(infobar_service,
host_content_settings_map);
} }
#endif #endif
} }
......
...@@ -1151,11 +1151,6 @@ const char kPluginsMetadata[] = "plugins.metadata"; ...@@ -1151,11 +1151,6 @@ const char kPluginsMetadata[] = "plugins.metadata";
const char kPluginsResourceCacheUpdate[] = "plugins.resource_cache_update"; const char kPluginsResourceCacheUpdate[] = "plugins.resource_cache_update";
#endif #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 // Int64 containing the internal value of the time at which the default browser
// infobar was last dismissed by the user. // infobar was last dismissed by the user.
const char kDefaultBrowserLastDeclined[] = const char kDefaultBrowserLastDeclined[] =
......
...@@ -377,7 +377,6 @@ extern const char kRunAllFlashInAllowMode[]; ...@@ -377,7 +377,6 @@ extern const char kRunAllFlashInAllowMode[];
extern const char kPluginsMetadata[]; extern const char kPluginsMetadata[];
extern const char kPluginsResourceCacheUpdate[]; extern const char kPluginsResourceCacheUpdate[];
#endif #endif
extern const char kPluginsDeprecationInfobarLastShown[];
extern const char kDefaultBrowserLastDeclined[]; extern const char kDefaultBrowserLastDeclined[];
extern const char kResetCheckDefaultBrowser[]; extern const char kResetCheckDefaultBrowser[];
extern const char kDefaultBrowserSettingEnabled[]; extern const char kDefaultBrowserSettingEnabled[];
......
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