summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authortbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-27 02:49:12 +0000
committertbarzic@chromium.org <tbarzic@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-27 02:49:12 +0000
commit09c7f0e70cbd6b5236d040db3e39118fcccc38ff (patch)
tree70520ffcb515aacafa7f1ed8a3ea7f9ced5988e9 /webkit
parent72dc29f662bf8f6f06c0019ab60bf942d6ef16f9 (diff)
downloadchromium_src-09c7f0e70cbd6b5236d040db3e39118fcccc38ff.zip
chromium_src-09c7f0e70cbd6b5236d040db3e39118fcccc38ff.tar.gz
chromium_src-09c7f0e70cbd6b5236d040db3e39118fcccc38ff.tar.bz2
Enabling creating of file_ref from filesystem and path for external filesystem.
At the moment file_ref will not get created for external file systems, which makes nacl plugin unable to access files on external file system, event when it owning render process has needed permissions (e.g. if renderer is running file browser extension) BUG=chromium-os:20497 TEST=On ChromeOS, Cr48: Made sure extension with fileBrowserHandler permission is able to read a file from local disk. Also, checked that an extension without required privileges fails opening the file with PP_ERROR_NOACCESS error code. Review URL: http://codereview.chromium.org/7982041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102875 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.cc37
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.cc10
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.h2
-rw-r--r--webkit/plugins/ppapi/ppb_file_system_impl.cc23
4 files changed, 44 insertions, 28 deletions
diff --git a/webkit/plugins/ppapi/ppb_file_io_impl.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc
index b074596..1460b27 100644
--- a/webkit/plugins/ppapi/ppb_file_io_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc
@@ -86,24 +86,25 @@ int32_t PPB_FileIO_Impl::Open(PP_Resource pp_file_ref,
return false;
file_system_type_ = file_ref->GetFileSystemType();
- switch (file_system_type_) {
- case PP_FILESYSTEMTYPE_EXTERNAL:
- if (!plugin_delegate->AsyncOpenFile(
- file_ref->GetSystemPath(), flags,
- callback_factory_.NewCallback(
- &PPB_FileIO_Impl::AsyncOpenFileCallback)))
- return PP_ERROR_FAILED;
- break;
- case PP_FILESYSTEMTYPE_LOCALPERSISTENT:
- case PP_FILESYSTEMTYPE_LOCALTEMPORARY:
- file_system_url_ = file_ref->GetFileSystemURL();
- if (!plugin_delegate->AsyncOpenFileSystemURL(
- file_system_url_, flags,
- callback_factory_.NewCallback(
- &PPB_FileIO_Impl::AsyncOpenFileCallback)))
- return PP_ERROR_FAILED;
- break;
- default:
+ if (file_system_type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
+ file_system_type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY &&
+ file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL)
+ return PP_ERROR_FAILED;
+
+ if (file_ref->HasValidFileSystem()) {
+ file_system_url_ = file_ref->GetFileSystemURL();
+ if (!plugin_delegate->AsyncOpenFileSystemURL(
+ file_system_url_, flags,
+ callback_factory_.NewCallback(
+ &PPB_FileIO_Impl::AsyncOpenFileCallback)))
+ return PP_ERROR_FAILED;
+ } else {
+ if (file_system_type_ != PP_FILESYSTEMTYPE_EXTERNAL)
+ return PP_ERROR_FAILED;
+ if (!plugin_delegate->AsyncOpenFile(
+ file_ref->GetSystemPath(), flags,
+ callback_factory_.NewCallback(
+ &PPB_FileIO_Impl::AsyncOpenFileCallback)))
return PP_ERROR_FAILED;
}
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
index 7c43ba4..673ec01 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
@@ -108,7 +108,8 @@ PPB_FileRef_Impl* PPB_FileRef_Impl::CreateInternal(PP_Resource pp_file_system,
return 0;
if (file_system->type() != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
- file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
+ file_system->type() != PP_FILESYSTEMTYPE_LOCALTEMPORARY &&
+ file_system->type() != PP_FILESYSTEMTYPE_EXTERNAL)
return 0;
PPB_FileRef_CreateInfo info;
@@ -253,7 +254,8 @@ FilePath PPB_FileRef_Impl::GetSystemPath() const {
GURL PPB_FileRef_Impl::GetFileSystemURL() const {
if (GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
- GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALTEMPORARY) {
+ GetFileSystemType() != PP_FILESYSTEMTYPE_LOCALTEMPORARY &&
+ GetFileSystemType() != PP_FILESYSTEMTYPE_EXTERNAL) {
NOTREACHED();
return GURL();
}
@@ -269,6 +271,10 @@ GURL PPB_FileRef_Impl::GetFileSystemURL() const {
return GURL(file_system_->root_url().spec() + virtual_path.substr(1));
}
+bool PPB_FileRef_Impl::HasValidFileSystem() const {
+ return file_system_ && file_system_->opened();
+}
+
bool PPB_FileRef_Impl::IsValidNonExternalFileSystem() const {
return file_system_ && file_system_->opened() &&
file_system_->type() != PP_FILESYSTEMTYPE_EXTERNAL;
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.h b/webkit/plugins/ppapi/ppb_file_ref_impl.h
index de1649d..64926de 100644
--- a/webkit/plugins/ppapi/ppb_file_ref_impl.h
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.h
@@ -53,6 +53,8 @@ class PPB_FileRef_Impl : public ::ppapi::FileRefImpl {
// Returns the FileSystem API URL corresponding to this file.
GURL GetFileSystemURL() const;
+ // Checks if file ref has file system instance and if the instance is opened.
+ bool HasValidFileSystem() const;
private:
// Many mutation functions are allow only to non-external filesystems, This
// function returns true if the filesystem is opened and isn't external as an
diff --git a/webkit/plugins/ppapi/ppb_file_system_impl.cc b/webkit/plugins/ppapi/ppb_file_system_impl.cc
index a63e954..b7576bc 100644
--- a/webkit/plugins/ppapi/ppb_file_system_impl.cc
+++ b/webkit/plugins/ppapi/ppb_file_system_impl.cc
@@ -61,18 +61,25 @@ int32_t PPB_FileSystem_Impl::Open(int64_t expected_size,
return PP_ERROR_INPROGRESS;
called_open_ = true;
- if (type_ != PP_FILESYSTEMTYPE_LOCALPERSISTENT &&
- type_ != PP_FILESYSTEMTYPE_LOCALTEMPORARY)
- return PP_ERROR_FAILED;
+ fileapi::FileSystemType file_system_type;
+ switch (type_) {
+ case PP_FILESYSTEMTYPE_LOCALTEMPORARY:
+ file_system_type = fileapi::kFileSystemTypeTemporary;
+ break;
+ case PP_FILESYSTEMTYPE_LOCALPERSISTENT:
+ file_system_type = fileapi::kFileSystemTypePersistent;
+ break;
+ case PP_FILESYSTEMTYPE_EXTERNAL:
+ file_system_type = fileapi::kFileSystemTypeExternal;
+ break;
+ default:
+ return PP_ERROR_FAILED;
+ }
- PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
+ PluginInstance* plugin_instance = ResourceHelper::GetPluginInstance(this);
if (!plugin_instance)
return PP_ERROR_FAILED;
- fileapi::FileSystemType file_system_type =
- (type_ == PP_FILESYSTEMTYPE_LOCALTEMPORARY ?
- fileapi::kFileSystemTypeTemporary :
- fileapi::kFileSystemTypePersistent);
if (!plugin_instance->delegate()->OpenFileSystem(
plugin_instance->container()->element().document().url(),
file_system_type, expected_size,