Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: chrome/browser/ui/gtk/tab_contents_drag_source.cc

Issue 7005011: Fix bug 79905: Drag and drop of "DownloadURL" type ignores specified filename for data URLs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tab_contents/web_drag_source.mm ('k') | chrome/browser/ui/views/tab_contents/tab_contents_drag_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698