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

Side by Side Diff: content/renderer/renderer_webkitplatformsupport_impl.cc

Issue 207323002: Gamepad API: add test support for gamepad events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 #include "third_party/WebKit/public/platform/WebScrollbarBehavior.h" 113 #include "third_party/WebKit/public/platform/WebScrollbarBehavior.h"
114 #define WebScrollbarBehaviorImpl blink::WebScrollbarBehavior 114 #define WebScrollbarBehaviorImpl blink::WebScrollbarBehavior
115 #endif 115 #endif
116 116
117 using blink::Platform; 117 using blink::Platform;
118 using blink::WebAudioDevice; 118 using blink::WebAudioDevice;
119 using blink::WebBlobRegistry; 119 using blink::WebBlobRegistry;
120 using blink::WebDatabaseObserver; 120 using blink::WebDatabaseObserver;
121 using blink::WebFileInfo; 121 using blink::WebFileInfo;
122 using blink::WebFileSystem; 122 using blink::WebFileSystem;
123 using blink::WebGamepad;
123 using blink::WebGamepads; 124 using blink::WebGamepads;
124 using blink::WebIDBFactory; 125 using blink::WebIDBFactory;
125 using blink::WebMIDIAccessor; 126 using blink::WebMIDIAccessor;
126 using blink::WebMediaStreamCenter; 127 using blink::WebMediaStreamCenter;
127 using blink::WebMediaStreamCenterClient; 128 using blink::WebMediaStreamCenterClient;
128 using blink::WebMimeRegistry; 129 using blink::WebMimeRegistry;
129 using blink::WebRTCPeerConnectionHandler; 130 using blink::WebRTCPeerConnectionHandler;
130 using blink::WebRTCPeerConnectionHandlerClient; 131 using blink::WebRTCPeerConnectionHandlerClient;
131 using blink::WebStorageNamespace; 132 using blink::WebStorageNamespace;
132 using blink::WebString; 133 using blink::WebString;
133 using blink::WebURL; 134 using blink::WebURL;
134 using blink::WebVector; 135 using blink::WebVector;
135 136
136 namespace content { 137 namespace content {
137 138
138 static bool g_sandbox_enabled = true; 139 static bool g_sandbox_enabled = true;
140 static blink::WebGamepadListener* web_gamepad_listener = NULL;
jochen (gone - plz use gerrit) 2014/03/24 12:22:40 can this be a member of RendererWebKitPlatformSupp
139 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = 141 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads =
140 LAZY_INSTANCE_INITIALIZER; 142 LAZY_INSTANCE_INITIALIZER;
141 base::LazyInstance<blink::WebDeviceMotionData>::Leaky 143 base::LazyInstance<blink::WebDeviceMotionData>::Leaky
142 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; 144 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER;
143 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky 145 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky
144 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; 146 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER;
145 base::LazyInstance<blink::WebScreenOrientation>::Leaky 147 base::LazyInstance<blink::WebScreenOrientation>::Leaky
146 g_test_screen_orientation_value = LAZY_INSTANCE_INITIALIZER; 148 g_test_screen_orientation_value = LAZY_INSTANCE_INITIALIZER;
147 149
148 //------------------------------------------------------------------------------ 150 //------------------------------------------------------------------------------
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 //------------------------------------------------------------------------------ 910 //------------------------------------------------------------------------------
909 911
910 void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) { 912 void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) {
911 if (g_test_gamepads == 0) { 913 if (g_test_gamepads == 0) {
912 RenderThreadImpl::current()->SampleGamepads(&gamepads); 914 RenderThreadImpl::current()->SampleGamepads(&gamepads);
913 } else { 915 } else {
914 gamepads = g_test_gamepads.Get(); 916 gamepads = g_test_gamepads.Get();
915 } 917 }
916 } 918 }
917 919
920 void RendererWebKitPlatformSupportImpl::setGamepadListener(
921 blink::WebGamepadListener* listener) {
922 web_gamepad_listener = listener;
923 }
924
918 //------------------------------------------------------------------------------ 925 //------------------------------------------------------------------------------
919 926
920 WebRTCPeerConnectionHandler* 927 WebRTCPeerConnectionHandler*
921 RendererWebKitPlatformSupportImpl::createRTCPeerConnectionHandler( 928 RendererWebKitPlatformSupportImpl::createRTCPeerConnectionHandler(
922 WebRTCPeerConnectionHandlerClient* client) { 929 WebRTCPeerConnectionHandlerClient* client) {
923 RenderThreadImpl* render_thread = RenderThreadImpl::current(); 930 RenderThreadImpl* render_thread = RenderThreadImpl::current();
924 DCHECK(render_thread); 931 DCHECK(render_thread);
925 if (!render_thread) 932 if (!render_thread)
926 return NULL; 933 return NULL;
927 934
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 g_sandbox_enabled = enable; 966 g_sandbox_enabled = enable;
960 return was_enabled; 967 return was_enabled;
961 } 968 }
962 969
963 // static 970 // static
964 void RendererWebKitPlatformSupportImpl::SetMockGamepadsForTesting( 971 void RendererWebKitPlatformSupportImpl::SetMockGamepadsForTesting(
965 const WebGamepads& pads) { 972 const WebGamepads& pads) {
966 g_test_gamepads.Get() = pads; 973 g_test_gamepads.Get() = pads;
967 } 974 }
968 975
976 // static
977 void RendererWebKitPlatformSupportImpl::MockGamepadConnected(
978 int index,
979 const WebGamepad& pad) {
980 if (web_gamepad_listener)
981 web_gamepad_listener->didConnectGamepad(index, pad);
982 }
983
984 // static
985 void RendererWebKitPlatformSupportImpl::MockGamepadDisconnected(
986 int index,
987 const WebGamepad& pad) {
988 if (web_gamepad_listener)
989 web_gamepad_listener->didDisconnectGamepad(index, pad);
990 }
991
969 //------------------------------------------------------------------------------ 992 //------------------------------------------------------------------------------
970 993
971 blink::WebSpeechSynthesizer* 994 blink::WebSpeechSynthesizer*
972 RendererWebKitPlatformSupportImpl::createSpeechSynthesizer( 995 RendererWebKitPlatformSupportImpl::createSpeechSynthesizer(
973 blink::WebSpeechSynthesizerClient* client) { 996 blink::WebSpeechSynthesizerClient* client) {
974 return GetContentClient()->renderer()->OverrideSpeechSynthesizer(client); 997 return GetContentClient()->renderer()->OverrideSpeechSynthesizer(client);
975 } 998 }
976 999
977 //------------------------------------------------------------------------------ 1000 //------------------------------------------------------------------------------
978 1001
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 return; 1193 return;
1171 QuotaDispatcher::ThreadSpecificInstance( 1194 QuotaDispatcher::ThreadSpecificInstance(
1172 thread_safe_sender_.get(), 1195 thread_safe_sender_.get(),
1173 quota_message_filter_.get())->QueryStorageUsageAndQuota( 1196 quota_message_filter_.get())->QueryStorageUsageAndQuota(
1174 storage_partition, 1197 storage_partition,
1175 static_cast<quota::StorageType>(type), 1198 static_cast<quota::StorageType>(type),
1176 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); 1199 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks));
1177 } 1200 }
1178 1201
1179 } // namespace content 1202 } // namespace content
OLDNEW
« 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