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/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "content/common/gpu/client/gpu_channel_host.h" | 31 #include "content/common/gpu/client/gpu_channel_host.h" |
32 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 32 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
33 #include "content/common/gpu/gpu_process_launch_causes.h" | 33 #include "content/common/gpu/gpu_process_launch_causes.h" |
34 #include "content/common/mime_registry_messages.h" | 34 #include "content/common/mime_registry_messages.h" |
35 #include "content/common/screen_orientation_messages.h" | 35 #include "content/common/screen_orientation_messages.h" |
36 #include "content/common/view_messages.h" | 36 #include "content/common/view_messages.h" |
37 #include "content/public/common/content_switches.h" | 37 #include "content/public/common/content_switches.h" |
38 #include "content/public/common/webplugininfo.h" | 38 #include "content/public/common/webplugininfo.h" |
39 #include "content/public/renderer/content_renderer_client.h" | 39 #include "content/public/renderer/content_renderer_client.h" |
40 #include "content/renderer/battery_status/battery_status_dispatcher.h" | 40 #include "content/renderer/battery_status/battery_status_dispatcher.h" |
| 41 #include "content/renderer/battery_status/fake_battery_status_dispatcher.h" |
41 #include "content/renderer/device_sensors/device_motion_event_pump.h" | 42 #include "content/renderer/device_sensors/device_motion_event_pump.h" |
42 #include "content/renderer/device_sensors/device_orientation_event_pump.h" | 43 #include "content/renderer/device_sensors/device_orientation_event_pump.h" |
43 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 44 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
44 #include "content/renderer/gamepad_shared_memory_reader.h" | 45 #include "content/renderer/gamepad_shared_memory_reader.h" |
45 #include "content/renderer/media/audio_decoder.h" | 46 #include "content/renderer/media/audio_decoder.h" |
46 #include "content/renderer/media/crypto/key_systems.h" | 47 #include "content/renderer/media/crypto/key_systems.h" |
47 #include "content/renderer/media/renderer_webaudiodevice_impl.h" | 48 #include "content/renderer/media/renderer_webaudiodevice_impl.h" |
48 #include "content/renderer/media/renderer_webmidiaccessor_impl.h" | 49 #include "content/renderer/media/renderer_webmidiaccessor_impl.h" |
49 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" | 50 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
50 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 51 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 static bool g_sandbox_enabled = true; | 145 static bool g_sandbox_enabled = true; |
145 static blink::WebGamepadListener* web_gamepad_listener = NULL; | 146 static blink::WebGamepadListener* web_gamepad_listener = NULL; |
146 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = | 147 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = |
147 LAZY_INSTANCE_INITIALIZER; | 148 LAZY_INSTANCE_INITIALIZER; |
148 base::LazyInstance<blink::WebDeviceMotionData>::Leaky | 149 base::LazyInstance<blink::WebDeviceMotionData>::Leaky |
149 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; | 150 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; |
150 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky | 151 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky |
151 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; | 152 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; |
152 base::LazyInstance<MockScreenOrientationController>::Leaky | 153 base::LazyInstance<MockScreenOrientationController>::Leaky |
153 g_test_screen_orientation_controller = LAZY_INSTANCE_INITIALIZER; | 154 g_test_screen_orientation_controller = LAZY_INSTANCE_INITIALIZER; |
| 155 base::LazyInstance<FakeBatteryStatusDispatcher>::Leaky |
| 156 g_test_battery_status_dispatcher = LAZY_INSTANCE_INITIALIZER; |
154 | 157 |
155 } // namespace | 158 } // namespace |
156 | 159 |
157 //------------------------------------------------------------------------------ | 160 //------------------------------------------------------------------------------ |
158 | 161 |
159 class RendererWebKitPlatformSupportImpl::MimeRegistry | 162 class RendererWebKitPlatformSupportImpl::MimeRegistry |
160 : public SimpleWebMimeRegistryImpl { | 163 : public SimpleWebMimeRegistryImpl { |
161 public: | 164 public: |
162 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( | 165 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
163 const blink::WebString& mime_type, | 166 const blink::WebString& mime_type, |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 quota_message_filter_.get())->QueryStorageUsageAndQuota( | 1185 quota_message_filter_.get())->QueryStorageUsageAndQuota( |
1183 storage_partition, | 1186 storage_partition, |
1184 static_cast<quota::StorageType>(type), | 1187 static_cast<quota::StorageType>(type), |
1185 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); | 1188 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
1186 } | 1189 } |
1187 | 1190 |
1188 //------------------------------------------------------------------------------ | 1191 //------------------------------------------------------------------------------ |
1189 | 1192 |
1190 void RendererWebKitPlatformSupportImpl::setBatteryStatusListener( | 1193 void RendererWebKitPlatformSupportImpl::setBatteryStatusListener( |
1191 blink::WebBatteryStatusListener* listener) { | 1194 blink::WebBatteryStatusListener* listener) { |
| 1195 if (RenderThreadImpl::current() && |
| 1196 RenderThreadImpl::current()->layout_test_mode()) { |
| 1197 // If we are in test mode, we want to use a fake battery status dispatcher, |
| 1198 // which does not communicate with the browser process. Battery status |
| 1199 // changes are signalled by invoking MockBatteryStatusChangedForTesting(). |
| 1200 g_test_battery_status_dispatcher.Get().SetListener(listener); |
| 1201 return; |
| 1202 } |
| 1203 |
1192 if (!battery_status_dispatcher_) { | 1204 if (!battery_status_dispatcher_) { |
1193 battery_status_dispatcher_.reset( | 1205 battery_status_dispatcher_.reset( |
1194 new BatteryStatusDispatcher(RenderThreadImpl::current())); | 1206 new BatteryStatusDispatcher(RenderThreadImpl::current())); |
1195 } | 1207 } |
1196 battery_status_dispatcher_->SetListener(listener); | 1208 battery_status_dispatcher_->SetListener(listener); |
1197 } | 1209 } |
1198 | 1210 |
| 1211 // static |
| 1212 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( |
| 1213 const blink::WebBatteryStatus& status) { |
| 1214 g_test_battery_status_dispatcher.Get().PostBatteryStatusChange(status); |
| 1215 } |
| 1216 |
1199 } // namespace content | 1217 } // namespace content |
OLD | NEW |