summaryrefslogtreecommitdiff
path: root/chromium/webkit/browser/fileapi/file_system_context.cc
diff options
context:
space:
mode:
authorAndras Becsi <andras.becsi@digia.com>2014-03-18 13:16:26 +0100
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-03-20 15:55:39 +0100
commit3f0f86b0caed75241fa71c95a5d73bc0164348c5 (patch)
tree92b9fb00f2e9e90b0be2262093876d4f43b6cd13 /chromium/webkit/browser/fileapi/file_system_context.cc
parente90d7c4b152c56919d963987e2503f9909a666d2 (diff)
downloadqtwebengine-chromium-3f0f86b0caed75241fa71c95a5d73bc0164348c5.tar.gz
Update to new stable branch 1750
This also includes an updated ninja and chromium dependencies needed on Windows. Change-Id: Icd597d80ed3fa4425933c9f1334c3c2e31291c42 Reviewed-by: Zoltan Arvai <zarvai@inf.u-szeged.hu> Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
Diffstat (limited to 'chromium/webkit/browser/fileapi/file_system_context.cc')
-rw-r--r--chromium/webkit/browser/fileapi/file_system_context.cc91
1 files changed, 73 insertions, 18 deletions
diff --git a/chromium/webkit/browser/fileapi/file_system_context.cc b/chromium/webkit/browser/fileapi/file_system_context.cc
index 9098649f245..869410498c9 100644
--- a/chromium/webkit/browser/fileapi/file_system_context.cc
+++ b/chromium/webkit/browser/fileapi/file_system_context.cc
@@ -23,8 +23,8 @@
#include "webkit/browser/fileapi/isolated_context.h"
#include "webkit/browser/fileapi/isolated_file_system_backend.h"
#include "webkit/browser/fileapi/mount_points.h"
+#include "webkit/browser/fileapi/quota/quota_reservation.h"
#include "webkit/browser/fileapi/sandbox_file_system_backend.h"
-#include "webkit/browser/fileapi/test_file_system_backend.h"
#include "webkit/browser/quota/quota_manager.h"
#include "webkit/browser/quota/special_storage_policy.h"
#include "webkit/common/fileapi/file_system_info.h"
@@ -42,13 +42,6 @@ QuotaClient* CreateQuotaClient(
return new FileSystemQuotaClient(context, is_incognito);
}
-void DidOpenFileSystem(
- const FileSystemContext::OpenFileSystemCallback& callback,
- const GURL& filesystem_root,
- const std::string& filesystem_name,
- base::PlatformFileError error) {
- callback.Run(error, filesystem_name, filesystem_root);
-}
void DidGetMetadataForResolveURL(
const base::FilePath& path,
@@ -87,9 +80,11 @@ int FileSystemContext::GetPermissionPolicy(FileSystemType type) {
case kFileSystemTypeDeviceMedia:
case kFileSystemTypeDragged:
case kFileSystemTypeForTransientFile:
+ case kFileSystemTypeIphoto:
case kFileSystemTypeItunes:
case kFileSystemTypeNativeMedia:
case kFileSystemTypePicasa:
+ case kFileSystemTypePluginPrivate:
return FILE_PERMISSION_ALWAYS_DENY;
// Following types only appear as mount_type, and will not be
@@ -131,6 +126,11 @@ FileSystemContext::FileSystemContext(
sandbox_backend_(new SandboxFileSystemBackend(
sandbox_delegate_.get())),
isolated_backend_(new IsolatedFileSystemBackend()),
+ plugin_private_backend_(new PluginPrivateFileSystemBackend(
+ file_task_runner,
+ partition_path,
+ special_storage_policy,
+ options)),
additional_backends_(additional_backends.Pass()),
external_mount_points_(external_mount_points),
partition_path_(partition_path),
@@ -138,6 +138,7 @@ FileSystemContext::FileSystemContext(
operation_runner_(new FileSystemOperationRunner(this)) {
RegisterBackend(sandbox_backend_.get());
RegisterBackend(isolated_backend_.get());
+ RegisterBackend(plugin_private_backend_.get());
for (ScopedVector<FileSystemBackend>::const_iterator iter =
additional_backends_.begin();
@@ -153,6 +154,7 @@ FileSystemContext::FileSystemContext(
sandbox_backend_->Initialize(this);
isolated_backend_->Initialize(this);
+ plugin_private_backend_->Initialize(this);
for (ScopedVector<FileSystemBackend>::const_iterator iter =
additional_backends_.begin();
iter != additional_backends_.end(); ++iter) {
@@ -190,6 +192,18 @@ bool FileSystemContext::DeleteDataForOriginOnFileThread(
return success;
}
+scoped_refptr<QuotaReservation>
+FileSystemContext::CreateQuotaReservationOnFileTaskRunner(
+ const GURL& origin_url,
+ FileSystemType type) {
+ DCHECK(default_file_task_runner()->RunsTasksOnCurrentThread());
+ FileSystemBackend* backend = GetFileSystemBackend(type);
+ if (!backend || !backend->GetQuotaUtil())
+ return scoped_refptr<QuotaReservation>();
+ return backend->GetQuotaUtil()->CreateQuotaReservationOnFileTaskRunner(
+ origin_url, type);
+}
+
void FileSystemContext::Shutdown() {
if (!io_task_runner_->RunsTasksOnCurrentThread()) {
io_task_runner_->PostTask(
@@ -277,16 +291,22 @@ void FileSystemContext::OpenFileSystem(
FileSystemType type,
OpenFileSystemMode mode,
const OpenFileSystemCallback& callback) {
+ DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
DCHECK(!callback.is_null());
+ if (!FileSystemContext::IsSandboxFileSystem(type)) {
+ // Disallow opening a non-sandboxed filesystem.
+ callback.Run(GURL(), std::string(), base::PLATFORM_FILE_ERROR_SECURITY);
+ return;
+ }
+
FileSystemBackend* backend = GetFileSystemBackend(type);
if (!backend) {
- callback.Run(base::PLATFORM_FILE_ERROR_SECURITY, std::string(), GURL());
+ callback.Run(GURL(), std::string(), base::PLATFORM_FILE_ERROR_SECURITY);
return;
}
- backend->OpenFileSystem(origin_url, type, mode,
- base::Bind(&DidOpenFileSystem, callback));
+ backend->OpenFileSystem(origin_url, type, mode, callback);
}
void FileSystemContext::ResolveURL(
@@ -295,6 +315,22 @@ void FileSystemContext::ResolveURL(
DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
DCHECK(!callback.is_null());
+ if (!FileSystemContext::IsSandboxFileSystem(url.type())) {
+#ifdef OS_CHROMEOS
+ // Do not have to open a non-sandboxed filesystem.
+ // TODO(nhiroki): For now we assume this path is called only on ChromeOS,
+ // but this assumption may be broken in the future and we should handle
+ // more generally. http://crbug.com/304062.
+ FileSystemInfo info = GetFileSystemInfoForChromeOS(url.origin());
+ DidOpenFileSystemForResolveURL(
+ url, callback, info.root_url, info.name, base::PLATFORM_FILE_OK);
+ return;
+#endif
+ callback.Run(base::PLATFORM_FILE_ERROR_SECURITY,
+ FileSystemInfo(), base::FilePath(), false);
+ return;
+ }
+
FileSystemBackend* backend = GetFileSystemBackend(url.type());
if (!backend) {
callback.Run(base::PLATFORM_FILE_ERROR_SECURITY,
@@ -312,8 +348,11 @@ void FileSystemContext::ResolveURL(
void FileSystemContext::DeleteFileSystem(
const GURL& origin_url,
FileSystemType type,
- const DeleteFileSystemCallback& callback) {
+ const StatusCallback& callback) {
+ DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
DCHECK(origin_url == origin_url.GetOrigin());
+ DCHECK(!callback.is_null());
+
FileSystemBackend* backend = GetFileSystemBackend(type);
if (!backend) {
callback.Run(base::PLATFORM_FILE_ERROR_SECURITY);
@@ -378,14 +417,17 @@ FileSystemURL FileSystemContext::CreateCrackedFileSystemURL(
return CrackFileSystemURL(FileSystemURL(origin, type, path));
}
-#if defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD)
+#if defined(OS_CHROMEOS)
void FileSystemContext::EnableTemporaryFileSystemInIncognito() {
sandbox_backend_->set_enable_temporary_file_system_in_incognito(true);
}
#endif
bool FileSystemContext::CanServeURLRequest(const FileSystemURL& url) const {
-#if defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD)
+ // We never support accessing files in isolated filesystems via an URL.
+ if (url.mount_type() == kFileSystemTypeIsolated)
+ return false;
+#if defined(OS_CHROMEOS)
if (url.type() == kFileSystemTypeTemporary &&
sandbox_backend_->enable_temporary_file_system_in_incognito()) {
return true;
@@ -394,6 +436,18 @@ bool FileSystemContext::CanServeURLRequest(const FileSystemURL& url) const {
return !is_incognito_ || !FileSystemContext::IsSandboxFileSystem(url.type());
}
+void FileSystemContext::OpenPluginPrivateFileSystem(
+ const GURL& origin_url,
+ FileSystemType type,
+ const std::string& filesystem_id,
+ const std::string& plugin_id,
+ OpenFileSystemMode mode,
+ const StatusCallback& callback) {
+ DCHECK(plugin_private_backend_);
+ plugin_private_backend_->OpenPrivateFileSystem(
+ origin_url, type, filesystem_id, plugin_id, mode, callback);
+}
+
FileSystemContext::~FileSystemContext() {
}
@@ -500,12 +554,13 @@ void FileSystemContext::DidOpenFileSystemForResolveURL(
filesystem_name, filesystem_root, url.mount_type());
// Extract the virtual path not containing a filesystem type part from |url|.
- base::FilePath parent =
- base::FilePath::FromUTF8Unsafe(filesystem_root.path());
- base::FilePath child = base::FilePath::FromUTF8Unsafe(url.ToGURL().path());
+ base::FilePath parent = CrackURL(filesystem_root).virtual_path();
+ base::FilePath child = url.virtual_path();
base::FilePath path;
- if (parent != child) {
+ if (parent.empty()) {
+ path = child;
+ } else if (parent != child) {
bool result = parent.AppendRelativePath(child, &path);
DCHECK(result);
}