Commit 113037db authored by Charlie Harrison's avatar Charlie Harrison Committed by Commit Bot

Break out the popup image model into its own class

The image model for the popup setting is currently a
ContentSettingBlockedImageModel. This CL makes it inherit from
ContentSettingSimpleImageModel in order to make policy changes easier
to make moving forward, including making the image visible in non-blocked
cases (e.g. an ambient UX).

This CL has no intended behavior change.

Bug: 82362
Change-Id: Ib49c5c0d428017ef566b465cb4cb1fb8a0ab79e1
Reviewed-on: https://chromium-review.googlesource.com/c/1331908Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607363}
parent bfd3bf43
......@@ -143,6 +143,16 @@ class ContentSettingSensorsImageModel : public ContentSettingSimpleImageModel {
DISALLOW_COPY_AND_ASSIGN(ContentSettingSensorsImageModel);
};
class ContentSettingPopupImageModel : public ContentSettingSimpleImageModel {
public:
ContentSettingPopupImageModel();
bool UpdateAndGetVisibility(WebContents* web_contents) override;
private:
DISALLOW_COPY_AND_ASSIGN(ContentSettingPopupImageModel);
};
namespace {
struct ContentSettingsImageDetails {
......@@ -162,8 +172,6 @@ const ContentSettingsImageDetails kImageDetails[] = {
IDS_BLOCKED_JAVASCRIPT_MESSAGE, 0, 0},
{CONTENT_SETTINGS_TYPE_PLUGINS, kExtensionIcon, IDS_BLOCKED_PLUGINS_MESSAGE,
IDS_BLOCKED_PLUGIN_EXPLANATORY_TEXT, 0},
{CONTENT_SETTINGS_TYPE_POPUPS, kWebIcon, IDS_BLOCKED_POPUPS_TOOLTIP,
IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT, 0},
{CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, kMixedContentIcon,
IDS_BLOCKED_DISPLAYING_INSECURE_CONTENT, 0, 0},
{CONTENT_SETTINGS_TYPE_PPAPI_BROKER, kExtensionIcon,
......@@ -222,8 +230,7 @@ ContentSettingImageModel::CreateForContentType(ImageType image_type) {
return std::make_unique<ContentSettingBlockedImageModel>(
ImageType::PLUGINS, CONTENT_SETTINGS_TYPE_PLUGINS);
case ImageType::POPUPS:
return std::make_unique<ContentSettingBlockedImageModel>(
ImageType::POPUPS, CONTENT_SETTINGS_TYPE_POPUPS);
return std::make_unique<ContentSettingPopupImageModel>();
case ImageType::GEOLOCATION:
return std::make_unique<ContentSettingGeolocationImageModel>();
case ImageType::MIXEDSCRIPT:
......@@ -588,6 +595,24 @@ bool ContentSettingSensorsImageModel::UpdateAndGetVisibility(
return true;
}
// Popups ---------------------------------------------------------------------
ContentSettingPopupImageModel::ContentSettingPopupImageModel()
: ContentSettingSimpleImageModel(ImageType::POPUPS,
CONTENT_SETTINGS_TYPE_POPUPS) {}
bool ContentSettingPopupImageModel::UpdateAndGetVisibility(
WebContents* web_contents) {
TabSpecificContentSettings* content_settings =
TabSpecificContentSettings::FromWebContents(web_contents);
if (!content_settings || !content_settings->IsContentBlocked(content_type()))
return false;
set_icon(kWebIcon, kBlockedBadgeIcon);
set_explanatory_string_id(IDS_BLOCKED_POPUPS_EXPLANATORY_TEXT);
set_tooltip(l10n_util::GetStringUTF16(IDS_BLOCKED_POPUPS_TOOLTIP));
return true;
}
// Base class ------------------------------------------------------------------
gfx::Image ContentSettingImageModel::GetIcon(SkColor icon_color) const {
......
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