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

Unified Diff: third_party/WebKit/Source/modules/sensor/Sensor.cpp

Issue 2458453002: [sensors] Add Permission guard to the generic sensor apis.
Patch Set: Fix mikhail's comments 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: third_party/WebKit/Source/modules/sensor/Sensor.cpp
diff --git a/third_party/WebKit/Source/modules/sensor/Sensor.cpp b/third_party/WebKit/Source/modules/sensor/Sensor.cpp
index 0a0ded64b3d126ed3e66cfde7491dc0d3b350ee7..5b6fe150d49867a0c44f2d40ed80f0fbcac022a2 100644
--- a/third_party/WebKit/Source/modules/sensor/Sensor.cpp
+++ b/third_party/WebKit/Source/modules/sensor/Sensor.cpp
@@ -13,6 +13,7 @@
#include "modules/sensor/SensorPollingStrategy.h"
#include "modules/sensor/SensorProviderProxy.h"
#include "modules/sensor/SensorReading.h"
+#include "platform/UserGestureIndicator.h"
using namespace device::mojom::blink;
@@ -72,6 +73,14 @@ void Sensor::start(ScriptState* scriptState, ExceptionState& exceptionState) {
return;
}
+ // If the algorithm is not allowed to show a popup, throw SecurityError.
+ if (!UserGestureIndicator::consumeUserGesture()) {
shalamov 2016/11/16 11:10:22 I have two comments for this line: 1. Since it do
riju_ 2016/11/16 12:38:25 I am removing it now, as getting "sensor" informat
+ exceptionState.throwDOMException(
+ SecurityError,
+ "Must be handling a user gesture to show a permission request.");
+ return;
+ }
+
initSensorProxyIfNeeded();
if (!m_sensorProxy) {
@@ -167,8 +176,8 @@ void Sensor::initSensorProxyIfNeeded() {
m_sensorProxy = provider->getSensor(m_type);
if (!m_sensorProxy) {
- m_sensorProxy =
- provider->createSensor(m_type, createSensorReadingFactory());
+ m_sensorProxy = provider->createSensor(m_type, getExecutionContext(),
+ createSensorReadingFactory());
}
}

Powered by Google App Engine
This is Rietveld 408576698