summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
authordcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 22:25:20 +0000
committerdcheng@chromium.org <dcheng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-17 22:25:20 +0000
commit386e26afbf4ac1149cdec18b133e728cf3a9e1d6 (patch)
treeb39381fb2302f12f9dc17a010f25cda646ee2b7e /content/browser
parent9ba21e1c84b7a9591b7569b11973975c40a34ad7 (diff)
downloadchromium_src-386e26afbf4ac1149cdec18b133e728cf3a9e1d6.zip
chromium_src-386e26afbf4ac1149cdec18b133e728cf3a9e1d6.tar.gz
chromium_src-386e26afbf4ac1149cdec18b133e728cf3a9e1d6.tar.bz2
Don't overwrite write permissions granted to renderer when dragging files.
We unconditionally granted the read access to the renderer when dragging in files. Unfortunately, this breaks things like the File Manager which actually have write access to certain parts of the filesystem. In order to prevent file dragging from downgrading child permissions, we first check if the renderer can already read the file before setting read permissions for it. BUG=chromium-os:28809 TEST=manual Review URL: http://codereview.chromium.org/10086020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132672 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/renderer_host/render_view_host_impl.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index 4e654a6..77a45b5 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -578,11 +578,19 @@ void RenderViewHostImpl::DragTargetDragEnter(
iter != filtered_data.filenames.end(); ++iter) {
FilePath path = FilePath::FromWStringHack(UTF16ToWideHack(*iter));
policy->GrantRequestURL(renderer_id, net::FilePathToFileURL(path));
- policy->GrantReadFile(renderer_id, path);
- // Allow dragged directories to be enumerated by the child process.
- // Note that we can't tell a file from a directory at this point.
- policy->GrantReadDirectory(renderer_id, path);
+ // If the renderer already has permission to read these paths, we don't need
+ // to re-grant them. This prevents problems with DnD for files in the CrOS
+ // file manager--the file manager already had read/write access to those
+ // directories, but dragging a file would cause the read/write access to be
+ // overwritten with read-only access, making them impossible to delete or
+ // rename until the renderer was killed.
+ if (!policy->CanReadFile(renderer_id, path)) {
+ policy->GrantReadFile(renderer_id, path);
+ // Allow dragged directories to be enumerated by the child process.
+ // Note that we can't tell a file from a directory at this point.
+ policy->GrantReadDirectory(renderer_id, path);
+ }
filesets.insert(path);
}