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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 43 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
44 #include "content/renderer/gamepad_shared_memory_reader.h" | 44 #include "content/renderer/gamepad_shared_memory_reader.h" |
45 #include "content/renderer/media/audio_decoder.h" | 45 #include "content/renderer/media/audio_decoder.h" |
46 #include "content/renderer/media/crypto/key_systems.h" | 46 #include "content/renderer/media/crypto/key_systems.h" |
47 #include "content/renderer/media/media_stream_dependency_factory.h" | 47 #include "content/renderer/media/media_stream_dependency_factory.h" |
48 #include "content/renderer/media/renderer_webaudiodevice_impl.h" | 48 #include "content/renderer/media/renderer_webaudiodevice_impl.h" |
49 #include "content/renderer/media/renderer_webmidiaccessor_impl.h" | 49 #include "content/renderer/media/renderer_webmidiaccessor_impl.h" |
50 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" | 50 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
51 #include "content/renderer/render_thread_impl.h" | 51 #include "content/renderer/render_thread_impl.h" |
52 #include "content/renderer/renderer_clipboard_client.h" | 52 #include "content/renderer/renderer_clipboard_client.h" |
| 53 #include "content/renderer/screen_orientation/mock_screen_orientation_controller
.h" |
53 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" | 54 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" |
54 #include "content/renderer/webclipboard_impl.h" | 55 #include "content/renderer/webclipboard_impl.h" |
55 #include "content/renderer/webgraphicscontext3d_provider_impl.h" | 56 #include "content/renderer/webgraphicscontext3d_provider_impl.h" |
56 #include "content/renderer/webpublicsuffixlist_impl.h" | 57 #include "content/renderer/webpublicsuffixlist_impl.h" |
57 #include "gpu/config/gpu_info.h" | 58 #include "gpu/config/gpu_info.h" |
58 #include "ipc/ipc_sync_message_filter.h" | 59 #include "ipc/ipc_sync_message_filter.h" |
59 #include "media/audio/audio_output_device.h" | 60 #include "media/audio/audio_output_device.h" |
60 #include "media/base/audio_hardware_config.h" | 61 #include "media/base/audio_hardware_config.h" |
61 #include "media/filters/stream_parser_factory.h" | 62 #include "media/filters/stream_parser_factory.h" |
62 #include "net/base/mime_util.h" | 63 #include "net/base/mime_util.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 using blink::WebMimeRegistry; | 131 using blink::WebMimeRegistry; |
131 using blink::WebRTCPeerConnectionHandler; | 132 using blink::WebRTCPeerConnectionHandler; |
132 using blink::WebRTCPeerConnectionHandlerClient; | 133 using blink::WebRTCPeerConnectionHandlerClient; |
133 using blink::WebStorageNamespace; | 134 using blink::WebStorageNamespace; |
134 using blink::WebString; | 135 using blink::WebString; |
135 using blink::WebURL; | 136 using blink::WebURL; |
136 using blink::WebVector; | 137 using blink::WebVector; |
137 | 138 |
138 namespace content { | 139 namespace content { |
139 | 140 |
| 141 namespace { |
| 142 |
140 static bool g_sandbox_enabled = true; | 143 static bool g_sandbox_enabled = true; |
141 static blink::WebGamepadListener* web_gamepad_listener = NULL; | 144 static blink::WebGamepadListener* web_gamepad_listener = NULL; |
142 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = | 145 base::LazyInstance<WebGamepads>::Leaky g_test_gamepads = |
143 LAZY_INSTANCE_INITIALIZER; | 146 LAZY_INSTANCE_INITIALIZER; |
144 base::LazyInstance<blink::WebDeviceMotionData>::Leaky | 147 base::LazyInstance<blink::WebDeviceMotionData>::Leaky |
145 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; | 148 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; |
146 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky | 149 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky |
147 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; | 150 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; |
148 static blink::WebScreenOrientationListener* | 151 base::LazyInstance<MockScreenOrientationController>::Leaky |
149 g_test_screen_orientation_listener = NULL; | 152 g_test_screen_orientation_controller = LAZY_INSTANCE_INITIALIZER; |
| 153 |
| 154 } // namespace |
150 | 155 |
151 //------------------------------------------------------------------------------ | 156 //------------------------------------------------------------------------------ |
152 | 157 |
153 class RendererWebKitPlatformSupportImpl::MimeRegistry | 158 class RendererWebKitPlatformSupportImpl::MimeRegistry |
154 : public SimpleWebMimeRegistryImpl { | 159 : public SimpleWebMimeRegistryImpl { |
155 public: | 160 public: |
156 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( | 161 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
157 const blink::WebString& mime_type, | 162 const blink::WebString& mime_type, |
158 const blink::WebString& codecs, | 163 const blink::WebString& codecs, |
159 const blink::WebString& key_system); | 164 const blink::WebString& key_system); |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 g_test_device_motion_data.Get())); | 1079 g_test_device_motion_data.Get())); |
1075 } | 1080 } |
1076 } | 1081 } |
1077 | 1082 |
1078 // static | 1083 // static |
1079 void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting( | 1084 void RendererWebKitPlatformSupportImpl::SetMockDeviceMotionDataForTesting( |
1080 const blink::WebDeviceMotionData& data) { | 1085 const blink::WebDeviceMotionData& data) { |
1081 g_test_device_motion_data.Get() = data; | 1086 g_test_device_motion_data.Get() = data; |
1082 } | 1087 } |
1083 | 1088 |
| 1089 // static |
| 1090 void RendererWebKitPlatformSupportImpl::ResetMockScreenOrientationForTesting() |
| 1091 { |
| 1092 g_test_screen_orientation_controller.Get().ResetData(); |
| 1093 } |
| 1094 |
1084 //------------------------------------------------------------------------------ | 1095 //------------------------------------------------------------------------------ |
1085 | 1096 |
1086 void RendererWebKitPlatformSupportImpl::setDeviceOrientationListener( | 1097 void RendererWebKitPlatformSupportImpl::setDeviceOrientationListener( |
1087 blink::WebDeviceOrientationListener* listener) { | 1098 blink::WebDeviceOrientationListener* listener) { |
1088 if (g_test_device_orientation_data == 0) { | 1099 if (g_test_device_orientation_data == 0) { |
1089 if (!device_orientation_event_pump_) { | 1100 if (!device_orientation_event_pump_) { |
1090 device_orientation_event_pump_.reset(new DeviceOrientationEventPump); | 1101 device_orientation_event_pump_.reset(new DeviceOrientationEventPump); |
1091 device_orientation_event_pump_->Attach(RenderThreadImpl::current()); | 1102 device_orientation_event_pump_->Attach(RenderThreadImpl::current()); |
1092 } | 1103 } |
1093 device_orientation_event_pump_->SetListener(listener); | 1104 device_orientation_event_pump_->SetListener(listener); |
(...skipping 28 matching lines...) Expand all Loading... |
1122 //------------------------------------------------------------------------------ | 1133 //------------------------------------------------------------------------------ |
1123 | 1134 |
1124 void RendererWebKitPlatformSupportImpl::setScreenOrientationListener( | 1135 void RendererWebKitPlatformSupportImpl::setScreenOrientationListener( |
1125 blink::WebScreenOrientationListener* listener) { | 1136 blink::WebScreenOrientationListener* listener) { |
1126 if (RenderThreadImpl::current() && | 1137 if (RenderThreadImpl::current() && |
1127 RenderThreadImpl::current()->layout_test_mode()) { | 1138 RenderThreadImpl::current()->layout_test_mode()) { |
1128 // If we are in test mode, we want to fully disable the screen orientation | 1139 // If we are in test mode, we want to fully disable the screen orientation |
1129 // backend in order to let Blink get tested properly, That means that screen | 1140 // backend in order to let Blink get tested properly, That means that screen |
1130 // orientation updates have to be done manually instead of from signals sent | 1141 // orientation updates have to be done manually instead of from signals sent |
1131 // by the browser process. | 1142 // by the browser process. |
1132 g_test_screen_orientation_listener = listener; | 1143 g_test_screen_orientation_controller.Get().SetListener(listener); |
1133 return; | 1144 return; |
1134 } | 1145 } |
1135 | 1146 |
1136 if (!screen_orientation_dispatcher_) { | 1147 if (!screen_orientation_dispatcher_) { |
1137 screen_orientation_dispatcher_.reset( | 1148 screen_orientation_dispatcher_.reset( |
1138 new ScreenOrientationDispatcher(RenderThread::Get())); | 1149 new ScreenOrientationDispatcher(RenderThread::Get())); |
1139 } | 1150 } |
1140 | 1151 |
1141 screen_orientation_dispatcher_->setListener(listener); | 1152 screen_orientation_dispatcher_->setListener(listener); |
1142 } | 1153 } |
1143 | 1154 |
1144 void RendererWebKitPlatformSupportImpl::lockOrientation( | 1155 void RendererWebKitPlatformSupportImpl::lockOrientation( |
1145 blink::WebScreenOrientationLockType orientation) { | 1156 blink::WebScreenOrientationLockType orientation) { |
1146 if (RenderThreadImpl::current() && | 1157 if (RenderThreadImpl::current() && |
1147 RenderThreadImpl::current()->layout_test_mode()) { | 1158 RenderThreadImpl::current()->layout_test_mode()) { |
| 1159 g_test_screen_orientation_controller.Get().UpdateLock(orientation); |
1148 return; | 1160 return; |
1149 } | 1161 } |
1150 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Lock(orientation)); | 1162 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Lock(orientation)); |
1151 } | 1163 } |
1152 | 1164 |
1153 void RendererWebKitPlatformSupportImpl::unlockOrientation() { | 1165 void RendererWebKitPlatformSupportImpl::unlockOrientation() { |
1154 if (RenderThreadImpl::current() && | 1166 if (RenderThreadImpl::current() && |
1155 RenderThreadImpl::current()->layout_test_mode()) { | 1167 RenderThreadImpl::current()->layout_test_mode()) { |
| 1168 g_test_screen_orientation_controller.Get().ResetLock(); |
1156 return; | 1169 return; |
1157 } | 1170 } |
1158 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Unlock); | 1171 RenderThread::Get()->Send(new ScreenOrientationHostMsg_Unlock); |
1159 } | 1172 } |
1160 | 1173 |
1161 // static | 1174 // static |
1162 void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting( | 1175 void RendererWebKitPlatformSupportImpl::SetMockScreenOrientationForTesting( |
1163 blink::WebScreenOrientationType orientation) { | 1176 blink::WebScreenOrientationType orientation) { |
1164 if (!g_test_screen_orientation_listener) | 1177 g_test_screen_orientation_controller.Get() |
1165 return; | 1178 .UpdateDeviceOrientation(orientation); |
1166 g_test_screen_orientation_listener->didChangeScreenOrientation(orientation); | |
1167 } | 1179 } |
1168 | 1180 |
1169 //------------------------------------------------------------------------------ | 1181 //------------------------------------------------------------------------------ |
1170 | 1182 |
1171 void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota( | 1183 void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota( |
1172 const blink::WebURL& storage_partition, | 1184 const blink::WebURL& storage_partition, |
1173 blink::WebStorageQuotaType type, | 1185 blink::WebStorageQuotaType type, |
1174 blink::WebStorageQuotaCallbacks callbacks) { | 1186 blink::WebStorageQuotaCallbacks callbacks) { |
1175 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) | 1187 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) |
1176 return; | 1188 return; |
1177 QuotaDispatcher::ThreadSpecificInstance( | 1189 QuotaDispatcher::ThreadSpecificInstance( |
1178 thread_safe_sender_.get(), | 1190 thread_safe_sender_.get(), |
1179 quota_message_filter_.get())->QueryStorageUsageAndQuota( | 1191 quota_message_filter_.get())->QueryStorageUsageAndQuota( |
1180 storage_partition, | 1192 storage_partition, |
1181 static_cast<quota::StorageType>(type), | 1193 static_cast<quota::StorageType>(type), |
1182 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); | 1194 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
1183 } | 1195 } |
1184 | 1196 |
1185 } // namespace content | 1197 } // namespace content |
OLD | NEW |