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

Side by Side Diff: base/nix/xdg_util.cc

Issue 200473002: Move all callers of GetHomeDir() to PathService::Get(base::DIR_HOME). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « base/file_util_posix.cc ('k') | chrome/app/chrome_main_delegate.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/nix/xdg_util.h" 5 #include "base/nix/xdg_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_paths.h"
9 #include "base/environment.h" 10 #include "base/environment.h"
10 #include "base/file_util.h" 11 #include "base/file_util.h"
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/path_service.h"
12 #include "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.h" 14 #include "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.h"
13 15
14 namespace { 16 namespace {
15 17
16 // The KDE session version environment variable used in KDE 4. 18 // The KDE session version environment variable used in KDE 4.
17 const char kKDE4SessionEnvVar[] = "KDE_SESSION_VERSION"; 19 const char kKDE4SessionEnvVar[] = "KDE_SESSION_VERSION";
18 20
19 } // namespace 21 } // namespace
20 22
21 namespace base { 23 namespace base {
22 namespace nix { 24 namespace nix {
23 25
24 const char kDotConfigDir[] = ".config"; 26 const char kDotConfigDir[] = ".config";
25 const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME"; 27 const char kXdgConfigHomeEnvVar[] = "XDG_CONFIG_HOME";
26 28
27 FilePath GetXDGDirectory(Environment* env, const char* env_name, 29 FilePath GetXDGDirectory(Environment* env, const char* env_name,
28 const char* fallback_dir) { 30 const char* fallback_dir) {
29 FilePath path; 31 FilePath path;
30 std::string env_value; 32 std::string env_value;
31 if (env->GetVar(env_name, &env_value) && !env_value.empty()) 33 if (env->GetVar(env_name, &env_value) && !env_value.empty()) {
32 path = FilePath(env_value); 34 path = FilePath(env_value);
33 else 35 } else {
34 path = GetHomeDir().Append(fallback_dir); 36 PathService::Get(base::DIR_HOME, &path);
37 path = path.Append(fallback_dir);
38 }
35 return path.StripTrailingSeparators(); 39 return path.StripTrailingSeparators();
36 } 40 }
37 41
38 FilePath GetXDGUserDirectory(const char* dir_name, const char* fallback_dir) { 42 FilePath GetXDGUserDirectory(const char* dir_name, const char* fallback_dir) {
39 FilePath path; 43 FilePath path;
40 char* xdg_dir = xdg_user_dir_lookup(dir_name); 44 char* xdg_dir = xdg_user_dir_lookup(dir_name);
41 if (xdg_dir) { 45 if (xdg_dir) {
42 path = FilePath(xdg_dir); 46 path = FilePath(xdg_dir);
43 free(xdg_dir); 47 free(xdg_dir);
44 } else { 48 } else {
45 path = GetHomeDir().Append(fallback_dir); 49 PathService::Get(base::DIR_HOME, &path);
50 path = path.Append(fallback_dir);
46 } 51 }
47 return path.StripTrailingSeparators(); 52 return path.StripTrailingSeparators();
48 } 53 }
49 54
50 DesktopEnvironment GetDesktopEnvironment(Environment* env) { 55 DesktopEnvironment GetDesktopEnvironment(Environment* env) {
51 // XDG_CURRENT_DESKTOP is the newest standard circa 2012. 56 // XDG_CURRENT_DESKTOP is the newest standard circa 2012.
52 std::string xdg_current_desktop; 57 std::string xdg_current_desktop;
53 if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) { 58 if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) {
54 // Not all desktop environments set this env var as of this writing. 59 // Not all desktop environments set this env var as of this writing.
55 if (xdg_current_desktop == "Unity") 60 if (xdg_current_desktop == "Unity")
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 111 }
107 return NULL; 112 return NULL;
108 } 113 }
109 114
110 const char* GetDesktopEnvironmentName(Environment* env) { 115 const char* GetDesktopEnvironmentName(Environment* env) {
111 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); 116 return GetDesktopEnvironmentName(GetDesktopEnvironment(env));
112 } 117 }
113 118
114 } // namespace nix 119 } // namespace nix
115 } // namespace base 120 } // namespace base
OLDNEW
« no previous file with comments | « base/file_util_posix.cc ('k') | chrome/app/chrome_main_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698