diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-17 18:52:28 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-17 18:52:28 +0000 |
commit | 16404c5b6387cf38199eef7a4a43944bf4c41d0c (patch) | |
tree | 62d0578c9462b5c2dbb0de6a040b148e90a16e93 /chrome/common/chrome_paths_linux.cc | |
parent | 557205cef10e483f2953299d241e21e0a96c007e (diff) | |
download | chromium_src-16404c5b6387cf38199eef7a4a43944bf4c41d0c.zip chromium_src-16404c5b6387cf38199eef7a4a43944bf4c41d0c.tar.gz chromium_src-16404c5b6387cf38199eef7a4a43944bf4c41d0c.tar.bz2 |
Cleanup: Make chrome paths code more consistent and use more constants when possible.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6528028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75289 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/chrome_paths_linux.cc')
-rw-r--r-- | chrome/common/chrome_paths_linux.cc | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/chrome/common/chrome_paths_linux.cc b/chrome/common/chrome_paths_linux.cc index a7fdb07..ff525db 100644 --- a/chrome/common/chrome_paths_linux.cc +++ b/chrome/common/chrome_paths_linux.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -10,6 +10,14 @@ #include "base/scoped_ptr.h" #include "base/nix/xdg_util.h" +namespace { + +const char kDotConfigDir[] = ".config"; +const char kDownloadsDir[] = "Downloads"; +const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME"; + +} // namespace + namespace chrome { // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html @@ -19,8 +27,9 @@ namespace chrome { // (This also helps us sidestep issues with other apps grabbing ~/.chromium .) bool GetDefaultUserDataDirectory(FilePath* result) { scoped_ptr<base::Environment> env(base::Environment::Create()); - FilePath config_dir( - base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config")); + FilePath config_dir(base::nix::GetXDGDirectory(env.get(), + kXdgConfigHomeEnvVar, + kDotConfigDir)); #if defined(GOOGLE_CHROME_BUILD) *result = config_dir.Append("google-chrome"); #else @@ -46,8 +55,9 @@ void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) { FilePath cache_dir; if (!PathService::Get(base::DIR_CACHE, &cache_dir)) return; - FilePath config_dir( - base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config")); + FilePath config_dir(base::nix::GetXDGDirectory(env.get(), + kXdgConfigHomeEnvVar, + kDotConfigDir)); if (!config_dir.AppendRelativePath(profile_dir, &cache_dir)) return; @@ -57,8 +67,9 @@ void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) { bool GetChromeFrameUserDataDirectory(FilePath* result) { scoped_ptr<base::Environment> env(base::Environment::Create()); - FilePath config_dir( - base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config")); + FilePath config_dir(base::nix::GetXDGDirectory(env.get(), + kXdgConfigHomeEnvVar, + kDotConfigDir)); #if defined(GOOGLE_CHROME_BUILD) *result = config_dir.Append("google-chrome-frame"); #else @@ -77,18 +88,19 @@ bool GetUserDocumentsDirectory(FilePath* result) { // ~ or their desktop directory, in which case we default to ~/Downloads. bool GetUserDownloadsDirectory(FilePath* result) { scoped_ptr<base::Environment> env(base::Environment::Create()); - *result = base::nix::GetXDGUserDirectory(env.get(), "DOWNLOAD", "Downloads"); + *result = base::nix::GetXDGUserDirectory(env.get(), "DOWNLOAD", + kDownloadsDir); FilePath home = file_util::GetHomeDir(); if (*result == home) { - *result = home.Append("Downloads"); + *result = home.Append(kDownloadsDir); return true; } FilePath desktop; GetUserDesktop(&desktop); if (*result == desktop) { - *result = home.Append("Downloads"); + *result = home.Append(kDownloadsDir); } return true; |