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

Unified Diff: chrome/browser/tab_contents/web_contents_view_win.cc

Issue 19417: Generate a file name when dragging an image to the desktop (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/render_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/web_contents_view_win.cc
===================================================================
--- chrome/browser/tab_contents/web_contents_view_win.cc (revision 8847)
+++ chrome/browser/tab_contents/web_contents_view_win.cc (working copy)
@@ -24,6 +24,7 @@
#include "chrome/browser/views/sad_tab_view.h"
#include "chrome/common/gfx/chrome_canvas.h"
#include "chrome/common/os_exchange_data.h"
+#include "net/base/net_util.h"
#include "webkit/glue/plugins/webplugin_delegate_impl.h"
namespace {
@@ -96,8 +97,17 @@
// contents (to a .URL shortcut). We want to prefer file content data over a
// shortcut so we add it first.
if (!drop_data.file_contents.empty()) {
- data->SetFileContents(drop_data.file_description_filename,
- drop_data.file_contents);
+ // Images without ALT text will only have a file extension so we need to
+ // synthesize one from the provided extension and URL.
+ FilePath file_name(drop_data.file_description_filename);
+ file_name = file_name.BaseName().RemoveExtension();
+ if (file_name.value().empty()) {
+ // Retrieve the name from the URL.
+ file_name = FilePath::FromWStringHack(
+ net::GetSuggestedFilename(drop_data.url, L"", L""));
+ }
+ file_name = file_name.ReplaceExtension(drop_data.file_extension);
+ data->SetFileContents(file_name.value(), drop_data.file_contents);
}
if (!drop_data.text_html.empty())
data->SetHtml(drop_data.text_html, drop_data.html_base_url);
« no previous file with comments | « no previous file | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698