diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 23:19:32 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-18 23:19:32 +0000 |
commit | e1d16eb9348270bb806f9b9622b84d0df842e2e4 (patch) | |
tree | 61efe423ed9e44b886b8d0f793baf762b4d74fdc /content | |
parent | 5fa89d72b2c9410e5d0bce2d8541c06ce714d5c2 (diff) | |
download | chromium_src-e1d16eb9348270bb806f9b9622b84d0df842e2e4.zip chromium_src-e1d16eb9348270bb806f9b9622b84d0df842e2e4.tar.gz chromium_src-e1d16eb9348270bb806f9b9622b84d0df842e2e4.tar.bz2 |
Have BaseFile ask the embedder for the default download directory.
BUG=82782
Review URL: http://codereview.chromium.org/7677029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/content_browser_client.h | 4 | ||||
-rw-r--r-- | content/browser/download/base_file.cc | 18 | ||||
-rw-r--r-- | content/browser/mock_content_browser_client.cc | 5 | ||||
-rw-r--r-- | content/browser/mock_content_browser_client.h | 1 |
4 files changed, 23 insertions, 5 deletions
diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h index fd5f4aa..2c5947c 100644 --- a/content/browser/content_browser_client.h +++ b/content/browser/content_browser_client.h @@ -262,6 +262,10 @@ class ContentBrowserClient { // Clears browser cookies. virtual void ClearCookies(RenderViewHost* rvh) = 0; + // Returns the default download directory. + // This can be called on any thread. + virtual FilePath GetDefaultDownloadDirectory() = 0; + #if defined(OS_POSIX) && !defined(OS_MACOSX) // Can return an optional fd for crash handling, otherwise returns -1. virtual int GetCrashSignalFD(const std::string& process_type) = 0; diff --git a/content/browser/download/base_file.cc b/content/browser/download/base_file.cc index 7593df8..0a40369 100644 --- a/content/browser/download/base_file.cc +++ b/content/browser/download/base_file.cc @@ -12,8 +12,8 @@ #include "crypto/secure_hash.h" #include "net/base/file_stream.h" #include "net/base/net_errors.h" -#include "chrome/browser/download/download_util.h" #include "content/browser/browser_thread.h" +#include "content/browser/content_browser_client.h" #if defined(OS_WIN) #include "content/browser/safe_util_win.h" @@ -55,10 +55,18 @@ bool BaseFile::Initialize(bool calculate_hash) { if (calculate_hash_) secure_hash_.reset(crypto::SecureHash::Create(crypto::SecureHash::SHA256)); - if (!full_path_.empty() || - download_util::CreateTemporaryFileForDownload(&full_path_)) - return Open(); - return false; + if (full_path_.empty()) { + FilePath temp_file; + FilePath download_dir = + content::GetContentClient()->browser()->GetDefaultDownloadDirectory(); + if (!file_util::CreateTemporaryFileInDir(download_dir, &temp_file) && + !file_util::CreateTemporaryFile(&temp_file)) { + return false; + } + full_path_ = temp_file; + } + + return Open(); } bool BaseFile::AppendDataToFile(const char* data, size_t data_len) { diff --git a/content/browser/mock_content_browser_client.cc b/content/browser/mock_content_browser_client.cc index 1c68a24..eaae014 100644 --- a/content/browser/mock_content_browser_client.cc +++ b/content/browser/mock_content_browser_client.cc @@ -6,6 +6,7 @@ #include <string> +#include "base/file_path.h" #include "content/browser/webui/empty_web_ui_factory.h" #include "googleurl/src/gurl.h" #include "third_party/skia/include/core/SkBitmap.h" @@ -219,6 +220,10 @@ void MockContentBrowserClient::ClearCache(RenderViewHost* rvh) { void MockContentBrowserClient::ClearCookies(RenderViewHost* rvh) { } +FilePath MockContentBrowserClient::GetDefaultDownloadDirectory() { + return FilePath(); +} + #if defined(OS_POSIX) && !defined(OS_MACOSX) int MockContentBrowserClient::GetCrashSignalFD( const std::string& process_type) { diff --git a/content/browser/mock_content_browser_client.h b/content/browser/mock_content_browser_client.h index b471552..956d53e 100644 --- a/content/browser/mock_content_browser_client.h +++ b/content/browser/mock_content_browser_client.h @@ -107,6 +107,7 @@ class MockContentBrowserClient : public ContentBrowserClient { virtual void BrowserURLHandlerCreated(BrowserURLHandler* handler) OVERRIDE; virtual void ClearCache(RenderViewHost* rvh) OVERRIDE; virtual void ClearCookies(RenderViewHost* rvh) OVERRIDE; + virtual FilePath GetDefaultDownloadDirectory() OVERRIDE; #if defined(OS_POSIX) && !defined(OS_MACOSX) virtual int GetCrashSignalFD(const std::string& process_type) OVERRIDE; |