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

Side by Side Diff: chrome/common/chrome_paths_linux.cc

Issue 5344003: Revert 67191 - chrome_paths: refactor and sanitize cache directory handling... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « chrome/common/chrome_paths_internal.h ('k') | chrome/common/chrome_paths_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/path_service.h"
10 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
11 #include "base/nix/xdg_util.h" 10 #include "base/nix/xdg_util.h"
12 11
13 namespace chrome { 12 namespace chrome {
14 13
15 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html 14 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
16 // for a spec on where config files go. The net effect for most 15 // for a spec on where config files go. The net effect for most
17 // systems is we use ~/.config/chromium/ for Chromium and 16 // systems is we use ~/.config/chromium/ for Chromium and
18 // ~/.config/google-chrome/ for official builds. 17 // ~/.config/google-chrome/ for official builds.
19 // (This also helps us sidestep issues with other apps grabbing ~/.chromium .) 18 // (This also helps us sidestep issues with other apps grabbing ~/.chromium .)
20 bool GetDefaultUserDataDirectory(FilePath* result) { 19 bool GetDefaultUserDataDirectory(FilePath* result) {
21 scoped_ptr<base::Environment> env(base::Environment::Create()); 20 scoped_ptr<base::Environment> env(base::Environment::Create());
22 FilePath config_dir( 21 FilePath config_dir(
23 base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config")); 22 base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config"));
24 #if defined(GOOGLE_CHROME_BUILD) 23 #if defined(GOOGLE_CHROME_BUILD)
25 *result = config_dir.Append("google-chrome"); 24 *result = config_dir.Append("google-chrome");
26 #else 25 #else
27 *result = config_dir.Append("chromium"); 26 *result = config_dir.Append("chromium");
28 #endif 27 #endif
29 return true; 28 return true;
30 } 29 }
31 30
32 void GetUserCacheDirectory(const FilePath& profile_dir, FilePath* result) {
33 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
34 // for a spec on where cache files go. Our rule is:
35 // - if the user-data-dir in the standard place,
36 // use same subdirectory of the cache directory.
37 // (this maps ~/.config/google-chrome to ~/.cache/google-chrome as well
38 // as the same thing for ~/.config/chromium)
39 // - otherwise, use the profile dir directly.
40
41 // Default value in cases where any of the following fails.
42 *result = profile_dir;
43
44 scoped_ptr<base::Environment> env(base::Environment::Create());
45
46 FilePath cache_dir;
47 if (!PathService::Get(base::DIR_CACHE, &cache_dir))
48 return;
49 FilePath config_dir(
50 base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config"));
51
52 if (!config_dir.AppendRelativePath(profile_dir, &cache_dir))
53 return;
54
55 *result = cache_dir;
56 }
57
58 bool GetChromeFrameUserDataDirectory(FilePath* result) { 31 bool GetChromeFrameUserDataDirectory(FilePath* result) {
59 scoped_ptr<base::Environment> env(base::Environment::Create()); 32 scoped_ptr<base::Environment> env(base::Environment::Create());
60 FilePath config_dir( 33 FilePath config_dir(
61 base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config")); 34 base::nix::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config"));
62 #if defined(GOOGLE_CHROME_BUILD) 35 #if defined(GOOGLE_CHROME_BUILD)
63 *result = config_dir.Append("google-chrome-frame"); 36 *result = config_dir.Append("google-chrome-frame");
64 #else 37 #else
65 *result = config_dir.Append("chrome-frame"); 38 *result = config_dir.Append("chrome-frame");
66 #endif 39 #endif
67 return true; 40 return true;
(...skipping 26 matching lines...) Expand all
94 return true; 67 return true;
95 } 68 }
96 69
97 bool GetUserDesktop(FilePath* result) { 70 bool GetUserDesktop(FilePath* result) {
98 scoped_ptr<base::Environment> env(base::Environment::Create()); 71 scoped_ptr<base::Environment> env(base::Environment::Create());
99 *result = base::nix::GetXDGUserDirectory(env.get(), "DESKTOP", "Desktop"); 72 *result = base::nix::GetXDGUserDirectory(env.get(), "DESKTOP", "Desktop");
100 return true; 73 return true;
101 } 74 }
102 75
103 } // namespace chrome 76 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/common/chrome_paths_internal.h ('k') | chrome/common/chrome_paths_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698