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

Unified Diff: content/browser/download/download_manager_impl.cc

Issue 2924433002: Change linux default hidden file save directory to XDG_DATA_HOME (Closed)
Patch Set: Fix DownloadManagerTest.StartDownload Created 3 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: content/browser/download/download_manager_impl.cc
diff --git a/content/browser/download/download_manager_impl.cc b/content/browser/download/download_manager_impl.cc
index 238508ca99da1c064a668b133e04744aa18688c0..db4abf7e31d77120c4f112cabc9dfa4c74171a11 100644
--- a/content/browser/download/download_manager_impl.cc
+++ b/content/browser/download/download_manager_impl.cc
@@ -56,6 +56,10 @@
#include "storage/browser/blob/blob_url_request_job_factory.h"
#include "url/origin.h"
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+#include "base/nix/xdg_util.h"
+#endif
+
namespace content {
namespace {
@@ -176,6 +180,13 @@ class DownloadItemFactoryImpl : public DownloadItemFactory {
}
};
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+base::FilePath GetTemporaryDownloadDirectory() {
+ std::unique_ptr<base::Environment> env(base::Environment::Create());
+ return base::nix::GetXDGDirectory(env.get(), "XDG_DATA_HOME", ".local/share");
+}
+#endif
+
} // namespace
DownloadManagerImpl::DownloadManagerImpl(net::NetLog* net_log,
@@ -361,12 +372,20 @@ void DownloadManagerImpl::StartDownloadWithId(
}
base::FilePath default_download_directory;
+#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
+ // TODO(thomasanderson): Remove this when all Linux distros with
+ // versions of GTK lower than 3.14.7 are no longer supported. This
+ // should happen when support for Ubuntu Trusty and Debian Jessie
+ // are removed.
+ default_download_directory = GetTemporaryDownloadDirectory();
+#else
if (delegate_) {
base::FilePath website_save_directory; // Unused
bool skip_dir_check = false; // Unused
delegate_->GetSaveDir(GetBrowserContext(), &website_save_directory,
&default_download_directory, &skip_dir_check);
}
+#endif
std::unique_ptr<DownloadFile> download_file;
« no previous file with comments | « chrome/browser/shell_integration_linux.cc ('k') | content/browser/download/download_manager_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698