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..ca76a46d14ed8120960a46b3ff7312708e942c10 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 |
msramek
2016/07/27 09:46:21
Please update the hierarchy comment at the top of
melandory
2016/07/27 12:53:41
Done.
|
+ : 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(); |
msramek
2016/07/27 09:46:21
This should check if the blockage has been *indica
melandory
2016/07/27 12:53:41
Done.
|
+} |
+ |
+void ContentSettingSubresourceFilterImageModel::SetAnimationHasRun( |
+ WebContents* web_contents) { |
+ if (!web_contents) |
+ return; |
+ TabSpecificContentSettings* content_settings = |
+ TabSpecificContentSettings::FromWebContents(web_contents); |
+ if (content_settings) |
+ content_settings->SetSubresourceBlockageIndicated(); |
+} |
+ |
// 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)); |