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

Unified Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 286793002: [DeviceLight] Add renderer+common parts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try fixing for windows build Created 6 years, 6 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: content/renderer/renderer_webkitplatformsupport_impl.cc
diff --git a/content/renderer/renderer_webkitplatformsupport_impl.cc b/content/renderer/renderer_webkitplatformsupport_impl.cc
index 5f9f398fc7633f3468c00d8925551f14be5ac084..bfdd5fb23a2b40eac2cc6f405b11588b7b7ed282 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -39,6 +39,7 @@
#include "content/public/renderer/content_renderer_client.h"
#include "content/renderer/battery_status/battery_status_dispatcher.h"
#include "content/renderer/battery_status/fake_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"
@@ -65,6 +66,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"
@@ -146,6 +148,7 @@ static bool g_sandbox_enabled = true;
static blink::WebGamepadListener* web_gamepad_listener = NULL;
base::LazyInstance<WebGamepads>::Leaky g_test_gamepads =
LAZY_INSTANCE_INITIALIZER;
+double g_test_device_light_data;
timvolodine 2014/06/11 15:30:06 does this compile? should it be static? you probab
riju_ 2014/06/12 10:34:22 It is inside an anonymous namespace, so why use "s
timvolodine 2014/06/12 15:17:28 looks like there is a difference between compilers
base::LazyInstance<blink::WebDeviceMotionData>::Leaky
g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
base::LazyInstance<blink::WebDeviceOrientationData>::Leaky
@@ -1056,6 +1059,33 @@ blink::WebString RendererWebKitPlatformSupportImpl::convertIDNToUnicode(
//------------------------------------------------------------------------------
+void RendererWebKitPlatformSupportImpl::setDeviceLightListener(
+ blink::WebDeviceLightListener* listener) {
+ if (g_test_device_light_data == 0) {
timvolodine 2014/06/11 15:30:06 so you won't be able to test zero-lux value...
riju_ 2014/06/12 10:34:22 Done.
+ 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));
+ }
+}
+
+// static
+void RendererWebKitPlatformSupportImpl::SetMockDeviceLightDataForTesting(
+ double data) {
+ g_test_device_light_data = data;
+}
+
+
+//------------------------------------------------------------------------------
+
void RendererWebKitPlatformSupportImpl::setDeviceMotionListener(
blink::WebDeviceMotionListener* listener) {
if (g_test_device_motion_data == 0) {

Powered by Google App Engine
This is Rietveld 408576698