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

Unified Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 268673015: Support screen.lockOrientation() / screen.unlockOrientation() when running layout tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Take jochen's feedback into consideration Created 6 years, 7 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 91906df8dbfc6a5ea5e8767a53602f41fe9c0f80..4645f9562ef00280cb7946b108b7472969b8a5cc 100644
--- a/content/renderer/renderer_webkitplatformsupport_impl.cc
+++ b/content/renderer/renderer_webkitplatformsupport_impl.cc
@@ -50,6 +50,7 @@
#include "content/renderer/media/webcontentdecryptionmodule_impl.h"
#include "content/renderer/render_thread_impl.h"
#include "content/renderer/renderer_clipboard_client.h"
+#include "content/renderer/screen_orientation/mock_screen_orientation_controller.h"
#include "content/renderer/screen_orientation/screen_orientation_dispatcher.h"
#include "content/renderer/webclipboard_impl.h"
#include "content/renderer/webgraphicscontext3d_provider_impl.h"
@@ -137,6 +138,8 @@ using blink::WebVector;
namespace content {
+namespace {
+
static bool g_sandbox_enabled = true;
static blink::WebGamepadListener* web_gamepad_listener = NULL;
base::LazyInstance<WebGamepads>::Leaky g_test_gamepads =
@@ -145,8 +148,10 @@ base::LazyInstance<blink::WebDeviceMotionData>::Leaky
g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
base::LazyInstance<blink::WebDeviceOrientationData>::Leaky
g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER;
-static blink::WebScreenOrientationListener*
- g_test_screen_orientation_listener = NULL;
+base::LazyInstance<MockScreenOrientationController>::Leaky
+ g_test_screen_orientation_controller = LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
//------------------------------------------------------------------------------
@@ -1081,6 +1086,12 @@ void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting(
g_test_device_motion_data.Get() = data;
}
+// static
+void RendererWebKitPlatformSupportImpl::ResetMockScreenOrientationForTesting()
+{
+ g_test_screen_orientation_controller.Get().ResetData();
+}
+
//------------------------------------------------------------------------------
void RendererWebKitPlatformSupportImpl::setDeviceOrientationListener(
@@ -1129,7 +1140,7 @@ void RendererWebKitPlatformSupportImpl::setScreenOrientationListener(
// backend in order to let Blink get tested properly, That means that screen
// orientation updates have to be done manually instead of from signals sent
// by the browser process.
- g_test_screen_orientation_listener = listener;
+ g_test_screen_orientation_controller.Get().SetListener(listener);
return;
}
@@ -1145,6 +1156,7 @@ void RendererWebKitPlatformSupportImpl::lockOrientation(
blink::WebScreenOrientationLockType orientation) {
if (RenderThreadImpl::current() &&
RenderThreadImpl::current()->layout_test_mode()) {
+ g_test_screen_orientation_controller.Get().UpdateLock(orientation);
return;
}
RenderThread::Get()->Send(new ScreenOrientationHostMsg_Lock(orientation));
@@ -1153,6 +1165,7 @@ void RendererWebKitPlatformSupportImpl::lockOrientation(
void RendererWebKitPlatformSupportImpl::unlockOrientation() {
if (RenderThreadImpl::current() &&
RenderThreadImpl::current()->layout_test_mode()) {
+ g_test_screen_orientation_controller.Get().ResetLock();
return;
}
RenderThread::Get()->Send(new ScreenOrientationHostMsg_Unlock);
@@ -1161,9 +1174,8 @@ void RendererWebKitPlatformSupportImpl::unlockOrientation() {
// static
void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting(
blink::WebScreenOrientationType orientation) {
- if (!g_test_screen_orientation_listener)
- return;
- g_test_screen_orientation_listener->didChangeScreenOrientation(orientation);
+ g_test_screen_orientation_controller.Get()
+ .UpdateDeviceOrientation(orientation);
}
//------------------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698