Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9552)

Unified Diff: chrome/common/chrome_paths_linux.cc

Issue 5123004: chrome_paths: refactor and sanitize cache directory handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 80 Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/chrome_paths_linux.cc
diff --git a/chrome/common/chrome_paths_linux.cc b/chrome/common/chrome_paths_linux.cc
index 42c6ae7e03e103cf1088f387a307fe202043a303..ae07bc11cb6576784ff08cd236044cb414ce37b1 100644
--- a/chrome/common/chrome_paths_linux.cc
+++ b/chrome/common/chrome_paths_linux.cc
@@ -6,6 +6,7 @@
#include "base/environment.h"
#include "base/file_util.h"
+#include "base/path_service.h"
#include "base/scoped_ptr.h"
#include "base/nix/xdg_util.h"
@@ -28,6 +29,32 @@ bool GetDefaultUserDataDirectory(FilePath* result) {
return true;
}
+bool GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) {
+ // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
+ // for a spec on where cache files go. Our rule is:
+ // - if the user-data-dir in the standard place,
+ // use same subdirectory of the cache directory.
+ // (this maps ~/.config/google-chrome to ~/.cache/google-chrome as well
+ // as the same thing for ~/.config/chromium)
+ // - otherwise, use the profile dir directly.
+
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+
+ FilePath cache_dir;
+ if (!PathService::Get(base::DIR_CACHE, &cache_dir))
+ return false;
+ FilePath config_dir(
+ base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config"));
+
+ if (config_dir.AppendRelativePath(profile_dir, &cache_dir)) {
+ *result = cache_dir;
+ return true;
+ }
+
+ *result = profile_dir;
+ return true;
+}
+
bool GetChromeFrameUserDataDirectory(FilePath* result) {
scoped_ptr<base::Environment> env(base::Environment::Create());
FilePath config_dir(

Powered by Google App Engine
This is Rietveld 408576698