Commit 12248936 authored by kinuko@chromium.org's avatar kinuko@chromium.org

We should grant read permission to the file returned by CreateFileSnapshot...

We should grant read permission to the file returned by CreateFileSnapshot since the file must have given for reading

BUG=none


Review URL: https://chromiumcodereview.appspot.com/10834138

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149798 0039d316-1c4b-4281-b951-d872f2087c98
parent e24a853b
...@@ -69,6 +69,11 @@ const int kOpenFilePermissions = base::PLATFORM_FILE_CREATE | ...@@ -69,6 +69,11 @@ const int kOpenFilePermissions = base::PLATFORM_FILE_CREATE |
base::PLATFORM_FILE_DELETE_ON_CLOSE | base::PLATFORM_FILE_DELETE_ON_CLOSE |
base::PLATFORM_FILE_WRITE_ATTRIBUTES; base::PLATFORM_FILE_WRITE_ATTRIBUTES;
void RevokeFilePermission(int child_id, const FilePath& path) {
ChildProcessSecurityPolicyImpl::GetInstance()->RevokeAllPermissionsForFile(
child_id, path);
}
} // namespace } // namespace
FileAPIMessageFilter::FileAPIMessageFilter( FileAPIMessageFilter::FileAPIMessageFilter(
...@@ -704,6 +709,19 @@ void FileAPIMessageFilter::RegisterFileAsBlob(const GURL& blob_url, ...@@ -704,6 +709,19 @@ void FileAPIMessageFilter::RegisterFileAsBlob(const GURL& blob_url,
if (!extension.empty()) if (!extension.empty())
extension = extension.substr(1); // Strip leading ".". extension = extension.substr(1); // Strip leading ".".
scoped_refptr<webkit_blob::ShareableFileReference> shareable_file =
webkit_blob::ShareableFileReference::Get(platform_path);
if (shareable_file &&
!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
process_id_, platform_path)) {
ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
process_id_, platform_path);
// This will revoke all permissions for the file when the last ref
// of the file is dropped (assuming it's ok).
shareable_file->AddFinalReleaseCallback(
base::Bind(&RevokeFilePermission, process_id_));
}
// This may fail, but then we'll be just setting the empty mime type. // This may fail, but then we'll be just setting the empty mime type.
std::string mime_type; std::string mime_type;
net::GetWellKnownMimeTypeFromExtension(extension, &mime_type); net::GetWellKnownMimeTypeFromExtension(extension, &mime_type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment