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 0dbc84527885d71944ddaa4506b9e4ef8aca0662..2df82d56ff620710efc3e7b0959c9411c52094ea 100644 |
--- a/chrome/browser/ui/content_settings/content_setting_image_model.cc |
+++ b/chrome/browser/ui/content_settings/content_setting_image_model.cc |
@@ -97,6 +97,16 @@ class ContentSettingMIDISysExImageModel |
DISALLOW_COPY_AND_ASSIGN(ContentSettingMIDISysExImageModel); |
}; |
+class ContentSettingSensorImageModel : public ContentSettingSimpleImageModel { |
+ public: |
+ ContentSettingSensorImageModel(); |
+ |
+ void UpdateFromWebContents(WebContents* web_contents) override; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(ContentSettingSensorImageModel); |
+}; |
+ |
namespace { |
struct ContentSettingsImageDetails { |
@@ -192,6 +202,9 @@ ContentSettingSimpleImageModel::CreateForContentTypeForTesting( |
if (content_settings_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) |
return base::MakeUnique<ContentSettingMIDISysExImageModel>(); |
+ if (content_settings_type == CONTENT_SETTINGS_TYPE_SENSORS) |
+ return base::MakeUnique<ContentSettingSensorImageModel>(); |
+ |
return base::MakeUnique<ContentSettingBlockedImageModel>( |
content_settings_type); |
} |
@@ -500,6 +513,42 @@ void ContentSettingMIDISysExImageModel::UpdateFromWebContents( |
: IDS_MIDI_SYSEX_BLOCKED_TOOLTIP)); |
} |
+// Sensors ------------------------------------------------------------------ |
+ |
+ContentSettingSensorImageModel::ContentSettingSensorImageModel() |
+ : ContentSettingSimpleImageModel(CONTENT_SETTINGS_TYPE_SENSORS) {} |
+ |
+void ContentSettingSensorImageModel::UpdateFromWebContents( |
+ WebContents* web_contents) { |
+ set_visible(false); |
+ if (!web_contents) |
+ return; |
+ TabSpecificContentSettings* content_settings = |
+ TabSpecificContentSettings::FromWebContents(web_contents); |
+ if (!content_settings) |
+ return; |
+ // TODO(riju): when UMA is ready |
+ /* |
+ const ContentSettingsUsagesState& usages_state = |
+ content_settings->sensors_usages_state(); |
+ if (usages_state.state_map().empty()) |
+ return; |
+ */ |
+ set_visible(true); |
+ |
+ // If any embedded site has access the allowed icon takes priority over the |
+ // blocked icon. |
+ unsigned int state_flags = 0; |
+ // usages_state.GetDetailedInfo(nullptr, &state_flags); |
+ bool allowed = |
+ !!(state_flags & ContentSettingsUsagesState::TABSTATE_HAS_ANY_ALLOWED); |
+ set_icon_by_vector_id(gfx::VectorIconId::MIDI, // TODO(riju) |
+ allowed ? gfx::VectorIconId::VECTOR_ICON_NONE |
+ : gfx::VectorIconId::BLOCKED_BADGE); |
+ set_tooltip(l10n_util::GetStringUTF16(allowed ? IDS_SENSORS_ALLOWED_TOOLTIP |
+ : IDS_SENSORS_BLOCKED_TOOLTIP)); |
+} |
+ |
// Base class ------------------------------------------------------------------ |
gfx::Image ContentSettingImageModel::GetIcon(SkColor nearby_text_color) const { |