| OLD | NEW |
| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 using blink::WebStorageNamespace; | 134 using blink::WebStorageNamespace; |
| 135 using blink::WebString; | 135 using blink::WebString; |
| 136 using blink::WebURL; | 136 using blink::WebURL; |
| 137 using blink::WebVector; | 137 using blink::WebVector; |
| 138 | 138 |
| 139 namespace content { | 139 namespace content { |
| 140 | 140 |
| 141 namespace { | 141 namespace { |
| 142 | 142 |
| 143 static bool g_sandbox_enabled = true; | 143 static bool g_sandbox_enabled = true; |
| 144 static blink::WebGamepadListener* web_gamepad_listener = NULL; | |
| 145 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = | |
| 146 LAZY_INSTANCE_INITIALIZER; | |
| 147 base::LazyInstance<blink::WebDeviceMotionData>::Leaky | 144 base::LazyInstance<blink::WebDeviceMotionData>::Leaky |
| 148 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; | 145 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; |
| 149 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky | 146 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky |
| 150 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; | 147 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; |
| 151 base::LazyInstance<MockScreenOrientationController>::Leaky | 148 base::LazyInstance<MockScreenOrientationController>::Leaky |
| 152 g_test_screen_orientation_controller = LAZY_INSTANCE_INITIALIZER; | 149 g_test_screen_orientation_controller = LAZY_INSTANCE_INITIALIZER; |
| 153 base::LazyInstance<FakeBatteryStatusDispatcher>::Leaky | 150 base::LazyInstance<FakeBatteryStatusDispatcher>::Leaky |
| 154 g_test_battery_status_dispatcher = LAZY_INSTANCE_INITIALIZER; | 151 g_test_battery_status_dispatcher = LAZY_INSTANCE_INITIALIZER; |
| 155 | 152 |
| 156 } // namespace | 153 } // namespace |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 221 |
| 225 //------------------------------------------------------------------------------ | 222 //------------------------------------------------------------------------------ |
| 226 | 223 |
| 227 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() | 224 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() |
| 228 : clipboard_client_(new RendererClipboardClient), | 225 : clipboard_client_(new RendererClipboardClient), |
| 229 clipboard_(new WebClipboardImpl(clipboard_client_.get())), | 226 clipboard_(new WebClipboardImpl(clipboard_client_.get())), |
| 230 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), | 227 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), |
| 231 sudden_termination_disables_(0), | 228 sudden_termination_disables_(0), |
| 232 plugin_refresh_allowed_(true), | 229 plugin_refresh_allowed_(true), |
| 233 child_thread_loop_(base::MessageLoopProxy::current()), | 230 child_thread_loop_(base::MessageLoopProxy::current()), |
| 234 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl) { | 231 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl), |
| 232 gamepad_provider_(NULL) { |
| 235 if (g_sandbox_enabled && sandboxEnabled()) { | 233 if (g_sandbox_enabled && sandboxEnabled()) { |
| 236 sandbox_support_.reset( | 234 sandbox_support_.reset( |
| 237 new RendererWebKitPlatformSupportImpl::SandboxSupport); | 235 new RendererWebKitPlatformSupportImpl::SandboxSupport); |
| 238 } else { | 236 } else { |
| 239 DVLOG(1) << "Disabling sandbox support for testing."; | 237 DVLOG(1) << "Disabling sandbox support for testing."; |
| 240 } | 238 } |
| 241 | 239 |
| 242 // ChildThread may not exist in some tests. | 240 // ChildThread may not exist in some tests. |
| 243 if (ChildThread::current()) { | 241 if (ChildThread::current()) { |
| 244 sync_message_filter_ = ChildThread::current()->sync_message_filter(); | 242 sync_message_filter_ = ChildThread::current()->sync_message_filter(); |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 //------------------------------------------------------------------------------ | 876 //------------------------------------------------------------------------------ |
| 879 | 877 |
| 880 WebBlobRegistry* RendererWebKitPlatformSupportImpl::blobRegistry() { | 878 WebBlobRegistry* RendererWebKitPlatformSupportImpl::blobRegistry() { |
| 881 // blob_registry_ can be NULL when running some tests. | 879 // blob_registry_ can be NULL when running some tests. |
| 882 return blob_registry_.get(); | 880 return blob_registry_.get(); |
| 883 } | 881 } |
| 884 | 882 |
| 885 //------------------------------------------------------------------------------ | 883 //------------------------------------------------------------------------------ |
| 886 | 884 |
| 887 void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) { | 885 void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) { |
| 888 if (g_test_gamepads == 0) { | 886 DCHECK(gamepad_provider_); |
| 889 RenderThreadImpl::current()->gamepad_shared_memory_reader()-> | 887 gamepad_provider_->SampleGamepads(gamepads); |
| 890 SampleGamepads(gamepads); | |
| 891 } else { | |
| 892 gamepads = g_test_gamepads.Get(); | |
| 893 } | |
| 894 } | 888 } |
| 895 | 889 |
| 896 void RendererWebKitPlatformSupportImpl::setGamepadListener( | 890 void RendererWebKitPlatformSupportImpl::setGamepadListener( |
| 897 blink::WebGamepadListener* listener) { | 891 blink::WebGamepadListener* listener) { |
| 898 web_gamepad_listener = listener; | 892 DCHECK(gamepad_provider_); |
| 899 RenderThreadImpl::current()->gamepad_shared_memory_reader()-> | 893 gamepad_provider_->SetGamepadListener(listener); |
| 900 SetGamepadListener(listener); | |
| 901 } | 894 } |
| 902 | 895 |
| 903 //------------------------------------------------------------------------------ | 896 //------------------------------------------------------------------------------ |
| 904 | 897 |
| 905 WebRTCPeerConnectionHandler* | 898 WebRTCPeerConnectionHandler* |
| 906 RendererWebKitPlatformSupportImpl::createRTCPeerConnectionHandler( | 899 RendererWebKitPlatformSupportImpl::createRTCPeerConnectionHandler( |
| 907 WebRTCPeerConnectionHandlerClient* client) { | 900 WebRTCPeerConnectionHandlerClient* client) { |
| 908 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 901 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 909 DCHECK(render_thread); | 902 DCHECK(render_thread); |
| 910 if (!render_thread) | 903 if (!render_thread) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 938 } | 931 } |
| 939 | 932 |
| 940 // static | 933 // static |
| 941 bool RendererWebKitPlatformSupportImpl::SetSandboxEnabledForTesting( | 934 bool RendererWebKitPlatformSupportImpl::SetSandboxEnabledForTesting( |
| 942 bool enable) { | 935 bool enable) { |
| 943 bool was_enabled = g_sandbox_enabled; | 936 bool was_enabled = g_sandbox_enabled; |
| 944 g_sandbox_enabled = enable; | 937 g_sandbox_enabled = enable; |
| 945 return was_enabled; | 938 return was_enabled; |
| 946 } | 939 } |
| 947 | 940 |
| 948 // static | |
| 949 void RendererWebKitPlatformSupportImpl::SetMockGamepadsForTesting( | |
| 950 const WebGamepads& pads) { | |
| 951 g_test_gamepads.Get() = pads; | |
| 952 } | |
| 953 | |
| 954 // static | |
| 955 void RendererWebKitPlatformSupportImpl::MockGamepadConnected( | |
| 956 int index, | |
| 957 const WebGamepad& pad) { | |
| 958 if (web_gamepad_listener) | |
| 959 web_gamepad_listener->didConnectGamepad(index, pad); | |
| 960 } | |
| 961 | |
| 962 // static | |
| 963 void RendererWebKitPlatformSupportImpl::MockGamepadDisconnected( | |
| 964 int index, | |
| 965 const WebGamepad& pad) { | |
| 966 if (web_gamepad_listener) | |
| 967 web_gamepad_listener->didDisconnectGamepad(index, pad); | |
| 968 } | |
| 969 | |
| 970 //------------------------------------------------------------------------------ | 941 //------------------------------------------------------------------------------ |
| 971 | 942 |
| 972 blink::WebSpeechSynthesizer* | 943 blink::WebSpeechSynthesizer* |
| 973 RendererWebKitPlatformSupportImpl::createSpeechSynthesizer( | 944 RendererWebKitPlatformSupportImpl::createSpeechSynthesizer( |
| 974 blink::WebSpeechSynthesizerClient* client) { | 945 blink::WebSpeechSynthesizerClient* client) { |
| 975 return GetContentClient()->renderer()->OverrideSpeechSynthesizer(client); | 946 return GetContentClient()->renderer()->OverrideSpeechSynthesizer(client); |
| 976 } | 947 } |
| 977 | 948 |
| 978 //------------------------------------------------------------------------------ | 949 //------------------------------------------------------------------------------ |
| 979 | 950 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 battery_status_dispatcher_->SetListener(listener); | 1135 battery_status_dispatcher_->SetListener(listener); |
| 1165 } | 1136 } |
| 1166 | 1137 |
| 1167 // static | 1138 // static |
| 1168 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( | 1139 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( |
| 1169 const blink::WebBatteryStatus& status) { | 1140 const blink::WebBatteryStatus& status) { |
| 1170 g_test_battery_status_dispatcher.Get().PostBatteryStatusChange(status); | 1141 g_test_battery_status_dispatcher.Get().PostBatteryStatusChange(status); |
| 1171 } | 1142 } |
| 1172 | 1143 |
| 1173 } // namespace content | 1144 } // namespace content |
| OLD | NEW |