OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/linux_util.h" | 5 #include "base/linux_util.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 checked_distro = true; | 92 checked_distro = true; |
93 } | 93 } |
94 return linux_distro; | 94 return linux_distro; |
95 } | 95 } |
96 | 96 |
97 // static | 97 // static |
98 EnvironmentVariableGetter* EnvironmentVariableGetter::Create() { | 98 EnvironmentVariableGetter* EnvironmentVariableGetter::Create() { |
99 return new EnvironmentVariableGetterImpl(); | 99 return new EnvironmentVariableGetterImpl(); |
100 } | 100 } |
101 | 101 |
102 bool UseGnomeForSettings(EnvironmentVariableGetter* env_var_getter) { | 102 DesktopEnvironment GetDesktopEnvironment(EnvironmentVariableGetter* env) { |
103 // GNOME_DESKTOP_SESSION_ID being defined is a good indication that | 103 std::string desktop_session; |
104 // we are probably running under GNOME. | 104 if (env->Getenv("DESKTOP_SESSION", &desktop_session)) { |
105 // Note: KDE_FULL_SESSION is a corresponding env var to recognize KDE. | 105 if (desktop_session == "gnome") |
106 std::string dummy, desktop_session; | 106 return DESKTOP_ENVIRONMENT_GNOME; |
107 return env_var_getter->Getenv("GNOME_DESKTOP_SESSION_ID", &dummy) | 107 else if (desktop_session.substr(3) == "kde") // kde3 or kde4 |
108 || (env_var_getter->Getenv("DESKTOP_SESSION", &desktop_session) | 108 return DESKTOP_ENVIRONMENT_KDE; |
109 && desktop_session == "gnome"); | 109 } |
| 110 |
| 111 // Fall back on some older environment variables. |
| 112 // Useful particularly in the DESKTOP_SESSION=default case. |
| 113 std::string dummy; |
| 114 if (env->Getenv("GNOME_DESKTOP_SESSION_ID", &dummy)) { |
| 115 return DESKTOP_ENVIRONMENT_GNOME; |
| 116 } else if (env->Getenv("KDE_FULL_SESSION", &dummy)) { |
| 117 return DESKTOP_ENVIRONMENT_KDE; |
| 118 } |
| 119 |
| 120 return DESKTOP_ENVIRONMENT_OTHER; |
110 } | 121 } |
111 | 122 |
112 } // namespace base | 123 } // namespace base |
OLD | NEW |