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

Side by Side 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: works 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/chrome_paths_internal.h" 5 #include "chrome/common/chrome_paths_internal.h"
6 6
7 #include "base/environment.h" 7 #include "base/environment.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/nix/xdg_util.h" 10 #include "base/nix/xdg_util.h"
(...skipping 10 matching lines...) Expand all
21 FilePath config_dir( 21 FilePath config_dir(
22 base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config")); 22 base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config"));
23 #if defined(GOOGLE_CHROME_BUILD) 23 #if defined(GOOGLE_CHROME_BUILD)
24 *result = config_dir.Append("google-chrome"); 24 *result = config_dir.Append("google-chrome");
25 #else 25 #else
26 *result = config_dir.Append("chromium"); 26 *result = config_dir.Append("chromium");
27 #endif 27 #endif
28 return true; 28 return true;
29 } 29 }
30 30
31 bool GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) {
32 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
33 // for a spec on where cache files go. Our rule is:
34 // - if the user-data-dir in the standard place,
35 // use same subdirectory of the cache directory.
36 // (this maps ~/.config/google-chrome to ~/.cache/google-chrome as well
37 // as the same thing for ~/.config/chromium)
38 // - otherwise, use the user-data-dir directly.
39
40 scoped_ptr<base::Environment> env(base::Environment::Create());
41 FilePath cache_dir(
42 base::nix::GetXDGDirectory(env.get(), "XDG_CACHE_HOME", ".cache"));
43 FilePath config_dir(
44 base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config"));
45
46 FilePath system_relative_dir = cache_dir;
Mark Mentovai 2010/11/18 16:55:57 By the way, “why the copy?” applies here too.
47 if (config_dir.AppendRelativePath(profile_dir, &system_relative_dir)) {
48 *result = system_relative_dir;
49 return true;
50 }
51
52 *result = profile_dir;
53 return true;
54 }
55
31 bool GetChromeFrameUserDataDirectory(FilePath* result) { 56 bool GetChromeFrameUserDataDirectory(FilePath* result) {
32 scoped_ptr<base::Environment> env(base::Environment::Create()); 57 scoped_ptr<base::Environment> env(base::Environment::Create());
33 FilePath config_dir( 58 FilePath config_dir(
34 base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config")); 59 base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config"));
35 #if defined(GOOGLE_CHROME_BUILD) 60 #if defined(GOOGLE_CHROME_BUILD)
36 *result = config_dir.Append("google-chrome-frame"); 61 *result = config_dir.Append("google-chrome-frame");
37 #else 62 #else
38 *result = config_dir.Append("chrome-frame"); 63 *result = config_dir.Append("chrome-frame");
39 #endif 64 #endif
40 return true; 65 return true;
(...skipping 26 matching lines...) Expand all
67 return true; 92 return true;
68 } 93 }
69 94
70 bool GetUserDesktop(FilePath* result) { 95 bool GetUserDesktop(FilePath* result) {
71 scoped_ptr<base::Environment> env(base::Environment::Create()); 96 scoped_ptr<base::Environment> env(base::Environment::Create());
72 *result = base::nix::GetXDGUserDirectory(env.get(), "DESKTOP", "Desktop"); 97 *result = base::nix::GetXDGUserDirectory(env.get(), "DESKTOP", "Desktop");
73 return true; 98 return true;
74 } 99 }
75 100
76 } // namespace chrome 101 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698