summaryrefslogtreecommitdiffstats
path: root/content/browser/child_process_security_policy.cc
diff options
context:
space:
mode:
authorjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-12 00:01:51 +0000
committerjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-12 00:01:51 +0000
commit600ea40f950f2c2a177428986b9a2d557e7a8c90 (patch)
treee1d602a1e424758b8c18aee583e4dbbef75427da /content/browser/child_process_security_policy.cc
parent491af0cde7544b0f973296782dbb1daccbc3d603 (diff)
downloadchromium_src-600ea40f950f2c2a177428986b9a2d557e7a8c90.zip
chromium_src-600ea40f950f2c2a177428986b9a2d557e7a8c90.tar.gz
chromium_src-600ea40f950f2c2a177428986b9a2d557e7a8c90.tar.bz2
Add a path for a web page to request the enumeration of a directory. This, together with a WebKit change, will allow a drag-and-drop on a Directory Upload control (<input type=file webkitdirectory>) which provides only the path to the renderer, to correctly populate the control as if the user had selected that directory in a file picker.
BUG=58977 TEST=drag-and-drop on directory upload control (with upstream change) Review URL: http://codereview.chromium.org/6623015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81183 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/child_process_security_policy.cc')
-rw-r--r--content/browser/child_process_security_policy.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/content/browser/child_process_security_policy.cc b/content/browser/child_process_security_policy.cc
index 33cf5e0..81eca77 100644
--- a/content/browser/child_process_security_policy.cc
+++ b/content/browser/child_process_security_policy.cc
@@ -20,6 +20,10 @@ static const int kReadFilePermissions =
base::PLATFORM_FILE_EXCLUSIVE_READ |
base::PLATFORM_FILE_ASYNC;
+static const int kEnumerateDirectoryPermissions =
+ kReadFilePermissions |
+ base::PLATFORM_FILE_ENUMERATE;
+
// The SecurityState class is used to maintain per-child process security state
// information.
class ChildProcessSecurityPolicy::SecurityState {
@@ -241,6 +245,11 @@ void ChildProcessSecurityPolicy::GrantReadFile(int child_id,
GrantPermissionsForFile(child_id, file, kReadFilePermissions);
}
+void ChildProcessSecurityPolicy::GrantReadDirectory(int child_id,
+ const FilePath& directory) {
+ GrantPermissionsForFile(child_id, directory, kEnumerateDirectoryPermissions);
+}
+
void ChildProcessSecurityPolicy::GrantPermissionsForFile(
int child_id, const FilePath& file, int permissions) {
base::AutoLock lock(lock_);
@@ -372,6 +381,13 @@ bool ChildProcessSecurityPolicy::CanReadFile(int child_id,
return HasPermissionsForFile(child_id, file, kReadFilePermissions);
}
+bool ChildProcessSecurityPolicy::CanReadDirectory(int child_id,
+ const FilePath& directory) {
+ return HasPermissionsForFile(child_id,
+ directory,
+ kEnumerateDirectoryPermissions);
+}
+
bool ChildProcessSecurityPolicy::HasPermissionsForFile(
int child_id, const FilePath& file, int permissions) {
base::AutoLock lock(lock_);