Chromium Code Reviews| Index: chrome/browser/ui/content_settings/content_setting_image_model.cc |
| diff --git a/chrome/browser/ui/content_settings/content_setting_image_model.cc b/chrome/browser/ui/content_settings/content_setting_image_model.cc |
| index 5b9e9821e8f6891fc768900abce62142c0249330..61fc9b6e27d828df9cfb50e0c16c7bcd93736cd0 100644 |
| --- a/chrome/browser/ui/content_settings/content_setting_image_model.cc |
| +++ b/chrome/browser/ui/content_settings/content_setting_image_model.cc |
| @@ -83,6 +83,26 @@ class ContentSettingMediaImageModel : public ContentSettingImageModel { |
| DISALLOW_COPY_AND_ASSIGN(ContentSettingMediaImageModel); |
| }; |
| +// Image model for subresource filter icons in the location bar. |
| +class ContentSettingSubresourceFilterImageModel |
| + : public ContentSettingImageModel { |
| + public: |
| + ContentSettingSubresourceFilterImageModel(); |
| + |
| + void UpdateFromWebContents(WebContents* web_contents) override; |
| + |
| + ContentSettingBubbleModel* CreateBubbleModel( |
| + ContentSettingBubbleModel::Delegate* delegate, |
| + WebContents* web_contents, |
| + Profile* profile) override; |
| + |
| + bool ShouldRunAnimation(content::WebContents* web_contents) override; |
| + void SetAnimationHasRun(content::WebContents* web_contents) override; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(ContentSettingSubresourceFilterImageModel); |
| +}; |
| + |
| class ContentSettingRPHImageModel : public ContentSettingSimpleImageModel { |
| public: |
| ContentSettingRPHImageModel(); |
| @@ -241,6 +261,11 @@ ContentSettingSimpleImageModel::CreateForContentTypeForTesting( |
| new ContentSettingBlockedImageModel(content_settings_type)); |
| } |
| +std::unique_ptr<ContentSettingImageModel> |
| +ContentSettingImageModel::CreateSubresourceFilterImageModelForTesting() { |
| + return base::WrapUnique(new ContentSettingSubresourceFilterImageModel()); |
| +} |
| + |
| // Generic blocked content settings -------------------------------------------- |
| ContentSettingBlockedImageModel::ContentSettingBlockedImageModel( |
| @@ -449,6 +474,64 @@ void ContentSettingMediaImageModel::SetAnimationHasRun( |
| } |
| } |
| +// Subresource Filter ---------------------------------------------------------- |
| + |
| +ContentSettingSubresourceFilterImageModel:: |
| + ContentSettingSubresourceFilterImageModel() |
| + : ContentSettingImageModel() {} |
| + |
| +void ContentSettingSubresourceFilterImageModel::UpdateFromWebContents( |
| + WebContents* web_contents) { |
| + set_visible(false); |
| + |
| + if (!web_contents) |
| + return; |
| + |
| + TabSpecificContentSettings* content_settings = |
| + TabSpecificContentSettings::FromWebContents(web_contents); |
| + |
| + if (!content_settings || !content_settings->is_subresource_filter_enabled()) |
| + return; |
| + |
| + if (!UseVectorGraphics()) { |
| + SetIconByResourceId(IDR_SUBRESOURCE_FILTER_ACTIVE); |
| + } else { |
| + set_icon_by_vector_id(gfx::VectorIconId::SUBRESOURCE_FILTER_ACTIVE, |
| + gfx::VectorIconId::VECTOR_ICON_NONE); |
| + } |
| + set_explanatory_string_id(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE); |
| + // TODO(melandory): Set tooltip text. |
| + set_visible(true); |
| +} |
| + |
| +ContentSettingBubbleModel* |
| +ContentSettingSubresourceFilterImageModel::CreateBubbleModel( |
| + ContentSettingBubbleModel::Delegate* delegate, |
| + WebContents* web_contents, |
| + Profile* profile) { |
| + return new ContentSettingSubresourceFilterBubbleModel(delegate, web_contents, |
| + profile); |
| +} |
| + |
| +bool ContentSettingSubresourceFilterImageModel::ShouldRunAnimation( |
| + WebContents* web_contents) { |
| + if (!web_contents) |
| + return false; |
| + TabSpecificContentSettings* content_settings = |
| + TabSpecificContentSettings::FromWebContents(web_contents); |
| + return content_settings && content_settings->is_subresource_filter_enabled(); |
| +} |
| + |
| +void ContentSettingSubresourceFilterImageModel::SetAnimationHasRun( |
| + WebContents* web_contents) { |
| + if (!web_contents) |
| + return; |
| + TabSpecificContentSettings* content_settings = |
| + TabSpecificContentSettings::FromWebContents(web_contents); |
| + if (content_settings) |
| + content_settings->SetSubresourceFilterActivationBeenIndicated(); |
| +} |
|
raymes
2016/07/26 07:19:36
Hmm, since we're planning to add a new content set
melandory
2016/07/26 11:58:11
Main motivation for not having a content setting i
msramek
2016/07/27 09:46:21
Just to add context - the refactoring that I made
raymes
2016/07/28 05:10:58
The reason I made the suggestion above was because
|
| + |
| // Protocol handlers ----------------------------------------------------------- |
| ContentSettingRPHImageModel::ContentSettingRPHImageModel() |
| @@ -563,6 +646,7 @@ ScopedVector<ContentSettingImageModel> |
| new ContentSettingBlockedImageModel(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); |
| result.push_back(new ContentSettingRPHImageModel()); |
| result.push_back(new ContentSettingMediaImageModel()); |
| + result.push_back(new ContentSettingSubresourceFilterImageModel()); |
| result.push_back( |
| new ContentSettingBlockedImageModel( |
| CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS)); |