OLD | NEW |
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" |
(...skipping 21 matching lines...) Expand all Loading... |
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->GetEnv("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->HasEnv("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) { |
46 return DESKTOP_ENVIRONMENT_XFCE; | 46 return DESKTOP_ENVIRONMENT_XFCE; |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 // Fall back on some older environment variables. | 50 // Fall back on some older environment variables. |
51 // Useful particularly in the DESKTOP_SESSION=default case. | 51 // Useful particularly in the DESKTOP_SESSION=default case. |
52 if (env->HasEnv("GNOME_DESKTOP_SESSION_ID")) { | 52 if (env->HasVar("GNOME_DESKTOP_SESSION_ID")) { |
53 return DESKTOP_ENVIRONMENT_GNOME; | 53 return DESKTOP_ENVIRONMENT_GNOME; |
54 } else if (env->HasEnv("KDE_FULL_SESSION")) { | 54 } else if (env->HasVar("KDE_FULL_SESSION")) { |
55 if (env->HasEnv("KDE_SESSION_VERSION")) | 55 if (env->HasVar("KDE_SESSION_VERSION")) |
56 return DESKTOP_ENVIRONMENT_KDE4; | 56 return DESKTOP_ENVIRONMENT_KDE4; |
57 return DESKTOP_ENVIRONMENT_KDE3; | 57 return DESKTOP_ENVIRONMENT_KDE3; |
58 } | 58 } |
59 | 59 |
60 return DESKTOP_ENVIRONMENT_OTHER; | 60 return DESKTOP_ENVIRONMENT_OTHER; |
61 } | 61 } |
62 | 62 |
63 const char* GetDesktopEnvironmentName(DesktopEnvironment env) { | 63 const char* GetDesktopEnvironmentName(DesktopEnvironment env) { |
64 switch (env) { | 64 switch (env) { |
65 case DESKTOP_ENVIRONMENT_OTHER: | 65 case DESKTOP_ENVIRONMENT_OTHER: |
66 return NULL; | 66 return NULL; |
67 case DESKTOP_ENVIRONMENT_GNOME: | 67 case DESKTOP_ENVIRONMENT_GNOME: |
68 return "GNOME"; | 68 return "GNOME"; |
69 case DESKTOP_ENVIRONMENT_KDE3: | 69 case DESKTOP_ENVIRONMENT_KDE3: |
70 return "KDE3"; | 70 return "KDE3"; |
71 case DESKTOP_ENVIRONMENT_KDE4: | 71 case DESKTOP_ENVIRONMENT_KDE4: |
72 return "KDE4"; | 72 return "KDE4"; |
73 case DESKTOP_ENVIRONMENT_XFCE: | 73 case DESKTOP_ENVIRONMENT_XFCE: |
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 |
OLD | NEW |