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

Unified Diff: chrome/browser/download/download_util.cc

Issue 6973052: When the download folder does not exist, change the download folder to a user's "Downloads" (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Overrides the user's "Downloads" folder in DownloadPrefs Created 9 years, 6 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
Index: chrome/browser/download/download_util.cc
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index 06c03b2b38b9b3e2e34ee3dcb2fb75043f7e8770..ebaac451da4d6fe8a9bff5178146317ac77f040d 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -203,36 +203,16 @@ void GenerateFileNameInternal(const GURL& url,
// Download temporary file creation --------------------------------------------
-class DefaultDownloadDirectory {
- public:
- const FilePath& path() const { return path_; }
- private:
- DefaultDownloadDirectory() {
- if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &path_)) {
+FilePath GetDefaultDownloadDirectoryFromPathService() {
+ FilePath default_download_dir;
+ if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &default_download_dir))
+ NOTREACHED();
+ if (DownloadPathIsDangerous(default_download_dir)) {
+ if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS_SAFE,
+ &default_download_dir))
NOTREACHED();
- }
- if (DownloadPathIsDangerous(path_)) {
- if (!PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS_SAFE, &path_)) {
- NOTREACHED();
- }
- }
}
- friend struct base::DefaultLazyInstanceTraits<DefaultDownloadDirectory>;
- FilePath path_;
-};
-
-static base::LazyInstance<DefaultDownloadDirectory>
- g_default_download_directory(base::LINKER_INITIALIZED);
-
-const FilePath& GetDefaultDownloadDirectory() {
- return g_default_download_directory.Get().path();
-}
-
-bool CreateTemporaryFileForDownload(FilePath* temp_file) {
- if (file_util::CreateTemporaryFileInDir(GetDefaultDownloadDirectory(),
- temp_file))
- return true;
- return file_util::CreateTemporaryFile(temp_file);
+ return default_download_dir;
}
bool DownloadPathIsDangerous(const FilePath& download_path) {

Powered by Google App Engine
This is Rietveld 408576698