| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/tab_contents_drag_source.h" | 5 #include "chrome/browser/gtk/tab_contents_drag_source.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "app/gtk_dnd_util.h" | 9 #include "app/gtk_dnd_util.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/mime_util.h" | 11 #include "base/mime_util.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/download/download_manager.h" | 13 #include "chrome/browser/download/download_util.h" |
| 14 #include "chrome/browser/download/drag_download_file.h" | 14 #include "chrome/browser/download/drag_download_file.h" |
| 15 #include "chrome/browser/download/drag_download_util.h" | 15 #include "chrome/browser/download/drag_download_util.h" |
| 16 #include "chrome/browser/gtk/gtk_util.h" | 16 #include "chrome/browser/gtk/gtk_util.h" |
| 17 #include "chrome/browser/renderer_host/render_view_host.h" | 17 #include "chrome/browser/renderer_host/render_view_host.h" |
| 18 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 18 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 19 #include "chrome/browser/tab_contents/tab_contents.h" | 19 #include "chrome/browser/tab_contents/tab_contents.h" |
| 20 #include "chrome/browser/tab_contents/tab_contents_view.h" | 20 #include "chrome/browser/tab_contents/tab_contents_view.h" |
| 21 #include "gfx/gtk_util.h" | 21 #include "gfx/gtk_util.h" |
| 22 #include "net/base/file_stream.h" | 22 #include "net/base/file_stream.h" |
| 23 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 } | 287 } |
| 288 | 288 |
| 289 void TabContentsDragSource::OnDragBegin(GtkWidget* sender, | 289 void TabContentsDragSource::OnDragBegin(GtkWidget* sender, |
| 290 GdkDragContext* drag_context) { | 290 GdkDragContext* drag_context) { |
| 291 if (!download_url_.is_empty()) { | 291 if (!download_url_.is_empty()) { |
| 292 // Generate the file name based on both mime type and proposed file name. | 292 // Generate the file name based on both mime type and proposed file name. |
| 293 std::string download_mime_type = UTF16ToUTF8(wide_download_mime_type_); | 293 std::string download_mime_type = UTF16ToUTF8(wide_download_mime_type_); |
| 294 std::string content_disposition("attachment; filename="); | 294 std::string content_disposition("attachment; filename="); |
| 295 content_disposition += download_file_name_.value(); | 295 content_disposition += download_file_name_.value(); |
| 296 FilePath generated_download_file_name; | 296 FilePath generated_download_file_name; |
| 297 DownloadManager::GenerateFileName(download_url_, | 297 download_util::GenerateFileName(download_url_, |
| 298 content_disposition, | 298 content_disposition, |
| 299 std::string(), | 299 std::string(), |
| 300 download_mime_type, | 300 download_mime_type, |
| 301 &generated_download_file_name); | 301 &generated_download_file_name); |
| 302 | 302 |
| 303 // Pass the file name to the drop target by setting the source window's | 303 // Pass the file name to the drop target by setting the source window's |
| 304 // XdndDirectSave0 property. | 304 // XdndDirectSave0 property. |
| 305 gdk_property_change(drag_context->source_window, | 305 gdk_property_change(drag_context->source_window, |
| 306 gtk_dnd_util::GetAtomForTarget( | 306 gtk_dnd_util::GetAtomForTarget( |
| 307 gtk_dnd_util::DIRECT_SAVE_FILE), | 307 gtk_dnd_util::DIRECT_SAVE_FILE), |
| 308 gtk_dnd_util::GetAtomForTarget( | 308 gtk_dnd_util::GetAtomForTarget( |
| 309 gtk_dnd_util::TEXT_PLAIN_NO_CHARSET), | 309 gtk_dnd_util::TEXT_PLAIN_NO_CHARSET), |
| 310 8, | 310 8, |
| 311 GDK_PROP_MODE_REPLACE, | 311 GDK_PROP_MODE_REPLACE, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 cairo_t* cr = gdk_cairo_create(event->window); | 370 cairo_t* cr = gdk_cairo_create(event->window); |
| 371 gdk_cairo_rectangle(cr, &event->area); | 371 gdk_cairo_rectangle(cr, &event->area); |
| 372 cairo_clip(cr); | 372 cairo_clip(cr); |
| 373 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 373 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
| 374 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); | 374 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); |
| 375 cairo_paint(cr); | 375 cairo_paint(cr); |
| 376 cairo_destroy(cr); | 376 cairo_destroy(cr); |
| 377 | 377 |
| 378 return TRUE; | 378 return TRUE; |
| 379 } | 379 } |
| OLD | NEW |