summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-28 03:45:47 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-28 03:45:47 +0000
commit83ad0766180d9196d711dab5cafcafa8f5148422 (patch)
treeb19e1bbcb1cb6bdea17527c4c60a956bd87e4d48 /chrome/common
parent443c4db65607dfd7dfc66ef9b621d784ce3e06ad (diff)
downloadchromium_src-83ad0766180d9196d711dab5cafcafa8f5148422.zip
chromium_src-83ad0766180d9196d711dab5cafcafa8f5148422.tar.gz
chromium_src-83ad0766180d9196d711dab5cafcafa8f5148422.tar.bz2
Linux: Use the same safe downloads logic as Windows. (try 2)
BUG=none TEST=none First attempt: http://codereview.chromium.org/10241007/ Review URL: http://codereview.chromium.org/10255018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134438 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/chrome_paths.cc2
-rw-r--r--chrome/common/chrome_paths.h3
-rw-r--r--chrome/common/chrome_paths_internal.h4
-rw-r--r--chrome/common/chrome_paths_linux.cc23
4 files changed, 12 insertions, 20 deletions
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index 6d4849e..3cacef7 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -144,7 +144,7 @@ bool PathProvider(int key, FilePath* result) {
create_dir = true;
break;
case chrome::DIR_DEFAULT_DOWNLOADS_SAFE:
-#if defined(OS_WIN)
+#if defined(OS_WIN) || defined(OS_LINUX)
if (!GetUserDownloadsDirectorySafe(&cur))
return false;
break;
diff --git a/chrome/common/chrome_paths.h b/chrome/common/chrome_paths.h
index 09988fc..9d6af14 100644
--- a/chrome/common/chrome_paths.h
+++ b/chrome/common/chrome_paths.h
@@ -27,7 +27,8 @@ enum {
DIR_APP_DICTIONARIES, // Directory where the global dictionaries are.
DIR_USER_DOCUMENTS, // Directory for a user's "My Documents".
DIR_DEFAULT_DOWNLOADS_SAFE, // Directory for a user's
- // "My Documents/Downloads".
+ // "My Documents/Downloads", (Windows) or
+ // "Downloads". (Linux)
DIR_DEFAULT_DOWNLOADS, // Directory for a user's downloads.
DIR_USER_DATA_TEMP, // A temp directory within DIR_USER_DATA. Use
// this when a temporary file or directory will
diff --git a/chrome/common/chrome_paths_internal.h b/chrome/common/chrome_paths_internal.h
index 23c3ec4..d4a1151 100644
--- a/chrome/common/chrome_paths_internal.h
+++ b/chrome/common/chrome_paths_internal.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -41,7 +41,7 @@ void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result);
// Get the path to the user's documents directory.
bool GetUserDocumentsDirectory(FilePath* result);
-#if defined (OS_WIN)
+#if defined(OS_WIN) || defined(OS_LINUX)
// Gets the path to a safe default download directory for a user.
bool GetUserDownloadsDirectorySafe(FilePath* result);
#endif
diff --git a/chrome/common/chrome_paths_linux.cc b/chrome/common/chrome_paths_linux.cc
index f5d4549..acfebc1 100644
--- a/chrome/common/chrome_paths_linux.cc
+++ b/chrome/common/chrome_paths_linux.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -84,25 +84,16 @@ bool GetUserDocumentsDirectory(FilePath* result) {
return true;
}
-// We respect the user's preferred download location, unless it is
-// ~ or their desktop directory, in which case we default to ~/Downloads.
+bool GetUserDownloadsDirectorySafe(FilePath* result) {
+ FilePath home = file_util::GetHomeDir();
+ *result = home.Append(kDownloadsDir);
+ return true;
+}
+
bool GetUserDownloadsDirectory(FilePath* result) {
scoped_ptr<base::Environment> env(base::Environment::Create());
*result = base::nix::GetXDGUserDirectory(env.get(), "DOWNLOAD",
kDownloadsDir);
-
- FilePath home = file_util::GetHomeDir();
- if (*result == home) {
- *result = home.Append(kDownloadsDir);
- return true;
- }
-
- FilePath desktop;
- GetUserDesktop(&desktop);
- if (*result == desktop) {
- *result = home.Append(kDownloadsDir);
- }
-
return true;
}