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

Unified Diff: chrome/browser/sensor/sensor_permission_context.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/sensor/sensor_permission_context.cc
diff --git a/chrome/browser/sensor/sensor_permission_context.cc b/chrome/browser/sensor/sensor_permission_context.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c43d9539b73fda1a396405dcd206b210aef77019
--- /dev/null
+++ b/chrome/browser/sensor/sensor_permission_context.cc
@@ -0,0 +1,37 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sensor/sensor_permission_context.h"
+
+#include "chrome/browser/content_settings/tab_specific_content_settings.h"
+#include "chrome/browser/permissions/permission_request_id.h"
+#include "content/public/browser/child_process_security_policy.h"
+#include "content/public/browser/permission_type.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/web_contents.h"
+#include "url/gurl.h"
+
+SensorPermissionContext::SensorPermissionContext(Profile* profile)
+ : PermissionContextBase(profile, CONTENT_SETTINGS_TYPE_SENSORS) {}
+
+SensorPermissionContext::~SensorPermissionContext() {}
+
+void SensorPermissionContext::UpdateTabContext(const PermissionRequestID& id,
+ const GURL& requesting_frame,
+ bool allowed) {
+ TabSpecificContentSettings* content_settings =
+ TabSpecificContentSettings::GetForFrame(id.render_process_id(),
+ id.render_frame_id());
+ if (!content_settings)
+ return;
+
+ if (allowed)
+ content_settings->OnSensorAccessed(requesting_frame);
+ else
+ content_settings->OnSensorAccessBlocked(requesting_frame);
+}
+
+bool SensorPermissionContext::IsRestrictedToSecureOrigins() const {
+ return true;
+}
« no previous file with comments | « chrome/browser/sensor/sensor_permission_context.h ('k') | chrome/browser/sensor/sensor_permission_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698