| 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_blink_platform_impl.h" | 5 #include "content/renderer/renderer_blink_platform_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 #include "content/common/gpu/client/gpu_channel_host.h" | 45 #include "content/common/gpu/client/gpu_channel_host.h" |
| 46 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 46 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 47 #include "content/common/gpu/gpu_process_launch_causes.h" | 47 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 48 #include "content/common/mime_registry_messages.h" | 48 #include "content/common/mime_registry_messages.h" |
| 49 #include "content/common/render_process_messages.h" | 49 #include "content/common/render_process_messages.h" |
| 50 #include "content/public/common/content_switches.h" | 50 #include "content/public/common/content_switches.h" |
| 51 #include "content/public/common/service_registry.h" | 51 #include "content/public/common/service_registry.h" |
| 52 #include "content/public/common/webplugininfo.h" | 52 #include "content/public/common/webplugininfo.h" |
| 53 #include "content/public/renderer/content_renderer_client.h" | 53 #include "content/public/renderer/content_renderer_client.h" |
| 54 #include "content/public/renderer/media_stream_api.h" | 54 #include "content/public/renderer/media_stream_api.h" |
| 55 #include "content/renderer/battery_status/battery_status_dispatcher.h" | |
| 56 #include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h" | 55 #include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h" |
| 57 #include "content/renderer/device_sensors/device_light_event_pump.h" | 56 #include "content/renderer/device_sensors/device_light_event_pump.h" |
| 58 #include "content/renderer/device_sensors/device_motion_event_pump.h" | 57 #include "content/renderer/device_sensors/device_motion_event_pump.h" |
| 59 #include "content/renderer/device_sensors/device_orientation_absolute_event_pump
.h" | 58 #include "content/renderer/device_sensors/device_orientation_absolute_event_pump
.h" |
| 60 #include "content/renderer/device_sensors/device_orientation_event_pump.h" | 59 #include "content/renderer/device_sensors/device_orientation_event_pump.h" |
| 61 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 60 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
| 62 #include "content/renderer/gamepad_shared_memory_reader.h" | 61 #include "content/renderer/gamepad_shared_memory_reader.h" |
| 63 #include "content/renderer/media/audio_decoder.h" | 62 #include "content/renderer/media/audio_decoder.h" |
| 64 #include "content/renderer/media/canvas_capture_handler.h" | 63 #include "content/renderer/media/canvas_capture_handler.h" |
| 65 #include "content/renderer/media/html_video_element_capturer_source.h" | 64 #include "content/renderer/media/html_video_element_capturer_source.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 77 #include "ipc/ipc_sync_message_filter.h" | 76 #include "ipc/ipc_sync_message_filter.h" |
| 78 #include "media/audio/audio_output_device.h" | 77 #include "media/audio/audio_output_device.h" |
| 79 #include "media/base/audio_hardware_config.h" | 78 #include "media/base/audio_hardware_config.h" |
| 80 #include "media/base/key_systems.h" | 79 #include "media/base/key_systems.h" |
| 81 #include "media/base/mime_util.h" | 80 #include "media/base/mime_util.h" |
| 82 #include "media/blink/webcontentdecryptionmodule_impl.h" | 81 #include "media/blink/webcontentdecryptionmodule_impl.h" |
| 83 #include "media/filters/stream_parser_factory.h" | 82 #include "media/filters/stream_parser_factory.h" |
| 84 #include "storage/common/database/database_identifier.h" | 83 #include "storage/common/database/database_identifier.h" |
| 85 #include "storage/common/quota/quota_types.h" | 84 #include "storage/common/quota/quota_types.h" |
| 86 #include "third_party/WebKit/public/platform/URLConversion.h" | 85 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 87 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h" | |
| 88 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | 86 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
| 89 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" | 87 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" |
| 90 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 88 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
| 91 #include "third_party/WebKit/public/platform/WebGamepads.h" | 89 #include "third_party/WebKit/public/platform/WebGamepads.h" |
| 92 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" | 90 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" |
| 93 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" | 91 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" |
| 94 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" | 92 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" |
| 95 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 93 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 96 #include "third_party/WebKit/public/platform/WebURL.h" | 94 #include "third_party/WebKit/public/platform/WebURL.h" |
| 97 #include "third_party/WebKit/public/platform/WebVector.h" | 95 #include "third_party/WebKit/public/platform/WebVector.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 namespace content { | 168 namespace content { |
| 171 | 169 |
| 172 namespace { | 170 namespace { |
| 173 | 171 |
| 174 bool g_sandbox_enabled = true; | 172 bool g_sandbox_enabled = true; |
| 175 double g_test_device_light_data = -1; | 173 double g_test_device_light_data = -1; |
| 176 base::LazyInstance<blink::WebDeviceMotionData>::Leaky | 174 base::LazyInstance<blink::WebDeviceMotionData>::Leaky |
| 177 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; | 175 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; |
| 178 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky | 176 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky |
| 179 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; | 177 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; |
| 180 // Set in startListening() when running layout tests, unset in stopListening(), | |
| 181 // not owned by us. | |
| 182 blink::WebBatteryStatusListener* g_test_battery_status_listener = nullptr; | |
| 183 | 178 |
| 184 } // namespace | 179 } // namespace |
| 185 | 180 |
| 186 //------------------------------------------------------------------------------ | 181 //------------------------------------------------------------------------------ |
| 187 | 182 |
| 188 class RendererBlinkPlatformImpl::MimeRegistry | 183 class RendererBlinkPlatformImpl::MimeRegistry |
| 189 : public SimpleWebMimeRegistryImpl { | 184 : public SimpleWebMimeRegistryImpl { |
| 190 public: | 185 public: |
| 191 blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( | 186 blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
| 192 const blink::WebString& mime_type, | 187 const blink::WebString& mime_type, |
| (...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " | 1167 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " |
| 1173 "unknown type."; | 1168 "unknown type."; |
| 1174 } | 1169 } |
| 1175 | 1170 |
| 1176 return NULL; | 1171 return NULL; |
| 1177 } | 1172 } |
| 1178 | 1173 |
| 1179 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( | 1174 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( |
| 1180 blink::WebPlatformEventType type, | 1175 blink::WebPlatformEventType type, |
| 1181 scoped_ptr<PlatformEventObserverBase> observer) { | 1176 scoped_ptr<PlatformEventObserverBase> observer) { |
| 1182 DCHECK(type != blink::WebPlatformEventTypeBattery); | |
| 1183 | |
| 1184 if (platform_event_observers_.Lookup(type)) | 1177 if (platform_event_observers_.Lookup(type)) |
| 1185 platform_event_observers_.Remove(type); | 1178 platform_event_observers_.Remove(type); |
| 1186 platform_event_observers_.AddWithID(observer.release(), type); | 1179 platform_event_observers_.AddWithID(observer.release(), type); |
| 1187 } | 1180 } |
| 1188 | 1181 |
| 1182 void RendererBlinkPlatformImpl::connectToRemoteService( |
| 1183 const char* name, mojo::ScopedMessagePipeHandle handle) { |
| 1184 // In the layout test mode, mock services should be used instead. |
| 1185 // TODO(yukishiino): We'd like to inject mock services implemented in |
| 1186 // JavaScript. Remove the following hack once we support JS-bindings |
| 1187 // of Mojo and service mocking in JS. |
| 1188 if (RenderThreadImpl::current() && |
| 1189 RenderThreadImpl::current()->layout_test_mode()) |
| 1190 return; |
| 1191 |
| 1192 if (ServiceRegistry* registry = RenderThread::Get()->GetServiceRegistry()) { |
| 1193 // registry can be null during testing. |
| 1194 registry->ConnectToRemoteService(name, std::move(handle)); |
| 1195 } |
| 1196 } |
| 1197 |
| 1189 void RendererBlinkPlatformImpl::startListening( | 1198 void RendererBlinkPlatformImpl::startListening( |
| 1190 blink::WebPlatformEventType type, | 1199 blink::WebPlatformEventType type, |
| 1191 blink::WebPlatformEventListener* listener) { | 1200 blink::WebPlatformEventListener* listener) { |
| 1192 if (type == blink::WebPlatformEventTypeBattery) { | |
| 1193 if (RenderThreadImpl::current() && | |
| 1194 RenderThreadImpl::current()->layout_test_mode()) { | |
| 1195 g_test_battery_status_listener = | |
| 1196 static_cast<blink::WebBatteryStatusListener*>(listener); | |
| 1197 } else { | |
| 1198 battery_status_dispatcher_.reset(new BatteryStatusDispatcher( | |
| 1199 static_cast<blink::WebBatteryStatusListener*>(listener))); | |
| 1200 } | |
| 1201 return; | |
| 1202 } | |
| 1203 | |
| 1204 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); | 1201 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); |
| 1205 if (!observer) { | 1202 if (!observer) { |
| 1206 observer = CreatePlatformEventObserverFromType(type); | 1203 observer = CreatePlatformEventObserverFromType(type); |
| 1207 if (!observer) | 1204 if (!observer) |
| 1208 return; | 1205 return; |
| 1209 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type)); | 1206 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type)); |
| 1210 } | 1207 } |
| 1211 observer->Start(listener); | 1208 observer->Start(listener); |
| 1212 | 1209 |
| 1213 // Device events (motion, orientation and light) expect to get an event fired | 1210 // Device events (motion, orientation and light) expect to get an event fired |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 if (!data) | 1250 if (!data) |
| 1254 return; | 1251 return; |
| 1255 | 1252 |
| 1256 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1253 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1257 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, | 1254 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, |
| 1258 base::Unretained(observer), data)); | 1255 base::Unretained(observer), data)); |
| 1259 } | 1256 } |
| 1260 | 1257 |
| 1261 void RendererBlinkPlatformImpl::stopListening( | 1258 void RendererBlinkPlatformImpl::stopListening( |
| 1262 blink::WebPlatformEventType type) { | 1259 blink::WebPlatformEventType type) { |
| 1263 if (type == blink::WebPlatformEventTypeBattery) { | |
| 1264 g_test_battery_status_listener = nullptr; | |
| 1265 battery_status_dispatcher_.reset(); | |
| 1266 return; | |
| 1267 } | |
| 1268 | |
| 1269 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); | 1260 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); |
| 1270 if (!observer) | 1261 if (!observer) |
| 1271 return; | 1262 return; |
| 1272 observer->Stop(); | 1263 observer->Stop(); |
| 1273 } | 1264 } |
| 1274 | 1265 |
| 1275 //------------------------------------------------------------------------------ | 1266 //------------------------------------------------------------------------------ |
| 1276 | 1267 |
| 1277 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota( | 1268 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota( |
| 1278 const blink::WebURL& storage_partition, | 1269 const blink::WebURL& storage_partition, |
| 1279 blink::WebStorageQuotaType type, | 1270 blink::WebStorageQuotaType type, |
| 1280 blink::WebStorageQuotaCallbacks callbacks) { | 1271 blink::WebStorageQuotaCallbacks callbacks) { |
| 1281 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) | 1272 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) |
| 1282 return; | 1273 return; |
| 1283 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(), | 1274 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(), |
| 1284 quota_message_filter_.get()) | 1275 quota_message_filter_.get()) |
| 1285 ->QueryStorageUsageAndQuota( | 1276 ->QueryStorageUsageAndQuota( |
| 1286 storage_partition, | 1277 storage_partition, |
| 1287 static_cast<storage::StorageType>(type), | 1278 static_cast<storage::StorageType>(type), |
| 1288 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); | 1279 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
| 1289 } | 1280 } |
| 1290 | 1281 |
| 1291 //------------------------------------------------------------------------------ | |
| 1292 | |
| 1293 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( | |
| 1294 const blink::WebBatteryStatus& status) { | |
| 1295 if (!g_test_battery_status_listener) | |
| 1296 return; | |
| 1297 g_test_battery_status_listener->updateBatteryStatus(status); | |
| 1298 } | |
| 1299 | |
| 1300 } // namespace content | 1282 } // namespace content |
| OLD | NEW |