diff options
-rw-r--r-- | content/common/file_system/webfilesystem_callback_dispatcher.cc | 10 | ||||
-rw-r--r-- | content/common/file_system/webfilesystem_impl.cc | 89 | ||||
-rw-r--r-- | content/common/file_system/webfilesystem_impl.h | 50 | ||||
-rw-r--r-- | webkit/fileapi/file_system_util.cc | 8 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_file_system.cc | 108 | ||||
-rw-r--r-- | webkit/tools/test_shell/simple_file_system.h | 51 |
6 files changed, 275 insertions, 41 deletions
diff --git a/content/common/file_system/webfilesystem_callback_dispatcher.cc b/content/common/file_system/webfilesystem_callback_dispatcher.cc index c59e377..00c3cdc 100644 --- a/content/common/file_system/webfilesystem_callback_dispatcher.cc +++ b/content/common/file_system/webfilesystem_callback_dispatcher.cc @@ -15,12 +15,14 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallbacks.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" #include "webkit/glue/webkit_glue.h" using WebKit::WebFileInfo; using WebKit::WebFileSystemCallbacks; using WebKit::WebFileSystemEntry; using WebKit::WebString; +using WebKit::WebURL; using WebKit::WebVector; WebFileSystemCallbackDispatcher::WebFileSystemCallbackDispatcher( @@ -60,8 +62,12 @@ void WebFileSystemCallbackDispatcher::DidReadDirectory( void WebFileSystemCallbackDispatcher::DidOpenFileSystem( const std::string& name, const GURL& root) { - callbacks_->didOpenFileSystem( - UTF8ToUTF16(name), UTF8ToUTF16(root.spec())); +// Temporary hack to ease a 4-phase Chromium/WebKit commit. +#ifdef WEBFILESYSTEMCALLBACKS_USE_URL_NOT_STRING + callbacks_->didOpenFileSystem(UTF8ToUTF16(name), root); +#else + callbacks_->didOpenFileSystem(UTF8ToUTF16(name), UTF8ToUTF16(root.spec())); +#endif } void WebFileSystemCallbackDispatcher::DidFail( diff --git a/content/common/file_system/webfilesystem_impl.cc b/content/common/file_system/webfilesystem_impl.cc index 38f1d2a..977bec4 100644 --- a/content/common/file_system/webfilesystem_impl.cc +++ b/content/common/file_system/webfilesystem_impl.cc @@ -11,19 +11,21 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileInfo.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallbacks.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" #include "webkit/glue/webkit_glue.h" using WebKit::WebFileInfo; using WebKit::WebFileSystemCallbacks; using WebKit::WebFileSystemEntry; using WebKit::WebString; +using WebKit::WebURL; using WebKit::WebVector; WebFileSystemImpl::WebFileSystemImpl() { } -void WebFileSystemImpl::move(const WebString& src_path, - const WebString& dest_path, +void WebFileSystemImpl::move(const WebURL& src_path, + const WebURL& dest_path, WebFileSystemCallbacks* callbacks) { FileSystemDispatcher* dispatcher = ChildThread::current()->file_system_dispatcher(); @@ -32,8 +34,8 @@ void WebFileSystemImpl::move(const WebString& src_path, new WebFileSystemCallbackDispatcher(callbacks)); } -void WebFileSystemImpl::copy(const WebString& src_path, - const WebString& dest_path, +void WebFileSystemImpl::copy(const WebURL& src_path, + const WebURL& dest_path, WebFileSystemCallbacks* callbacks) { FileSystemDispatcher* dispatcher = ChildThread::current()->file_system_dispatcher(); @@ -42,7 +44,7 @@ void WebFileSystemImpl::copy(const WebString& src_path, new WebFileSystemCallbackDispatcher(callbacks)); } -void WebFileSystemImpl::remove(const WebString& path, +void WebFileSystemImpl::remove(const WebURL& path, WebFileSystemCallbacks* callbacks) { FileSystemDispatcher* dispatcher = ChildThread::current()->file_system_dispatcher(); @@ -51,7 +53,7 @@ void WebFileSystemImpl::remove(const WebString& path, new WebFileSystemCallbackDispatcher(callbacks)); } -void WebFileSystemImpl::removeRecursively(const WebString& path, +void WebFileSystemImpl::removeRecursively(const WebURL& path, WebFileSystemCallbacks* callbacks) { FileSystemDispatcher* dispatcher = ChildThread::current()->file_system_dispatcher(); @@ -60,7 +62,7 @@ void WebFileSystemImpl::removeRecursively(const WebString& path, new WebFileSystemCallbackDispatcher(callbacks)); } -void WebFileSystemImpl::readMetadata(const WebString& path, +void WebFileSystemImpl::readMetadata(const WebURL& path, WebFileSystemCallbacks* callbacks) { FileSystemDispatcher* dispatcher = ChildThread::current()->file_system_dispatcher(); @@ -68,7 +70,7 @@ void WebFileSystemImpl::readMetadata(const WebString& path, new WebFileSystemCallbackDispatcher(callbacks)); } -void WebFileSystemImpl::createFile(const WebString& path, +void WebFileSystemImpl::createFile(const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) { FileSystemDispatcher* dispatcher = @@ -77,7 +79,7 @@ void WebFileSystemImpl::createFile(const WebString& path, false, new WebFileSystemCallbackDispatcher(callbacks)); } -void WebFileSystemImpl::createDirectory(const WebString& path, +void WebFileSystemImpl::createDirectory(const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) { FileSystemDispatcher* dispatcher = @@ -86,7 +88,7 @@ void WebFileSystemImpl::createDirectory(const WebString& path, false, new WebFileSystemCallbackDispatcher(callbacks)); } -void WebFileSystemImpl::fileExists(const WebString& path, +void WebFileSystemImpl::fileExists(const WebURL& path, WebFileSystemCallbacks* callbacks) { FileSystemDispatcher* dispatcher = ChildThread::current()->file_system_dispatcher(); @@ -94,7 +96,7 @@ void WebFileSystemImpl::fileExists(const WebString& path, new WebFileSystemCallbackDispatcher(callbacks)); } -void WebFileSystemImpl::directoryExists(const WebString& path, +void WebFileSystemImpl::directoryExists(const WebURL& path, WebFileSystemCallbacks* callbacks) { FileSystemDispatcher* dispatcher = ChildThread::current()->file_system_dispatcher(); @@ -102,7 +104,7 @@ void WebFileSystemImpl::directoryExists(const WebString& path, new WebFileSystemCallbackDispatcher(callbacks)); } -void WebFileSystemImpl::readDirectory(const WebString& path, +void WebFileSystemImpl::readDirectory(const WebURL& path, WebFileSystemCallbacks* callbacks) { FileSystemDispatcher* dispatcher = ChildThread::current()->file_system_dispatcher(); @@ -111,6 +113,67 @@ void WebFileSystemImpl::readDirectory(const WebString& path, } WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( - const WebString& path, WebKit::WebFileWriterClient* client) { + const WebURL& path, WebKit::WebFileWriterClient* client) { return new WebFileWriterImpl(GURL(path), client); } + +// These are temporary shims to link up the old calls to the new implementation. +// They'll go away as soon as the webkit side gets updated. +void WebFileSystemImpl::move(const WebString& src_path, + const WebString& dest_path, + WebFileSystemCallbacks* callbacks) { + move(GURL(src_path), GURL(dest_path), callbacks); +} + +void WebFileSystemImpl::copy(const WebString& src_path, + const WebString& dest_path, + WebFileSystemCallbacks* callbacks) { + copy(GURL(src_path), GURL(dest_path), callbacks); +} + +void WebFileSystemImpl::remove(const WebString& path, + WebFileSystemCallbacks* callbacks) { + remove(GURL(path), callbacks); +} + +void WebFileSystemImpl::removeRecursively(const WebString& path, + WebFileSystemCallbacks* callbacks) { + removeRecursively(GURL(path), callbacks); +} + +void WebFileSystemImpl::readMetadata(const WebString& path, + WebFileSystemCallbacks* callbacks) { + readMetadata(GURL(path), callbacks); +} + +void WebFileSystemImpl::createFile(const WebString& path, + bool exclusive, + WebFileSystemCallbacks* callbacks) { + createFile(GURL(path), exclusive, callbacks); +} + +void WebFileSystemImpl::createDirectory(const WebString& path, + bool exclusive, + WebFileSystemCallbacks* callbacks) { + createDirectory(GURL(path), exclusive, callbacks); +} + +void WebFileSystemImpl::fileExists(const WebString& path, + WebFileSystemCallbacks* callbacks) { + fileExists(GURL(path), callbacks); +} + +void WebFileSystemImpl::directoryExists(const WebString& path, + WebFileSystemCallbacks* callbacks) { + directoryExists(GURL(path), callbacks); +} + +void WebFileSystemImpl::readDirectory(const WebString& path, + WebFileSystemCallbacks* callbacks) { + readDirectory(GURL(path), callbacks); +} + +WebKit::WebFileWriter* WebFileSystemImpl::createFileWriter( + const WebString& path, WebKit::WebFileWriterClient* client) { + return createFileWriter(GURL(path), client); +} diff --git a/content/common/file_system/webfilesystem_impl.h b/content/common/file_system/webfilesystem_impl.h index 1d8b002..b28cd1e 100644 --- a/content/common/file_system/webfilesystem_impl.h +++ b/content/common/file_system/webfilesystem_impl.h @@ -9,6 +9,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystem.h" namespace WebKit { +class WebURL; class WebFileWriter; class WebFileWriterClient; } @@ -18,6 +19,55 @@ class WebFileSystemImpl : public WebKit::WebFileSystem { WebFileSystemImpl(); virtual ~WebFileSystemImpl() { } + // New WebFileSystem overrides. + virtual void move( + const WebKit::WebURL& src_path, + const WebKit::WebURL& dest_path, + WebKit::WebFileSystemCallbacks*); + + virtual void copy( + const WebKit::WebURL& src_path, + const WebKit::WebURL& dest_path, + WebKit::WebFileSystemCallbacks*); + + virtual void remove( + const WebKit::WebURL& path, + WebKit::WebFileSystemCallbacks*); + + virtual void removeRecursively( + const WebKit::WebURL& path, + WebKit::WebFileSystemCallbacks*); + + virtual void readMetadata( + const WebKit::WebURL& path, + WebKit::WebFileSystemCallbacks*); + + virtual void createFile( + const WebKit::WebURL& path, + bool exclusive, + WebKit::WebFileSystemCallbacks*); + + virtual void createDirectory( + const WebKit::WebURL& path, + bool exclusive, + WebKit::WebFileSystemCallbacks*); + + virtual void fileExists( + const WebKit::WebURL& path, + WebKit::WebFileSystemCallbacks*); + + virtual void directoryExists( + const WebKit::WebURL& path, + WebKit::WebFileSystemCallbacks*); + + virtual void readDirectory( + const WebKit::WebURL& path, + WebKit::WebFileSystemCallbacks*); + + virtual WebKit::WebFileWriter* createFileWriter( + const WebKit::WebURL& path, WebKit::WebFileWriterClient*); + + // Old WebFileSystem overrides, soon to go away. virtual void move( const WebKit::WebString& src_path, const WebKit::WebString& dest_path, diff --git a/webkit/fileapi/file_system_util.cc b/webkit/fileapi/file_system_util.cc index 80b22e4..ff2024f 100644 --- a/webkit/fileapi/file_system_util.cc +++ b/webkit/fileapi/file_system_util.cc @@ -36,8 +36,9 @@ bool CrackFileSystemURL(const GURL& url, GURL* origin_url, FileSystemType* type, return false; std::string temp = url.path(); - // TODO(ericu) remove this code when that ceases to be true, which should be - // soon. + // TODO(ericu) remove this code when that ceases to be true, which will be as + // soon as the WEBFILESYSTEMCALLBACKS_USE_URL_NOT_STRING macro goes into + // WebKit. // On Windows, this will have backslashes for now. // url will look something like: // filesystem:http://example.com/temporary/\dir\file.txt @@ -63,8 +64,7 @@ bool CrackFileSystemURL(const GURL& url, GURL* origin_url, FileSystemType* type, } // bare_url will look something like: - // http://example.com/temporary//dir/file.txt [on Windows; the double slash - // before dir will be single on posix]. + // http://example.com/temporary/dir/file.txt. GURL bare_url(temp); // The input URL was malformed, bail out early. diff --git a/webkit/tools/test_shell/simple_file_system.cc b/webkit/tools/test_shell/simple_file_system.cc index 77a7a21..31de57f 100644 --- a/webkit/tools/test_shell/simple_file_system.cc +++ b/webkit/tools/test_shell/simple_file_system.cc @@ -16,6 +16,7 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemEntry.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" #include "webkit/fileapi/file_system_callback_dispatcher.h" #include "webkit/fileapi/file_system_context.h" @@ -37,6 +38,7 @@ using WebKit::WebFileWriterClient; using WebKit::WebFrame; using WebKit::WebSecurityOrigin; using WebKit::WebString; +using WebKit::WebURL; using WebKit::WebVector; using fileapi::FileSystemCallbackDispatcher; @@ -100,8 +102,13 @@ class SimpleFileSystemCallbackDispatcher if (!root.is_valid()) callbacks_->didFail(WebKit::WebFileErrorSecurity); else +// Temporary hack to ease a 4-phase Chromium/WebKit commit. +#ifdef WEBFILESYSTEMCALLBACKS_USE_URL_NOT_STRING + callbacks_->didOpenFileSystem(WebString::fromUTF8(name), root); +#else callbacks_->didOpenFileSystem( WebString::fromUTF8(name), WebString::fromUTF8(root.spec())); +#endif } virtual void DidFail(base::PlatformFileError error_code) { @@ -169,61 +176,120 @@ void SimpleFileSystem::OpenFileSystem( GetNewOperation(callbacks)->OpenFileSystem(origin_url, type, create); } +void SimpleFileSystem::move(const WebString& src_path, + const WebString& dest_path, + WebFileSystemCallbacks* callbacks) { + move(GURL(src_path), GURL(dest_path), callbacks); +} + +void SimpleFileSystem::copy(const WebString& src_path, + const WebString& dest_path, + WebFileSystemCallbacks* callbacks) { + copy(GURL(src_path), GURL(dest_path), callbacks); +} + +void SimpleFileSystem::remove(const WebString& path, + WebFileSystemCallbacks* callbacks) { + remove(GURL(path), callbacks); +} + +void SimpleFileSystem::removeRecursively(const WebString& path, + WebFileSystemCallbacks* callbacks) { + removeRecursively(GURL(path), callbacks); +} + +void SimpleFileSystem::readMetadata(const WebString& path, + WebFileSystemCallbacks* callbacks) { + readMetadata(GURL(path), callbacks); +} + +void SimpleFileSystem::createFile(const WebString& path, + bool exclusive, + WebFileSystemCallbacks* callbacks) { + createFile(GURL(path), exclusive, callbacks); +} + +void SimpleFileSystem::createDirectory(const WebString& path, + bool exclusive, + WebFileSystemCallbacks* callbacks) { + createDirectory(GURL(path), exclusive, callbacks); +} + +void SimpleFileSystem::fileExists(const WebString& path, + WebFileSystemCallbacks* callbacks) { + fileExists(GURL(path), callbacks); +} + +void SimpleFileSystem::directoryExists(const WebString& path, + WebFileSystemCallbacks* callbacks) { + directoryExists(GURL(path), callbacks); +} + +void SimpleFileSystem::readDirectory(const WebString& path, + WebFileSystemCallbacks* callbacks) { + readDirectory(GURL(path), callbacks); +} + +WebKit::WebFileWriter* SimpleFileSystem::createFileWriter( + const WebString& path, WebKit::WebFileWriterClient* client) { + return createFileWriter(GURL(path), client); +} + void SimpleFileSystem::move( - const WebString& src_path, - const WebString& dest_path, WebFileSystemCallbacks* callbacks) { + const WebURL& src_path, + const WebURL& dest_path, WebFileSystemCallbacks* callbacks) { GetNewOperation(callbacks)->Move(GURL(src_path), GURL(dest_path)); } void SimpleFileSystem::copy( - const WebString& src_path, const WebString& dest_path, + const WebURL& src_path, const WebURL& dest_path, WebFileSystemCallbacks* callbacks) { GetNewOperation(callbacks)->Copy(GURL(src_path), GURL(dest_path)); } void SimpleFileSystem::remove( - const WebString& path, WebFileSystemCallbacks* callbacks) { - GetNewOperation(callbacks)->Remove(GURL(path), false /* recursive */); + const WebURL& path, WebFileSystemCallbacks* callbacks) { + GetNewOperation(callbacks)->Remove(path, false /* recursive */); } void SimpleFileSystem::removeRecursively( - const WebString& path, WebFileSystemCallbacks* callbacks) { - GetNewOperation(callbacks)->Remove(GURL(path), true /* recursive */); + const WebURL& path, WebFileSystemCallbacks* callbacks) { + GetNewOperation(callbacks)->Remove(path, true /* recursive */); } void SimpleFileSystem::readMetadata( - const WebString& path, WebFileSystemCallbacks* callbacks) { - GetNewOperation(callbacks)->GetMetadata(GURL(path)); + const WebURL& path, WebFileSystemCallbacks* callbacks) { + GetNewOperation(callbacks)->GetMetadata(path); } void SimpleFileSystem::createFile( - const WebString& path, bool exclusive, WebFileSystemCallbacks* callbacks) { - GetNewOperation(callbacks)->CreateFile(GURL(path), exclusive); + const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) { + GetNewOperation(callbacks)->CreateFile(path, exclusive); } void SimpleFileSystem::createDirectory( - const WebString& path, bool exclusive, WebFileSystemCallbacks* callbacks) { - GetNewOperation(callbacks)->CreateDirectory(GURL(path), exclusive, false); + const WebURL& path, bool exclusive, WebFileSystemCallbacks* callbacks) { + GetNewOperation(callbacks)->CreateDirectory(path, exclusive, false); } void SimpleFileSystem::fileExists( - const WebString& path, WebFileSystemCallbacks* callbacks) { - GetNewOperation(callbacks)->FileExists(GURL(path)); + const WebURL& path, WebFileSystemCallbacks* callbacks) { + GetNewOperation(callbacks)->FileExists(path); } void SimpleFileSystem::directoryExists( - const WebString& path, WebFileSystemCallbacks* callbacks) { - GetNewOperation(callbacks)->DirectoryExists(GURL(path)); + const WebURL& path, WebFileSystemCallbacks* callbacks) { + GetNewOperation(callbacks)->DirectoryExists(path); } void SimpleFileSystem::readDirectory( - const WebString& path, WebFileSystemCallbacks* callbacks) { - GetNewOperation(callbacks)->ReadDirectory(GURL(path)); + const WebURL& path, WebFileSystemCallbacks* callbacks) { + GetNewOperation(callbacks)->ReadDirectory(path); } WebFileWriter* SimpleFileSystem::createFileWriter( - const WebString& path, WebFileWriterClient* client) { - return new SimpleFileWriter(GURL(path), client, file_system_context_.get()); + const WebURL& path, WebFileWriterClient* client) { + return new SimpleFileWriter(path, client, file_system_context_.get()); } FileSystemOperation* SimpleFileSystem::GetNewOperation( diff --git a/webkit/tools/test_shell/simple_file_system.h b/webkit/tools/test_shell/simple_file_system.h index ddc4fce..1cd983c 100644 --- a/webkit/tools/test_shell/simple_file_system.h +++ b/webkit/tools/test_shell/simple_file_system.h @@ -16,6 +16,7 @@ namespace WebKit { class WebFileSystemCallbacks; class WebFrame; +class WebURL; } namespace fileapi { @@ -40,7 +41,55 @@ class SimpleFileSystem return file_system_context_.get(); } - // WebKit::WebFileSystem methods. + // New WebKit::WebFileSystem overrides. + virtual void move( + const WebKit::WebURL& src_path, + const WebKit::WebURL& dest_path, + WebKit::WebFileSystemCallbacks*); + + virtual void copy( + const WebKit::WebURL& src_path, + const WebKit::WebURL& dest_path, + WebKit::WebFileSystemCallbacks*); + + virtual void remove( + const WebKit::WebURL& path, + WebKit::WebFileSystemCallbacks*); + + virtual void removeRecursively( + const WebKit::WebURL& path, + WebKit::WebFileSystemCallbacks*); + + virtual void readMetadata( + const WebKit::WebURL& path, + WebKit::WebFileSystemCallbacks*); + + virtual void createFile( + const WebKit::WebURL& path, + bool exclusive, + WebKit::WebFileSystemCallbacks*); + + virtual void createDirectory( + const WebKit::WebURL& path, + bool exclusive, + WebKit::WebFileSystemCallbacks*); + + virtual void fileExists( + const WebKit::WebURL& path, + WebKit::WebFileSystemCallbacks*); + + virtual void directoryExists( + const WebKit::WebURL& path, + WebKit::WebFileSystemCallbacks*); + + virtual void readDirectory( + const WebKit::WebURL& path, + WebKit::WebFileSystemCallbacks*); + + virtual WebKit::WebFileWriter* createFileWriter( + const WebKit::WebURL& path, WebKit::WebFileWriterClient*); + + // Old WebKit::WebFileSystem overrides, soon to go away. virtual void move(const WebKit::WebString& src_path, const WebKit::WebString& dest_path, WebKit::WebFileSystemCallbacks* callbacks); |