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"
19 class MessageLoopProxy
;
23 class ContextProvider
;
27 class SyncMessageFilter
;
31 class WebGraphicsContext3DProvider
;
35 class GamepadSharedMemoryReader
;
36 class RendererClipboardClient
;
37 class ThreadSafeSender
;
38 class WebClipboardImpl
;
39 class WebFileSystemImpl
;
40 class WebSharedWorkerRepositoryImpl
;
42 class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
43 : public WebKitPlatformSupportImpl
{
45 RendererWebKitPlatformSupportImpl();
46 virtual ~RendererWebKitPlatformSupportImpl();
48 void set_plugin_refresh_allowed(bool plugin_refresh_allowed
) {
49 plugin_refresh_allowed_
= plugin_refresh_allowed
;
52 virtual WebKit::WebClipboard
* clipboard();
53 virtual WebKit::WebMimeRegistry
* mimeRegistry();
54 virtual WebKit::WebFileUtilities
* fileUtilities();
55 virtual WebKit::WebSandboxSupport
* sandboxSupport();
56 virtual WebKit::WebCookieJar
* cookieJar();
57 virtual WebKit::WebHyphenator
* hyphenator();
58 virtual WebKit::WebThemeEngine
* themeEngine();
59 virtual WebKit::WebSpeechSynthesizer
* createSpeechSynthesizer(
60 WebKit::WebSpeechSynthesizerClient
* client
);
61 virtual bool sandboxEnabled();
62 virtual unsigned long long visitedLinkHash(
63 const char* canonicalURL
, size_t length
);
64 virtual bool isLinkVisited(unsigned long long linkHash
);
65 virtual WebKit::WebMessagePortChannel
* createMessagePortChannel();
66 virtual void prefetchHostName(const WebKit::WebString
&);
67 virtual WebKit::WebPrescientNetworking
* prescientNetworking();
68 virtual void cacheMetadata(
69 const WebKit::WebURL
&, double, const char*, size_t);
70 virtual WebKit::WebString
defaultLocale();
71 virtual void suddenTerminationChanged(bool enabled
);
72 virtual WebKit::WebStorageNamespace
* createLocalStorageNamespace();
73 virtual WebKit::Platform::FileHandle
databaseOpenFile(
74 const WebKit::WebString
& vfs_file_name
, int desired_flags
);
75 virtual int databaseDeleteFile(const WebKit::WebString
& vfs_file_name
,
77 virtual long databaseGetFileAttributes(
78 const WebKit::WebString
& vfs_file_name
);
79 virtual long long databaseGetFileSize(
80 const WebKit::WebString
& vfs_file_name
);
81 virtual long long databaseGetSpaceAvailableForOrigin(
82 const WebKit::WebString
& origin_identifier
);
83 virtual WebKit::WebString
signedPublicKeyAndChallengeString(
84 unsigned key_size_index
,
85 const WebKit::WebString
& challenge
,
86 const WebKit::WebURL
& url
);
87 virtual void screenColorProfile(WebKit::WebVector
<char>* to_profile
);
88 virtual WebKit::WebIDBFactory
* idbFactory();
89 virtual WebKit::WebFileSystem
* fileSystem();
90 virtual WebKit::WebSharedWorkerRepository
* sharedWorkerRepository();
91 virtual bool canAccelerate2dCanvas();
92 virtual bool isThreadedCompositingEnabled();
93 virtual double audioHardwareSampleRate();
94 virtual size_t audioHardwareBufferSize();
95 virtual unsigned audioHardwareOutputChannels();
97 // TODO(crogers): remove deprecated API as soon as WebKit calls new API.
98 virtual WebKit::WebAudioDevice
* createAudioDevice(
99 size_t buffer_size
, unsigned channels
, double sample_rate
,
100 WebKit::WebAudioDevice::RenderCallback
* callback
);
101 // TODO(crogers): remove deprecated API as soon as WebKit calls new API.
102 virtual WebKit::WebAudioDevice
* createAudioDevice(
103 size_t buffer_size
, unsigned input_channels
, unsigned channels
,
104 double sample_rate
, WebKit::WebAudioDevice::RenderCallback
* callback
);
106 virtual WebKit::WebAudioDevice
* createAudioDevice(
107 size_t buffer_size
, unsigned input_channels
, unsigned channels
,
108 double sample_rate
, WebKit::WebAudioDevice::RenderCallback
* callback
,
109 const WebKit::WebString
& input_device_id
);
111 virtual bool loadAudioResource(
112 WebKit::WebAudioBus
* destination_bus
, const char* audio_file_data
,
113 size_t data_size
, double sample_rate
);
115 virtual WebKit::WebContentDecryptionModule
* createContentDecryptionModule(
116 const WebKit::WebString
& key_system
);
117 virtual WebKit::WebMIDIAccessor
*
118 createMIDIAccessor(WebKit::WebMIDIAccessorClient
* client
);
120 virtual WebKit::WebBlobRegistry
* blobRegistry();
121 virtual void sampleGamepads(WebKit::WebGamepads
&);
122 virtual WebKit::WebString
userAgent(const WebKit::WebURL
& url
);
123 virtual void GetPlugins(bool refresh
,
124 std::vector
<webkit::WebPluginInfo
>* plugins
) OVERRIDE
;
125 virtual WebKit::WebRTCPeerConnectionHandler
* createRTCPeerConnectionHandler(
126 WebKit::WebRTCPeerConnectionHandlerClient
* client
);
127 virtual WebKit::WebMediaStreamCenter
* createMediaStreamCenter(
128 WebKit::WebMediaStreamCenterClient
* client
);
129 virtual bool processMemorySizesInBytes(
130 size_t* private_bytes
, size_t* shared_bytes
);
131 virtual WebKit::WebGraphicsContext3D
* createOffscreenGraphicsContext3D(
132 const WebKit::WebGraphicsContext3D::Attributes
& attributes
);
133 virtual WebKit::WebGraphicsContext3DProvider
*
134 createSharedOffscreenGraphicsContext3DProvider();
135 virtual WebKit::WebCompositorSupport
* compositorSupport();
136 virtual WebKit::WebString
convertIDNToUnicode(
137 const WebKit::WebString
& host
, const WebKit::WebString
& languages
);
139 // Disables the WebSandboxSupport implementation for testing.
140 // Tests that do not set up a full sandbox environment should call
141 // SetSandboxEnabledForTesting(false) _before_ creating any instances
142 // of this class, to ensure that we don't attempt to use sandbox-related
143 // file descriptors or other resources.
145 // Returns the previous |enable| value.
146 static bool SetSandboxEnabledForTesting(bool enable
);
148 // Set WebGamepads to return when sampleGamepads() is invoked.
149 static void SetMockGamepadsForTesting(const WebKit::WebGamepads
& pads
);
152 bool CheckPreparsedJsCachingEnabled() const;
154 scoped_ptr
<RendererClipboardClient
> clipboard_client_
;
155 scoped_ptr
<WebClipboardImpl
> clipboard_
;
158 scoped_ptr
<FileUtilities
> file_utilities_
;
161 scoped_ptr
<MimeRegistry
> mime_registry_
;
163 class SandboxSupport
;
164 scoped_ptr
<SandboxSupport
> sandbox_support_
;
167 scoped_ptr
<Hyphenator
> hyphenator_
;
169 // This counter keeps track of the number of times sudden termination is
170 // enabled or disabled. It starts at 0 (enabled) and for every disable
171 // increments by 1, for every enable decrements by 1. When it reaches 0,
172 // we tell the browser to enable fast termination.
173 int sudden_termination_disables_
;
175 // If true, then a GetPlugins call is allowed to rescan the disk.
176 bool plugin_refresh_allowed_
;
178 // Implementation of the WebSharedWorkerRepository APIs (provides an interface
179 // to WorkerService on the browser thread.
180 scoped_ptr
<WebSharedWorkerRepositoryImpl
> shared_worker_repository_
;
182 scoped_ptr
<WebKit::WebIDBFactory
> web_idb_factory_
;
184 scoped_ptr
<WebFileSystemImpl
> web_file_system_
;
186 scoped_ptr
<WebKit::WebBlobRegistry
> blob_registry_
;
188 scoped_ptr
<GamepadSharedMemoryReader
> gamepad_shared_memory_reader_
;
190 scoped_refptr
<base::MessageLoopProxy
> child_thread_loop_
;
191 scoped_refptr
<IPC::SyncMessageFilter
> sync_message_filter_
;
192 scoped_refptr
<ThreadSafeSender
> thread_safe_sender_
;
194 scoped_refptr
<cc::ContextProvider
> shared_offscreen_context_
;
196 webkit::WebCompositorSupportImpl compositor_support_
;
199 } // namespace content
201 #endif // CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_