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

Unified Diff: third_party/WebKit/Source/modules/permissions/Permissions.cpp

Issue 2791623004: [sensors][permission] Add new permission types in permission module. (Closed)
Patch Set: Remove orientation-sensor permission string. 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: third_party/WebKit/Source/modules/permissions/Permissions.cpp
diff --git a/third_party/WebKit/Source/modules/permissions/Permissions.cpp b/third_party/WebKit/Source/modules/permissions/Permissions.cpp
index f9a49940254a69240cbb17a52e311b23c9a8f6cb..00f20a8b87859f028cced4cd71b39a81d3efd80b 100644
--- a/third_party/WebKit/Source/modules/permissions/Permissions.cpp
+++ b/third_party/WebKit/Source/modules/permissions/Permissions.cpp
@@ -20,6 +20,7 @@
#include "modules/permissions/PermissionDescriptor.h"
#include "modules/permissions/PermissionStatus.h"
#include "modules/permissions/PermissionUtils.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/UserGestureIndicator.h"
#include "platform/wtf/Functional.h"
#include "platform/wtf/NotFound.h"
@@ -35,6 +36,14 @@ using mojom::blink::PermissionService;
namespace {
+bool IsSensorRuntimeFlagEnabled(ExceptionState& exception_state) {
+ if (!RuntimeEnabledFeatures::sensorEnabled()) {
+ exception_state.ThrowTypeError("GenericSensor flag is not enabled.");
+ return false;
+ }
+ return true;
+}
+
// Parses the raw permission dictionary and returns the Mojo
// PermissionDescriptor if parsing was successful. If an exception occurs, it
// will be stored in |exceptionState| and null will be returned. Therefore, the
@@ -91,6 +100,17 @@ PermissionDescriptorPtr ParsePermission(ScriptState* script_state,
}
if (name == "background-sync")
return CreatePermissionDescriptor(PermissionName::BACKGROUND_SYNC);
+ // TODO(riju): Remove runtime flag check when Generic Sensor feature is
+ // stable.
+ if (name == "ambient-light-sensor" &&
+ IsSensorRuntimeFlagEnabled(exception_state))
mlamouri (slow - plz ping) 2017/04/20 13:26:32 Instead of checking for the flag N times, could yo
riju_ 2017/07/19 06:56:46 Done.
+ return CreatePermissionDescriptor(PermissionName::AMBIENT_LIGHT_SENSOR);
+ if (name == "accelerometer" && IsSensorRuntimeFlagEnabled(exception_state))
+ return CreatePermissionDescriptor(PermissionName::ACCELEROMETER);
+ if (name == "gyroscope" && IsSensorRuntimeFlagEnabled(exception_state))
+ return CreatePermissionDescriptor(PermissionName::GYROSCOPE);
+ if (name == "magnetometer" && IsSensorRuntimeFlagEnabled(exception_state))
+ return CreatePermissionDescriptor(PermissionName::MAGNETOMETER);
return nullptr;
}

Powered by Google App Engine
This is Rietveld 408576698