summaryrefslogtreecommitdiffstats
path: root/chrome/common/chrome_paths_linux.cc
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-14 04:18:14 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-14 04:18:14 +0000
commitfa9ac63a311ff3754dae28f8facc6ffd5db37f5d (patch)
treea7cf6404ddd4700619ce569a605371a0072cb243 /chrome/common/chrome_paths_linux.cc
parentad377ae01314e1b74db3e7810c151ddfc6daaa7c (diff)
downloadchromium_src-fa9ac63a311ff3754dae28f8facc6ffd5db37f5d.zip
chromium_src-fa9ac63a311ff3754dae28f8facc6ffd5db37f5d.tar.gz
chromium_src-fa9ac63a311ff3754dae28f8facc6ffd5db37f5d.tar.bz2
Add Add PathService::Get(chrome::DIR_USER_MUSIC) and PathService::Get(chrome::DIR_USER_VIDEOS).
Review URL: https://chromiumcodereview.appspot.com/10918228 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/chrome_paths_linux.cc')
-rw-r--r--chrome/common/chrome_paths_linux.cc67
1 files changed, 44 insertions, 23 deletions
diff --git a/chrome/common/chrome_paths_linux.cc b/chrome/common/chrome_paths_linux.cc
index adfcca6..321032f 100644
--- a/chrome/common/chrome_paths_linux.cc
+++ b/chrome/common/chrome_paths_linux.cc
@@ -10,19 +10,45 @@
#include "base/nix/xdg_util.h"
#include "base/path_service.h"
+namespace chrome {
+
+using base::nix::GetXDGDirectory;
+using base::nix::GetXDGUserDirectory;
+using base::nix::kDotConfigDir;
+using base::nix::kXdgConfigHomeEnvVar;
+
namespace {
const char kDownloadsDir[] = "Downloads";
+const char kMusicDir[] = "Music";
const char kPicturesDir[] = "Pictures";
+const char kVideosDir[] = "Videos";
-} // namespace
+// Generic function for GetUser{Music,Pictures,Video}Directory.
+bool GetUserMediaDirectory(const std::string& xdg_name,
+ const std::string& fallback_name,
+ FilePath* result) {
+#if defined(OS_CHROMEOS)
+ // No local media directories on CrOS.
+ return false;
+#else
+ *result = GetXDGUserDirectory(xdg_name.c_str(), fallback_name.c_str());
-namespace chrome {
+ FilePath home = file_util::GetHomeDir();
+ if (*result != home) {
+ FilePath desktop;
+ GetUserDesktop(&desktop);
+ if (*result != desktop) {
+ return true;
+ }
+ }
-using base::nix::GetXDGDirectory;
-using base::nix::GetXDGUserDirectory;
-using base::nix::kDotConfigDir;
-using base::nix::kXdgConfigHomeEnvVar;
+ *result = home.Append(fallback_name);
+ return true;
+#endif
+}
+
+} // namespace
// See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
// for a spec on where config files go. The net effect for most
@@ -99,26 +125,21 @@ bool GetUserDownloadsDirectory(FilePath* result) {
}
// We respect the user's preferred pictures location, unless it is
+// ~ or their desktop directory, in which case we default to ~/Music.
+bool GetUserMusicDirectory(FilePath* result) {
+ return GetUserMediaDirectory("MUSIC", kMusicDir, result);
+}
+
+// We respect the user's preferred pictures location, unless it is
// ~ or their desktop directory, in which case we default to ~/Pictures.
bool GetUserPicturesDirectory(FilePath* result) {
-#if defined(OS_CHROMEOS)
- // No local Pictures directory on CrOS.
- return false;
-#else
- *result = GetXDGUserDirectory("PICTURES", kPicturesDir);
-
- FilePath home = file_util::GetHomeDir();
- if (*result != home) {
- FilePath desktop;
- GetUserDesktop(&desktop);
- if (*result != desktop) {
- return true;
- }
- }
+ return GetUserMediaDirectory("PICTURES", kPicturesDir, result);
+}
- *result = home.Append(kPicturesDir);
- return true;
-#endif
+// We respect the user's preferred pictures location, unless it is
+// ~ or their desktop directory, in which case we default to ~/Videos.
+bool GetUserVideosDirectory(FilePath* result) {
+ return GetUserMediaDirectory("VIDEOS", kVideosDir, result);
}
bool GetUserDesktop(FilePath* result) {