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

Unified Diff: chrome/browser/sensor/sensor_permission_context.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/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..08ca7de733fcfab1ca42f3312d4a7f9fc8176bec
--- /dev/null
+++ b/chrome/browser/sensor/sensor_permission_context.cc
@@ -0,0 +1,39 @@
+// 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::PermissionType::SENSORS,
+ 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;
+}

Powered by Google App Engine
This is Rietveld 408576698