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 15 matching lines...) Expand all Loading... |
26 #include "content/child/web_database_observer_impl.h" | 26 #include "content/child/web_database_observer_impl.h" |
27 #include "content/child/webblobregistry_impl.h" | 27 #include "content/child/webblobregistry_impl.h" |
28 #include "content/child/webfileutilities_impl.h" | 28 #include "content/child/webfileutilities_impl.h" |
29 #include "content/child/webmessageportchannel_impl.h" | 29 #include "content/child/webmessageportchannel_impl.h" |
30 #include "content/common/file_utilities_messages.h" | 30 #include "content/common/file_utilities_messages.h" |
31 #include "content/common/gpu/client/context_provider_command_buffer.h" | 31 #include "content/common/gpu/client/context_provider_command_buffer.h" |
32 #include "content/common/gpu/client/gpu_channel_host.h" | 32 #include "content/common/gpu/client/gpu_channel_host.h" |
33 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 33 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
34 #include "content/common/gpu/gpu_process_launch_causes.h" | 34 #include "content/common/gpu/gpu_process_launch_causes.h" |
35 #include "content/common/mime_registry_messages.h" | 35 #include "content/common/mime_registry_messages.h" |
36 #include "content/common/screen_orientation_messages.h" | |
37 #include "content/common/view_messages.h" | 36 #include "content/common/view_messages.h" |
38 #include "content/public/common/content_switches.h" | 37 #include "content/public/common/content_switches.h" |
39 #include "content/public/common/webplugininfo.h" | 38 #include "content/public/common/webplugininfo.h" |
40 #include "content/public/renderer/content_renderer_client.h" | 39 #include "content/public/renderer/content_renderer_client.h" |
41 #include "content/renderer/battery_status/battery_status_dispatcher.h" | 40 #include "content/renderer/battery_status/battery_status_dispatcher.h" |
42 #include "content/renderer/battery_status/fake_battery_status_dispatcher.h" | |
43 #include "content/renderer/device_sensors/device_light_event_pump.h" | 41 #include "content/renderer/device_sensors/device_light_event_pump.h" |
44 #include "content/renderer/device_sensors/device_motion_event_pump.h" | 42 #include "content/renderer/device_sensors/device_motion_event_pump.h" |
45 #include "content/renderer/device_sensors/device_orientation_event_pump.h" | 43 #include "content/renderer/device_sensors/device_orientation_event_pump.h" |
46 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 44 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
47 #include "content/renderer/gamepad_shared_memory_reader.h" | 45 #include "content/renderer/gamepad_shared_memory_reader.h" |
48 #include "content/renderer/media/audio_decoder.h" | 46 #include "content/renderer/media/audio_decoder.h" |
49 #include "content/renderer/media/crypto/key_systems.h" | 47 #include "content/renderer/media/crypto/key_systems.h" |
50 #include "content/renderer/media/renderer_webaudiodevice_impl.h" | 48 #include "content/renderer/media/renderer_webaudiodevice_impl.h" |
51 #include "content/renderer/media/renderer_webmidiaccessor_impl.h" | 49 #include "content/renderer/media/renderer_webmidiaccessor_impl.h" |
52 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" | 50 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
53 #include "content/renderer/render_thread_impl.h" | 51 #include "content/renderer/render_thread_impl.h" |
54 #include "content/renderer/renderer_clipboard_client.h" | 52 #include "content/renderer/renderer_clipboard_client.h" |
| 53 #include "content/renderer/screen_orientation/screen_orientation_observer.h" |
55 #include "content/renderer/webclipboard_impl.h" | 54 #include "content/renderer/webclipboard_impl.h" |
56 #include "content/renderer/webgraphicscontext3d_provider_impl.h" | 55 #include "content/renderer/webgraphicscontext3d_provider_impl.h" |
57 #include "content/renderer/webpublicsuffixlist_impl.h" | 56 #include "content/renderer/webpublicsuffixlist_impl.h" |
58 #include "gpu/config/gpu_info.h" | 57 #include "gpu/config/gpu_info.h" |
59 #include "ipc/ipc_sync_message_filter.h" | 58 #include "ipc/ipc_sync_message_filter.h" |
60 #include "media/audio/audio_output_device.h" | 59 #include "media/audio/audio_output_device.h" |
61 #include "media/base/audio_hardware_config.h" | 60 #include "media/base/audio_hardware_config.h" |
62 #include "media/filters/stream_parser_factory.h" | 61 #include "media/filters/stream_parser_factory.h" |
63 #include "net/base/mime_util.h" | 62 #include "net/base/mime_util.h" |
64 #include "net/base/net_util.h" | 63 #include "net/base/net_util.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 namespace content { | 143 namespace content { |
145 | 144 |
146 namespace { | 145 namespace { |
147 | 146 |
148 bool g_sandbox_enabled = true; | 147 bool g_sandbox_enabled = true; |
149 double g_test_device_light_data = -1; | 148 double g_test_device_light_data = -1; |
150 base::LazyInstance<blink::WebDeviceMotionData>::Leaky | 149 base::LazyInstance<blink::WebDeviceMotionData>::Leaky |
151 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; | 150 g_test_device_motion_data = LAZY_INSTANCE_INITIALIZER; |
152 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky | 151 base::LazyInstance<blink::WebDeviceOrientationData>::Leaky |
153 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; | 152 g_test_device_orientation_data = LAZY_INSTANCE_INITIALIZER; |
154 base::LazyInstance<FakeBatteryStatusDispatcher>::Leaky | |
155 g_test_battery_status_dispatcher = LAZY_INSTANCE_INITIALIZER; | |
156 | 153 |
157 } // namespace | 154 } // namespace |
158 | 155 |
159 //------------------------------------------------------------------------------ | 156 //------------------------------------------------------------------------------ |
160 | 157 |
161 class RendererWebKitPlatformSupportImpl::MimeRegistry | 158 class RendererWebKitPlatformSupportImpl::MimeRegistry |
162 : public SimpleWebMimeRegistryImpl { | 159 : public SimpleWebMimeRegistryImpl { |
163 public: | 160 public: |
164 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( | 161 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( |
165 const blink::WebString& mime_type, | 162 const blink::WebString& mime_type, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 222 |
226 //------------------------------------------------------------------------------ | 223 //------------------------------------------------------------------------------ |
227 | 224 |
228 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() | 225 RendererWebKitPlatformSupportImpl::RendererWebKitPlatformSupportImpl() |
229 : clipboard_client_(new RendererClipboardClient), | 226 : clipboard_client_(new RendererClipboardClient), |
230 clipboard_(new WebClipboardImpl(clipboard_client_.get())), | 227 clipboard_(new WebClipboardImpl(clipboard_client_.get())), |
231 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), | 228 mime_registry_(new RendererWebKitPlatformSupportImpl::MimeRegistry), |
232 sudden_termination_disables_(0), | 229 sudden_termination_disables_(0), |
233 plugin_refresh_allowed_(true), | 230 plugin_refresh_allowed_(true), |
234 child_thread_loop_(base::MessageLoopProxy::current()), | 231 child_thread_loop_(base::MessageLoopProxy::current()), |
235 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl), | 232 web_scrollbar_behavior_(new WebScrollbarBehaviorImpl) { |
236 gamepad_provider_(NULL) { | |
237 if (g_sandbox_enabled && sandboxEnabled()) { | 233 if (g_sandbox_enabled && sandboxEnabled()) { |
238 sandbox_support_.reset( | 234 sandbox_support_.reset( |
239 new RendererWebKitPlatformSupportImpl::SandboxSupport); | 235 new RendererWebKitPlatformSupportImpl::SandboxSupport); |
240 } else { | 236 } else { |
241 DVLOG(1) << "Disabling sandbox support for testing."; | 237 DVLOG(1) << "Disabling sandbox support for testing."; |
242 } | 238 } |
243 | 239 |
244 // ChildThread may not exist in some tests. | 240 // ChildThread may not exist in some tests. |
245 if (ChildThread::current()) { | 241 if (ChildThread::current()) { |
246 sync_message_filter_ = ChildThread::current()->sync_message_filter(); | 242 sync_message_filter_ = ChildThread::current()->sync_message_filter(); |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 //------------------------------------------------------------------------------ | 862 //------------------------------------------------------------------------------ |
867 | 863 |
868 WebBlobRegistry* RendererWebKitPlatformSupportImpl::blobRegistry() { | 864 WebBlobRegistry* RendererWebKitPlatformSupportImpl::blobRegistry() { |
869 // blob_registry_ can be NULL when running some tests. | 865 // blob_registry_ can be NULL when running some tests. |
870 return blob_registry_.get(); | 866 return blob_registry_.get(); |
871 } | 867 } |
872 | 868 |
873 //------------------------------------------------------------------------------ | 869 //------------------------------------------------------------------------------ |
874 | 870 |
875 void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) { | 871 void RendererWebKitPlatformSupportImpl::sampleGamepads(WebGamepads& gamepads) { |
876 DCHECK(gamepad_provider_); | 872 PlatformEventObserverBase* observer = |
877 gamepad_provider_->SampleGamepads(gamepads); | 873 platform_event_observers_.Lookup(blink::WebPlatformEventGamepad); |
| 874 if (!observer) |
| 875 return; |
| 876 static_cast<RendererGamepadProvider*>(observer)->SampleGamepads(gamepads); |
878 } | 877 } |
879 | 878 |
880 //------------------------------------------------------------------------------ | 879 //------------------------------------------------------------------------------ |
881 | 880 |
882 WebRTCPeerConnectionHandler* | 881 WebRTCPeerConnectionHandler* |
883 RendererWebKitPlatformSupportImpl::createRTCPeerConnectionHandler( | 882 RendererWebKitPlatformSupportImpl::createRTCPeerConnectionHandler( |
884 WebRTCPeerConnectionHandlerClient* client) { | 883 WebRTCPeerConnectionHandlerClient* client) { |
885 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 884 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
886 DCHECK(render_thread); | 885 DCHECK(render_thread); |
887 if (!render_thread) | 886 if (!render_thread) |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 RenderThread::Get()->Send( | 1031 RenderThread::Get()->Send( |
1033 new ViewHostMsg_Vibrate(base::checked_cast<int64>(milliseconds))); | 1032 new ViewHostMsg_Vibrate(base::checked_cast<int64>(milliseconds))); |
1034 } | 1033 } |
1035 | 1034 |
1036 void RendererWebKitPlatformSupportImpl::cancelVibration() { | 1035 void RendererWebKitPlatformSupportImpl::cancelVibration() { |
1037 RenderThread::Get()->Send(new ViewHostMsg_CancelVibration()); | 1036 RenderThread::Get()->Send(new ViewHostMsg_CancelVibration()); |
1038 } | 1037 } |
1039 | 1038 |
1040 //------------------------------------------------------------------------------ | 1039 //------------------------------------------------------------------------------ |
1041 | 1040 |
1042 void RendererWebKitPlatformSupportImpl::startListening( | 1041 // static |
1043 blink::WebPlatformEventType type, | 1042 PlatformEventObserverBase* |
1044 blink::WebPlatformEventListener* listener) { | 1043 RendererWebKitPlatformSupportImpl::CreatePlatformEventObserverFromType( |
| 1044 blink::WebPlatformEventType type) { |
| 1045 RenderThread* thread = RenderThreadImpl::current(); |
| 1046 |
| 1047 // When running layout tests, those observers should not listen to the actual |
| 1048 // hardware changes. In order to make that happen, they will receive a null |
| 1049 // thread. |
| 1050 if (thread && RenderThreadImpl::current()->layout_test_mode()) |
| 1051 thread = 0; |
| 1052 |
1045 switch (type) { | 1053 switch (type) { |
1046 case blink::WebPlatformEventDeviceMotion: | 1054 case blink::WebPlatformEventDeviceMotion: { |
1047 SetDeviceMotionListener( | 1055 return new DeviceMotionEventPump(thread); |
1048 static_cast<blink::WebDeviceMotionListener*>(listener)); | 1056 } |
1049 break; | 1057 case blink::WebPlatformEventDeviceOrientation: { |
1050 case blink::WebPlatformEventDeviceOrientation: | 1058 return new DeviceOrientationEventPump(thread); |
1051 SetDeviceOrientationListener( | 1059 } |
1052 static_cast<blink::WebDeviceOrientationListener*>(listener)); | 1060 case blink::WebPlatformEventDeviceLight: { |
1053 break; | 1061 return new DeviceLightEventPump(thread); |
1054 case blink::WebPlatformEventDeviceLight: | 1062 } |
1055 SetDeviceLightListener( | 1063 case blink::WebPlatformEventBattery: { |
1056 static_cast<blink::WebDeviceLightListener*>(listener)); | 1064 return new BatteryStatusDispatcher(thread); |
1057 break; | 1065 } |
1058 case blink::WebPlatformEventBattery: | |
1059 SetBatteryStatusListener( | |
1060 static_cast<blink::WebBatteryStatusListener*>(listener)); | |
1061 break; | |
1062 case blink::WebPlatformEventGamepad: | 1066 case blink::WebPlatformEventGamepad: |
1063 SetGamepadListener( | 1067 return new GamepadSharedMemoryReader(thread); |
1064 static_cast<blink::WebGamepadListener*>(listener)); | |
1065 break; | 1068 break; |
1066 case blink::WebPlatformEventScreenOrientation: | 1069 case blink::WebPlatformEventScreenOrientation: |
1067 RenderThread::Get()->Send(new ScreenOrientationHostMsg_StartListening()); | 1070 return new ScreenOrientationObserver(); |
1068 break; | |
1069 default: | 1071 default: |
1070 // A default statement is required to prevent compilation errors when Blink | 1072 // A default statement is required to prevent compilation errors when Blink |
1071 // adds a new type. | 1073 // adds a new type. |
1072 VLOG(1) << "RendererWebKitPlatformSupportImpl::startListening() with " | 1074 VLOG(1) << "RendererWebKitPlatformSupportImpl::startListening() with " |
1073 "unknown type."; | 1075 "unknown type."; |
1074 } | 1076 } |
| 1077 |
| 1078 return 0; |
| 1079 } |
| 1080 |
| 1081 void RendererWebKitPlatformSupportImpl::SetPlatformEventObserverForTesting( |
| 1082 blink::WebPlatformEventType type, |
| 1083 scoped_ptr<PlatformEventObserverBase> observer) { |
| 1084 if (platform_event_observers_.Lookup(type)) |
| 1085 platform_event_observers_.Remove(type); |
| 1086 platform_event_observers_.AddWithID(observer.release(), type); |
| 1087 } |
| 1088 |
| 1089 void RendererWebKitPlatformSupportImpl::startListening( |
| 1090 blink::WebPlatformEventType type, |
| 1091 blink::WebPlatformEventListener* listener) { |
| 1092 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); |
| 1093 if (!observer) { |
| 1094 observer = CreatePlatformEventObserverFromType(type); |
| 1095 if (!observer) |
| 1096 return; |
| 1097 platform_event_observers_.AddWithID(observer, static_cast<int32>(type)); |
| 1098 } |
| 1099 observer->Start(listener); |
| 1100 |
| 1101 // Device events (motion, orientation and light) expect to get an event fired |
| 1102 // as soon as a listener is registered if a fake data was passed before. |
| 1103 // TODO(mlamouri,timvolodine): make those send mock values directly instead of |
| 1104 // using this broken pattern. |
| 1105 if (RenderThreadImpl::current() && |
| 1106 RenderThreadImpl::current()->layout_test_mode() && |
| 1107 (type == blink::WebPlatformEventDeviceMotion || |
| 1108 type == blink::WebPlatformEventDeviceOrientation || |
| 1109 type == blink::WebPlatformEventDeviceLight)) { |
| 1110 SendFakeDeviceEventDataForTesting(type); |
| 1111 } |
| 1112 } |
| 1113 |
| 1114 void RendererWebKitPlatformSupportImpl::SendFakeDeviceEventDataForTesting( |
| 1115 blink::WebPlatformEventType type) { |
| 1116 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); |
| 1117 CHECK(observer); |
| 1118 |
| 1119 void* data = 0; |
| 1120 |
| 1121 switch (type) { |
| 1122 case blink::WebPlatformEventDeviceMotion: |
| 1123 if (!(g_test_device_motion_data == 0)) |
| 1124 data = &g_test_device_motion_data.Get(); |
| 1125 break; |
| 1126 case blink::WebPlatformEventDeviceOrientation: |
| 1127 if (!(g_test_device_orientation_data == 0)) |
| 1128 data = &g_test_device_orientation_data.Get(); |
| 1129 break; |
| 1130 case blink::WebPlatformEventDeviceLight: |
| 1131 if (g_test_device_light_data >= 0) |
| 1132 data = &g_test_device_light_data; |
| 1133 break; |
| 1134 default: |
| 1135 NOTREACHED(); |
| 1136 break; |
| 1137 } |
| 1138 |
| 1139 if (!data) |
| 1140 return; |
| 1141 |
| 1142 base::MessageLoopProxy::current()->PostTask( |
| 1143 FROM_HERE, |
| 1144 base::Bind(&PlatformEventObserverBase::SendFakeDataForTesting, |
| 1145 base::Unretained(observer), data)); |
1075 } | 1146 } |
1076 | 1147 |
1077 void RendererWebKitPlatformSupportImpl::stopListening( | 1148 void RendererWebKitPlatformSupportImpl::stopListening( |
1078 blink::WebPlatformEventType type) { | 1149 blink::WebPlatformEventType type) { |
1079 switch (type) { | 1150 PlatformEventObserverBase* observer = platform_event_observers_.Lookup(type); |
1080 case blink::WebPlatformEventDeviceMotion: | 1151 if (!observer) |
1081 SetDeviceMotionListener(0); | |
1082 break; | |
1083 case blink::WebPlatformEventDeviceOrientation: | |
1084 SetDeviceOrientationListener(0); | |
1085 break; | |
1086 case blink::WebPlatformEventDeviceLight: | |
1087 SetDeviceLightListener(0); | |
1088 break; | |
1089 case blink::WebPlatformEventBattery: | |
1090 SetBatteryStatusListener(0); | |
1091 break; | |
1092 case blink::WebPlatformEventGamepad: | |
1093 SetGamepadListener(0); | |
1094 break; | |
1095 case blink::WebPlatformEventScreenOrientation: | |
1096 RenderThread::Get()->Send(new ScreenOrientationHostMsg_StopListening()); | |
1097 break; | |
1098 default: | |
1099 // A default statement is required to prevent compilation errors when Blink | |
1100 // adds a new type. | |
1101 VLOG(1) << "RendererWebKitPlatformSupportImpl::stopListening() with " | |
1102 "unknown type."; | |
1103 } | |
1104 } | |
1105 | |
1106 void RendererWebKitPlatformSupportImpl::SetDeviceMotionListener( | |
1107 blink::WebDeviceMotionListener* listener) { | |
1108 if (g_test_device_motion_data == 0) { | |
1109 if (!device_motion_event_pump_) { | |
1110 device_motion_event_pump_.reset(new DeviceMotionEventPump); | |
1111 device_motion_event_pump_->Attach(RenderThreadImpl::current()); | |
1112 } | |
1113 device_motion_event_pump_->SetListener(listener); | |
1114 } else if (listener) { | |
1115 // Testing mode: just echo the test data to the listener. | |
1116 base::MessageLoopProxy::current()->PostTask( | |
1117 FROM_HERE, | |
1118 base::Bind(&blink::WebDeviceMotionListener::didChangeDeviceMotion, | |
1119 base::Unretained(listener), | |
1120 g_test_device_motion_data.Get())); | |
1121 } | |
1122 } | |
1123 | |
1124 void RendererWebKitPlatformSupportImpl::SetDeviceOrientationListener( | |
1125 blink::WebDeviceOrientationListener* listener) { | |
1126 if (g_test_device_orientation_data == 0) { | |
1127 if (!device_orientation_event_pump_) { | |
1128 device_orientation_event_pump_.reset(new DeviceOrientationEventPump); | |
1129 device_orientation_event_pump_->Attach(RenderThreadImpl::current()); | |
1130 } | |
1131 device_orientation_event_pump_->SetListener(listener); | |
1132 } else if (listener) { | |
1133 // Testing mode: just echo the test data to the listener. | |
1134 base::MessageLoopProxy::current()->PostTask( | |
1135 FROM_HERE, | |
1136 base::Bind( | |
1137 &blink::WebDeviceOrientationListener::didChangeDeviceOrientation, | |
1138 base::Unretained(listener), | |
1139 g_test_device_orientation_data.Get())); | |
1140 } | |
1141 } | |
1142 | |
1143 void RendererWebKitPlatformSupportImpl::SetDeviceLightListener( | |
1144 blink::WebDeviceLightListener* listener) { | |
1145 if (g_test_device_light_data < 0) { | |
1146 if (!device_light_event_pump_) { | |
1147 device_light_event_pump_.reset(new DeviceLightEventPump); | |
1148 device_light_event_pump_->Attach(RenderThreadImpl::current()); | |
1149 } | |
1150 device_light_event_pump_->SetListener(listener); | |
1151 } else if (listener) { | |
1152 // Testing mode: just echo the test data to the listener. | |
1153 base::MessageLoopProxy::current()->PostTask( | |
1154 FROM_HERE, | |
1155 base::Bind(&blink::WebDeviceLightListener::didChangeDeviceLight, | |
1156 base::Unretained(listener), | |
1157 g_test_device_light_data)); | |
1158 } | |
1159 } | |
1160 | |
1161 void RendererWebKitPlatformSupportImpl::SetGamepadListener( | |
1162 blink::WebGamepadListener* listener) { | |
1163 DCHECK(gamepad_provider_); | |
1164 gamepad_provider_->SetGamepadListener(listener); | |
1165 } | |
1166 | |
1167 void RendererWebKitPlatformSupportImpl::SetBatteryStatusListener( | |
1168 blink::WebBatteryStatusListener* listener) { | |
1169 if (RenderThreadImpl::current() && | |
1170 RenderThreadImpl::current()->layout_test_mode()) { | |
1171 // If we are in test mode, we want to use a fake battery status dispatcher, | |
1172 // which does not communicate with the browser process. Battery status | |
1173 // changes are signalled by invoking MockBatteryStatusChangedForTesting(). | |
1174 g_test_battery_status_dispatcher.Get().SetListener(listener); | |
1175 return; | 1152 return; |
1176 } | 1153 observer->Stop(); |
1177 | |
1178 if (!battery_status_dispatcher_) { | |
1179 battery_status_dispatcher_.reset( | |
1180 new BatteryStatusDispatcher(RenderThreadImpl::current())); | |
1181 } | |
1182 battery_status_dispatcher_->SetListener(listener); | |
1183 } | 1154 } |
1184 | 1155 |
1185 //------------------------------------------------------------------------------ | 1156 //------------------------------------------------------------------------------ |
1186 | 1157 |
1187 void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota( | 1158 void RendererWebKitPlatformSupportImpl::queryStorageUsageAndQuota( |
1188 const blink::WebURL& storage_partition, | 1159 const blink::WebURL& storage_partition, |
1189 blink::WebStorageQuotaType type, | 1160 blink::WebStorageQuotaType type, |
1190 blink::WebStorageQuotaCallbacks callbacks) { | 1161 blink::WebStorageQuotaCallbacks callbacks) { |
1191 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) | 1162 if (!thread_safe_sender_.get() || !quota_message_filter_.get()) |
1192 return; | 1163 return; |
1193 QuotaDispatcher::ThreadSpecificInstance( | 1164 QuotaDispatcher::ThreadSpecificInstance( |
1194 thread_safe_sender_.get(), | 1165 thread_safe_sender_.get(), |
1195 quota_message_filter_.get())->QueryStorageUsageAndQuota( | 1166 quota_message_filter_.get())->QueryStorageUsageAndQuota( |
1196 storage_partition, | 1167 storage_partition, |
1197 static_cast<quota::StorageType>(type), | 1168 static_cast<quota::StorageType>(type), |
1198 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); | 1169 QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
1199 } | 1170 } |
1200 | 1171 |
1201 //------------------------------------------------------------------------------ | 1172 //------------------------------------------------------------------------------ |
1202 | 1173 |
1203 // static | |
1204 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( | 1174 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( |
1205 const blink::WebBatteryStatus& status) { | 1175 const blink::WebBatteryStatus& status) { |
1206 g_test_battery_status_dispatcher.Get().PostBatteryStatusChange(status); | 1176 PlatformEventObserverBase* observer = |
| 1177 platform_event_observers_.Lookup(blink::WebPlatformEventBattery); |
| 1178 if (!observer) |
| 1179 return; |
| 1180 observer->SendFakeDataForTesting((void*)&status); |
1207 } | 1181 } |
1208 | 1182 |
1209 } // namespace content | 1183 } // namespace content |
OLD | NEW |