Commit 286784d8 authored by kinuko@chromium.org's avatar kinuko@chromium.org

2010-08-19 Kinuko Yasuda <kinuko@chromium.org>

        Reviewed by Darin Fisher.

        Add WebKit API for FileSystem API
        https://bugs.webkit.org/show_bug.cgi?id=43151

        Add asynchronous FileSystem interface to WebKit API for
        FileSystem API.
        http://dev.w3.org/2009/dap/file-system/file-dir-sys.html

        * WebKit.gyp:
        * public/WebFileError.h: Added.
        * public/WebFileSystem.h: Added.
        * public/WebFileSystemEntry.h: Added.
        * public/WebFileSystemCallbacks.h: Added.
        * public/WebKitClient.h:
        (WebKit::WebKitClient::fileSystem):
        * public/WebFrameClient.h:
        (WebKit::WebFrameClient::openFileSystem):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65718 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3ffb2e6b
2010-08-19 Kinuko Yasuda <kinuko@chromium.org>
Reviewed by Darin Fisher.
Add WebKit API for FileSystem API
https://bugs.webkit.org/show_bug.cgi?id=43151
Add asynchronous FileSystem interface to WebKit API for
FileSystem API.
http://dev.w3.org/2009/dap/file-system/file-dir-sys.html
* WebKit.gyp:
* public/WebFileError.h: Added.
* public/WebFileSystem.h: Added.
* public/WebFileSystemEntry.h: Added.
* public/WebFileSystemCallbacks.h: Added.
* public/WebKitClient.h:
(WebKit::WebKitClient::fileSystem):
* public/WebFrameClient.h:
(WebKit::WebFrameClient::openFileSystem):
2010-08-19 Kinuko Yasuda <kinuko@chromium.org>
Reviewed by Jian Li.
......
......@@ -163,8 +163,11 @@
'public/WebEventListener.h',
'public/WebFileChooserCompletion.h',
'public/WebFileChooserParams.h',
'public/WebFileError.h',
'public/WebFileInfo.h',
'public/WebFileSystem.h',
'public/WebFileSystemCallbacks.h',
'public/WebFileSystemEntry.h',
'public/WebFileUtilities.h',
'public/WebFindOptions.h',
'public/WebFloatPoint.h',
......
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebFileError_h
#define WebFileError_h
namespace WebKit {
// File-related error code defined in HTML5 File API.
enum WebFileError {
WebFileErrorNoModificationAllowed = 7,
WebFileErrorNotFound = 8,
WebFileErrorInvalidState = 11,
WebFileErrorInvalidModification = 13,
WebFileErrorSecurity = 18,
WebFileErrorAbort = 20,
WebFileErrorQuotaExceeded = 22,
WebFileErrorNotReadable = 24,
WebFileErrorEncoding = 26,
};
} // namespace WebKit
#endif
......@@ -31,12 +31,77 @@
#ifndef WebFileSystem_h
#define WebFileSystem_h
#include "WebFileUtilities.h"
#include "WebCommon.h"
#include "WebString.h"
namespace WebKit {
// FIXME: Clean up this class once the renaming to WebFileUtilities is done.
class WebFileSystem : public WebFileUtilities {
class WebFileSystemCallbacks;
class WebFileSystem {
public:
enum Type {
TypeTemporary,
TypePersistent,
};
// Moves a file or directory at |srcPath| to |destPath|.
// WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void move(const WebString& srcPath, const WebString& destPath, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Copies a file or directory at |srcPath| to |destPath|.
// WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void copy(const WebString& srcPath, const WebString& destPath, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Deletes a file or directory at a given |path|.
// WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void remove(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Retrieves the metadata information of the file or directory at the given |path|.
// WebFileSystemCallbacks::didReadMetadata() must be called with a valid metadata when the retrieval is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void readMetadata(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Creates a file at given |path|.
// If the |path| doesn't exist, it creates a new file at |path|.
// If |exclusive| is true, it fails if the |path| already exists.
// If |exclusive| is false, it succeeds if the |path| already exists or
// it has successfully created a new file at |path|.
//
// WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void createFile(const WebString& path, bool exclusive, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Creates a directory at a given |path|.
// If the |path| doesn't exist, it creates a new directory at |path|.
// If |exclusive| is true, it fails if the |path| already exists.
// If |exclusive| is false, it succeeds if the |path| already exists or it has successfully created a new directory at |path|.
//
// WebFileSystemCallbacks::didSucceed() must be called when
// the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void createDirectory(const WebString& path, bool exclusive, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Checks if a file exists at a given |path|.
// WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void fileExists(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Checks if a directory exists at a given |path|.
// WebFileSystemCallbacks::didSucceed() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void directoryExists(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
// Reads directory entries of a given directory at |path|.
// WebFileSystemCallbacks::didReadDirectory() must be called when the operation is completed successfully.
// WebFileSystemCallbacks::didFail() must be called otherwise.
virtual void readDirectory(const WebString& path, WebFileSystemCallbacks*) { WEBKIT_ASSERT_NOT_REACHED(); }
protected:
virtual ~WebFileSystem() { }
};
} // namespace WebKit
......
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebFileSystemCallbacks_h
#define WebFileSystemCallbacks_h
#include "WebFileError.h"
#include "WebFileSystemEntry.h"
#include "WebVector.h"
namespace WebKit {
class WebString;
struct WebFileInfo;
class WebFileSystemCallbacks {
public:
// Callback for WebFileSystem's various operations that don't require
// return values.
virtual void didSucceed() = 0;
// Callback for WebFileSystem::readMetadata. Called with the file metadata
// for the requested path.
virtual void didReadMetadata(const WebFileInfo&) = 0;
// Callback for WebFileSystem::readDirectory. Called with a vector of
// file entries in the requested directory. This callback might be called
// multiple times if the directory has many entries. |hasMore| must be
// true when there are more entries.
virtual void didReadDirectory(const WebVector<WebFileSystemEntry>&, bool hasMore) = 0;
// Callback for WebFrameClient::openFileSystem. Called with a name and
// root path for the FileSystem when the request is accepted.
virtual void didOpenFileSystem(const WebString& name, const WebString& rootPath) = 0;
// Called with an error code when a requested operation hasn't been
// completed.
virtual void didFail(WebFileError) = 0;
protected:
virtual ~WebFileSystemCallbacks() {}
};
} // namespace WebKit
#endif
/*
* Copyright (C) 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebFileSystemEntry_h
#define WebFileSystemEntry_h
#include "WebString.h"
namespace WebKit {
struct WebFileSystemEntry {
WebFileSystemEntry() : isDirectory(false) { }
// The name of the entry.
WebString name;
// This flag indicates if the entry is directory or not.
bool isDirectory;
};
} // namespace WebKit
#endif // WebFileSystemEntry_h
......@@ -32,6 +32,7 @@
#define WebFrameClient_h
#include "WebCommon.h"
#include "WebFileSystem.h"
#include "WebNavigationPolicy.h"
#include "WebNavigationType.h"
#include "WebURLError.h"
......@@ -333,6 +334,19 @@ public:
virtual void reportFindInPageSelection(
int identifier, int activeMatchOrdinal, const WebRect& selection) { }
// FileSystem ----------------------------------------------------
// Requests to open a FileSystem.
// |size| indicates how much storage space (in bytes) the caller expects
// to need.
// WebFileSystemCallbacks::didOpenFileSystem() must be called with
// a name and root path for the requested FileSystem when the operation
// is completed successfully. WebFileSystemCallbacks::didFail() must be
// called otherwise.
virtual void openFileSystem(
WebFrame*, WebFileSystem::Type, long long size,
WebFileSystemCallbacks*) { }
protected:
~WebFrameClient() { }
};
......
......@@ -33,7 +33,6 @@
#include "WebCommon.h"
#include "WebData.h"
#include "WebFileSystem.h"
#include "WebLocalizedString.h"
#include "WebString.h"
#include "WebURL.h"
......@@ -51,6 +50,7 @@ class WebApplicationCacheHostClient;
class WebBlobRegistry;
class WebClipboard;
class WebCookieJar;
class WebFileSystem;
class WebFileUtilities;
class WebGLES2Context;
class WebGraphicsContext3D;
......@@ -74,12 +74,7 @@ public:
virtual WebMimeRegistry* mimeRegistry() { return 0; }
// Must return non-null.
// FIXME: Clean up this one once the renaming to WebFileUtilities is done.
virtual WebFileSystem* fileSystem() { return 0; }
// Must return non-null.
// FIXME: Clean up this one once the renaming from WebFileSystem is done.
virtual WebFileUtilities* fileUtilities() { return fileSystem(); }
virtual WebFileUtilities* fileUtilities() { return 0; }
// May return null if sandbox support is not necessary
virtual WebSandboxSupport* sandboxSupport() { return 0; }
......@@ -274,6 +269,11 @@ public:
// May return null if it fails to create the context.
virtual WebGLES2Context* createGLES2Context() { return 0; }
// FileSystem ----------------------------------------------------------
// Must return non-null.
virtual WebFileSystem* fileSystem() { return 0; }
protected:
~WebKitClient() { }
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment