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

Unified Diff: chrome/browser/content_settings/tab_specific_content_settings.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/content_settings/tab_specific_content_settings.cc
diff --git a/chrome/browser/content_settings/tab_specific_content_settings.cc b/chrome/browser/content_settings/tab_specific_content_settings.cc
index c96b71ae3da9f5ac146465d60c7e81316400c634..e097dea683cde0f64bbeb1f8ff0d7f7581df5414 100644
--- a/chrome/browser/content_settings/tab_specific_content_settings.cc
+++ b/chrome/browser/content_settings/tab_specific_content_settings.cc
@@ -248,8 +248,8 @@ bool TabSpecificContentSettings::IsContentBlocked(
content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
content_type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA ||
content_type == CONTENT_SETTINGS_TYPE_PPAPI_BROKER ||
- content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX ||
- content_type == CONTENT_SETTINGS_TYPE_SUBRESOURCE_FILTER) {
+ content_type == CONTENT_SETTINGS_TYPE_SENSORS ||
+ content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
const auto& it = content_settings_status_.find(content_type);
if (it != content_settings_status_.end())
return it->second.blocked;
@@ -282,6 +282,7 @@ bool TabSpecificContentSettings::IsContentAllowed(
content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC &&
content_type != CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA &&
content_type != CONTENT_SETTINGS_TYPE_PPAPI_BROKER &&
+ content_type != CONTENT_SETTINGS_TYPE_SENSORS &&
content_type != CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
return false;
}
@@ -646,6 +647,16 @@ void TabSpecificContentSettings::OnMidiSysExAccessBlocked(
OnContentBlocked(CONTENT_SETTINGS_TYPE_MIDI_SYSEX);
}
+void TabSpecificContentSettings::OnSensorAccessed(
+ const GURL& requesting_origin) {
+ OnContentAllowed(CONTENT_SETTINGS_TYPE_SENSORS);
+}
+
+void TabSpecificContentSettings::OnSensorAccessBlocked(
+ const GURL& requesting_origin) {
+ OnContentBlocked(CONTENT_SETTINGS_TYPE_SENSORS);
+}
+
void TabSpecificContentSettings::
ClearContentSettingsExceptForNavigationRelatedSettings() {
for (auto& status : content_settings_status_) {
@@ -792,6 +803,7 @@ void TabSpecificContentSettings::DidStartNavigation(
ClearNavigationRelatedContentSettings();
ClearGeolocationContentSettings();
ClearMidiContentSettings();
+ // ClearSensorContentSettings();
ClearPendingProtocolHandler();
}
@@ -808,6 +820,7 @@ void TabSpecificContentSettings::DidFinishNavigation(
blocked_plugin_names_.clear();
GeolocationDidNavigate(navigation_handle);
MidiDidNavigate(navigation_handle);
+ // SensorDidNavigate(navigation_handle);
if (web_contents()->GetVisibleURL().SchemeIsHTTPOrHTTPS()) {
content_settings::RecordPluginsAction(
@@ -849,6 +862,12 @@ void TabSpecificContentSettings::ClearMidiContentSettings() {
midi_usages_state_.ClearStateMap();
}
+/*
+void TabSpecificContentSettings::ClearSensorContentSettings() {
+ sensors_usages_state_.ClearStateMap();
+}
+*/
+
void TabSpecificContentSettings::GeolocationDidNavigate(
content::NavigationHandle* navigation_handle) {
ContentSettingsUsagesState::CommittedDetails committed_details;
@@ -866,6 +885,16 @@ void TabSpecificContentSettings::MidiDidNavigate(
midi_usages_state_.DidNavigate(committed_details);
}
+/*
+void TabSpecificContentSettings::SensorDidNavigate(
+ content::NavigationHandle* navigation_handle) {
+ ContentSettingsUsagesState::CommittedDetails committed_details;
+ committed_details.current_url = navigation_handle->GetURL();
+ committed_details.previous_url = previous_url_;
+ sensors_usages_state_.DidNavigate(committed_details);
+}
+*/
+
void TabSpecificContentSettings::BlockAllContentForTesting() {
content_settings::ContentSettingsRegistry* registry =
content_settings::ContentSettingsRegistry::GetInstance();
« no previous file with comments | « chrome/browser/content_settings/tab_specific_content_settings.h ('k') | chrome/browser/generic_sensor_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698