| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/gtk/tab_contents_drag_source.h" | 5 #include "chrome/browser/ui/gtk/tab_contents_drag_source.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/mime_util.h" | 10 #include "base/mime_util.h" |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 284 } |
| 285 | 285 |
| 286 // Let the native failure animation run. | 286 // Let the native failure animation run. |
| 287 return FALSE; | 287 return FALSE; |
| 288 } | 288 } |
| 289 | 289 |
| 290 void TabContentsDragSource::OnDragBegin(GtkWidget* sender, | 290 void TabContentsDragSource::OnDragBegin(GtkWidget* sender, |
| 291 GdkDragContext* drag_context) { | 291 GdkDragContext* drag_context) { |
| 292 if (!download_url_.is_empty()) { | 292 if (!download_url_.is_empty()) { |
| 293 // Generate the file name based on both mime type and proposed file name. | 293 // Generate the file name based on both mime type and proposed file name. |
| 294 std::string download_mime_type = UTF16ToUTF8(wide_download_mime_type_); | |
| 295 std::string content_disposition("attachment; filename="); | |
| 296 content_disposition += download_file_name_.value(); | |
| 297 FilePath generated_download_file_name; | 294 FilePath generated_download_file_name; |
| 298 download_util::GenerateFileName(download_url_, | 295 download_util::GenerateFileNameFromSuggestedName( |
| 299 content_disposition, | 296 download_url_, |
| 300 std::string(), | 297 download_file_name_.value(), |
| 301 download_mime_type, | 298 UTF16ToUTF8(wide_download_mime_type_), |
| 302 &generated_download_file_name); | 299 &generated_download_file_name); |
| 303 | 300 |
| 304 // Pass the file name to the drop target by setting the source window's | 301 // Pass the file name to the drop target by setting the source window's |
| 305 // XdndDirectSave0 property. | 302 // XdndDirectSave0 property. |
| 306 gdk_property_change(drag_context->source_window, | 303 gdk_property_change(drag_context->source_window, |
| 307 ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE), | 304 ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE), |
| 308 ui::GetAtomForTarget(ui::TEXT_PLAIN_NO_CHARSET), | 305 ui::GetAtomForTarget(ui::TEXT_PLAIN_NO_CHARSET), |
| 309 8, | 306 8, |
| 310 GDK_PROP_MODE_REPLACE, | 307 GDK_PROP_MODE_REPLACE, |
| 311 reinterpret_cast<const guchar*>( | 308 reinterpret_cast<const guchar*>( |
| 312 generated_download_file_name.value().c_str()), | 309 generated_download_file_name.value().c_str()), |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 cairo_t* cr = gdk_cairo_create(event->window); | 368 cairo_t* cr = gdk_cairo_create(event->window); |
| 372 gdk_cairo_rectangle(cr, &event->area); | 369 gdk_cairo_rectangle(cr, &event->area); |
| 373 cairo_clip(cr); | 370 cairo_clip(cr); |
| 374 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 371 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
| 375 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); | 372 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); |
| 376 cairo_paint(cr); | 373 cairo_paint(cr); |
| 377 cairo_destroy(cr); | 374 cairo_destroy(cr); |
| 378 | 375 |
| 379 return TRUE; | 376 return TRUE; |
| 380 } | 377 } |
| OLD | NEW |