Commit 2d81b66f authored by avi@chromium.org's avatar avi@chromium.org

Make all drag sources not depend on download_util.

Apply the same change as r106124 to Mac/Win.

BUG=95573
TEST=no change

Review URL: http://codereview.chromium.org/8380021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107112 0039d316-1c4b-4281-b951-d872f2087c98
parent eb5bc975
...@@ -88,24 +88,6 @@ namespace download_util { ...@@ -88,24 +88,6 @@ namespace download_util {
// so that the animation ends faded out. // so that the animation ends faded out.
static const int kCompleteAnimationCycles = 5; static const int kCompleteAnimationCycles = 5;
namespace {
void GenerateFileNameInternal(const GURL& url,
const std::string& content_disposition,
const std::string& referrer_charset,
const std::string& suggested_name,
const std::string& mime_type,
FilePath* generated_name) {
std::string default_file_name(
l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
*generated_name = net::GenerateFileName(url, content_disposition,
referrer_charset, suggested_name,
mime_type, default_file_name);
}
} // namespace
// Download temporary file creation -------------------------------------------- // Download temporary file creation --------------------------------------------
class DefaultDownloadDirectory { class DefaultDownloadDirectory {
...@@ -144,21 +126,15 @@ bool DownloadPathIsDangerous(const FilePath& download_path) { ...@@ -144,21 +126,15 @@ bool DownloadPathIsDangerous(const FilePath& download_path) {
void GenerateFileNameFromRequest(const DownloadItem& download_item, void GenerateFileNameFromRequest(const DownloadItem& download_item,
FilePath* generated_name) { FilePath* generated_name) {
GenerateFileNameInternal(download_item.GetURL(), std::string default_file_name(
download_item.content_disposition(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
download_item.referrer_charset(),
download_item.suggested_filename(),
download_item.mime_type(),
generated_name);
}
void GenerateFileNameFromSuggestedName(const GURL& url, *generated_name = net::GenerateFileName(download_item.GetURL(),
const std::string& suggested_name, download_item.content_disposition(),
const std::string& mime_type, download_item.referrer_charset(),
FilePath* generated_name) { download_item.suggested_filename(),
// TODO(asanka): We should pass in a valid referrer_charset here. download_item.mime_type(),
GenerateFileNameInternal(url, std::string(), std::string(), default_file_name);
suggested_name, mime_type, generated_name);
} }
// Download progress painting -------------------------------------------------- // Download progress painting --------------------------------------------------
......
...@@ -61,14 +61,6 @@ bool DownloadPathIsDangerous(const FilePath& download_path); ...@@ -61,14 +61,6 @@ bool DownloadPathIsDangerous(const FilePath& download_path);
void GenerateFileNameFromRequest(const DownloadItem& download_item, void GenerateFileNameFromRequest(const DownloadItem& download_item,
FilePath* generated_name); FilePath* generated_name);
// Generate a filename based on the URL, a suggested name and a MIME
// type. Similar in operation to net::GenerateFileName(), but uses a
// localized default name.
void GenerateFileNameFromSuggestedName(const GURL& url,
const std::string& suggested_name,
const std::string& mime_type,
FilePath* generated_name);
// Download progress animations ------------------------------------------------ // Download progress animations ------------------------------------------------
// Arc sweep angle for use with downloads of unknown size // Arc sweep angle for use with downloads of unknown size
......
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/tab_contents/tab_contents_view_mac.h" #include "chrome/browser/tab_contents/tab_contents_view_mac.h"
#include "content/browser/download/drag_download_file.h" #include "content/browser/download/drag_download_file.h"
#include "content/browser/download/drag_download_util.h" #include "content/browser/download/drag_download_util.h"
#include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "net/base/file_stream.h" #include "net/base/file_stream.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
...@@ -402,11 +402,17 @@ void PromiseWriterTask::Run() { ...@@ -402,11 +402,17 @@ void PromiseWriterTask::Run() {
&mimeType, &mimeType,
&fileName, &fileName,
&downloadURL_)) { &downloadURL_)) {
download_util::GenerateFileNameFromSuggestedName( // Generate the file name based on both mime type and proposed file
downloadURL_, // name.
fileName.value(), std::string defaultName =
UTF16ToUTF8(mimeType), content::GetContentClient()->browser()->GetDefaultDownloadName();
&downloadFileName_); downloadFileName_ =
net::GenerateFileName(downloadURL_,
std::string(),
std::string(),
fileName.value(),
UTF16ToUTF8(mimeType),
defaultName);
fileExtension = SysUTF8ToNSString(downloadFileName_.Extension()); fileExtension = SysUTF8ToNSString(downloadFileName_.Extension());
} }
} }
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "base/threading/thread.h" #include "base/threading/thread.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_node_data.h" #include "chrome/browser/bookmarks/bookmark_node_data.h"
#include "chrome/browser/download/download_util.h"
#include "chrome/browser/tab_contents/web_drag_source_win.h" #include "chrome/browser/tab_contents/web_drag_source_win.h"
#include "chrome/browser/tab_contents/web_drag_utils_win.h" #include "chrome/browser/tab_contents/web_drag_utils_win.h"
#include "chrome/browser/tab_contents/web_drop_target_win.h" #include "chrome/browser/tab_contents/web_drop_target_win.h"
...@@ -26,6 +25,7 @@ ...@@ -26,6 +25,7 @@
#include "content/browser/download/drag_download_file.h" #include "content/browser/download/drag_download_file.h"
#include "content/browser/download/drag_download_util.h" #include "content/browser/download/drag_download_util.h"
#include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/content_browser_client.h"
#include "net/base/net_util.h" #include "net/base/net_util.h"
#include "views/drag_utils.h" #include "views/drag_utils.h"
#include "webkit/glue/webdropdata.h" #include "webkit/glue/webdropdata.h"
...@@ -197,19 +197,22 @@ void TabContentsDragWin::PrepareDragForDownload( ...@@ -197,19 +197,22 @@ void TabContentsDragWin::PrepareDragForDownload(
&download_url)) &download_url))
return; return;
// Generate the download filename. // Generate the file name based on both mime type and proposed file name.
FilePath generated_file_name; std::string default_name =
download_util::GenerateFileNameFromSuggestedName( content::GetContentClient()->browser()->GetDefaultDownloadName();
download_url, FilePath generated_download_file_name =
UTF16ToUTF8(file_name.value()), net::GenerateFileName(download_url,
UTF16ToUTF8(mime_type), std::string(),
&generated_file_name); std::string(),
UTF16ToUTF8(file_name.value()),
UTF16ToUTF8(mime_type),
default_name);
// Provide the data as file (CF_HDROP). A temporary download file with the // Provide the data as file (CF_HDROP). A temporary download file with the
// Zone.Identifier ADS (Alternate Data Stream) attached will be created. // Zone.Identifier ADS (Alternate Data Stream) attached will be created.
linked_ptr<net::FileStream> empty_file_stream; linked_ptr<net::FileStream> empty_file_stream;
scoped_refptr<DragDownloadFile> download_file = scoped_refptr<DragDownloadFile> download_file =
new DragDownloadFile(generated_file_name, new DragDownloadFile(generated_download_file_name,
empty_file_stream, empty_file_stream,
download_url, download_url,
page_url, page_url,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment