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

Side by Side 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 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/renderer_webkitplatformsupport_impl.h" 5 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" 43 #include "content/renderer/dom_storage/webstoragenamespace_impl.h"
44 #include "content/renderer/gamepad_shared_memory_reader.h" 44 #include "content/renderer/gamepad_shared_memory_reader.h"
45 #include "content/renderer/media/audio_decoder.h" 45 #include "content/renderer/media/audio_decoder.h"
46 #include "content/renderer/media/crypto/key_systems.h" 46 #include "content/renderer/media/crypto/key_systems.h"
47 #include "content/renderer/media/media_stream_dependency_factory.h" 47 #include "content/renderer/media/media_stream_dependency_factory.h"
48 #include "content/renderer/media/renderer_webaudiodevice_impl.h" 48 #include "content/renderer/media/renderer_webaudiodevice_impl.h"
49 #include "content/renderer/media/renderer_webmidiaccessor_impl.h" 49 #include "content/renderer/media/renderer_webmidiaccessor_impl.h"
50 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" 50 #include "content/renderer/media/webcontentdecryptionmodule_impl.h"
51 #include "content/renderer/render_thread_impl.h" 51 #include "content/renderer/render_thread_impl.h"
52 #include "content/renderer/renderer_clipboard_client.h" 52 #include "content/renderer/renderer_clipboard_client.h"
53 #include "content/renderer/screen_orientation/mock_screen_orientation_controller .h"
53 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" 54 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h"
54 #include "content/renderer/webclipboard_impl.h" 55 #include "content/renderer/webclipboard_impl.h"
55 #include "content/renderer/webgraphicscontext3d_provider_impl.h" 56 #include "content/renderer/webgraphicscontext3d_provider_impl.h"
56 #include "content/renderer/webpublicsuffixlist_impl.h" 57 #include "content/renderer/webpublicsuffixlist_impl.h"
57 #include "gpu/config/gpu_info.h" 58 #include "gpu/config/gpu_info.h"
58 #include "ipc/ipc_sync_message_filter.h" 59 #include "ipc/ipc_sync_message_filter.h"
59 #include "media/audio/audio_output_device.h" 60 #include "media/audio/audio_output_device.h"
60 #include "media/base/audio_hardware_config.h" 61 #include "media/base/audio_hardware_config.h"
61 #include "media/filters/stream_parser_factory.h" 62 #include "media/filters/stream_parser_factory.h"
62 #include "net/base/mime_util.h" 63 #include "net/base/mime_util.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 using blink::WebMimeRegistry; 131 using blink::WebMimeRegistry;
131 using blink::WebRTCPeerConnectionHandler; 132 using blink::WebRTCPeerConnectionHandler;
132 using blink::WebRTCPeerConnectionHandlerClient; 133 using blink::WebRTCPeerConnectionHandlerClient;
133 using blink::WebStorageNamespace; 134 using blink::WebStorageNamespace;
134 using blink::WebString; 135 using blink::WebString;
135 using blink::WebURL; 136 using blink::WebURL;
136 using blink::WebVector; 137 using blink::WebVector;
137 138
138 namespace content { 139 namespace content {
139 140
141 namespace {
142
140 static bool g_sandbox_enabled = true; 143 static bool g_sandbox_enabled = true;
141 static blink::WebGamepadListener* web_gamepad_listener = NULL; 144 static blink::WebGamepadListener* web_gamepad_listener = NULL;
142 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = 145 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads =
143 LAZY_INSTANCE_INITIALIZER; 146 LAZY_INSTANCE_INITIALIZER;
144 base::LazyInstance<blink::WebDeviceMotionData>::Leaky 147 base::LazyInstance<blink::WebDeviceMotionData>::Leaky
145 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; 148 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
146 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky 149 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky
147 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; 150 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER;
148 static blink::WebScreenOrientationListener* 151 base::LazyInstance<MockScreenOrientationController>::Leaky
149 g_test_screen_orientation_listener = NULL; 152 g_test_screen_orientation_controller = LAZY_INSTANCE_INITIALIZER;
153
154 } // namespace
150 155
151 //------------------------------------------------------------------------------ 156 //------------------------------------------------------------------------------
152 157
153 class RendererWebKitPlatformSupportImpl::MimeRegistry 158 class RendererWebKitPlatformSupportImpl::MimeRegistry
154 : public SimpleWebMimeRegistryImpl { 159 : public SimpleWebMimeRegistryImpl {
155 public: 160 public:
156 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( 161 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType(
157 const blink::WebString& mime_type, 162 const blink::WebString& mime_type,
158 const blink::WebString& codecs, 163 const blink::WebString& codecs,
159 const blink::WebString& key_system); 164 const blink::WebString& key_system);
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 g_test_device_motion_data.Get())); 1076 g_test_device_motion_data.Get()));
1072 } 1077 }
1073 } 1078 }
1074 1079
1075 // static 1080 // static
1076 void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting( 1081 void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting(
1077 const blink::WebDeviceMotionData& data) { 1082 const blink::WebDeviceMotionData& data) {
1078 g_test_device_motion_data.Get() = data; 1083 g_test_device_motion_data.Get() = data;
1079 } 1084 }
1080 1085
1086 // static
1087 void RendererWebKitPlatformSupportImpl::ResetMockScreenOrientationForTesting()
1088 {
1089 g_test_screen_orientation_controller.Get().ResetData();
1090 }
1091
1081 //------------------------------------------------------------------------------ 1092 //------------------------------------------------------------------------------
1082 1093
1083 void RendererWebKitPlatformSupportImpl::setDeviceOrientationListener( 1094 void RendererWebKitPlatformSupportImpl::setDeviceOrientationListener(
1084 blink::WebDeviceOrientationListener* listener) { 1095 blink::WebDeviceOrientationListener* listener) {
1085 if (g_test_device_orientation_data == 0) { 1096 if (g_test_device_orientation_data == 0) {
1086 if (!device_orientation_event_pump_) { 1097 if (!device_orientation_event_pump_) {
1087 device_orientation_event_pump_.reset(new DeviceOrientationEventPump); 1098 device_orientation_event_pump_.reset(new DeviceOrientationEventPump);
1088 device_orientation_event_pump_->Attach(RenderThreadImpl::current()); 1099 device_orientation_event_pump_->Attach(RenderThreadImpl::current());
1089 } 1100 }
1090 device_orientation_event_pump_->SetListener(listener); 1101 device_orientation_event_pump_->SetListener(listener);
(...skipping 28 matching lines...) Expand all
1119 //------------------------------------------------------------------------------ 1130 //------------------------------------------------------------------------------
1120 1131
1121 void RendererWebKitPlatformSupportImpl::setScreenOrientationListener( 1132 void RendererWebKitPlatformSupportImpl::setScreenOrientationListener(
1122 blink::WebScreenOrientationListener* listener) { 1133 blink::WebScreenOrientationListener* listener) {
1123 if (RenderThreadImpl::current() && 1134 if (RenderThreadImpl::current() &&
1124 RenderThreadImpl::current()->layout_test_mode()) { 1135 RenderThreadImpl::current()->layout_test_mode()) {
1125 // If we are in test mode, we want to fully disable the screen orientation 1136 // If we are in test mode, we want to fully disable the screen orientation
1126 // backend in order to let Blink get tested properly, That means that screen 1137 // backend in order to let Blink get tested properly, That means that screen
1127 // orientation updates have to be done manually instead of from signals sent 1138 // orientation updates have to be done manually instead of from signals sent
1128 // by the browser process. 1139 // by the browser process.
1129 g_test_screen_orientation_listener = listener; 1140 g_test_screen_orientation_controller.Get().SetListener(listener);
1130 return; 1141 return;
1131 } 1142 }
1132 1143
1133 if (!screen_orientation_dispatcher_) { 1144 if (!screen_orientation_dispatcher_) {
1134 screen_orientation_dispatcher_.reset( 1145 screen_orientation_dispatcher_.reset(
1135 new ScreenOrientationDispatcher(RenderThread::Get())); 1146 new ScreenOrientationDispatcher(RenderThread::Get()));
1136 } 1147 }
1137 1148
1138 screen_orientation_dispatcher_->setListener(listener); 1149 screen_orientation_dispatcher_->setListener(listener);
1139 } 1150 }
1140 1151
1141 void RendererWebKitPlatformSupportImpl::lockOrientation( 1152 void RendererWebKitPlatformSupportImpl::lockOrientation(
1142 blink::WebScreenOrientationLockType orientation) { 1153 blink::WebScreenOrientationLockType orientation) {
1143 if (RenderThreadImpl::current() && 1154 if (RenderThreadImpl::current() &&
1144 RenderThreadImpl::current()->layout_test_mode()) { 1155 RenderThreadImpl::current()->layout_test_mode()) {
1156 g_test_screen_orientation_controller.Get().UpdateLock(orientation);
1145 return; 1157 return;
1146 } 1158 }
1147 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Lock(orientation)); 1159 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Lock(orientation));
1148 } 1160 }
1149 1161
1150 void RendererWebKitPlatformSupportImpl::unlockOrientation() { 1162 void RendererWebKitPlatformSupportImpl::unlockOrientation() {
1151 if (RenderThreadImpl::current() && 1163 if (RenderThreadImpl::current() &&
1152 RenderThreadImpl::current()->layout_test_mode()) { 1164 RenderThreadImpl::current()->layout_test_mode()) {
1165 g_test_screen_orientation_controller.Get().ResetLock();
1153 return; 1166 return;
1154 } 1167 }
1155 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Unlock); 1168 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Unlock);
1156 } 1169 }
1157 1170
1158 // static 1171 // static
1159 void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting( 1172 void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting(
1160 blink::WebScreenOrientationType orientation) { 1173 blink::WebScreenOrientationType orientation) {
1161 if (!g_test_screen_orientation_listener) 1174 g_test_screen_orientation_controller.Get()
1162 return; 1175 .UpdateDeviceOrientation(orientation);
1163 g_test_screen_orientation_listener->didChangeScreenOrientation(orientation);
1164 } 1176 }
1165 1177
1166 //------------------------------------------------------------------------------ 1178 //------------------------------------------------------------------------------
1167 1179
1168 void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota( 1180 void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota(
1169 const blink::WebURL& storage_partition, 1181 const blink::WebURL& storage_partition,
1170 blink::WebStorageQuotaType type, 1182 blink::WebStorageQuotaType type,
1171 blink::WebStorageQuotaCallbacks callbacks) { 1183 blink::WebStorageQuotaCallbacks callbacks) {
1172 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) 1184 if (!thread_safe_sender_.get() || !quota_message_filter_.get())
1173 return; 1185 return;
1174 QuotaDispatcher::ThreadSpecificInstance( 1186 QuotaDispatcher::ThreadSpecificInstance(
1175 thread_safe_sender_.get(), 1187 thread_safe_sender_.get(),
1176 quota_message_filter_.get())->QueryStorageUsageAndQuota( 1188 quota_message_filter_.get())->QueryStorageUsageAndQuota(
1177 storage_partition, 1189 storage_partition,
1178 static_cast<quota::StorageType>(type), 1190 static_cast<quota::StorageType>(type),
1179 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); 1191 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
1180 } 1192 }
1181 1193
1182 } // namespace content 1194 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698