diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-17 01:06:57 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-17 01:06:57 +0000 |
commit | a87c920b12f4a9443afd9e1e8eead7ef46aab2d3 (patch) | |
tree | 98dd81f11e5bd908f0ad6fecad2a6c3ef358f511 /chrome/common/chrome_paths_linux.cc | |
parent | 4266def2249351b884b0b9b91eca39c1516a1ba1 (diff) | |
download | chromium_src-a87c920b12f4a9443afd9e1e8eead7ef46aab2d3.zip chromium_src-a87c920b12f4a9443afd9e1e8eead7ef46aab2d3.tar.gz chromium_src-a87c920b12f4a9443afd9e1e8eead7ef46aab2d3.tar.bz2 |
Add PathService::Get(chrome::DIR_USER_PICTURES).
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10392094
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137596 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/chrome_paths_linux.cc')
-rw-r--r-- | chrome/common/chrome_paths_linux.cc | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/chrome/common/chrome_paths_linux.cc b/chrome/common/chrome_paths_linux.cc index b8987cf..669061f 100644 --- a/chrome/common/chrome_paths_linux.cc +++ b/chrome/common/chrome_paths_linux.cc @@ -7,13 +7,14 @@ #include "base/environment.h" #include "base/file_util.h" #include "base/memory/scoped_ptr.h" -#include "base/path_service.h" #include "base/nix/xdg_util.h" +#include "base/path_service.h" namespace { const char kDotConfigDir[] = ".config"; const char kDownloadsDir[] = "Downloads"; +const char kPicturesDir[] = "Pictures"; const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME"; } // namespace @@ -97,6 +98,25 @@ bool GetUserDownloadsDirectory(FilePath* result) { return true; } +// 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) { + scoped_ptr<base::Environment> env(base::Environment::Create()); + *result = base::nix::GetXDGUserDirectory(env.get(), "PICTURES", kPicturesDir); + + FilePath home = file_util::GetHomeDir(); + if (*result != home) { + FilePath desktop; + GetUserDesktop(&desktop); + if (*result != desktop) { + return true; + } + } + + *result = home.Append(kPicturesDir); + return true; +} + bool GetUserDesktop(FilePath* result) { scoped_ptr<base::Environment> env(base::Environment::Create()); *result = base::nix::GetXDGUserDirectory(env.get(), "DESKTOP", "Desktop"); |