Add test_runner support for new accessibility event
[chromium-blink-merge.git] / content / renderer / renderer_blink_platform_impl.h
bloba9e39add5db7adcfe6999d8155851da925f5d97a
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_RENDERER_BLINK_PLATFORM_IMPL_H_
6 #define CONTENT_RENDERER_RENDERER_BLINK_PLATFORM_IMPL_H_
8 #include "base/compiler_specific.h"
9 #include "base/id_map.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "cc/blink/web_compositor_support_impl.h"
12 #include "content/child/blink_platform_impl.h"
13 #include "content/common/content_export.h"
14 #include "content/renderer/webpublicsuffixlist_impl.h"
15 #include "device/vibration/vibration_manager.mojom.h"
16 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
17 #include "third_party/WebKit/public/platform/WebIDBFactory.h"
18 #include "third_party/WebKit/public/platform/WebScreenOrientationType.h"
20 namespace base {
21 class MessageLoopProxy;
24 namespace cc {
25 class ContextProvider;
28 namespace IPC {
29 class SyncMessageFilter;
32 namespace blink {
33 class WebBatteryStatus;
34 class WebDeviceMotionData;
35 class WebDeviceOrientationData;
36 class WebGraphicsContext3DProvider;
37 class WebServiceWorkerCacheStorage;
40 namespace content {
41 class BatteryStatusDispatcher;
42 class DeviceLightEventPump;
43 class DeviceMotionEventPump;
44 class DeviceOrientationEventPump;
45 class PlatformEventObserverBase;
46 class QuotaMessageFilter;
47 class RendererClipboardDelegate;
48 class RendererScheduler;
49 class RenderView;
50 class ThreadSafeSender;
51 class WebClipboardImpl;
52 class WebDatabaseObserverImpl;
53 class WebFileSystemImpl;
54 class WebThreadImplForScheduler;
55 class WebSchedulerImpl;
57 class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
58 public:
59 explicit RendererBlinkPlatformImpl(RendererScheduler* renderer_scheduler);
60 virtual ~RendererBlinkPlatformImpl();
62 void set_plugin_refresh_allowed(bool plugin_refresh_allowed) {
63 plugin_refresh_allowed_ = plugin_refresh_allowed;
65 // Platform methods:
66 virtual blink::WebClipboard* clipboard();
67 virtual blink::WebMimeRegistry* mimeRegistry();
68 virtual blink::WebFileUtilities* fileUtilities();
69 virtual blink::WebSandboxSupport* sandboxSupport();
70 virtual blink::WebCookieJar* cookieJar();
71 virtual blink::WebThemeEngine* themeEngine();
72 virtual blink::WebSpeechSynthesizer* createSpeechSynthesizer(
73 blink::WebSpeechSynthesizerClient* client);
74 virtual bool sandboxEnabled();
75 virtual unsigned long long visitedLinkHash(
76 const char* canonicalURL, size_t length);
77 virtual bool isLinkVisited(unsigned long long linkHash);
78 virtual void createMessageChannel(blink::WebMessagePortChannel** channel1,
79 blink::WebMessagePortChannel** channel2);
80 virtual blink::WebPrescientNetworking* prescientNetworking();
81 virtual void cacheMetadata(const blink::WebURL&, int64, const char*, size_t);
82 virtual blink::WebString defaultLocale();
83 virtual void suddenTerminationChanged(bool enabled);
84 virtual blink::WebStorageNamespace* createLocalStorageNamespace();
85 virtual blink::Platform::FileHandle databaseOpenFile(
86 const blink::WebString& vfs_file_name, int desired_flags);
87 virtual int databaseDeleteFile(const blink::WebString& vfs_file_name,
88 bool sync_dir);
89 virtual long databaseGetFileAttributes(
90 const blink::WebString& vfs_file_name);
91 virtual long long databaseGetFileSize(
92 const blink::WebString& vfs_file_name);
93 virtual long long databaseGetSpaceAvailableForOrigin(
94 const blink::WebString& origin_identifier);
95 virtual blink::WebString signedPublicKeyAndChallengeString(
96 unsigned key_size_index,
97 const blink::WebString& challenge,
98 const blink::WebURL& url);
99 virtual void getPluginList(bool refresh,
100 blink::WebPluginListBuilder* builder);
101 virtual blink::WebPublicSuffixList* publicSuffixList();
102 virtual void screenColorProfile(blink::WebVector<char>* to_profile);
103 virtual blink::WebScrollbarBehavior* scrollbarBehavior();
104 virtual blink::WebIDBFactory* idbFactory();
105 virtual blink::WebServiceWorkerCacheStorage* cacheStorage(
106 const blink::WebString& origin_identifier);
107 virtual blink::WebFileSystem* fileSystem();
108 virtual bool canAccelerate2dCanvas();
109 virtual bool isThreadedCompositingEnabled();
110 virtual double audioHardwareSampleRate();
111 virtual size_t audioHardwareBufferSize();
112 virtual unsigned audioHardwareOutputChannels();
113 virtual blink::WebDatabaseObserver* databaseObserver();
115 virtual blink::WebAudioDevice* createAudioDevice(
116 size_t buffer_size, unsigned input_channels, unsigned channels,
117 double sample_rate, blink::WebAudioDevice::RenderCallback* callback,
118 const blink::WebString& input_device_id);
120 virtual bool loadAudioResource(
121 blink::WebAudioBus* destination_bus, const char* audio_file_data,
122 size_t data_size);
124 virtual blink::WebMIDIAccessor*
125 createMIDIAccessor(blink::WebMIDIAccessorClient* client);
127 virtual blink::WebBlobRegistry* blobRegistry();
128 virtual void sampleGamepads(blink::WebGamepads&);
129 virtual blink::WebRTCPeerConnectionHandler* createRTCPeerConnectionHandler(
130 blink::WebRTCPeerConnectionHandlerClient* client);
131 virtual blink::WebMediaStreamCenter* createMediaStreamCenter(
132 blink::WebMediaStreamCenterClient* client);
133 virtual bool processMemorySizesInBytes(
134 size_t* private_bytes, size_t* shared_bytes);
135 virtual blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
136 const blink::WebGraphicsContext3D::Attributes& attributes);
137 virtual blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
138 const blink::WebGraphicsContext3D::Attributes& attributes,
139 blink::WebGraphicsContext3D* share_context);
140 virtual blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
141 const blink::WebGraphicsContext3D::Attributes& attributes,
142 blink::WebGraphicsContext3D* share_context,
143 blink::WebGLInfo* gl_info);
144 virtual blink::WebGraphicsContext3DProvider*
145 createSharedOffscreenGraphicsContext3DProvider();
146 virtual blink::WebCompositorSupport* compositorSupport();
147 virtual blink::WebString convertIDNToUnicode(
148 const blink::WebString& host, const blink::WebString& languages);
149 virtual void startListening(blink::WebPlatformEventType,
150 blink::WebPlatformEventListener*);
151 virtual void stopListening(blink::WebPlatformEventType);
152 virtual void queryStorageUsageAndQuota(
153 const blink::WebURL& storage_partition,
154 blink::WebStorageQuotaType,
155 blink::WebStorageQuotaCallbacks);
156 virtual void vibrate(unsigned int milliseconds);
157 virtual void cancelVibration();
158 virtual blink::WebScheduler* scheduler();
159 virtual blink::WebThread* currentThread();
161 // Set the PlatformEventObserverBase in |platform_event_observers_| associated
162 // with |type| to |observer|. If there was already an observer associated to
163 // the given |type|, it will be replaced.
164 // Note that |observer| will be owned by this object after the call.
165 void SetPlatformEventObserverForTesting(
166 blink::WebPlatformEventType type,
167 scoped_ptr<PlatformEventObserverBase> observer);
169 // Disables the WebSandboxSupport implementation for testing.
170 // Tests that do not set up a full sandbox environment should call
171 // SetSandboxEnabledForTesting(false) _before_ creating any instances
172 // of this class, to ensure that we don't attempt to use sandbox-related
173 // file descriptors or other resources.
175 // Returns the previous |enable| value.
176 static bool SetSandboxEnabledForTesting(bool enable);
178 // Set a double to return when setDeviceLightListener is invoked.
179 static void SetMockDeviceLightDataForTesting(double data);
180 // Set WebDeviceMotionData to return when setDeviceMotionListener is invoked.
181 static void SetMockDeviceMotionDataForTesting(
182 const blink::WebDeviceMotionData& data);
183 // Set WebDeviceOrientationData to return when setDeviceOrientationListener
184 // is invoked.
185 static void SetMockDeviceOrientationDataForTesting(
186 const blink::WebDeviceOrientationData& data);
188 // Notifies blink::WebBatteryStatusListener that battery status has changed.
189 void MockBatteryStatusChangedForTesting(
190 const blink::WebBatteryStatus& status);
192 WebDatabaseObserverImpl* web_database_observer_impl() {
193 return web_database_observer_impl_.get();
196 private:
197 bool CheckPreparsedJsCachingEnabled() const;
199 // Factory that takes a type and return PlatformEventObserverBase that matches
200 // it.
201 static PlatformEventObserverBase* CreatePlatformEventObserverFromType(
202 blink::WebPlatformEventType type);
204 // Use the data previously set via SetMockDevice...DataForTesting() and send
205 // them to the registered listener.
206 void SendFakeDeviceEventDataForTesting(blink::WebPlatformEventType type);
207 device::VibrationManagerPtr& GetConnectedVibrationManagerService();
209 scoped_ptr<WebSchedulerImpl> web_scheduler_;
210 scoped_ptr<WebThreadImplForScheduler> main_thread_;
212 scoped_ptr<RendererClipboardDelegate> clipboard_delegate_;
213 scoped_ptr<WebClipboardImpl> clipboard_;
215 class FileUtilities;
216 scoped_ptr<FileUtilities> file_utilities_;
218 class MimeRegistry;
219 scoped_ptr<MimeRegistry> mime_registry_;
221 #if !defined(OS_ANDROID) && !defined(OS_WIN)
222 class SandboxSupport;
223 scoped_ptr<SandboxSupport> sandbox_support_;
224 #endif
226 // This counter keeps track of the number of times sudden termination is
227 // enabled or disabled. It starts at 0 (enabled) and for every disable
228 // increments by 1, for every enable decrements by 1. When it reaches 0,
229 // we tell the browser to enable fast termination.
230 int sudden_termination_disables_;
232 // If true, then a GetPlugins call is allowed to rescan the disk.
233 bool plugin_refresh_allowed_;
235 scoped_ptr<blink::WebIDBFactory> web_idb_factory_;
237 scoped_ptr<blink::WebBlobRegistry> blob_registry_;
239 WebPublicSuffixListImpl public_suffix_list_;
241 scoped_ptr<DeviceLightEventPump> device_light_event_pump_;
242 scoped_ptr<DeviceMotionEventPump> device_motion_event_pump_;
243 scoped_ptr<DeviceOrientationEventPump> device_orientation_event_pump_;
245 scoped_refptr<base::SingleThreadTaskRunner> default_task_runner_;
246 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
247 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
248 scoped_refptr<QuotaMessageFilter> quota_message_filter_;
250 scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_;
252 cc_blink::WebCompositorSupportImpl compositor_support_;
254 scoped_ptr<blink::WebScrollbarBehavior> web_scrollbar_behavior_;
256 scoped_ptr<BatteryStatusDispatcher> battery_status_dispatcher_;
258 // Handle to the Vibration mojo service.
259 device::VibrationManagerPtr vibration_manager_;
261 IDMap<PlatformEventObserverBase, IDMapOwnPointer> platform_event_observers_;
263 DISALLOW_COPY_AND_ASSIGN(RendererBlinkPlatformImpl);
266 } // namespace content
268 #endif // CONTENT_RENDERER_RENDERER_BLINK_PLATFORM_IMPL_H_