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

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: Verified xib file 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..14e82c42aa8da37582f705eefe095e253749424f 100644
--- a/chrome/browser/ui/content_settings/content_setting_image_model.cc
+++ b/chrome/browser/ui/content_settings/content_setting_image_model.cc
@@ -42,6 +42,7 @@ bool UseVectorGraphics() {
// ContentSettingRPHImageModel - protocol handlers
// ContentSettingMIDISysExImageModel - midi sysex
// ContentSettingMediaImageModel - media
+// ContentSettingSubresourceFilterImageModel - deceptive content
class ContentSettingBlockedImageModel : public ContentSettingSimpleImageModel {
public:
@@ -419,10 +420,6 @@ ContentSettingBubbleModel* ContentSettingMediaImageModel::CreateBubbleModel(
bool ContentSettingMediaImageModel::ShouldRunAnimation(
WebContents* web_contents) {
- // TODO(msramek): For bubbles that are not tied to a single content setting,
- // TabSpecificContentSettings is not a good place to store this bit.
- // Perhaps we should instead use a map<WebContents*, bool> here in
- // ContentSettingMediaImageModel.
if (!web_contents)
return false;
TabSpecificContentSettings* content_settings =
@@ -449,6 +446,60 @@ 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->IsSubresourceBlocked())
+ return;
+
+ set_icon_by_vector_id(gfx::VectorIconId::SUBRESOURCE_FILTER_ACTIVE,
+ gfx::VectorIconId::BLOCKED_BADGE);
+ 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->IsSubresourceBlockageIndicated();
+}
+
+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 +614,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