| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |