blob: 2ca005750b89d02c271a0d3b6e6e52e6b3627ea1 [file] [log] [blame]
[email protected]273558fb2012-01-12 15:03:511// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]dd9241932010-02-24 19:23:132// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
[email protected]8d86fce2009-02-26 23:37:554
[email protected]8d6cba42011-09-02 10:05:195#ifndef CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_
6#define CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_
[email protected]8d86fce2009-02-26 23:37:557
[email protected]f3112a52011-09-30 23:47:498#include "base/compiler_specific.h"
[email protected]3b63f8f42011-03-28 01:54:159#include "base/memory/scoped_ptr.h"
[email protected]017022b2009-07-27 23:06:3410#include "base/platform_file.h"
[email protected]4db58d72014-03-24 17:05:1911#include "content/child/blink_platform_impl.h"
[email protected]f3112a52011-09-30 23:47:4912#include "content/common/content_export.h"
[email protected]b9829df2013-11-18 22:03:5113#include "content/renderer/webpublicsuffixlist_impl.h"
[email protected]5c30b5e02013-05-30 03:46:0814#include "third_party/WebKit/public/platform/WebGraphicsContext3D.h"
15#include "third_party/WebKit/public/platform/WebIDBFactory.h"
[email protected]799fd732013-05-15 21:18:5216#include "webkit/renderer/compositor_bindings/web_compositor_support_impl.h"
[email protected]8d86fce2009-02-26 23:37:5517
[email protected]ca405d22013-06-25 23:28:5518namespace base {
19class MessageLoopProxy;
20}
21
[email protected]c29b7ff2013-03-06 03:51:0422namespace cc {
23class ContextProvider;
24}
25
[email protected]ca405d22013-06-25 23:28:5526namespace IPC {
27class SyncMessageFilter;
28}
29
[email protected]180ef242013-11-07 06:50:4630namespace blink {
[email protected]70bf1a6b2013-07-17 17:46:0831class WebDeviceMotionData;
[email protected]fb640b462013-08-16 00:00:1032class WebDeviceOrientationData;
[email protected]39604c32013-05-09 12:40:1733class WebGraphicsContext3DProvider;
[email protected]785d5142014-02-27 20:03:1134class WebScreenOrientationListener;
[email protected]39604c32013-05-09 12:40:1735}
36
[email protected]e9ff79c2012-10-19 21:31:2637namespace content {
[email protected]876526aa2013-07-11 08:00:5738class DeviceMotionEventPump;
[email protected]cee8a8162013-08-05 21:17:1439class DeviceOrientationEventPump;
[email protected]a2d03c0b2013-07-29 10:48:1140class QuotaMessageFilter;
[email protected]e9ff79c2012-10-19 21:31:2641class RendererClipboardClient;
[email protected]785d5142014-02-27 20:03:1142class ScreenOrientationDispatcher;
[email protected]b180a0bb2013-03-06 00:36:1043class ThreadSafeSender;
[email protected]bb7538f2013-06-21 00:40:2844class WebClipboardImpl;
[email protected]1406f892013-11-12 19:38:1945class WebDatabaseObserverImpl;
[email protected]eb398192012-10-22 20:16:1946class WebFileSystemImpl;
[email protected]e9ff79c2012-10-19 21:31:2647
[email protected]f3112a52011-09-30 23:47:4948class CONTENT_EXPORT RendererWebKitPlatformSupportImpl
[email protected]4db58d72014-03-24 17:05:1949 : public BlinkPlatformImpl {
[email protected]8d86fce2009-02-26 23:37:5550 public:
[email protected]8d6cba42011-09-02 10:05:1951 RendererWebKitPlatformSupportImpl();
52 virtual ~RendererWebKitPlatformSupportImpl();
[email protected]eb6f2c542009-10-02 04:53:5953
[email protected]a70b4352012-07-31 22:34:5354 void set_plugin_refresh_allowed(bool plugin_refresh_allowed) {
55 plugin_refresh_allowed_ = plugin_refresh_allowed;
56 }
[email protected]8467ae0d2013-02-27 02:02:4857 // Platform methods:
[email protected]180ef242013-11-07 06:50:4658 virtual blink::WebClipboard* clipboard();
59 virtual blink::WebMimeRegistry* mimeRegistry();
60 virtual blink::WebFileUtilities* fileUtilities();
61 virtual blink::WebSandboxSupport* sandboxSupport();
62 virtual blink::WebCookieJar* cookieJar();
63 virtual blink::WebThemeEngine* themeEngine();
64 virtual blink::WebSpeechSynthesizer* createSpeechSynthesizer(
65 blink::WebSpeechSynthesizerClient* client);
[email protected]937c4eb2013-01-03 00:36:5666 virtual bool sandboxEnabled();
[email protected]b8caa3d2009-04-16 16:17:2067 virtual unsigned long long visitedLinkHash(
[email protected]937c4eb2013-01-03 00:36:5668 const char* canonicalURL, size_t length);
69 virtual bool isLinkVisited(unsigned long long linkHash);
[email protected]180ef242013-11-07 06:50:4670 virtual blink::WebMessagePortChannel* createMessagePortChannel();
[email protected]802d61ca2014-04-08 18:11:5571 virtual void createMessageChannel(
72 blink::WebMessagePortChannel** channel1,
73 blink::WebMessagePortChannel** channel2);
[email protected]180ef242013-11-07 06:50:4674 virtual blink::WebPrescientNetworking* prescientNetworking();
[email protected]b808eb6f2010-05-18 17:09:3375 virtual void cacheMetadata(
[email protected]180ef242013-11-07 06:50:4676 const blink::WebURL&, double, const char*, size_t);
77 virtual blink::WebString defaultLocale();
[email protected]937c4eb2013-01-03 00:36:5678 virtual void suddenTerminationChanged(bool enabled);
[email protected]180ef242013-11-07 06:50:4679 virtual blink::WebStorageNamespace* createLocalStorageNamespace();
80 virtual blink::Platform::FileHandle databaseOpenFile(
81 const blink::WebString& vfs_file_name, int desired_flags);
82 virtual int databaseDeleteFile(const blink::WebString& vfs_file_name,
[email protected]937c4eb2013-01-03 00:36:5683 bool sync_dir);
[email protected]60cba792009-11-13 06:37:0384 virtual long databaseGetFileAttributes(
[email protected]180ef242013-11-07 06:50:4685 const blink::WebString& vfs_file_name);
[email protected]60cba792009-11-13 06:37:0386 virtual long long databaseGetFileSize(
[email protected]180ef242013-11-07 06:50:4687 const blink::WebString& vfs_file_name);
[email protected]db4d49812011-05-25 00:34:3288 virtual long long databaseGetSpaceAvailableForOrigin(
[email protected]180ef242013-11-07 06:50:4689 const blink::WebString& origin_identifier);
90 virtual blink::WebString signedPublicKeyAndChallengeString(
[email protected]a755e1072009-10-23 16:58:3791 unsigned key_size_index,
[email protected]180ef242013-11-07 06:50:4692 const blink::WebString& challenge,
93 const blink::WebURL& url);
[email protected]b00dedd2013-07-20 06:36:5394 virtual void getPluginList(bool refresh,
[email protected]180ef242013-11-07 06:50:4695 blink::WebPluginListBuilder* builder);
[email protected]b9829df2013-11-18 22:03:5196 virtual blink::WebPublicSuffixList* publicSuffixList();
[email protected]180ef242013-11-07 06:50:4697 virtual void screenColorProfile(blink::WebVector<char>* to_profile);
[email protected]33b02992014-03-01 01:06:2998 virtual blink::WebScrollbarBehavior* scrollbarBehavior();
[email protected]180ef242013-11-07 06:50:4699 virtual blink::WebIDBFactory* idbFactory();
100 virtual blink::WebFileSystem* fileSystem();
[email protected]e4f81812012-03-14 04:15:58101 virtual bool canAccelerate2dCanvas();
[email protected]cbc8a452013-03-05 06:03:47102 virtual bool isThreadedCompositingEnabled();
[email protected]937c4eb2013-01-03 00:36:56103 virtual double audioHardwareSampleRate();
104 virtual size_t audioHardwareBufferSize();
[email protected]06ea4f7c2013-03-13 20:36:51105 virtual unsigned audioHardwareOutputChannels();
[email protected]9f5b3532013-11-18 11:49:49106 virtual blink::WebDatabaseObserver* databaseObserver();
[email protected]a19efb72013-01-12 17:05:46107
[email protected]180ef242013-11-07 06:50:46108 virtual blink::WebAudioDevice* createAudioDevice(
[email protected]8d22e5872013-02-22 20:07:11109 size_t buffer_size, unsigned input_channels, unsigned channels,
[email protected]180ef242013-11-07 06:50:46110 double sample_rate, blink::WebAudioDevice::RenderCallback* callback,
111 const blink::WebString& input_device_id);
[email protected]8d22e5872013-02-22 20:07:11112
[email protected]99902de2013-06-20 23:04:09113 virtual bool loadAudioResource(
[email protected]180ef242013-11-07 06:50:46114 blink::WebAudioBus* destination_bus, const char* audio_file_data,
[email protected]33fcc33e2014-03-13 10:56:24115 size_t data_size);
[email protected]99902de2013-06-20 23:04:09116
[email protected]180ef242013-11-07 06:50:46117 virtual blink::WebMIDIAccessor*
118 createMIDIAccessor(blink::WebMIDIAccessorClient* client);
[email protected]dbc628a2013-06-15 17:08:28119
[email protected]180ef242013-11-07 06:50:46120 virtual blink::WebBlobRegistry* blobRegistry();
[email protected]85603cbb2014-03-25 02:20:01121 virtual void sampleGamepads(blink::WebGamepads&) OVERRIDE;
122 virtual void setGamepadListener(blink::WebGamepadListener*) OVERRIDE;
[email protected]180ef242013-11-07 06:50:46123 virtual blink::WebRTCPeerConnectionHandler* createRTCPeerConnectionHandler(
124 blink::WebRTCPeerConnectionHandlerClient* client);
125 virtual blink::WebMediaStreamCenter* createMediaStreamCenter(
126 blink::WebMediaStreamCenterClient* client);
[email protected]2af28f22013-02-04 16:11:03127 virtual bool processMemorySizesInBytes(
128 size_t* private_bytes, size_t* shared_bytes);
[email protected]180ef242013-11-07 06:50:46129 virtual blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
[email protected]7f430ab62014-03-18 20:38:41130 const blink::WebGraphicsContext3D::Attributes& attributes);
131 virtual blink::WebGraphicsContext3D* createOffscreenGraphicsContext3D(
[email protected]4f8fd7802014-02-25 18:19:36132 const blink::WebGraphicsContext3D::Attributes& attributes,
133 blink::WebGraphicsContext3D* share_context);
[email protected]180ef242013-11-07 06:50:46134 virtual blink::WebGraphicsContext3DProvider*
[email protected]39604c32013-05-09 12:40:17135 createSharedOffscreenGraphicsContext3DProvider();
[email protected]180ef242013-11-07 06:50:46136 virtual blink::WebCompositorSupport* compositorSupport();
137 virtual blink::WebString convertIDNToUnicode(
138 const blink::WebString& host, const blink::WebString& languages);
[email protected]876526aa2013-07-11 08:00:57139 virtual void setDeviceMotionListener(
[email protected]180ef242013-11-07 06:50:46140 blink::WebDeviceMotionListener* listener) OVERRIDE;
[email protected]cee8a8162013-08-05 21:17:14141 virtual void setDeviceOrientationListener(
[email protected]180ef242013-11-07 06:50:46142 blink::WebDeviceOrientationListener* listener) OVERRIDE;
[email protected]b469e8b2013-07-23 05:25:07143 virtual void queryStorageUsageAndQuota(
[email protected]180ef242013-11-07 06:50:46144 const blink::WebURL& storage_partition,
145 blink::WebStorageQuotaType,
[email protected]45868f072014-02-06 11:58:59146 blink::WebStorageQuotaCallbacks) OVERRIDE;
[email protected]16518f9e2013-07-19 22:20:04147 virtual void vibrate(unsigned int milliseconds);
148 virtual void cancelVibration();
[email protected]785d5142014-02-27 20:03:11149 virtual void setScreenOrientationListener(
150 blink::WebScreenOrientationListener*) OVERRIDE;
[email protected]055e6982014-02-28 16:24:21151 virtual void lockOrientation(blink::WebScreenOrientations) OVERRIDE;
152 virtual void unlockOrientation() OVERRIDE;
[email protected]16518f9e2013-07-19 22:20:04153
[email protected]6d3367d2012-06-05 22:01:02154 // Disables the WebSandboxSupport implementation for testing.
155 // Tests that do not set up a full sandbox environment should call
156 // SetSandboxEnabledForTesting(false) _before_ creating any instances
157 // of this class, to ensure that we don't attempt to use sandbox-related
158 // file descriptors or other resources.
159 //
160 // Returns the previous |enable| value.
161 static bool SetSandboxEnabledForTesting(bool enable);
162
[email protected]e5196922012-12-11 22:18:25163 // Set WebGamepads to return when sampleGamepads() is invoked.
[email protected]180ef242013-11-07 06:50:46164 static void SetMockGamepadsForTesting(const blink::WebGamepads& pads);
[email protected]85603cbb2014-03-25 02:20:01165
166 // Notifies blink::WebGamepadListener about a new gamepad if a listener
167 // has been set via setGamepadListener.
168 static void MockGamepadConnected(int index, const blink::WebGamepad& pad);
169
170 // Notifies blink::WebGamepadListener that a gamepad has been disconnected if
171 // a listener has been set via setGamepadListener.
172 static void MockGamepadDisconnected(int index, const blink::WebGamepad& pad);
173
[email protected]70bf1a6b2013-07-17 17:46:08174 // Set WebDeviceMotionData to return when setDeviceMotionListener is invoked.
175 static void SetMockDeviceMotionDataForTesting(
[email protected]180ef242013-11-07 06:50:46176 const blink::WebDeviceMotionData& data);
[email protected]fb640b462013-08-16 00:00:10177 // Set WebDeviceOrientationData to return when setDeviceOrientationListener
178 // is invoked.
179 static void SetMockDeviceOrientationDataForTesting(
[email protected]180ef242013-11-07 06:50:46180 const blink::WebDeviceOrientationData& data);
[email protected]e0bc2cb2014-03-20 17:34:24181 // Set WebScreenOrientation to return when setScreenOrientationListener is
182 // invoked.
183 static void SetMockScreenOrientationForTesting(blink::WebScreenOrientation);
[email protected]e5196922012-12-11 22:18:25184
[email protected]1406f892013-11-12 19:38:19185 WebDatabaseObserverImpl* web_database_observer_impl() {
186 return web_database_observer_impl_.get();
187 }
188
[email protected]8d86fce2009-02-26 23:37:55189 private:
[email protected]b808eb6f2010-05-18 17:09:33190 bool CheckPreparsedJsCachingEnabled() const;
191
[email protected]0de5d8602011-11-22 03:48:52192 scoped_ptr<RendererClipboardClient> clipboard_client_;
[email protected]bb7538f2013-06-21 00:40:28193 scoped_ptr<WebClipboardImpl> clipboard_;
[email protected]b9a0b1b32009-03-30 23:09:37194
[email protected]9bf103ed2010-08-18 18:34:31195 class FileUtilities;
196 scoped_ptr<FileUtilities> file_utilities_;
[email protected]10b998f82010-05-06 21:08:59197
[email protected]46f36a492010-07-28 19:36:41198 class MimeRegistry;
199 scoped_ptr<MimeRegistry> mime_registry_;
[email protected]bce61672010-06-20 06:54:00200
[email protected]46f36a492010-07-28 19:36:41201 class SandboxSupport;
202 scoped_ptr<SandboxSupport> sandbox_support_;
[email protected]eb6f2c542009-10-02 04:53:59203
204 // This counter keeps track of the number of times sudden termination is
205 // enabled or disabled. It starts at 0 (enabled) and for every disable
206 // increments by 1, for every enable decrements by 1. When it reaches 0,
207 // we tell the browser to enable fast termination.
208 int sudden_termination_disables_;
[email protected]ab3505362009-10-30 18:11:47209
[email protected]a70b4352012-07-31 22:34:53210 // If true, then a GetPlugins call is allowed to rescan the disk.
211 bool plugin_refresh_allowed_;
212
[email protected]180ef242013-11-07 06:50:46213 scoped_ptr<blink::WebIDBFactory> web_idb_factory_;
[email protected]52785d4c2010-08-25 19:44:49214
[email protected]180ef242013-11-07 06:50:46215 scoped_ptr<blink::WebBlobRegistry> blob_registry_;
[email protected]4324e612011-12-01 00:01:38216
[email protected]b9829df2013-11-18 22:03:51217 WebPublicSuffixListImpl public_suffix_list_;
218
[email protected]876526aa2013-07-11 08:00:57219 scoped_ptr<DeviceMotionEventPump> device_motion_event_pump_;
[email protected]cee8a8162013-08-05 21:17:14220 scoped_ptr<DeviceOrientationEventPump> device_orientation_event_pump_;
[email protected]876526aa2013-07-11 08:00:57221
[email protected]ca405d22013-06-25 23:28:55222 scoped_refptr<base::MessageLoopProxy> child_thread_loop_;
223 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
[email protected]b180a0bb2013-03-06 00:36:10224 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
[email protected]a2d03c0b2013-07-29 10:48:11225 scoped_refptr<QuotaMessageFilter> quota_message_filter_;
[email protected]c29b7ff2013-03-06 03:51:04226
[email protected]1406f892013-11-12 19:38:19227 scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_;
228
[email protected]8bcb11a2013-05-10 01:00:00229 webkit::WebCompositorSupportImpl compositor_support_;
[email protected]408699c2013-07-17 21:23:16230
[email protected]785d5142014-02-27 20:03:11231 scoped_ptr<ScreenOrientationDispatcher> screen_orientation_dispatcher_;
232
[email protected]33b02992014-03-01 01:06:29233 scoped_ptr<blink::WebScrollbarBehavior> web_scrollbar_behavior_;
234
[email protected]546d91c42014-02-04 05:13:38235 DISALLOW_COPY_AND_ASSIGN(RendererWebKitPlatformSupportImpl);
[email protected]8d86fce2009-02-26 23:37:55236};
237
[email protected]e9ff79c2012-10-19 21:31:26238} // namespace content
239
[email protected]8d6cba42011-09-02 10:05:19240#endif // CONTENT_RENDERER_RENDERER_WEBKITPLATFORMSUPPORT_IMPL_H_