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

Unified Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 152893002: [DeviceLight API] Content Side Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix in Java file, stop() Created 6 years, 9 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 2bd6fca9ec332920b5a14712f142908d512d368a..77714f91dbd2b260679b7ae8edf0e06bc0320f4c 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -38,6 +38,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/common/webplugininfo.h"
#include "content/public/renderer/content_renderer_client.h"
+#include "content/renderer/device_light/device_light_event_pump.h"
#include "content/renderer/device_orientation/device_motion_event_pump.h"
#include "content/renderer/device_orientation/device_orientation_event_pump.h"
#include "content/renderer/dom_storage/webstoragenamespace_impl.h"
@@ -62,6 +63,7 @@
#include "net/base/mime_util.h"
#include "net/base/net_util.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"
@@ -140,6 +142,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
+ 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
@@ -1043,6 +1047,32 @@ 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(
+ const double& data) {
+ g_test_device_light_data.Get() = data;
+}
+
+//------------------------------------------------------------------------------
+
void RendererWebKitPlatformSupportImpl::setDeviceMotionListener(
blink::WebDeviceMotionListener* listener) {
if (g_test_device_motion_data == 0) {
« no previous file with comments | « content/renderer/renderer_webkitplatformsupport_impl.h ('k') | content/shell/renderer/test_runner/WebTestDelegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698