Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Unified Diff: chrome/browser/ui/content_settings/content_setting_image_model.cc

Issue 2171713002: Safe browsing subresource filter bubble UI skeleton. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: xib with osx 10.9 Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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));

Powered by Google App Engine
This is Rietveld 408576698