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

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

Issue 3052034: base: Rename EnvVarGetter to Environment. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: review Created 10 years, 4 months 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
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/env_var.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/xdg_util.h" 10 #include "base/xdg_util.h"
11 11
12 namespace chrome { 12 namespace chrome {
13 13
14 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html 14 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
15 // 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
16 // systems is we use ~/.config/chromium/ for Chromium and 16 // systems is we use ~/.config/chromium/ for Chromium and
17 // ~/.config/google-chrome/ for official builds. 17 // ~/.config/google-chrome/ for official builds.
18 // (This also helps us sidestep issues with other apps grabbing ~/.chromium .) 18 // (This also helps us sidestep issues with other apps grabbing ~/.chromium .)
19 bool GetDefaultUserDataDirectory(FilePath* result) { 19 bool GetDefaultUserDataDirectory(FilePath* result) {
20 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); 20 scoped_ptr<base::Environment> env(base::Environment::Create());
21 FilePath config_dir( 21 FilePath config_dir(
22 base::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config")); 22 base::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 GetChromeFrameUserDataDirectory(FilePath* result) { 31 bool GetChromeFrameUserDataDirectory(FilePath* result) {
32 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); 32 scoped_ptr<base::Environment> env(base::Environment::Create());
33 FilePath config_dir( 33 FilePath config_dir(
34 base::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config")); 34 base::GetXDGDirectory(env.get(), "XDG_CONFIG_HOME", ".config"));
35 #if defined(GOOGLE_CHROME_BUILD) 35 #if defined(GOOGLE_CHROME_BUILD)
36 *result = config_dir.Append("google-chrome-frame"); 36 *result = config_dir.Append("google-chrome-frame");
37 #else 37 #else
38 *result = config_dir.Append("chrome-frame"); 38 *result = config_dir.Append("chrome-frame");
39 #endif 39 #endif
40 return true; 40 return true;
41 } 41 }
42 42
43 bool GetUserDocumentsDirectory(FilePath* result) { 43 bool GetUserDocumentsDirectory(FilePath* result) {
44 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); 44 scoped_ptr<base::Environment> env(base::Environment::Create());
45 *result = base::GetXDGUserDirectory(env.get(), "DOCUMENTS", "Documents"); 45 *result = base::GetXDGUserDirectory(env.get(), "DOCUMENTS", "Documents");
46 return true; 46 return true;
47 } 47 }
48 48
49 // We respect the user's preferred download location, unless it is 49 // We respect the user's preferred download location, unless it is
50 // ~ or their desktop directory, in which case we default to ~/Downloads. 50 // ~ or their desktop directory, in which case we default to ~/Downloads.
51 bool GetUserDownloadsDirectory(FilePath* result) { 51 bool GetUserDownloadsDirectory(FilePath* result) {
52 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); 52 scoped_ptr<base::Environment> env(base::Environment::Create());
53 *result = base::GetXDGUserDirectory(env.get(), "DOWNLOAD", "Downloads"); 53 *result = base::GetXDGUserDirectory(env.get(), "DOWNLOAD", "Downloads");
54 54
55 FilePath home = file_util::GetHomeDir(); 55 FilePath home = file_util::GetHomeDir();
56 if (*result == home) { 56 if (*result == home) {
57 *result = home.Append("Downloads"); 57 *result = home.Append("Downloads");
58 return true; 58 return true;
59 } 59 }
60 60
61 FilePath desktop; 61 FilePath desktop;
62 GetUserDesktop(&desktop); 62 GetUserDesktop(&desktop);
63 if (*result == desktop) { 63 if (*result == desktop) {
64 *result = home.Append("Downloads"); 64 *result = home.Append("Downloads");
65 } 65 }
66 66
67 return true; 67 return true;
68 } 68 }
69 69
70 bool GetUserDesktop(FilePath* result) { 70 bool GetUserDesktop(FilePath* result) {
71 scoped_ptr<base::EnvVarGetter> env(base::EnvVarGetter::Create()); 71 scoped_ptr<base::Environment> env(base::Environment::Create());
72 *result = base::GetXDGUserDirectory(env.get(), "DESKTOP", "Desktop"); 72 *result = base::GetXDGUserDirectory(env.get(), "DESKTOP", "Desktop");
73 return true; 73 return true;
74 } 74 }
75 75
76 } // namespace chrome 76 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698