| 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_source_gtk.h" | 5 #include "content/browser/web_contents/web_drag_source_gtk.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/nix/mime_util_xdg.h" | 10 #include "base/nix/mime_util_xdg.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 FALSE, | 232 FALSE, |
| 233 NULL, | 233 NULL, |
| 234 NULL, | 234 NULL, |
| 235 &file_url_len, | 235 &file_url_len, |
| 236 &file_url_value) && | 236 &file_url_value) && |
| 237 file_url_value) { | 237 file_url_value) { |
| 238 // Convert from the file url to the file path. | 238 // Convert from the file url to the file path. |
| 239 GURL file_url(std::string(reinterpret_cast<char*>(file_url_value), | 239 GURL file_url(std::string(reinterpret_cast<char*>(file_url_value), |
| 240 file_url_len)); | 240 file_url_len)); |
| 241 g_free(file_url_value); | 241 g_free(file_url_value); |
| 242 FilePath file_path; | 242 base::FilePath file_path; |
| 243 if (net::FileURLToFilePath(file_url, &file_path)) { | 243 if (net::FileURLToFilePath(file_url, &file_path)) { |
| 244 // Open the file as a stream. | 244 // Open the file as a stream. |
| 245 scoped_ptr<net::FileStream> file_stream( | 245 scoped_ptr<net::FileStream> file_stream( |
| 246 CreateFileStreamForDrop( | 246 CreateFileStreamForDrop( |
| 247 &file_path, | 247 &file_path, |
| 248 GetContentClient()->browser()->GetNetLog())); | 248 GetContentClient()->browser()->GetNetLog())); |
| 249 if (file_stream.get()) { | 249 if (file_stream.get()) { |
| 250 // Start downloading the file to the stream. | 250 // Start downloading the file to the stream. |
| 251 scoped_refptr<DragDownloadFile> drag_file_downloader = | 251 scoped_refptr<DragDownloadFile> drag_file_downloader = |
| 252 new DragDownloadFile( | 252 new DragDownloadFile( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // Let the native failure animation run. | 309 // Let the native failure animation run. |
| 310 return FALSE; | 310 return FALSE; |
| 311 } | 311 } |
| 312 | 312 |
| 313 void WebDragSourceGtk::OnDragBegin(GtkWidget* sender, | 313 void WebDragSourceGtk::OnDragBegin(GtkWidget* sender, |
| 314 GdkDragContext* drag_context) { | 314 GdkDragContext* drag_context) { |
| 315 if (!download_url_.is_empty()) { | 315 if (!download_url_.is_empty()) { |
| 316 // Generate the file name based on both mime type and proposed file name. | 316 // Generate the file name based on both mime type and proposed file name. |
| 317 std::string default_name = | 317 std::string default_name = |
| 318 GetContentClient()->browser()->GetDefaultDownloadName(); | 318 GetContentClient()->browser()->GetDefaultDownloadName(); |
| 319 FilePath generated_download_file_name = | 319 base::FilePath generated_download_file_name = |
| 320 net::GenerateFileName(download_url_, | 320 net::GenerateFileName(download_url_, |
| 321 std::string(), | 321 std::string(), |
| 322 std::string(), | 322 std::string(), |
| 323 download_file_name_.value(), | 323 download_file_name_.value(), |
| 324 UTF16ToUTF8(wide_download_mime_type_), | 324 UTF16ToUTF8(wide_download_mime_type_), |
| 325 default_name); | 325 default_name); |
| 326 | 326 |
| 327 // Pass the file name to the drop target by setting the source window's | 327 // Pass the file name to the drop target by setting the source window's |
| 328 // XdndDirectSave0 property. | 328 // XdndDirectSave0 property. |
| 329 gdk_property_change(drag_context->source_window, | 329 gdk_property_change(drag_context->source_window, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 cairo_clip(cr); | 400 cairo_clip(cr); |
| 401 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 401 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
| 402 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); | 402 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); |
| 403 cairo_paint(cr); | 403 cairo_paint(cr); |
| 404 cairo_destroy(cr); | 404 cairo_destroy(cr); |
| 405 | 405 |
| 406 return TRUE; | 406 return TRUE; |
| 407 } | 407 } |
| 408 | 408 |
| 409 } // namespace content | 409 } // namespace content |
| OLD | NEW |