diff options
-rw-r--r-- | chrome/browser/tab_contents/web_contents_view_win.cc | 14 | ||||
-rw-r--r-- | chrome/common/render_messages.h | 2 | ||||
-rw-r--r-- | webkit/glue/clipboard_conversion.cc | 4 | ||||
-rw-r--r-- | webkit/glue/webdropdata.h | 3 |
4 files changed, 21 insertions, 2 deletions
diff --git a/chrome/browser/tab_contents/web_contents_view_win.cc b/chrome/browser/tab_contents/web_contents_view_win.cc index 9f6ee1a..f2cee8b 100644 --- a/chrome/browser/tab_contents/web_contents_view_win.cc +++ b/chrome/browser/tab_contents/web_contents_view_win.cc @@ -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 @@ void WebContentsViewWin::StartDragging(const WebDropData& drop_data) { // 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); diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 7d1273f..fa459a6 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -1666,6 +1666,7 @@ struct ParamTraits<WebDropData> { static void Write(Message* m, const param_type& p) { WriteParam(m, p.url); WriteParam(m, p.url_title); + WriteParam(m, p.file_extension); WriteParam(m, p.filenames); WriteParam(m, p.plain_text); WriteParam(m, p.text_html); @@ -1677,6 +1678,7 @@ struct ParamTraits<WebDropData> { return ReadParam(m, iter, &p->url) && ReadParam(m, iter, &p->url_title) && + ReadParam(m, iter, &p->file_extension) && ReadParam(m, iter, &p->filenames) && ReadParam(m, iter, &p->plain_text) && ReadParam(m, iter, &p->text_html) && diff --git a/webkit/glue/clipboard_conversion.cc b/webkit/glue/clipboard_conversion.cc index 02a14ab..28f191d 100644 --- a/webkit/glue/clipboard_conversion.cc +++ b/webkit/glue/clipboard_conversion.cc @@ -24,6 +24,8 @@ WebDropData ChromiumDataObjectToWebDropData( drop_data.url = KURLToGURL(data_object->url); drop_data.url_title = StringToStdWString(data_object->urlTitle); + drop_data.file_extension = StringToStdWString(data_object->fileExtension); + for (size_t i = 0; i < data_object->filenames.size(); ++i) { drop_data.filenames.push_back(StringToStdWString( data_object->filenames[i])); @@ -51,6 +53,8 @@ PassRefPtr<WebCore::ChromiumDataObject> WebDropDataToChromiumDataObject( data_object->url = GURLToKURL(drop_data.url); data_object->urlTitle = StdWStringToString(drop_data.url_title); + data_object->fileExtension = StdWStringToString(drop_data.file_extension); + for (size_t i = 0; i < drop_data.filenames.size(); ++i) { data_object->filenames.append(StdWStringToString(drop_data.filenames[i])); } diff --git a/webkit/glue/webdropdata.h b/webkit/glue/webdropdata.h index e6d51f4..9afcd04 100644 --- a/webkit/glue/webdropdata.h +++ b/webkit/glue/webdropdata.h @@ -20,6 +20,9 @@ struct WebDropData { GURL url; std::wstring url_title; // The title associated with |url|. + // File extension for dragging images from a webview to the desktop. + std::wstring file_extension; + // User is dropping one or more files on the webview. std::vector<std::wstring> filenames; |