Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 211383007: Use FilePaths in content::DropData to avoid redundant conversions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang-format Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_view_host_impl.cc
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc
index 5917cc541c9aab47f42b59fed335c2c61a722de7..8de4ddc9e33a6c8fdf71e3dc7a3f401e64eb687b 100644
--- a/content/browser/renderer_host/render_view_host_impl.cc
+++ b/content/browser/renderer_host/render_view_host_impl.cc
@@ -781,28 +781,27 @@ void RenderViewHostImpl::DragTargetDragEnter(
// The filenames vector, on the other hand, does represent a capability to
// access the given files.
fileapi::IsolatedContext::FileInfoSet files;
- for (std::vector<DropData::FileInfo>::iterator iter(
+ for (std::vector<ui::FileInfo>::iterator iter(
filtered_data.filenames.begin());
- iter != filtered_data.filenames.end(); ++iter) {
+ iter != filtered_data.filenames.end();
+ ++iter) {
// A dragged file may wind up as the value of an input element, or it
// may be used as the target of a navigation instead. We don't know
// which will happen at this point, so generously grant both access
// and request permissions to the specific file to cover both cases.
// We do not give it the permission to request all file:// URLs.
- base::FilePath path =
- base::FilePath::FromUTF8Unsafe(base::UTF16ToUTF8(iter->path));
// Make sure we have the same display_name as the one we register.
if (iter->display_name.empty()) {
std::string name;
- files.AddPath(path, &name);
- iter->display_name = base::UTF8ToUTF16(name);
+ files.AddPath(iter->path, &name);
+ iter->display_name = base::FilePath::FromUTF8Unsafe(name);
} else {
- files.AddPathWithName(path, base::UTF16ToUTF8(iter->display_name));
+ files.AddPathWithName(iter->path, iter->display_name.AsUTF8Unsafe());
}
policy->GrantRequestSpecificFileURL(renderer_id,
- net::FilePathToFileURL(path));
+ net::FilePathToFileURL(iter->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
@@ -810,8 +809,8 @@ void RenderViewHostImpl::DragTargetDragEnter(
// 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);
+ if (!policy->CanReadFile(renderer_id, iter->path))
+ policy->GrantReadFile(renderer_id, iter->path);
}
fileapi::IsolatedContext* isolated_context =
@@ -1491,12 +1490,11 @@ void RenderViewHostImpl::OnStartDragging(
// still fire though, which causes read permissions to be granted to the
// renderer for any file paths in the drop.
filtered_data.filenames.clear();
- for (std::vector<DropData::FileInfo>::const_iterator it =
+ for (std::vector<ui::FileInfo>::const_iterator it =
drop_data.filenames.begin();
- it != drop_data.filenames.end(); ++it) {
- base::FilePath path(
- base::FilePath::FromUTF8Unsafe(base::UTF16ToUTF8(it->path)));
- if (policy->CanReadFile(GetProcess()->GetID(), path))
+ it != drop_data.filenames.end();
+ ++it) {
+ if (policy->CanReadFile(GetProcess()->GetID(), it->path))
filtered_data.filenames.push_back(*it);
}
float scale = ui::GetImageScale(GetScaleFactorForView(GetView()));

Powered by Google App Engine
This is Rietveld 408576698