Index: content/renderer/renderer_webkitplatformsupport_impl.cc |
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc |
index 433cca128460c80fe3c84eeac8fa56c3714c8fa0..8d0cfe9366755a4d28f05defcb9dbbb5d8c24c11 100644 |
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc |
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc |
@@ -38,6 +38,7 @@ |
#include "content/public/common/webplugininfo.h" |
#include "content/public/renderer/content_renderer_client.h" |
#include "content/renderer/battery_status/battery_status_dispatcher.h" |
+#include "content/renderer/device_sensors/device_light_event_pump.h" |
#include "content/renderer/device_sensors/device_motion_event_pump.h" |
#include "content/renderer/device_sensors/device_orientation_event_pump.h" |
#include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
@@ -64,6 +65,7 @@ |
#include "net/base/net_util.h" |
#include "third_party/WebKit/public/platform/WebBatteryStatusListener.h" |
#include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
+#include "third_party/WebKit/public/platform/WebDeviceLightListener.h" |
#include "third_party/WebKit/public/platform/WebDeviceMotionListener.h" |
#include "third_party/WebKit/public/platform/WebDeviceOrientationListener.h" |
#include "third_party/WebKit/public/platform/WebFileInfo.h" |
@@ -145,6 +147,8 @@ static bool g_sandbox_enabled = true; |
static blink::WebGamepadListener* web_gamepad_listener = NULL; |
base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = |
LAZY_INSTANCE_INITIALIZER; |
+base::LazyInstance<double>::Leaky |
timvolodine
2014/06/03 16:08:12
I wonder if LazyInstance is really needed here bec
riju_
2014/06/05 19:50:00
Done.
|
+ g_test_device_light_data = LAZY_INSTANCE_INITIALIZER; |
base::LazyInstance<blink::WebDeviceMotionData>::Leaky |
g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; |
base::LazyInstance<blink::WebDeviceOrientationData>::Leaky |
@@ -1053,6 +1057,33 @@ blink::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode( |
//------------------------------------------------------------------------------ |
+void RendererWebKitPlatformSupportImpl::setDeviceLightListener( |
+ blink::WebDeviceLightListener* listener) { |
+ if (g_test_device_light_data == 0) { |
+ if (!device_light_event_pump_) { |
+ device_light_event_pump_.reset(new DeviceLightEventPump); |
+ device_light_event_pump_->Attach(RenderThreadImpl::current()); |
+ } |
+ device_light_event_pump_->SetListener(listener); |
+ } else if (listener) { |
+ // Testing mode: just echo the test data to the listener. |
+ base::MessageLoopProxy::current()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&blink::WebDeviceLightListener::didChangeDeviceLight, |
+ base::Unretained(listener), |
+ g_test_device_light_data.Get())); |
+ } |
+} |
+ |
+// static |
+void RendererWebKitPlatformSupportImpl::SetMockDeviceLightDataForTesting( |
+ double& data) { |
+ g_test_device_light_data.Get() = data; |
+} |
+ |
+ |
+//------------------------------------------------------------------------------ |
+ |
void RendererWebKitPlatformSupportImpl::setDeviceMotionListener( |
blink::WebDeviceMotionListener* listener) { |
if (g_test_device_motion_data == 0) { |