2012-02-17 15:51:20 +01:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
2010-10-15 20:37:25 +02:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2010-10-03 22:35:06 +02:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#ifndef CEF_LIBCEF_BROWSER_FILE_SYSTEM_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_FILE_SYSTEM_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
2010-10-03 22:35:06 +02:00
|
|
|
|
|
|
|
#include "base/file_util_proxy.h"
|
|
|
|
#include "base/id_map.h"
|
2011-04-05 18:17:33 +02:00
|
|
|
#include "base/memory/weak_ptr.h"
|
2011-12-16 15:51:10 +01:00
|
|
|
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSystem.h"
|
2012-02-18 01:19:52 +01:00
|
|
|
#include "webkit/fileapi/file_system_context.h"
|
2012-08-29 22:11:26 +02:00
|
|
|
#include "webkit/fileapi/file_system_operation.h"
|
2010-12-16 22:54:42 +01:00
|
|
|
#include "webkit/fileapi/file_system_types.h"
|
2010-10-03 22:35:06 +02:00
|
|
|
|
2010-12-16 22:54:42 +01:00
|
|
|
namespace WebKit {
|
|
|
|
class WebFileSystemCallbacks;
|
|
|
|
class WebFrame;
|
2011-07-03 02:03:30 +02:00
|
|
|
class WebURL;
|
2010-12-16 22:54:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace fileapi {
|
2011-02-15 19:07:24 +01:00
|
|
|
class FileSystemContext;
|
2012-08-07 15:58:35 +02:00
|
|
|
class FileSystemURL;
|
2010-12-16 22:54:42 +01:00
|
|
|
}
|
|
|
|
|
2012-04-05 00:32:24 +02:00
|
|
|
namespace webkit_blob {
|
|
|
|
class BlobStorageController;
|
|
|
|
}
|
|
|
|
|
2010-12-16 22:54:42 +01:00
|
|
|
class BrowserFileSystem
|
|
|
|
: public WebKit::WebFileSystem,
|
|
|
|
public base::SupportsWeakPtr<BrowserFileSystem> {
|
2010-10-03 22:35:06 +02:00
|
|
|
public:
|
2010-12-16 22:54:42 +01:00
|
|
|
BrowserFileSystem();
|
2010-10-03 22:35:06 +02:00
|
|
|
virtual ~BrowserFileSystem();
|
|
|
|
|
2011-12-06 11:16:51 +01:00
|
|
|
void CreateContext();
|
|
|
|
|
2010-12-16 22:54:42 +01:00
|
|
|
void OpenFileSystem(WebKit::WebFrame* frame,
|
|
|
|
WebKit::WebFileSystem::Type type,
|
2012-01-10 00:46:23 +01:00
|
|
|
long long size, // NOLINT(runtime/int)
|
2010-12-16 22:54:42 +01:00
|
|
|
bool create,
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks);
|
2012-08-29 22:11:26 +02:00
|
|
|
void DeleteFileSystem(WebKit::WebFrame* frame,
|
|
|
|
WebKit::WebFileSystem::Type type,
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks);
|
2010-10-03 22:35:06 +02:00
|
|
|
|
2011-04-05 18:17:33 +02:00
|
|
|
fileapi::FileSystemContext* file_system_context() {
|
|
|
|
return file_system_context_.get();
|
|
|
|
}
|
|
|
|
|
2011-09-10 21:40:03 +02:00
|
|
|
// WebKit::WebFileSystem implementation.
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void move(
|
|
|
|
const WebKit::WebURL& src_path,
|
|
|
|
const WebKit::WebURL& dest_path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void copy(
|
|
|
|
const WebKit::WebURL& src_path,
|
|
|
|
const WebKit::WebURL& dest_path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void remove(
|
|
|
|
const WebKit::WebURL& path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void removeRecursively(
|
|
|
|
const WebKit::WebURL& path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void readMetadata(
|
|
|
|
const WebKit::WebURL& path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void createFile(
|
|
|
|
const WebKit::WebURL& path,
|
|
|
|
bool exclusive,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void createDirectory(
|
|
|
|
const WebKit::WebURL& path,
|
|
|
|
bool exclusive,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void fileExists(
|
|
|
|
const WebKit::WebURL& path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void directoryExists(
|
|
|
|
const WebKit::WebURL& path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2011-07-03 02:03:30 +02:00
|
|
|
virtual void readDirectory(
|
|
|
|
const WebKit::WebURL& path,
|
2011-09-10 21:40:03 +02:00
|
|
|
WebKit::WebFileSystemCallbacks*) OVERRIDE;
|
2010-10-15 20:37:25 +02:00
|
|
|
virtual WebKit::WebFileWriter* createFileWriter(
|
2011-09-10 21:40:03 +02:00
|
|
|
const WebKit::WebURL& path, WebKit::WebFileWriterClient*) OVERRIDE;
|
2012-04-05 00:32:24 +02:00
|
|
|
virtual void createSnapshotFileAndReadMetadata(
|
|
|
|
const WebKit::WebURL& blobURL,
|
|
|
|
const WebKit::WebURL& path,
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks) OVERRIDE;
|
|
|
|
|
|
|
|
static void InitializeOnIOThread(
|
|
|
|
webkit_blob::BlobStorageController* blob_storage_controller);
|
|
|
|
static void CleanupOnIOThread();
|
2010-10-03 22:35:06 +02:00
|
|
|
|
|
|
|
private:
|
2012-08-07 15:58:35 +02:00
|
|
|
enum FilePermission {
|
|
|
|
FILE_PERMISSION_READ,
|
|
|
|
FILE_PERMISSION_WRITE,
|
|
|
|
FILE_PERMISSION_CREATE,
|
|
|
|
};
|
|
|
|
|
2010-10-03 22:35:06 +02:00
|
|
|
// Helpers.
|
2012-08-07 15:58:35 +02:00
|
|
|
bool HasFilePermission(const fileapi::FileSystemURL& url,
|
|
|
|
FilePermission permission);
|
2012-08-29 22:11:26 +02:00
|
|
|
fileapi::FileSystemOperation* GetNewOperation(
|
2012-08-07 15:58:35 +02:00
|
|
|
const fileapi::FileSystemURL& url);
|
2012-02-18 01:19:52 +01:00
|
|
|
|
|
|
|
// Callback Handlers
|
2012-08-29 22:11:26 +02:00
|
|
|
fileapi::FileSystemOperation::StatusCallback FinishHandler(
|
2012-02-18 01:19:52 +01:00
|
|
|
WebKit::WebFileSystemCallbacks* callbacks);
|
2012-08-29 22:11:26 +02:00
|
|
|
fileapi::FileSystemOperation::GetMetadataCallback GetMetadataHandler(
|
2012-02-18 01:19:52 +01:00
|
|
|
WebKit::WebFileSystemCallbacks* callbacks);
|
2012-08-29 22:11:26 +02:00
|
|
|
fileapi::FileSystemOperation::ReadDirectoryCallback
|
2012-02-18 01:19:52 +01:00
|
|
|
ReadDirectoryHandler(WebKit::WebFileSystemCallbacks* callbacks);
|
|
|
|
fileapi::FileSystemContext::OpenFileSystemCallback OpenFileSystemHandler(
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks);
|
2012-08-29 22:11:26 +02:00
|
|
|
fileapi::FileSystemContext::DeleteFileSystemCallback DeleteFileSystemHandler(
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks);
|
|
|
|
fileapi::FileSystemOperation::SnapshotFileCallback
|
2012-04-05 00:32:24 +02:00
|
|
|
SnapshotFileHandler(const GURL& blob_url,
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks);
|
2012-02-18 01:19:52 +01:00
|
|
|
void DidFinish(WebKit::WebFileSystemCallbacks* callbacks,
|
|
|
|
base::PlatformFileError result);
|
|
|
|
void DidGetMetadata(WebKit::WebFileSystemCallbacks* callbacks,
|
|
|
|
base::PlatformFileError result,
|
|
|
|
const base::PlatformFileInfo& info,
|
|
|
|
const FilePath& platform_path);
|
|
|
|
void DidReadDirectory(
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks,
|
|
|
|
base::PlatformFileError result,
|
|
|
|
const std::vector<base::FileUtilProxy::Entry>& entries,
|
|
|
|
bool has_more);
|
|
|
|
void DidOpenFileSystem(WebKit::WebFileSystemCallbacks* callbacks,
|
|
|
|
base::PlatformFileError result,
|
|
|
|
const std::string& name, const GURL& root);
|
2012-08-29 22:11:26 +02:00
|
|
|
void DidDeleteFileSystem(WebKit::WebFileSystemCallbacks* callbacks,
|
|
|
|
base::PlatformFileError result);
|
2012-04-05 00:32:24 +02:00
|
|
|
void DidCreateSnapshotFile(
|
|
|
|
const GURL& blob_url,
|
|
|
|
WebKit::WebFileSystemCallbacks* callbacks,
|
|
|
|
base::PlatformFileError result,
|
|
|
|
const base::PlatformFileInfo& info,
|
|
|
|
const FilePath& platform_path,
|
|
|
|
const scoped_refptr<webkit_blob::ShareableFileReference>& file_ref);
|
2010-10-03 22:35:06 +02:00
|
|
|
|
2011-02-15 19:07:24 +01:00
|
|
|
scoped_refptr<fileapi::FileSystemContext> file_system_context_;
|
2010-10-03 22:35:06 +02:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(BrowserFileSystem);
|
|
|
|
};
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#endif // CEF_LIBCEF_BROWSER_FILE_SYSTEM_H_
|