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

Side by Side Diff: content/browser/web_contents/web_drag_dest_gtk.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, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_drag_dest_gtk.h" 5 #include "content/browser/web_contents/web_drag_dest_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 for (gchar** uri_iter = uris; *uri_iter; uri_iter++) { 202 for (gchar** uri_iter = uris; *uri_iter; uri_iter++) {
203 // Most file managers populate text/uri-list with file URLs when 203 // Most file managers populate text/uri-list with file URLs when
204 // dragging files. To avoid exposing file system paths to web content, 204 // dragging files. To avoid exposing file system paths to web content,
205 // file URLs are never set as the URL content for the drop. 205 // file URLs are never set as the URL content for the drop.
206 // TODO(estade): Can the filenames have a non-UTF8 encoding? 206 // TODO(estade): Can the filenames have a non-UTF8 encoding?
207 GURL url(*uri_iter); 207 GURL url(*uri_iter);
208 base::FilePath file_path; 208 base::FilePath file_path;
209 if (url.SchemeIs(kFileScheme) && 209 if (url.SchemeIs(kFileScheme) &&
210 net::FileURLToFilePath(url, &file_path)) { 210 net::FileURLToFilePath(url, &file_path)) {
211 drop_data_->filenames.push_back( 211 drop_data_->filenames.push_back(
212 DropData::FileInfo(base::UTF8ToUTF16(file_path.value()), 212 ui::FileInfo(file_path, base::FilePath()));
213 base::string16()));
214 // This is a hack. Some file managers also populate text/plain with 213 // This is a hack. Some file managers also populate text/plain with
215 // a file URL when dragging files, so we clear it to avoid exposing 214 // a file URL when dragging files, so we clear it to avoid exposing
216 // it to the web content. 215 // it to the web content.
217 drop_data_->text = base::NullableString16(); 216 drop_data_->text = base::NullableString16();
218 } else if (!drop_data_->url.is_valid()) { 217 } else if (!drop_data_->url.is_valid()) {
219 // Also set the first non-file URL as the URL content for the drop. 218 // Also set the first non-file URL as the URL content for the drop.
220 drop_data_->url = url; 219 drop_data_->url = url;
221 } 220 }
222 } 221 }
223 g_strfreev(uris); 222 g_strfreev(uris);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 gtk_drag_finish(context, is_drop_target_, FALSE, time); 336 gtk_drag_finish(context, is_drop_target_, FALSE, time);
338 337
339 return TRUE; 338 return TRUE;
340 } 339 }
341 340
342 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { 341 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const {
343 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); 342 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost());
344 } 343 }
345 344
346 } // namespace content 345 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698