Refactor management of overview window copy lifetime into a separate class.
[chromium-blink-merge.git] / content / renderer / renderer_webkitplatformsupport_impl.h
blob8378c3402368de34064fbc20dd291e5713fe82dc
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_WEBKITPLATFORMSUPPORT_IMPL_H_
6 #define CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/platform_file.h"
11 #include "content/child/webkitplatformsupport_impl.h"
12 #include "content/common/content_export.h"
13 #include "third_party/WebKit/public/web/WebSharedWorkerRepository.h"
14 #include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
15 #include "third_party/WebKit/public/platform/WebIDBFactory.h"
16 #include "webkit/renderer/compositor_bindings/web_compositor_support_impl.h"
18 namespace base {
19 class MessageLoopProxy;
22 namespace cc {
23 class ContextProvider;
26 namespace IPC {
27 class SyncMessageFilter;
30 namespace WebKit {
31 class WebDeviceMotionData;
32 class WebDeviceOrientationData;
33 class WebGraphicsContext3DProvider;
36 namespace content {
37 class DeviceMotionEventPump;
38 class DeviceOrientationEventPump;
39 class QuotaMessageFilter;
40 class RendererClipboardClient;
41 class ThreadSafeSender;
42 class WebClipboardImpl;
43 class WebCryptoImpl;
44 class WebFileSystemImpl;
45 class WebSharedWorkerRepositoryImpl;
47 class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
48 : public WebKitPlatformSupportImpl {
49 public:
50 RendererWebKitPlatformSupportImpl();
51 virtual ~RendererWebKitPlatformSupportImpl();
53 void set_plugin_refresh_allowed(bool plugin_refresh_allowed) {
54 plugin_refresh_allowed_ = plugin_refresh_allowed;
56 // Platform methods:
57 virtual WebKit::WebClipboard* clipboard();
58 virtual WebKit::WebMimeRegistry* mimeRegistry();
59 virtual WebKit::WebFileUtilities* fileUtilities();
60 virtual WebKit::WebSandboxSupport* sandboxSupport();
61 virtual WebKit::WebCookieJar* cookieJar();
62 virtual WebKit::WebThemeEngine* themeEngine();
63 virtual WebKit::WebSpeechSynthesizer* createSpeechSynthesizer(
64 WebKit::WebSpeechSynthesizerClient* client);
65 virtual bool sandboxEnabled();
66 virtual unsigned long long visitedLinkHash(
67 const char* canonicalURL, size_t length);
68 virtual bool isLinkVisited(unsigned long long linkHash);
69 virtual WebKit::WebMessagePortChannel* createMessagePortChannel();
70 virtual WebKit::WebPrescientNetworking* prescientNetworking();
71 virtual void cacheMetadata(
72 const WebKit::WebURL&, double, const char*, size_t);
73 virtual WebKit::WebString defaultLocale();
74 virtual void suddenTerminationChanged(bool enabled);
75 virtual WebKit::WebStorageNamespace* createLocalStorageNamespace();
76 virtual WebKit::Platform::FileHandle databaseOpenFile(
77 const WebKit::WebString& vfs_file_name, int desired_flags);
78 virtual int databaseDeleteFile(const WebKit::WebString& vfs_file_name,
79 bool sync_dir);
80 virtual long databaseGetFileAttributes(
81 const WebKit::WebString& vfs_file_name);
82 virtual long long databaseGetFileSize(
83 const WebKit::WebString& vfs_file_name);
84 virtual long long databaseGetSpaceAvailableForOrigin(
85 const WebKit::WebString& origin_identifier);
86 virtual WebKit::WebString signedPublicKeyAndChallengeString(
87 unsigned key_size_index,
88 const WebKit::WebString& challenge,
89 const WebKit::WebURL& url);
90 virtual void getPluginList(bool refresh,
91 WebKit::WebPluginListBuilder* builder);
92 virtual void screenColorProfile(WebKit::WebVector<char>* to_profile);
93 virtual WebKit::WebIDBFactory* idbFactory();
94 virtual WebKit::WebFileSystem* fileSystem();
95 virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository();
96 virtual bool canAccelerate2dCanvas();
97 virtual bool isThreadedCompositingEnabled();
98 virtual double audioHardwareSampleRate();
99 virtual size_t audioHardwareBufferSize();
100 virtual unsigned audioHardwareOutputChannels();
102 // TODO(crogers): remove deprecated API as soon as WebKit calls new API.
103 virtual WebKit::WebAudioDevice* createAudioDevice(
104 size_t buffer_size, unsigned channels, double sample_rate,
105 WebKit::WebAudioDevice::RenderCallback* callback);
106 // TODO(crogers): remove deprecated API as soon as WebKit calls new API.
107 virtual WebKit::WebAudioDevice* createAudioDevice(
108 size_t buffer_size, unsigned input_channels, unsigned channels,
109 double sample_rate, WebKit::WebAudioDevice::RenderCallback* callback);
111 virtual WebKit::WebAudioDevice* createAudioDevice(
112 size_t buffer_size, unsigned input_channels, unsigned channels,
113 double sample_rate, WebKit::WebAudioDevice::RenderCallback* callback,
114 const WebKit::WebString& input_device_id);
116 virtual bool loadAudioResource(
117 WebKit::WebAudioBus* destination_bus, const char* audio_file_data,
118 size_t data_size, double sample_rate);
120 virtual WebKit::WebContentDecryptionModule* createContentDecryptionModule(
121 const WebKit::WebString& key_system);
122 virtual WebKit::WebMIDIAccessor*
123 createMIDIAccessor(WebKit::WebMIDIAccessorClient* client);
125 virtual WebKit::WebBlobRegistry* blobRegistry();
126 virtual void sampleGamepads(WebKit::WebGamepads&);
127 virtual WebKit::WebString userAgent(const WebKit::WebURL& url);
128 virtual WebKit::WebRTCPeerConnectionHandler* createRTCPeerConnectionHandler(
129 WebKit::WebRTCPeerConnectionHandlerClient* client);
130 virtual WebKit::WebMediaStreamCenter* createMediaStreamCenter(
131 WebKit::WebMediaStreamCenterClient* client);
132 virtual bool processMemorySizesInBytes(
133 size_t* private_bytes, size_t* shared_bytes);
134 virtual WebKit::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
135 const WebKit::WebGraphicsContext3D::Attributes& attributes);
136 virtual WebKit::WebGraphicsContext3DProvider*
137 createSharedOffscreenGraphicsContext3DProvider();
138 virtual WebKit::WebCompositorSupport* compositorSupport();
139 virtual WebKit::WebString convertIDNToUnicode(
140 const WebKit::WebString& host, const WebKit::WebString& languages);
141 virtual void setDeviceMotionListener(
142 WebKit::WebDeviceMotionListener* listener) OVERRIDE;
143 virtual void setDeviceOrientationListener(
144 WebKit::WebDeviceOrientationListener* listener) OVERRIDE;
145 virtual WebKit::WebCrypto* crypto() OVERRIDE;
146 virtual void queryStorageUsageAndQuota(
147 const WebKit::WebURL& storage_partition,
148 WebKit::WebStorageQuotaType,
149 WebKit::WebStorageQuotaCallbacks*) OVERRIDE;
151 #if defined(OS_ANDROID)
152 virtual void vibrate(unsigned int milliseconds);
153 virtual void cancelVibration();
154 #endif // defined(OS_ANDROID)
156 // Disables the WebSandboxSupport implementation for testing.
157 // Tests that do not set up a full sandbox environment should call
158 // SetSandboxEnabledForTesting(false) _before_ creating any instances
159 // of this class, to ensure that we don't attempt to use sandbox-related
160 // file descriptors or other resources.
162 // Returns the previous |enable| value.
163 static bool SetSandboxEnabledForTesting(bool enable);
165 // Set WebGamepads to return when sampleGamepads() is invoked.
166 static void SetMockGamepadsForTesting(const WebKit::WebGamepads& pads);
167 // Set WebDeviceMotionData to return when setDeviceMotionListener is invoked.
168 static void SetMockDeviceMotionDataForTesting(
169 const WebKit::WebDeviceMotionData& data);
170 // Set WebDeviceOrientationData to return when setDeviceOrientationListener
171 // is invoked.
172 static void SetMockDeviceOrientationDataForTesting(
173 const WebKit::WebDeviceOrientationData& data);
175 private:
176 bool CheckPreparsedJsCachingEnabled() const;
178 scoped_ptr<RendererClipboardClient> clipboard_client_;
179 scoped_ptr<WebClipboardImpl> clipboard_;
181 class FileUtilities;
182 scoped_ptr<FileUtilities> file_utilities_;
184 class MimeRegistry;
185 scoped_ptr<MimeRegistry> mime_registry_;
187 class SandboxSupport;
188 scoped_ptr<SandboxSupport> sandbox_support_;
190 // This counter keeps track of the number of times sudden termination is
191 // enabled or disabled. It starts at 0 (enabled) and for every disable
192 // increments by 1, for every enable decrements by 1. When it reaches 0,
193 // we tell the browser to enable fast termination.
194 int sudden_termination_disables_;
196 // If true, then a GetPlugins call is allowed to rescan the disk.
197 bool plugin_refresh_allowed_;
199 // Implementation of the WebSharedWorkerRepository APIs (provides an interface
200 // to WorkerService on the browser thread.
201 scoped_ptr<WebSharedWorkerRepositoryImpl> shared_worker_repository_;
203 scoped_ptr<WebKit::WebIDBFactory> web_idb_factory_;
205 scoped_ptr<WebFileSystemImpl> web_file_system_;
207 scoped_ptr<WebKit::WebBlobRegistry> blob_registry_;
209 scoped_ptr<DeviceMotionEventPump> device_motion_event_pump_;
210 scoped_ptr<DeviceOrientationEventPump> device_orientation_event_pump_;
212 scoped_refptr<base::MessageLoopProxy> child_thread_loop_;
213 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
214 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
215 scoped_refptr<QuotaMessageFilter> quota_message_filter_;
217 webkit::WebCompositorSupportImpl compositor_support_;
219 scoped_ptr<WebCryptoImpl> web_crypto_;
222 } // namespace content
224 #endif // CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_