summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/fileapi')
-rw-r--r--webkit/fileapi/file_system_context.cc3
-rw-r--r--webkit/fileapi/file_system_context.h4
-rw-r--r--webkit/fileapi/file_system_context_unittest.cc5
-rw-r--r--webkit/fileapi/file_system_dir_url_request_job_unittest.cc3
-rw-r--r--webkit/fileapi/file_system_mount_point_provider.h1
-rw-r--r--webkit/fileapi/file_system_operation.cc5
-rw-r--r--webkit/fileapi/file_system_path_manager.cc49
-rw-r--r--webkit/fileapi/file_system_path_manager.h21
-rw-r--r--webkit/fileapi/file_system_path_manager_unittest.cc24
-rw-r--r--webkit/fileapi/file_system_types.h1
-rw-r--r--webkit/fileapi/file_system_url_request_job_unittest.cc2
-rw-r--r--webkit/fileapi/file_system_util.cc7
-rw-r--r--webkit/fileapi/local_file_system_file_util.cc2
-rw-r--r--webkit/fileapi/sandbox_mount_point_provider.cc3
-rw-r--r--webkit/fileapi/sandbox_mount_point_provider.h1
-rw-r--r--webkit/fileapi/webkit_fileapi.gypi5
16 files changed, 115 insertions, 21 deletions
diff --git a/webkit/fileapi/file_system_context.cc b/webkit/fileapi/file_system_context.cc
index b5c1308..205963a 100644
--- a/webkit/fileapi/file_system_context.cc
+++ b/webkit/fileapi/file_system_context.cc
@@ -27,7 +27,8 @@ FileSystemContext::FileSystemContext(
allow_file_access_from_files_(allow_file_access),
unlimited_quota_(unlimited_quota),
path_manager_(new FileSystemPathManager(
- file_message_loop, profile_path, is_incognito, allow_file_access)),
+ file_message_loop, profile_path, special_storage_policy, is_incognito,
+ allow_file_access)),
usage_tracker_(new FileSystemUsageTracker(
file_message_loop, profile_path, is_incognito)) {
}
diff --git a/webkit/fileapi/file_system_context.h b/webkit/fileapi/file_system_context.h
index 16e3551..dbdb9aa 100644
--- a/webkit/fileapi/file_system_context.h
+++ b/webkit/fileapi/file_system_context.h
@@ -16,10 +16,6 @@ namespace base {
class MessageLoopProxy;
}
-namespace quota {
-class SpecialStoragePolicy;
-}
-
namespace fileapi {
class FileSystemContext;
diff --git a/webkit/fileapi/file_system_context_unittest.cc b/webkit/fileapi/file_system_context_unittest.cc
index 55dfcd9..d3ea661 100644
--- a/webkit/fileapi/file_system_context_unittest.cc
+++ b/webkit/fileapi/file_system_context_unittest.cc
@@ -12,7 +12,6 @@
#include "base/string_number_conversions.h"
#include "googleurl/src/gurl.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "webkit/quota/special_storage_policy.h"
using namespace fileapi;
@@ -34,6 +33,10 @@ class TestSpecialStoragePolicy : public quota::SpecialStoragePolicy {
virtual bool IsStorageUnlimited(const GURL& origin) {
return origin == GURL(kTestOrigins[1]);
}
+
+ virtual bool IsLocalFileSystemAccessAllowed(const GURL& origin) {
+ return false;
+ }
};
scoped_refptr<FileSystemContext> NewFileSystemContext(
diff --git a/webkit/fileapi/file_system_dir_url_request_job_unittest.cc b/webkit/fileapi/file_system_dir_url_request_job_unittest.cc
index eff2b3b..49c68b5 100644
--- a/webkit/fileapi/file_system_dir_url_request_job_unittest.cc
+++ b/webkit/fileapi/file_system_dir_url_request_job_unittest.cc
@@ -48,7 +48,8 @@ class FileSystemDirURLRequestJobTest : public testing::Test {
file_thread_proxy_ = base::MessageLoopProxy::CreateForCurrentThread();
path_manager_.reset(new FileSystemPathManager(
- file_thread_proxy_, temp_dir_.path(), false, false));
+ file_thread_proxy_, temp_dir_.path(),
+ NULL, false, false));
path_manager_->GetFileSystemRootPath(
GURL("http://remote/"), kFileSystemTypeTemporary, true, // create
diff --git a/webkit/fileapi/file_system_mount_point_provider.h b/webkit/fileapi/file_system_mount_point_provider.h
index 3136636..3210331 100644
--- a/webkit/fileapi/file_system_mount_point_provider.h
+++ b/webkit/fileapi/file_system_mount_point_provider.h
@@ -35,6 +35,7 @@ class FileSystemMountPointProvider {
virtual FilePath GetFileSystemRootPathOnFileThread(
const GURL& origin_url,
FileSystemType type,
+ const FilePath& virtual_path,
bool create) = 0;
// Checks if a given |name| contains any restricted names/chars in it.
diff --git a/webkit/fileapi/file_system_operation.cc b/webkit/fileapi/file_system_operation.cc
index 5de0c64..1555cd7 100644
--- a/webkit/fileapi/file_system_operation.cc
+++ b/webkit/fileapi/file_system_operation.cc
@@ -405,7 +405,8 @@ void FileSystemOperation::Cancel(FileSystemOperation* cancel_operation_ptr) {
}
void FileSystemOperation::DidGetRootPath(
- bool success, const FilePath& path, const std::string& name) {
+ bool success,
+ const FilePath& path, const std::string& name) {
DCHECK(success || path.empty());
FilePath result;
// We ignore the path, and return a URL instead. The point was just to verify
@@ -492,6 +493,7 @@ void FileSystemOperation::DidGetMetadata(
void FileSystemOperation::DidReadDirectory(
base::PlatformFileError rv,
const std::vector<base::FileUtilProxy::Entry>& entries) {
+
if (rv == base::PLATFORM_FILE_OK)
dispatcher_->DidReadDirectory(entries, false /* has_more */);
else
@@ -550,6 +552,7 @@ bool FileSystemOperation::VerifyFileSystemPathForRead(
dispatcher_->DidFail(base::PLATFORM_FILE_ERROR_SECURITY);
return false;
}
+
return true;
}
diff --git a/webkit/fileapi/file_system_path_manager.cc b/webkit/fileapi/file_system_path_manager.cc
index 64f3274..3f4ed9f 100644
--- a/webkit/fileapi/file_system_path_manager.cc
+++ b/webkit/fileapi/file_system_path_manager.cc
@@ -19,6 +19,10 @@
#include "webkit/fileapi/sandbox_mount_point_provider.h"
#include "webkit/glue/webkit_glue.h"
+#if defined(OS_CHROMEOS)
+#include "webkit/chromeos/fileapi/cros_mount_point_provider.h"
+#endif
+
// We use some of WebKit types for conversions between origin identifiers
// and origin URLs.
using WebKit::WebFileSystem;
@@ -32,6 +36,7 @@ namespace fileapi {
FileSystemPathManager::FileSystemPathManager(
scoped_refptr<base::MessageLoopProxy> file_message_loop,
const FilePath& profile_path,
+ scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
bool is_incognito,
bool allow_file_access_from_files)
: is_incognito_(is_incognito),
@@ -41,6 +46,10 @@ FileSystemPathManager::FileSystemPathManager(
ALLOW_THIS_IN_INITIALIZER_LIST(this),
file_message_loop,
profile_path)) {
+#if defined(OS_CHROMEOS)
+ local_provider_.reset(
+ new chromeos::CrosMountPointProvider(special_storage_policy));
+#endif
}
FileSystemPathManager::~FileSystemPathManager() {}
@@ -55,6 +64,14 @@ void FileSystemPathManager::GetFileSystemRootPath(
sandbox_provider_->GetFileSystemRootPath(
origin_url, type, create, callback_ptr);
break;
+ case kFileSystemTypeLocal:
+ if (local_provider_.get()) {
+ local_provider_->GetFileSystemRootPath(
+ origin_url, type, create, callback_ptr);
+ } else {
+ callback_ptr->Run(false, FilePath(), std::string());
+ }
+ break;
case kFileSystemTypeUnknown:
default:
NOTREACHED();
@@ -63,13 +80,19 @@ void FileSystemPathManager::GetFileSystemRootPath(
}
FilePath FileSystemPathManager::GetFileSystemRootPathOnFileThread(
- const GURL& origin_url, FileSystemType type, bool create) {
+ const GURL& origin_url, FileSystemType type, const FilePath& virtual_path,
+ bool create) {
switch (type) {
case kFileSystemTypeTemporary:
case kFileSystemTypePersistent:
return sandbox_provider_->GetFileSystemRootPathOnFileThread(
- origin_url, type, create);
+ origin_url, type, virtual_path, create);
break;
+ case kFileSystemTypeLocal:
+ return local_provider_.get() ?
+ local_provider_->GetFileSystemRootPathOnFileThread(
+ origin_url, type, virtual_path, create) :
+ FilePath();
case kFileSystemTypeUnknown:
default:
NOTREACHED();
@@ -114,6 +137,25 @@ bool FileSystemPathManager::CrackFileSystemPath(
local_path = local_path.NormalizeWindowsPathSeparators();
#endif
+ // Check if file access to this type of file system is allowed
+ // for this origin.
+ switch (local_type) {
+ case kFileSystemTypeTemporary:
+ case kFileSystemTypePersistent:
+ if (!sandbox_provider_->IsAccessAllowed(local_url))
+ return false;
+ break;
+ case kFileSystemTypeLocal:
+ if (!local_provider_.get() ||
+ !local_provider_->IsAccessAllowed(local_url)) {
+ return false;
+ }
+ break;
+ case kFileSystemTypeUnknown:
+ default:
+ NOTREACHED();
+ return false;
+ }
// Any paths that include parent references are considered invalid.
// These should have been taken care of in CrackFileSystemURL.
DCHECK(!local_path.ReferencesParent());
@@ -160,6 +202,9 @@ bool FileSystemPathManager::IsRestrictedFileName(
case kFileSystemTypeTemporary:
case kFileSystemTypePersistent:
return sandbox_provider_->IsRestrictedFileName(filename);
+ case kFileSystemTypeLocal:
+ return local_provider_.get() ?
+ local_provider_->IsRestrictedFileName(filename) : true;
case kFileSystemTypeUnknown:
default:
NOTREACHED();
diff --git a/webkit/fileapi/file_system_path_manager.h b/webkit/fileapi/file_system_path_manager.h
index c1d2df9..5a9613a 100644
--- a/webkit/fileapi/file_system_path_manager.h
+++ b/webkit/fileapi/file_system_path_manager.h
@@ -10,6 +10,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "webkit/fileapi/file_system_types.h"
+#include "webkit/quota/special_storage_policy.h"
class GURL;
@@ -19,6 +20,7 @@ class MessageLoopProxy;
namespace fileapi {
+class FileSystemMountPointProvider;
class SandboxMountPointProvider;
// TODO(kinuko): Probably this module must be called FileSystemPathUtil
@@ -32,10 +34,12 @@ class SandboxMountPointProvider;
// <type> is either one of "Temporary" or "Persistent".
class FileSystemPathManager {
public:
- FileSystemPathManager(scoped_refptr<base::MessageLoopProxy> file_message_loop,
- const FilePath& profile_path,
- bool is_incognito,
- bool allow_file_access_from_files);
+ FileSystemPathManager(
+ scoped_refptr<base::MessageLoopProxy> file_message_loop,
+ const FilePath& profile_path,
+ scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy,
+ bool is_incognito,
+ bool allow_file_access_from_files);
~FileSystemPathManager();
// Callback for GetFileSystemRootPath.
@@ -59,9 +63,11 @@ class FileSystemPathManager {
// Like GetFileSystemRootPath, but synchronous, and can be called only while
// running on the file thread.
- virtual FilePath GetFileSystemRootPathOnFileThread(const GURL& origin_url,
- FileSystemType type,
- bool create);
+ virtual FilePath GetFileSystemRootPathOnFileThread(
+ const GURL& origin_url,
+ FileSystemType type,
+ const FilePath& virtual_path,
+ bool create);
// Cracks the given |path|, retrieves the information embedded in the path
// and populates |origin_url|, |type| and |virtual_path|. The |virtual_path|
// is a sandboxed path in the file system, i.e. the relative path to the
@@ -95,6 +101,7 @@ class FileSystemPathManager {
const bool is_incognito_;
const bool allow_file_access_from_files_;
scoped_ptr<SandboxMountPointProvider> sandbox_provider_;
+ scoped_ptr<FileSystemMountPointProvider> local_provider_;
DISALLOW_COPY_AND_ASSIGN(FileSystemPathManager);
};
diff --git a/webkit/fileapi/file_system_path_manager_unittest.cc b/webkit/fileapi/file_system_path_manager_unittest.cc
index 8f004c2..ca7a74a 100644
--- a/webkit/fileapi/file_system_path_manager_unittest.cc
+++ b/webkit/fileapi/file_system_path_manager_unittest.cc
@@ -19,6 +19,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/fileapi/file_system_util.h"
#include "webkit/fileapi/sandbox_mount_point_provider.h"
+#include "webkit/quota/special_storage_policy.h"
using namespace fileapi;
@@ -69,6 +70,8 @@ const struct RootPathFileURITest {
"file__0" PS "Temporary" },
{ fileapi::kFileSystemTypePersistent, "file:///",
"file__0" PS "Persistent" },
+ // TODO(zelidrag): Add fileapi::kFileSystemTypeLocal test cases here once
+ // we fix ChromeOS build of this test.
};
const struct CheckValidPathTest {
@@ -160,6 +163,21 @@ const struct IsRestrictedNameTest {
{ FILE_PATH_LITERAL("|ab"), true, },
};
+class TestSpecialStoragePolicy : public quota::SpecialStoragePolicy {
+ public:
+ virtual bool IsStorageProtected(const GURL& origin) {
+ return false;
+ }
+
+ virtual bool IsStorageUnlimited(const GURL& origin) {
+ return true;
+ }
+
+ virtual bool IsLocalFileSystemAccessAllowed(const GURL& origin) {
+ return true;
+ }
+};
+
} // namespace
class FileSystemPathManagerTest : public testing::Test {
@@ -181,7 +199,11 @@ class FileSystemPathManagerTest : public testing::Test {
bool allow_file_access) {
return new FileSystemPathManager(
base::MessageLoopProxy::CreateForCurrentThread(),
- data_dir_.path(), incognito, allow_file_access);
+ data_dir_.path(),
+ scoped_refptr<quota::SpecialStoragePolicy>(
+ new TestSpecialStoragePolicy()),
+ incognito,
+ allow_file_access);
}
void OnGetRootPath(bool success,
diff --git a/webkit/fileapi/file_system_types.h b/webkit/fileapi/file_system_types.h
index 043e3a2..8b7fe01 100644
--- a/webkit/fileapi/file_system_types.h
+++ b/webkit/fileapi/file_system_types.h
@@ -10,6 +10,7 @@ namespace fileapi {
enum FileSystemType {
kFileSystemTypeTemporary,
kFileSystemTypePersistent,
+ kFileSystemTypeLocal,
kFileSystemTypeUnknown,
};
diff --git a/webkit/fileapi/file_system_url_request_job_unittest.cc b/webkit/fileapi/file_system_url_request_job_unittest.cc
index 2cdb6d1c..d23923c 100644
--- a/webkit/fileapi/file_system_url_request_job_unittest.cc
+++ b/webkit/fileapi/file_system_url_request_job_unittest.cc
@@ -69,7 +69,7 @@ class FileSystemURLRequestJobTest : public testing::Test {
// TODO(adamk): Run this on the FILE thread we've created as well.
path_manager_.reset(new FileSystemPathManager(
base::MessageLoopProxy::CreateForCurrentThread(),
- temp_dir_.path(), false, false));
+ temp_dir_.path(), NULL, false, false));
path_manager_->GetFileSystemRootPath(
GURL("http://remote/"), kFileSystemTypeTemporary, true, // create
diff --git a/webkit/fileapi/file_system_util.cc b/webkit/fileapi/file_system_util.cc
index ae36fa850..a15c2a8 100644
--- a/webkit/fileapi/file_system_util.cc
+++ b/webkit/fileapi/file_system_util.cc
@@ -17,6 +17,7 @@ namespace fileapi {
static const char kPersistentDir[] = "/persistent/";
static const char kTemporaryDir[] = "/temporary/";
+static const char kLocalDir[] = "/local/";
bool CrackFileSystemURL(const GURL& url, GURL* origin_url, FileSystemType* type,
FilePath* file_path) {
@@ -76,6 +77,9 @@ bool CrackFileSystemURL(const GURL& url, GURL* origin_url, FileSystemType* type,
} else if (path.compare(0, strlen(kTemporaryDir), kTemporaryDir) == 0) {
file_system_type = kFileSystemTypeTemporary;
path = path.substr(strlen(kTemporaryDir));
+ } else if (path.compare(0, strlen(kLocalDir), kLocalDir) == 0) {
+ file_system_type = kFileSystemTypeLocal;
+ path = path.substr(strlen(kLocalDir));
} else {
return false;
}
@@ -110,6 +114,9 @@ GURL GetFileSystemRootURI(
case kFileSystemTypePersistent:
path += (kPersistentDir + 1); // We don't want the leading slash.
break;
+ case kFileSystemTypeLocal:
+ path += (kLocalDir + 1); // We don't want the leading slash.
+ break;
default:
NOTREACHED();
return GURL();
diff --git a/webkit/fileapi/local_file_system_file_util.cc b/webkit/fileapi/local_file_system_file_util.cc
index a017d57..8def3f6 100644
--- a/webkit/fileapi/local_file_system_file_util.cc
+++ b/webkit/fileapi/local_file_system_file_util.cc
@@ -169,7 +169,7 @@ FilePath LocalFileSystemFileUtil::GetLocalPath(
FileSystemType type,
const FilePath& virtual_path) {
FilePath root = context->file_system_context()->path_manager()->
- GetFileSystemRootPathOnFileThread(origin_url, type, false);
+ GetFileSystemRootPathOnFileThread(origin_url, type, virtual_path, false);
if (root.empty())
return FilePath();
return root.Append(virtual_path);
diff --git a/webkit/fileapi/sandbox_mount_point_provider.cc b/webkit/fileapi/sandbox_mount_point_provider.cc
index d7f6146..7576055 100644
--- a/webkit/fileapi/sandbox_mount_point_provider.cc
+++ b/webkit/fileapi/sandbox_mount_point_provider.cc
@@ -231,7 +231,8 @@ void SandboxMountPointProvider::GetFileSystemRootPath(
};
FilePath SandboxMountPointProvider::GetFileSystemRootPathOnFileThread(
- const GURL& origin_url, FileSystemType type, bool create) {
+ const GURL& origin_url, FileSystemType type, const FilePath& unused,
+ bool create) {
FilePath origin_base_path;
if (!GetOriginBasePathAndName(origin_url, &origin_base_path, type, NULL)) {
return FilePath();
diff --git a/webkit/fileapi/sandbox_mount_point_provider.h b/webkit/fileapi/sandbox_mount_point_provider.h
index b401435..be85f77 100644
--- a/webkit/fileapi/sandbox_mount_point_provider.h
+++ b/webkit/fileapi/sandbox_mount_point_provider.h
@@ -45,6 +45,7 @@ class SandboxMountPointProvider : public FileSystemMountPointProvider {
virtual FilePath GetFileSystemRootPathOnFileThread(
const GURL& origin_url,
FileSystemType type,
+ const FilePath& unused,
bool create);
// The FileSystem directory name.
diff --git a/webkit/fileapi/webkit_fileapi.gypi b/webkit/fileapi/webkit_fileapi.gypi
index 1b0e127..acb1b4a 100644
--- a/webkit/fileapi/webkit_fileapi.gypi
+++ b/webkit/fileapi/webkit_fileapi.gypi
@@ -54,6 +54,11 @@
'<(DEPTH)/webkit/support/setup_third_party.gyp:third_party_headers',
],
}],
+ ['chromeos==1', {
+ 'sources': [
+ '../chromeos/fileapi/cros_mount_point_provider.cc',
+ ],
+ }],
],
},
],