Commit 9f0fcc5f authored by Tommy C. Li's avatar Tommy C. Li Committed by Commit Bot

[flash] Add "Turn off" button to Flash Deprecation Infobar

This "Turn off" button just resets the content setting to the default
setting, which is now BLOCK.

Bug: 965760
Change-Id: I32002bfdcad61ee36041d1ecb733b4cdc52981ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1629041
Commit-Queue: Tommy Li <tommycli@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663915}
parent 5567fdda
...@@ -8250,17 +8250,11 @@ Please help our engineers fix this problem. Tell us what happened right before y ...@@ -8250,17 +8250,11 @@ Please help our engineers fix this problem. Tell us what happened right before y
<message name="IDS_AUTO_SIGNIN_FIRST_RUN_OK" desc="The text of the OK button in the dialog during the autosign-in first run experience."> <message name="IDS_AUTO_SIGNIN_FIRST_RUN_OK" desc="The text of the OK button in the dialog during the autosign-in first run experience.">
OK, Got It OK, Got It
</message> </message>
<message name="IDS_AUTO_SIGNIN_FIRST_RUN_TURN_OFF" desc="The text of the 'turn off' button in the dialog during the autosign-in first run experience.">
Turn Off
</message>
</if> </if>
<if expr="not use_titlecase"> <if expr="not use_titlecase">
<message name="IDS_AUTO_SIGNIN_FIRST_RUN_OK" desc="The text of the OK button in the dialog during the autosign-in first run experience."> <message name="IDS_AUTO_SIGNIN_FIRST_RUN_OK" desc="The text of the OK button in the dialog during the autosign-in first run experience.">
OK, got it OK, got it
</message> </message>
<message name="IDS_AUTO_SIGNIN_FIRST_RUN_TURN_OFF" desc="The text of the 'turn off' button in the dialog during the autosign-in first run experience.">
Turn off
</message>
</if> </if>
<!-- Extra Mac UI Strings --> <!-- Extra Mac UI Strings -->
......
...@@ -402,7 +402,7 @@ void InfoBarUiTest::ShowUi(const std::string& name) { ...@@ -402,7 +402,7 @@ void InfoBarUiTest::ShowUi(const std::string& name) {
break; break;
case IBD::FLASH_DEPRECATION_INFOBAR_DELEGATE: case IBD::FLASH_DEPRECATION_INFOBAR_DELEGATE:
FlashDeprecationInfoBarDelegate::Create(GetInfoBarService()); FlashDeprecationInfoBarDelegate::Create(GetInfoBarService(), nullptr);
break; break;
case IBD::TAB_SHARING_INFOBAR_DELEGATE: case IBD::TAB_SHARING_INFOBAR_DELEGATE:
TabSharingInfoBarDelegate::Create(GetInfoBarService(), TabSharingInfoBarDelegate::Create(GetInfoBarService(),
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "components/password_manager/core/browser/password_bubble_experiment.h" #include "components/password_manager/core/browser/password_bubble_experiment.h"
#include "components/password_manager/core/browser/password_manager_constants.h" #include "components/password_manager/core/browser/password_manager_constants.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/strings/grit/components_strings.h"
#include "jni/AutoSigninFirstRunDialog_jni.h" #include "jni/AutoSigninFirstRunDialog_jni.h"
#include "ui/android/window_android.h" #include "ui/android/window_android.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -56,8 +57,7 @@ void AutoSigninFirstRunDialogAndroid::ShowDialog() { ...@@ -56,8 +57,7 @@ void AutoSigninFirstRunDialogAndroid::ShowDialog() {
: IDS_AUTO_SIGNIN_FIRST_RUN_TITLE_LOCAL_DEVICE); : IDS_AUTO_SIGNIN_FIRST_RUN_TITLE_LOCAL_DEVICE);
base::string16 ok_button_text = base::string16 ok_button_text =
l10n_util::GetStringUTF16(IDS_AUTO_SIGNIN_FIRST_RUN_OK); l10n_util::GetStringUTF16(IDS_AUTO_SIGNIN_FIRST_RUN_OK);
base::string16 turn_off_button_text = base::string16 turn_off_button_text = l10n_util::GetStringUTF16(IDS_TURN_OFF);
l10n_util::GetStringUTF16(IDS_AUTO_SIGNIN_FIRST_RUN_TURN_OFF);
dialog_jobject_.Reset(Java_AutoSigninFirstRunDialog_createAndShowDialog( dialog_jobject_.Reset(Java_AutoSigninFirstRunDialog_createAndShowDialog(
env, native_window->GetJavaObject(), reinterpret_cast<intptr_t>(this), env, native_window->GetJavaObject(), reinterpret_cast<intptr_t>(this),
......
...@@ -6,12 +6,13 @@ ...@@ -6,12 +6,13 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#include "chrome/app/vector_icons/vector_icons.h" #include "chrome/app/vector_icons/vector_icons.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/common/chrome_features.h" #include "chrome/common/chrome_features.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_types.h"
#include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -19,24 +20,26 @@ ...@@ -19,24 +20,26 @@
#include "url/url_constants.h" #include "url/url_constants.h"
// static // static
void FlashDeprecationInfoBarDelegate::Create(InfoBarService* infobar_service) { void FlashDeprecationInfoBarDelegate::Create(
InfoBarService* infobar_service,
HostContentSettingsMap* host_content_settings_map) {
infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
std::make_unique<FlashDeprecationInfoBarDelegate>())); std::make_unique<FlashDeprecationInfoBarDelegate>(
host_content_settings_map)));
} }
// static // static
bool FlashDeprecationInfoBarDelegate::ShouldDisplayFlashDeprecation( bool FlashDeprecationInfoBarDelegate::ShouldDisplayFlashDeprecation(
Profile* profile) { HostContentSettingsMap* host_content_settings_map) {
DCHECK(profile); DCHECK(host_content_settings_map);
if (!base::FeatureList::IsEnabled(features::kFlashDeprecationWarning)) if (!base::FeatureList::IsEnabled(features::kFlashDeprecationWarning))
return false; return false;
bool is_managed = false; bool is_managed = false;
auto* settings_map = HostContentSettingsMapFactory::GetForProfile(profile);
ContentSetting flash_setting = ContentSetting flash_setting =
PluginUtils::UnsafeGetRawDefaultFlashContentSetting(settings_map, PluginUtils::UnsafeGetRawDefaultFlashContentSetting(
&is_managed); host_content_settings_map, &is_managed);
// If the user can't do anything about their browser's Flash behavior, // If the user can't do anything about their browser's Flash behavior,
// there's no point to showing a Flash deprecation warning infobar. // there's no point to showing a Flash deprecation warning infobar.
...@@ -47,6 +50,10 @@ bool FlashDeprecationInfoBarDelegate::ShouldDisplayFlashDeprecation( ...@@ -47,6 +50,10 @@ bool FlashDeprecationInfoBarDelegate::ShouldDisplayFlashDeprecation(
return flash_setting != CONTENT_SETTING_BLOCK; return flash_setting != CONTENT_SETTING_BLOCK;
} }
FlashDeprecationInfoBarDelegate::FlashDeprecationInfoBarDelegate(
HostContentSettingsMap* host_content_settings_map)
: host_content_settings_map_(host_content_settings_map) {}
infobars::InfoBarDelegate::InfoBarIdentifier infobars::InfoBarDelegate::InfoBarIdentifier
FlashDeprecationInfoBarDelegate::GetIdentifier() const { FlashDeprecationInfoBarDelegate::GetIdentifier() const {
return FLASH_DEPRECATION_INFOBAR_DELEGATE; return FLASH_DEPRECATION_INFOBAR_DELEGATE;
...@@ -61,7 +68,23 @@ base::string16 FlashDeprecationInfoBarDelegate::GetMessageText() const { ...@@ -61,7 +68,23 @@ base::string16 FlashDeprecationInfoBarDelegate::GetMessageText() const {
} }
int FlashDeprecationInfoBarDelegate::GetButtons() const { int FlashDeprecationInfoBarDelegate::GetButtons() const {
return BUTTON_NONE; return BUTTON_OK;
}
base::string16 FlashDeprecationInfoBarDelegate::GetButtonLabel(
InfoBarButton button) const {
DCHECK_EQ(button, BUTTON_OK);
return l10n_util::GetStringUTF16(IDS_TURN_OFF);
}
bool FlashDeprecationInfoBarDelegate::Accept() {
// Can be nullptr in tests.
if (!host_content_settings_map_)
return true;
host_content_settings_map_->SetDefaultContentSetting(
CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_DEFAULT);
return true;
} }
base::string16 FlashDeprecationInfoBarDelegate::GetLinkText() const { base::string16 FlashDeprecationInfoBarDelegate::GetLinkText() const {
......
...@@ -7,17 +7,21 @@ ...@@ -7,17 +7,21 @@
#include "components/infobars/core/confirm_infobar_delegate.h" #include "components/infobars/core/confirm_infobar_delegate.h"
class HostContentSettingsMap;
class InfoBarService; class InfoBarService;
class Profile;
class FlashDeprecationInfoBarDelegate : public ConfirmInfoBarDelegate { class FlashDeprecationInfoBarDelegate : public ConfirmInfoBarDelegate {
public: public:
static void Create(InfoBarService* infobar_service); static void Create(InfoBarService* infobar_service,
HostContentSettingsMap* host_content_settings_map);
// Returns true if we should display a deprecation warning for |profile|. // Returns true if we should display a deprecation warning for
static bool ShouldDisplayFlashDeprecation(Profile* profile); // |host_content_settings_map|.
static bool ShouldDisplayFlashDeprecation(
HostContentSettingsMap* host_content_settings_map);
FlashDeprecationInfoBarDelegate() = default; explicit FlashDeprecationInfoBarDelegate(
HostContentSettingsMap* host_content_settings_map);
~FlashDeprecationInfoBarDelegate() override = default; ~FlashDeprecationInfoBarDelegate() override = default;
// ConfirmInfobarDelegate: // ConfirmInfobarDelegate:
...@@ -25,8 +29,13 @@ class FlashDeprecationInfoBarDelegate : public ConfirmInfoBarDelegate { ...@@ -25,8 +29,13 @@ class FlashDeprecationInfoBarDelegate : public ConfirmInfoBarDelegate {
const gfx::VectorIcon& GetVectorIcon() const override; const gfx::VectorIcon& GetVectorIcon() const 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;
bool Accept() override;
base::string16 GetLinkText() const override; base::string16 GetLinkText() const override;
GURL GetLinkURL() const override; GURL GetLinkURL() const override;
private:
HostContentSettingsMap* const host_content_settings_map_;
}; };
#endif // CHROME_BROWSER_PLUGINS_FLASH_DEPRECATION_INFOBAR_DELEGATE_H_ #endif // CHROME_BROWSER_PLUGINS_FLASH_DEPRECATION_INFOBAR_DELEGATE_H_
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "chrome/browser/apps/apps_launch.h" #include "chrome/browser/apps/apps_launch.h"
#include "chrome/browser/apps/platform_apps/install_chrome_app.h" #include "chrome/browser/apps/platform_apps/install_chrome_app.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/defaults.h" #include "chrome/browser/defaults.h"
...@@ -875,9 +876,12 @@ void StartupBrowserCreatorImpl::AddInfoBarsIfNecessary( ...@@ -875,9 +876,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); FlashDeprecationInfoBarDelegate::Create(infobar_service,
host_content_settings_map);
} }
#endif #endif
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "chrome/browser/ui/views/chrome_typography.h" #include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/constrained_window/constrained_window_views.h" #include "components/constrained_window/constrained_window_views.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/views/border.h" #include "ui/views/border.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
...@@ -88,7 +89,7 @@ base::string16 AutoSigninFirstRunDialogView::GetDialogButtonLabel( ...@@ -88,7 +89,7 @@ base::string16 AutoSigninFirstRunDialogView::GetDialogButtonLabel(
ui::DialogButton button) const { ui::DialogButton button) const {
return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK
? IDS_AUTO_SIGNIN_FIRST_RUN_OK ? IDS_AUTO_SIGNIN_FIRST_RUN_OK
: IDS_AUTO_SIGNIN_FIRST_RUN_TURN_OFF); : IDS_TURN_OFF);
} }
void AutoSigninFirstRunDialogView::InitWindow() { void AutoSigninFirstRunDialogView::InitWindow() {
......
...@@ -287,6 +287,16 @@ ...@@ -287,6 +287,16 @@
Not Now Not Now
</message> </message>
</if> </if>
<if expr="not use_titlecase">
<message name="IDS_TURN_OFF" desc="Used on a button that turns off a function.">
Turn off
</message>
</if>
<if expr="use_titlecase">
<message name="IDS_TURN_OFF" desc="In Title Case: Used on a button that turns off a function.">
Turn Off
</message>
</if>
<message name="IDS_PLUGIN_NOT_SUPPORTED" desc="The placeholder text for an unsupported plugin."> <message name="IDS_PLUGIN_NOT_SUPPORTED" desc="The placeholder text for an unsupported plugin.">
This plugin is not supported This plugin is not supported
......
db1700a2a9452a95045a6e70e76e1178feb0f61e
\ No newline at end of file
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