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. 4 5 #ifndef CONTENT_WORKER_WORKER_WEBKITPLATFORMSUPPORT_IMPL_H_ 6 #define CONTENT_WORKER_WORKER_WEBKITPLATFORMSUPPORT_IMPL_H_ 7 8 #include "base/memory/scoped_ptr.h" 9 #include "content/child/blink_platform_impl.h" 10 #include "third_party/WebKit/public/platform/WebIDBFactory.h" 11 #include "third_party/WebKit/public/platform/WebMimeRegistry.h" 12 13 namespace base { 14 class MessageLoopProxy; 15 } 16 17 namespace IPC { 18 class SyncMessageFilter; 19 } 20 21 namespace blink { 22 class WebFileUtilities; 23 } 24 25 namespace content { 26 class QuotaMessageFilter; 27 class ThreadSafeSender; 28 class WebDatabaseObserverImpl; 29 class WebFileSystemImpl; 30 31 class WorkerWebKitPlatformSupportImpl : public BlinkPlatformImpl, 32 public blink::WebMimeRegistry { 33 public: 34 WorkerWebKitPlatformSupportImpl( 35 ThreadSafeSender* sender, 36 IPC::SyncMessageFilter* sync_message_filter, 37 QuotaMessageFilter* quota_message_filter); 38 virtual ~WorkerWebKitPlatformSupportImpl(); 39 40 // WebKitPlatformSupport methods: 41 virtual blink::WebClipboard* clipboard(); 42 virtual blink::WebMimeRegistry* mimeRegistry(); 43 virtual blink::WebFileSystem* fileSystem(); 44 virtual blink::WebFileUtilities* fileUtilities(); 45 virtual blink::WebSandboxSupport* sandboxSupport(); 46 virtual bool sandboxEnabled(); 47 virtual unsigned long long visitedLinkHash(const char* canonicalURL, 48 size_t length); 49 virtual bool isLinkVisited(unsigned long long linkHash); 50 virtual void createMessageChannel(blink::WebMessagePortChannel** channel1, 51 blink::WebMessagePortChannel** channel2); 52 virtual void setCookies(const blink::WebURL& url, 53 const blink::WebURL& first_party_for_cookies, 54 const blink::WebString& value); 55 virtual blink::WebString cookies( 56 const blink::WebURL& url, 57 const blink::WebURL& first_party_for_cookies); 58 virtual blink::WebString defaultLocale(); 59 virtual blink::WebStorageNamespace* createLocalStorageNamespace(); 60 virtual void dispatchStorageEvent( 61 const blink::WebString& key, const blink::WebString& old_value, 62 const blink::WebString& new_value, const blink::WebString& origin, 63 const blink::WebURL& url, bool is_local_storage); 64 65 virtual blink::Platform::FileHandle databaseOpenFile( 66 const blink::WebString& vfs_file_name, int desired_flags); 67 virtual int databaseDeleteFile(const blink::WebString& vfs_file_name, 68 bool sync_dir); 69 virtual long databaseGetFileAttributes( 70 const blink::WebString& vfs_file_name); 71 virtual long long databaseGetFileSize( 72 const blink::WebString& vfs_file_name); 73 virtual long long databaseGetSpaceAvailableForOrigin( 74 const blink::WebString& origin_identifier); 75 virtual blink::WebBlobRegistry* blobRegistry(); 76 virtual blink::WebIDBFactory* idbFactory(); 77 virtual blink::WebDatabaseObserver* databaseObserver(); 78 79 // WebMimeRegistry methods: 80 virtual blink::WebMimeRegistry::SupportsType supportsMIMEType( 81 const blink::WebString&); 82 virtual blink::WebMimeRegistry::SupportsType supportsImageMIMEType( 83 const blink::WebString&); 84 virtual blink::WebMimeRegistry::SupportsType supportsJavaScriptMIMEType( 85 const blink::WebString&); 86 virtual blink::WebMimeRegistry::SupportsType supportsMediaMIMEType( 87 const blink::WebString&, 88 const blink::WebString&, 89 const blink::WebString&); 90 virtual bool supportsMediaSourceMIMEType( 91 const blink::WebString&, 92 const blink::WebString&); 93 virtual bool supportsEncryptedMediaMIMEType(const blink::WebString&, 94 const blink::WebString&, 95 const blink::WebString&); 96 virtual blink::WebMimeRegistry::SupportsType supportsNonImageMIMEType( 97 const blink::WebString&); 98 virtual blink::WebString mimeTypeForExtension(const blink::WebString&); 99 virtual blink::WebString wellKnownMimeTypeForExtension( 100 const blink::WebString&); 101 virtual blink::WebString mimeTypeFromFile(const blink::WebString&); 102 virtual void queryStorageUsageAndQuota( 103 const blink::WebURL& storage_partition, 104 blink::WebStorageQuotaType, 105 blink::WebStorageQuotaCallbacks) OVERRIDE; 106 web_database_observer_impl()107 WebDatabaseObserverImpl* web_database_observer_impl() { 108 return web_database_observer_impl_.get(); 109 } 110 111 private: 112 113 class FileUtilities; 114 scoped_ptr<FileUtilities> file_utilities_; 115 scoped_ptr<blink::WebBlobRegistry> blob_registry_; 116 scoped_ptr<blink::WebIDBFactory> web_idb_factory_; 117 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 118 scoped_refptr<base::MessageLoopProxy> child_thread_loop_; 119 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_; 120 scoped_refptr<QuotaMessageFilter> quota_message_filter_; 121 scoped_ptr<WebDatabaseObserverImpl> web_database_observer_impl_; 122 123 DISALLOW_COPY_AND_ASSIGN(WorkerWebKitPlatformSupportImpl); 124 }; 125 126 } // namespace content 127 128 #endif // CONTENT_WORKER_WORKER_WEBKITPLATFORMSUPPORT_IMPL_H_ 129