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

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: rebase + blink reformat Created 3 years, 8 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 43bfc3e073eba46813e5c09e77da5f63e3acbdf8..cae5c68f07f076ec06e15345e98c45f7da92b556 100644
--- a/chrome/browser/ui/content_settings/content_setting_image_model.cc
+++ b/chrome/browser/ui/content_settings/content_setting_image_model.cc
@@ -218,8 +218,8 @@ ContentSettingSimpleImageModel::CreateForContentTypeForTesting(
if (content_settings_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX)
return base::MakeUnique<ContentSettingMIDISysExImageModel>();
- if (content_settings_type == CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS)
- return base::MakeUnique<ContentSettingDownloadsImageModel>();
+ if (content_settings_type == CONTENT_SETTINGS_TYPE_SENSORS)
+ return base::MakeUnique<ContentSettingSensorImageModel>();
return base::MakeUnique<ContentSettingBlockedImageModel>(
content_settings_type);
@@ -526,6 +526,35 @@ 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.
+ set_visible(true);
+
+ // If any embedded site has access the allowed icon takes priority over the
+ // blocked icon.
+ unsigned int state_flags = 0;
+ 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));
+}
+
// Automatic downloads ---------------------------------------------------------
ContentSettingDownloadsImageModel::ContentSettingDownloadsImageModel()
« no previous file with comments | « chrome/browser/ui/content_settings/content_setting_bubble_model.cc ('k') | chrome/browser/ui/page_info/page_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698