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 #ifndef CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_ |
6 #define CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_ | 6 #define CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/id_map.h" |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "cc/blink/web_compositor_support_impl.h" | 11 #include "cc/blink/web_compositor_support_impl.h" |
11 #include "content/child/blink_platform_impl.h" | 12 #include "content/child/blink_platform_impl.h" |
12 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
13 #include "content/renderer/webpublicsuffixlist_impl.h" | 14 #include "content/renderer/webpublicsuffixlist_impl.h" |
14 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" | 15 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h" |
15 #include "third_party/WebKit/public/platform/WebIDBFactory.h" | 16 #include "third_party/WebKit/public/platform/WebIDBFactory.h" |
16 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h" | 17 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
(...skipping 13 matching lines...) Expand all Loading... |
32 class WebDeviceMotionData; | 33 class WebDeviceMotionData; |
33 class WebDeviceOrientationData; | 34 class WebDeviceOrientationData; |
34 class WebGraphicsContext3DProvider; | 35 class WebGraphicsContext3DProvider; |
35 } | 36 } |
36 | 37 |
37 namespace content { | 38 namespace content { |
38 class BatteryStatusDispatcher; | 39 class BatteryStatusDispatcher; |
39 class DeviceLightEventPump; | 40 class DeviceLightEventPump; |
40 class DeviceMotionEventPump; | 41 class DeviceMotionEventPump; |
41 class DeviceOrientationEventPump; | 42 class DeviceOrientationEventPump; |
| 43 class PlatformEventObserverBase; |
42 class QuotaMessageFilter; | 44 class QuotaMessageFilter; |
43 class RendererClipboardClient; | 45 class RendererClipboardClient; |
44 class RenderView; | 46 class RenderView; |
45 class RendererGamepadProvider; | |
46 class ThreadSafeSender; | 47 class ThreadSafeSender; |
47 class WebClipboardImpl; | 48 class WebClipboardImpl; |
48 class WebDatabaseObserverImpl; | 49 class WebDatabaseObserverImpl; |
49 class WebFileSystemImpl; | 50 class WebFileSystemImpl; |
50 | 51 |
51 class CONTENT_EXPORT RendererWebKitPlatformSupportImpl | 52 class CONTENT_EXPORT RendererWebKitPlatformSupportImpl |
52 : public BlinkPlatformImpl { | 53 : public BlinkPlatformImpl { |
53 public: | 54 public: |
54 RendererWebKitPlatformSupportImpl(); | 55 RendererWebKitPlatformSupportImpl(); |
55 virtual ~RendererWebKitPlatformSupportImpl(); | 56 virtual ~RendererWebKitPlatformSupportImpl(); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 virtual void startListening(blink::WebPlatformEventType, | 140 virtual void startListening(blink::WebPlatformEventType, |
140 blink::WebPlatformEventListener*); | 141 blink::WebPlatformEventListener*); |
141 virtual void stopListening(blink::WebPlatformEventType); | 142 virtual void stopListening(blink::WebPlatformEventType); |
142 virtual void queryStorageUsageAndQuota( | 143 virtual void queryStorageUsageAndQuota( |
143 const blink::WebURL& storage_partition, | 144 const blink::WebURL& storage_partition, |
144 blink::WebStorageQuotaType, | 145 blink::WebStorageQuotaType, |
145 blink::WebStorageQuotaCallbacks); | 146 blink::WebStorageQuotaCallbacks); |
146 virtual void vibrate(unsigned int milliseconds); | 147 virtual void vibrate(unsigned int milliseconds); |
147 virtual void cancelVibration(); | 148 virtual void cancelVibration(); |
148 | 149 |
149 void set_gamepad_provider(RendererGamepadProvider* provider) { | 150 // Set the PlatformEventObserverBase in |platform_event_observers_| associated |
150 gamepad_provider_ = provider; | 151 // with |type| to |observer|. If there was already an observer associated to |
151 } | 152 // the given |type|, it will be replaced. |
| 153 // Note that |observer| will be owned by this object after the call. |
| 154 void SetPlatformEventObserverForTesting( |
| 155 blink::WebPlatformEventType type, |
| 156 scoped_ptr<PlatformEventObserverBase> observer); |
152 | 157 |
153 // Disables the WebSandboxSupport implementation for testing. | 158 // Disables the WebSandboxSupport implementation for testing. |
154 // Tests that do not set up a full sandbox environment should call | 159 // Tests that do not set up a full sandbox environment should call |
155 // SetSandboxEnabledForTesting(false) _before_ creating any instances | 160 // SetSandboxEnabledForTesting(false) _before_ creating any instances |
156 // of this class, to ensure that we don't attempt to use sandbox-related | 161 // of this class, to ensure that we don't attempt to use sandbox-related |
157 // file descriptors or other resources. | 162 // file descriptors or other resources. |
158 // | 163 // |
159 // Returns the previous |enable| value. | 164 // Returns the previous |enable| value. |
160 static bool SetSandboxEnabledForTesting(bool enable); | 165 static bool SetSandboxEnabledForTesting(bool enable); |
161 | 166 |
162 // Set a double to return when setDeviceLightListener is invoked. | 167 // Set a double to return when setDeviceLightListener is invoked. |
163 static void SetMockDeviceLightDataForTesting(double data); | 168 static void SetMockDeviceLightDataForTesting(double data); |
164 // Set WebDeviceMotionData to return when setDeviceMotionListener is invoked. | 169 // Set WebDeviceMotionData to return when setDeviceMotionListener is invoked. |
165 static void SetMockDeviceMotionDataForTesting( | 170 static void SetMockDeviceMotionDataForTesting( |
166 const blink::WebDeviceMotionData& data); | 171 const blink::WebDeviceMotionData& data); |
167 // Set WebDeviceOrientationData to return when setDeviceOrientationListener | 172 // Set WebDeviceOrientationData to return when setDeviceOrientationListener |
168 // is invoked. | 173 // is invoked. |
169 static void SetMockDeviceOrientationDataForTesting( | 174 static void SetMockDeviceOrientationDataForTesting( |
170 const blink::WebDeviceOrientationData& data); | 175 const blink::WebDeviceOrientationData& data); |
171 | 176 |
172 // Notifies blink::WebBatteryStatusListener that battery status has changed. | 177 // Notifies blink::WebBatteryStatusListener that battery status has changed. |
173 static void MockBatteryStatusChangedForTesting( | 178 void MockBatteryStatusChangedForTesting( |
174 const blink::WebBatteryStatus& status); | 179 const blink::WebBatteryStatus& status); |
175 | 180 |
176 WebDatabaseObserverImpl* web_database_observer_impl() { | 181 WebDatabaseObserverImpl* web_database_observer_impl() { |
177 return web_database_observer_impl_.get(); | 182 return web_database_observer_impl_.get(); |
178 } | 183 } |
179 | 184 |
180 private: | 185 private: |
181 bool CheckPreparsedJsCachingEnabled() const; | 186 bool CheckPreparsedJsCachingEnabled() const; |
182 | 187 |
183 // Implement those methods internally so startListening() and stopListening() | 188 // Factory that takes a type and return PlatformEventObserverBase that matches |
184 // are being used and Blink can change its interface. | 189 // it. |
185 void SetDeviceMotionListener(blink::WebDeviceMotionListener*); | 190 static PlatformEventObserverBase* CreatePlatformEventObserverFromType( |
186 void SetDeviceOrientationListener(blink::WebDeviceOrientationListener*); | 191 blink::WebPlatformEventType type); |
187 void SetDeviceLightListener(blink::WebDeviceLightListener*); | |
188 void SetBatteryStatusListener(blink::WebBatteryStatusListener*); | |
189 void SetGamepadListener(blink::WebGamepadListener*); | |
190 | 192 |
| 193 // Use the data previously set via SetMockDevice...DataForTesting() and send |
| 194 // them to the registered listener. |
| 195 void SendFakeDeviceEventDataForTesting(blink::WebPlatformEventType type); |
191 | 196 |
192 scoped_ptr<RendererClipboardClient> clipboard_client_; | 197 scoped_ptr<RendererClipboardClient> clipboard_client_; |
193 scoped_ptr<WebClipboardImpl> clipboard_; | 198 scoped_ptr<WebClipboardImpl> clipboard_; |
194 | 199 |
195 class FileUtilities; | 200 class FileUtilities; |
196 scoped_ptr<FileUtilities> file_utilities_; | 201 scoped_ptr<FileUtilities> file_utilities_; |
197 | 202 |
198 class MimeRegistry; | 203 class MimeRegistry; |
199 scoped_ptr<MimeRegistry> mime_registry_; | 204 scoped_ptr<MimeRegistry> mime_registry_; |
200 | 205 |
(...skipping 25 matching lines...) Expand all Loading... |
226 scoped_refptr<QuotaMessageFilter> quota_message_filter_; | 231 scoped_refptr<QuotaMessageFilter> quota_message_filter_; |
227 | 232 |
228 scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_; | 233 scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_; |
229 | 234 |
230 cc_blink::WebCompositorSupportImpl compositor_support_; | 235 cc_blink::WebCompositorSupportImpl compositor_support_; |
231 | 236 |
232 scoped_ptr<blink::WebScrollbarBehavior> web_scrollbar_behavior_; | 237 scoped_ptr<blink::WebScrollbarBehavior> web_scrollbar_behavior_; |
233 | 238 |
234 scoped_ptr<BatteryStatusDispatcher> battery_status_dispatcher_; | 239 scoped_ptr<BatteryStatusDispatcher> battery_status_dispatcher_; |
235 | 240 |
236 RendererGamepadProvider* gamepad_provider_; | 241 IDMap<PlatformEventObserverBase, IDMapOwnPointer> platform_event_observers_; |
237 | 242 |
238 DISALLOW_COPY_AND_ASSIGN(RendererWebKitPlatformSupportImpl); | 243 DISALLOW_COPY_AND_ASSIGN(RendererWebKitPlatformSupportImpl); |
239 }; | 244 }; |
240 | 245 |
241 } // namespace content | 246 } // namespace content |
242 | 247 |
243 #endif // CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_ | 248 #endif // CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_ |
OLD | NEW |