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

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

Issue 2458453002: [sensors] Add Permission guard to the generic sensor apis.
Patch Set: Move permissions stuff to SensorProxy, remove aw related stuff Created 4 years, 1 month 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 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 {

Powered by Google App Engine
This is Rietveld 408576698