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" |
55 #include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h" | 56 #include "content/renderer/cache_storage/webserviceworkercachestorage_impl.h" |
56 #include "content/renderer/device_sensors/device_light_event_pump.h" | 57 #include "content/renderer/device_sensors/device_light_event_pump.h" |
57 #include "content/renderer/device_sensors/device_motion_event_pump.h" | 58 #include "content/renderer/device_sensors/device_motion_event_pump.h" |
58 #include "content/renderer/device_sensors/device_orientation_absolute_event_pump
.h" | 59 #include "content/renderer/device_sensors/device_orientation_absolute_event_pump
.h" |
59 #include "content/renderer/device_sensors/device_orientation_event_pump.h" | 60 #include "content/renderer/device_sensors/device_orientation_event_pump.h" |
60 #include "content/renderer/dom_storage/local_storage_namespace.h" | 61 #include "content/renderer/dom_storage/local_storage_namespace.h" |
61 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 62 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
62 #include "content/renderer/gamepad_shared_memory_reader.h" | 63 #include "content/renderer/gamepad_shared_memory_reader.h" |
63 #include "content/renderer/media/audio_decoder.h" | 64 #include "content/renderer/media/audio_decoder.h" |
64 #include "content/renderer/media/canvas_capture_handler.h" | 65 #include "content/renderer/media/canvas_capture_handler.h" |
(...skipping 12 matching lines...) Expand all Loading... |
77 #include "ipc/ipc_sync_message_filter.h" | 78 #include "ipc/ipc_sync_message_filter.h" |
78 #include "media/audio/audio_output_device.h" | 79 #include "media/audio/audio_output_device.h" |
79 #include "media/base/audio_hardware_config.h" | 80 #include "media/base/audio_hardware_config.h" |
80 #include "media/base/mime_util.h" | 81 #include "media/base/mime_util.h" |
81 #include "media/blink/webcontentdecryptionmodule_impl.h" | 82 #include "media/blink/webcontentdecryptionmodule_impl.h" |
82 #include "media/filters/stream_parser_factory.h" | 83 #include "media/filters/stream_parser_factory.h" |
83 #include "storage/common/database/database_identifier.h" | 84 #include "storage/common/database/database_identifier.h" |
84 #include "storage/common/quota/quota_types.h" | 85 #include "storage/common/quota/quota_types.h" |
85 #include "third_party/WebKit/public/platform/FilePathConversion.h" | 86 #include "third_party/WebKit/public/platform/FilePathConversion.h" |
86 #include "third_party/WebKit/public/platform/URLConversion.h" | 87 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 88 #include "third_party/WebKit/public/platform/WebBatteryStatusListener.h" |
87 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" | 89 #include "third_party/WebKit/public/platform/WebBlobRegistry.h" |
88 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" | 90 #include "third_party/WebKit/public/platform/WebDeviceLightListener.h" |
89 #include "third_party/WebKit/public/platform/WebFileInfo.h" | 91 #include "third_party/WebKit/public/platform/WebFileInfo.h" |
90 #include "third_party/WebKit/public/platform/WebGamepads.h" | 92 #include "third_party/WebKit/public/platform/WebGamepads.h" |
91 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" | 93 #include "third_party/WebKit/public/platform/WebMediaStreamCenter.h" |
92 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" | 94 #include "third_party/WebKit/public/platform/WebMediaStreamCenterClient.h" |
93 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" | 95 #include "third_party/WebKit/public/platform/WebPluginListBuilder.h" |
94 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 96 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
95 #include "third_party/WebKit/public/platform/WebURL.h" | 97 #include "third_party/WebKit/public/platform/WebURL.h" |
96 #include "third_party/WebKit/public/platform/WebVector.h" | 98 #include "third_party/WebKit/public/platform/WebVector.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 namespace content { | 171 namespace content { |
170 | 172 |
171 namespace { | 173 namespace { |
172 | 174 |
173 bool g_sandbox_enabled = true; | 175 bool g_sandbox_enabled = true; |
174 double g_test_device_light_data = -1; | 176 double g_test_device_light_data = -1; |
175 base::LazyInstance<blink::WebDeviceMotionData>::Leaky | 177 base::LazyInstance<blink::WebDeviceMotionData>::Leaky |
176 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; | 178 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; |
177 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky | 179 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky |
178 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; | 180 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; |
| 181 // Set in startListening() when running layout tests, unset in stopListening(), |
| 182 // not owned by us. |
| 183 blink::WebBatteryStatusListener* g_test_battery_status_listener = nullptr; |
179 | 184 |
180 } // namespace | 185 } // namespace |
181 | 186 |
182 //------------------------------------------------------------------------------ | 187 //------------------------------------------------------------------------------ |
183 | 188 |
184 class RendererBlinkPlatformImpl::MimeRegistry | 189 class RendererBlinkPlatformImpl::MimeRegistry |
185 : public SimpleWebMimeRegistryImpl { | 190 : public SimpleWebMimeRegistryImpl { |
186 public: | 191 public: |
187 blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( | 192 blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
188 const blink::WebString& mime_type, | 193 const blink::WebString& mime_type, |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " | 1151 DVLOG(1) << "RendererBlinkPlatformImpl::startListening() with " |
1147 "unknown type."; | 1152 "unknown type."; |
1148 } | 1153 } |
1149 | 1154 |
1150 return NULL; | 1155 return NULL; |
1151 } | 1156 } |
1152 | 1157 |
1153 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( | 1158 void RendererBlinkPlatformImpl::SetPlatformEventObserverForTesting( |
1154 blink::WebPlatformEventType type, | 1159 blink::WebPlatformEventType type, |
1155 scoped_ptr<PlatformEventObserverBase> observer) { | 1160 scoped_ptr<PlatformEventObserverBase> observer) { |
| 1161 DCHECK(type != blink::WebPlatformEventTypeBattery); |
| 1162 |
1156 if (platform_event_observers_.Lookup(type)) | 1163 if (platform_event_observers_.Lookup(type)) |
1157 platform_event_observers_.Remove(type); | 1164 platform_event_observers_.Remove(type); |
1158 platform_event_observers_.AddWithID(observer.release(), type); | 1165 platform_event_observers_.AddWithID(observer.release(), type); |
1159 } | 1166 } |
1160 | 1167 |
1161 void RendererBlinkPlatformImpl::connectToRemoteService( | |
1162 const char* name, | |
1163 mojo::ScopedMessagePipeHandle handle) { | |
1164 // In the layout test mode, mock services should be used instead. | |
1165 // TODO(yukishiino): We'd like to inject mock services implemented in | |
1166 // JavaScript. Remove the following hack once we support JS-bindings | |
1167 // of Mojo and service mocking in JS. | |
1168 if (RenderThreadImpl::current() && | |
1169 RenderThreadImpl::current()->layout_test_mode()) | |
1170 return; | |
1171 | |
1172 if (ServiceRegistry* registry = RenderThread::Get()->GetServiceRegistry()) { | |
1173 // registry can be null during testing. | |
1174 registry->ConnectToRemoteService(name, std::move(handle)); | |
1175 } | |
1176 } | |
1177 | |
1178 void RendererBlinkPlatformImpl::startListening( | 1168 void RendererBlinkPlatformImpl::startListening( |
1179 blink::WebPlatformEventType type, | 1169 blink::WebPlatformEventType type, |
1180 blink::WebPlatformEventListener* listener) { | 1170 blink::WebPlatformEventListener* listener) { |
| 1171 if (type == blink::WebPlatformEventTypeBattery) { |
| 1172 if (RenderThreadImpl::current() && |
| 1173 RenderThreadImpl::current()->layout_test_mode()) { |
| 1174 g_test_battery_status_listener = |
| 1175 static_cast<blink::WebBatteryStatusListener*>(listener); |
| 1176 } else { |
| 1177 battery_status_dispatcher_.reset(new BatteryStatusDispatcher( |
| 1178 static_cast<blink::WebBatteryStatusListener*>(listener))); |
| 1179 } |
| 1180 return; |
| 1181 } |
| 1182 |
1181 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); | 1183 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); |
1182 if (!observer) { | 1184 if (!observer) { |
1183 observer = CreatePlatformEventObserverFromType(type); | 1185 observer = CreatePlatformEventObserverFromType(type); |
1184 if (!observer) | 1186 if (!observer) |
1185 return; | 1187 return; |
1186 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type)); | 1188 platform_event_observers_.AddWithID(observer, static_cast<int32_t>(type)); |
1187 } | 1189 } |
1188 observer->Start(listener); | 1190 observer->Start(listener); |
1189 | 1191 |
1190 // Device events (motion, orientation and light) expect to get an event fired | 1192 // 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... |
1230 if (!data) | 1232 if (!data) |
1231 return; | 1233 return; |
1232 | 1234 |
1233 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1235 base::ThreadTaskRunnerHandle::Get()->PostTask( |
1234 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, | 1236 FROM_HERE, base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, |
1235 base::Unretained(observer), data)); | 1237 base::Unretained(observer), data)); |
1236 } | 1238 } |
1237 | 1239 |
1238 void RendererBlinkPlatformImpl::stopListening( | 1240 void RendererBlinkPlatformImpl::stopListening( |
1239 blink::WebPlatformEventType type) { | 1241 blink::WebPlatformEventType type) { |
| 1242 if (type == blink::WebPlatformEventTypeBattery) { |
| 1243 g_test_battery_status_listener = nullptr; |
| 1244 battery_status_dispatcher_.reset(); |
| 1245 return; |
| 1246 } |
| 1247 |
1240 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); | 1248 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); |
1241 if (!observer) | 1249 if (!observer) |
1242 return; | 1250 return; |
1243 observer->Stop(); | 1251 observer->Stop(); |
1244 } | 1252 } |
1245 | 1253 |
1246 //------------------------------------------------------------------------------ | 1254 //------------------------------------------------------------------------------ |
1247 | 1255 |
1248 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota( | 1256 void RendererBlinkPlatformImpl::queryStorageUsageAndQuota( |
1249 const blink::WebURL& storage_partition, | 1257 const blink::WebURL& storage_partition, |
1250 blink::WebStorageQuotaType type, | 1258 blink::WebStorageQuotaType type, |
1251 blink::WebStorageQuotaCallbacks callbacks) { | 1259 blink::WebStorageQuotaCallbacks callbacks) { |
1252 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) | 1260 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) |
1253 return; | 1261 return; |
1254 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(), | 1262 QuotaDispatcher::ThreadSpecificInstance(thread_safe_sender_.get(), |
1255 quota_message_filter_.get()) | 1263 quota_message_filter_.get()) |
1256 ->QueryStorageUsageAndQuota( | 1264 ->QueryStorageUsageAndQuota( |
1257 storage_partition, | 1265 storage_partition, |
1258 static_cast<storage::StorageType>(type), | 1266 static_cast<storage::StorageType>(type), |
1259 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); | 1267 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
1260 } | 1268 } |
1261 | 1269 |
1262 //------------------------------------------------------------------------------ | 1270 //------------------------------------------------------------------------------ |
1263 | 1271 |
| 1272 void RendererBlinkPlatformImpl::MockBatteryStatusChangedForTesting( |
| 1273 const blink::WebBatteryStatus& status) { |
| 1274 if (!g_test_battery_status_listener) |
| 1275 return; |
| 1276 g_test_battery_status_listener->updateBatteryStatus(status); |
| 1277 } |
| 1278 |
| 1279 //------------------------------------------------------------------------------ |
| 1280 |
1264 blink::WebTrialTokenValidator* | 1281 blink::WebTrialTokenValidator* |
1265 RendererBlinkPlatformImpl::trialTokenValidator() { | 1282 RendererBlinkPlatformImpl::trialTokenValidator() { |
1266 return &trial_token_validator_; | 1283 return &trial_token_validator_; |
1267 } | 1284 } |
1268 | 1285 |
1269 } // namespace content | 1286 } // namespace content |
OLD | NEW |