Index: third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp |
diff --git a/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp b/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp |
index 243c8f567abd3b83ac192d914e82462333631f7b..4c7042981bce73abd1a23021604d4dafe1a3a37a 100644 |
--- a/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp |
+++ b/third_party/WebKit/Source/modules/sensor/SensorProviderProxy.cpp |
@@ -4,6 +4,8 @@ |
#include "modules/sensor/SensorProviderProxy.h" |
+#include "core/dom/ExecutionContext.h" |
+#include "modules/permissions/PermissionUtils.h" |
#include "modules/sensor/SensorProxy.h" |
#include "modules/sensor/SensorReading.h" |
#include "platform/mojo/MojoHelper.h" |
@@ -42,15 +44,43 @@ DEFINE_TRACE(SensorProviderProxy) { |
Supplement<LocalFrame>::trace(visitor); |
} |
+void SensorProviderProxy::onPermissionServiceConnectionError() { |
+ if (!Platform::current()) { |
+ // TODO(rockot): Clean this up once renderer shutdown sequence is fixed. |
+ return; |
+ } |
+ |
+ m_permissionService.reset(); |
+ for (SensorProxy* sensor : m_sensors) { |
+ sensor->handleSensorError(SecurityError, |
+ "Permission service not available."); |
+ } |
+} |
+ |
SensorProxy* SensorProviderProxy::createSensor( |
device::mojom::blink::SensorType type, |
+ ExecutionContext* context, |
std::unique_ptr<SensorReadingFactory> readingFactory) { |
DCHECK(!getSensor(type)); |
- SensorProxy* sensor = new SensorProxy(type, this, std::move(readingFactory)); |
- m_sensors.add(sensor); |
+ // Get permission service. |
+ if (!m_permissionService && |
+ connectToPermissionService(context, |
+ mojo::GetProxy(&m_permissionService))) { |
+ m_permissionService.set_connection_error_handler(convertToBaseCallback( |
+ WTF::bind(&SensorProviderProxy::onPermissionServiceConnectionError, |
+ wrapWeakPersistent(this)))); |
+ |
+ RefPtr<SecurityOrigin> origin = context->getSecurityOrigin(); |
+ DCHECK(origin); |
+ SensorProxy* sensor = |
+ new SensorProxy(type, m_permissionService.get(), origin, this, |
+ std::move(readingFactory)); |
+ m_sensors.add(sensor); |
+ return sensor; |
+ } |
- return sensor; |
+ return nullptr; |
Mikhail
2016/11/18 12:37:42
createSensor should not return nullptr, if there i
riju_
2016/11/21 11:23:28
OK, reusing onSensorProviderConnectionError for pe
|
} |
SensorProxy* SensorProviderProxy::getSensor( |