| 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/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } else if (target == ui::GetAtomForTarget(ui::TEXT_URI_LIST)) { | 182 } else if (target == ui::GetAtomForTarget(ui::TEXT_URI_LIST)) { |
| 183 gchar** uris = gtk_selection_data_get_uris(data); | 183 gchar** uris = gtk_selection_data_get_uris(data); |
| 184 if (uris) { | 184 if (uris) { |
| 185 drop_data_->url = GURL(); | 185 drop_data_->url = GURL(); |
| 186 for (gchar** uri_iter = uris; *uri_iter; uri_iter++) { | 186 for (gchar** uri_iter = uris; *uri_iter; uri_iter++) { |
| 187 // Most file managers populate text/uri-list with file URLs when | 187 // Most file managers populate text/uri-list with file URLs when |
| 188 // dragging files. To avoid exposing file system paths to web content, | 188 // dragging files. To avoid exposing file system paths to web content, |
| 189 // file URLs are never set as the URL content for the drop. | 189 // file URLs are never set as the URL content for the drop. |
| 190 // TODO(estade): Can the filenames have a non-UTF8 encoding? | 190 // TODO(estade): Can the filenames have a non-UTF8 encoding? |
| 191 GURL url(*uri_iter); | 191 GURL url(*uri_iter); |
| 192 FilePath file_path; | 192 base::FilePath file_path; |
| 193 if (url.SchemeIs(chrome::kFileScheme) && | 193 if (url.SchemeIs(chrome::kFileScheme) && |
| 194 net::FileURLToFilePath(url, &file_path)) { | 194 net::FileURLToFilePath(url, &file_path)) { |
| 195 drop_data_->filenames.push_back( | 195 drop_data_->filenames.push_back( |
| 196 WebDropData::FileInfo(UTF8ToUTF16(file_path.value()), | 196 WebDropData::FileInfo(UTF8ToUTF16(file_path.value()), |
| 197 string16())); | 197 string16())); |
| 198 // This is a hack. Some file managers also populate text/plain with | 198 // This is a hack. Some file managers also populate text/plain with |
| 199 // a file URL when dragging files, so we clear it to avoid exposing | 199 // a file URL when dragging files, so we clear it to avoid exposing |
| 200 // it to the web content. | 200 // it to the web content. |
| 201 drop_data_->text = NullableString16(true); | 201 drop_data_->text = NullableString16(true); |
| 202 } else if (!drop_data_->url.is_valid()) { | 202 } else if (!drop_data_->url.is_valid()) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 gtk_drag_finish(context, is_drop_target_, FALSE, time); | 301 gtk_drag_finish(context, is_drop_target_, FALSE, time); |
| 302 | 302 |
| 303 return TRUE; | 303 return TRUE; |
| 304 } | 304 } |
| 305 | 305 |
| 306 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { | 306 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { |
| 307 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); | 307 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); |
| 308 } | 308 } |
| 309 | 309 |
| 310 } // namespace content | 310 } // namespace content |
| OLD | NEW |