summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_path_manager.cc
diff options
context:
space:
mode:
authorzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-25 20:37:59 +0000
committerzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-25 20:37:59 +0000
commit55d9bed8de248d583bd5770a42c8520e1225162b (patch)
tree6be27d9ee263e9a475385120a933bcb29fe75a74 /webkit/fileapi/file_system_path_manager.cc
parente69b903ec57dc0f511598b03d4aae148a56e33bc (diff)
downloadchromium_src-55d9bed8de248d583bd5770a42c8520e1225162b.zip
chromium_src-55d9bed8de248d583bd5770a42c8520e1225162b.tar.gz
chromium_src-55d9bed8de248d583bd5770a42c8520e1225162b.tar.bz2
Wired local file system support for File API. The local file system provider currently exists for ChromeOS builds only.
This CL exposes new extension permission 'fileSystem' that controls access to individual local file system elements from 3rd party extensions. Another new permission 'fileBrowserPrivate' controls access to following API call that retrieves root DOMFileSystem instance for locally exposed folders:  chrome.fileBrowserPrivate.requestLocalFileSystem(callback) BUG=chromium-os:11983 TEST=ExtensionApiTest.LocalFileSystem Review URL: http://codereview.chromium.org/6519040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79451 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_path_manager.cc')
-rw-r--r--webkit/fileapi/file_system_path_manager.cc49
1 files changed, 47 insertions, 2 deletions
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();