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

Side by Side Diff: base/xdg_util.cc

Issue 3029062: base: rename Environment::GetEnv to Environment::GetVar. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: 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
« no previous file with comments | « base/environment_unittest.cc ('k') | base/xdg_util_unittest.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) 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 "base/xdg_util.h" 5 #include "base/xdg_util.h"
6 6
7 #include "base/environment.h" 7 #include "base/environment.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.h" 10 #include "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.h"
11 11
12 namespace base { 12 namespace base {
13 13
14 FilePath GetXDGDirectory(Environment* env, const char* env_name, 14 FilePath GetXDGDirectory(Environment* env, const char* env_name,
15 const char* fallback_dir) { 15 const char* fallback_dir) {
16 std::string env_value; 16 std::string env_value;
17 if (env->GetEnv(env_name, &env_value) && !env_value.empty()) 17 if (env->GetVar(env_name, &env_value) && !env_value.empty())
18 return FilePath(env_value); 18 return FilePath(env_value);
19 return file_util::GetHomeDir().Append(fallback_dir); 19 return file_util::GetHomeDir().Append(fallback_dir);
20 } 20 }
21 21
22 FilePath GetXDGUserDirectory(Environment* env, const char* dir_name, 22 FilePath GetXDGUserDirectory(Environment* env, const char* dir_name,
23 const char* fallback_dir) { 23 const char* fallback_dir) {
24 char* xdg_dir = xdg_user_dir_lookup(dir_name); 24 char* xdg_dir = xdg_user_dir_lookup(dir_name);
25 if (xdg_dir) { 25 if (xdg_dir) {
26 FilePath rv(xdg_dir); 26 FilePath rv(xdg_dir);
27 free(xdg_dir); 27 free(xdg_dir);
28 return rv; 28 return rv;
29 } 29 }
30 return file_util::GetHomeDir().Append(fallback_dir); 30 return file_util::GetHomeDir().Append(fallback_dir);
31 } 31 }
32 32
33 DesktopEnvironment GetDesktopEnvironment(Environment* env) { 33 DesktopEnvironment GetDesktopEnvironment(Environment* env) {
34 std::string desktop_session; 34 std::string desktop_session;
35 if (env->GetEnv("DESKTOP_SESSION", &desktop_session)) { 35 if (env->GetVar("DESKTOP_SESSION", &desktop_session)) {
36 if (desktop_session == "gnome") { 36 if (desktop_session == "gnome") {
37 return DESKTOP_ENVIRONMENT_GNOME; 37 return DESKTOP_ENVIRONMENT_GNOME;
38 } else if (desktop_session == "kde4") { 38 } else if (desktop_session == "kde4") {
39 return DESKTOP_ENVIRONMENT_KDE4; 39 return DESKTOP_ENVIRONMENT_KDE4;
40 } else if (desktop_session == "kde") { 40 } else if (desktop_session == "kde") {
41 // This may mean KDE4 on newer systems, so we have to check. 41 // This may mean KDE4 on newer systems, so we have to check.
42 if (env->HasVar("KDE_SESSION_VERSION")) 42 if (env->HasVar("KDE_SESSION_VERSION"))
43 return DESKTOP_ENVIRONMENT_KDE4; 43 return DESKTOP_ENVIRONMENT_KDE4;
44 return DESKTOP_ENVIRONMENT_KDE3; 44 return DESKTOP_ENVIRONMENT_KDE3;
45 } else if (desktop_session.find("xfce") != std::string::npos) { 45 } else if (desktop_session.find("xfce") != std::string::npos) {
(...skipping 28 matching lines...) Expand all
74 return "XFCE"; 74 return "XFCE";
75 } 75 }
76 return NULL; 76 return NULL;
77 } 77 }
78 78
79 const char* GetDesktopEnvironmentName(Environment* env) { 79 const char* GetDesktopEnvironmentName(Environment* env) {
80 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); 80 return GetDesktopEnvironmentName(GetDesktopEnvironment(env));
81 } 81 }
82 82
83 } // namespace base 83 } // namespace base
OLDNEW
« no previous file with comments | « base/environment_unittest.cc ('k') | base/xdg_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698