summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/chrome_paths.cc15
-rw-r--r--chrome/common/chrome_paths_internal.h6
-rw-r--r--chrome/common/chrome_paths_linux.cc20
-rw-r--r--chrome/common/chrome_paths_mac.cc6
-rw-r--r--chrome/common/chrome_paths_win.cc14
5 files changed, 46 insertions, 15 deletions
diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc
index 2c80ff3..f9c12be 100644
--- a/chrome/common/chrome_paths.cc
+++ b/chrome/common/chrome_paths.cc
@@ -74,19 +74,8 @@ bool PathProvider(int key, FilePath* result) {
create_dir = true;
break;
case chrome::DIR_DEFAULT_DOWNLOADS:
- // On Vista, we can get the download path using a Win API
- // (http://msdn.microsoft.com/en-us/library/bb762584(VS.85).aspx),
- // but it can be set to Desktop, which is dangerous. Instead,
- // we just use 'Downloads' under DIR_USER_DOCUMENTS. Localizing
- // 'downloads' is not a good idea because Chrome's UI language
- // can be changed.
- if (!PathService::Get(chrome::DIR_USER_DOCUMENTS, &cur))
- return false;
- cur = cur.Append(FILE_PATH_LITERAL("Downloads"));
- // TODO(port): this may not be what we want on other platforms. But it
- // is not clear what we would prefer: $XDG_DOWNLOAD_DIR appears to point
- // to ~/Downloads for many users, which is something we want to avoid.
- // We probably need to add a GetUserDownloadsDirectory().
+ if (!GetUserDownloadsDirectory(&cur))
+ return false;
break;
case chrome::DIR_CRASH_DUMPS:
// The crash reports are always stored relative to the default user data
diff --git a/chrome/common/chrome_paths_internal.h b/chrome/common/chrome_paths_internal.h
index a9912dd..ce7a039 100644
--- a/chrome/common/chrome_paths_internal.h
+++ b/chrome/common/chrome_paths_internal.h
@@ -13,10 +13,12 @@ namespace chrome {
// DIR_USER_DATA has been overridden by a command-line option.
bool GetDefaultUserDataDirectory(FilePath* result);
-// Get the path to the user's documents directory. We use this to construct
-// the default download directory.
+// Get the path to the user's documents directory.
bool GetUserDocumentsDirectory(FilePath* result);
+// Get the path to the user's downloads directory.
+bool GetUserDownloadsDirectory(FilePath* result);
+
// The path to the user's desktop.
bool GetUserDesktop(FilePath* result);
diff --git a/chrome/common/chrome_paths_linux.cc b/chrome/common/chrome_paths_linux.cc
index 93556f1..8ffd9e0 100644
--- a/chrome/common/chrome_paths_linux.cc
+++ b/chrome/common/chrome_paths_linux.cc
@@ -78,6 +78,26 @@ 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 GetUserDownloadsDirectory(FilePath* result) {
+ *result = GetXDGUserDirectory("DOWNLOAD", "Downloads");
+
+ FilePath home = GetHomeDir();
+ if (*result == home) {
+ *result = home.Append("Downloads");
+ return true;
+ }
+
+ FilePath desktop;
+ GetUserDesktop(&desktop);
+ if (*result == desktop) {
+ *result = home.Append("Downloads");
+ }
+
+ return true;
+}
+
bool GetUserDesktop(FilePath* result) {
*result = GetXDGUserDirectory("DESKTOP", "Desktop");
return true;
diff --git a/chrome/common/chrome_paths_mac.cc b/chrome/common/chrome_paths_mac.cc
index 788ffc1..ebc9876 100644
--- a/chrome/common/chrome_paths_mac.cc
+++ b/chrome/common/chrome_paths_mac.cc
@@ -23,6 +23,12 @@ bool GetUserDocumentsDirectory(FilePath* result) {
return false;
}
+bool GetUserDownloadsDirectory(FilePath* result) {
+ // TODO(port)
+ NOTIMPLEMENTED();
+ return false;
+}
+
bool GetUserDesktop(FilePath* result) {
// TODO(port)
NOTIMPLEMENTED();
diff --git a/chrome/common/chrome_paths_win.cc b/chrome/common/chrome_paths_win.cc
index aab3182..52e8712 100644
--- a/chrome/common/chrome_paths_win.cc
+++ b/chrome/common/chrome_paths_win.cc
@@ -34,6 +34,20 @@ bool GetUserDocumentsDirectory(FilePath* result) {
return true;
}
+// On Vista, we can get the download path using a Win API
+// (http://msdn.microsoft.com/en-us/library/bb762584(VS.85).aspx),
+// but it can be set to Desktop, which is dangerous. Instead,
+// we just use 'Downloads' under DIR_USER_DOCUMENTS. Localizing
+// 'downloads' is not a good idea because Chrome's UI language
+// can be changed.
+bool GetUserDownloadsDirectory(FilePath* result) {
+ if (!GetUserDocumentsDirectory(result))
+ return false;
+
+ *result = result->Append(L"Downloads");
+ return true;
+}
+
bool GetUserDesktop(FilePath* result) {
// We need to go compute the value. It would be nice to support paths
// with names longer than MAX_PATH, but the system functions don't seem