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