| 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 DesktopEnvironment GetDesktopEnvironment(EnvironmentVariableGetter* env) { | 102 DesktopEnvironment GetDesktopEnvironment(EnvironmentVariableGetter* env) { |
| 103 std::string desktop_session; | 103 std::string desktop_session; |
| 104 if (env->Getenv("DESKTOP_SESSION", &desktop_session)) { | 104 if (env->Getenv("DESKTOP_SESSION", &desktop_session)) { |
| 105 if (desktop_session == "gnome") | 105 if (desktop_session == "gnome") |
| 106 return DESKTOP_ENVIRONMENT_GNOME; | 106 return DESKTOP_ENVIRONMENT_GNOME; |
| 107 else if (desktop_session.substr(3) == "kde") // kde3 or kde4 | 107 else if (desktop_session == "kde4") |
| 108 return DESKTOP_ENVIRONMENT_KDE; | 108 return DESKTOP_ENVIRONMENT_KDE4; |
| 109 else if (desktop_session == "kde") |
| 110 return DESKTOP_ENVIRONMENT_KDE3; |
| 109 } | 111 } |
| 110 | 112 |
| 111 // Fall back on some older environment variables. | 113 // Fall back on some older environment variables. |
| 112 // Useful particularly in the DESKTOP_SESSION=default case. | 114 // Useful particularly in the DESKTOP_SESSION=default case. |
| 113 std::string dummy; | 115 std::string dummy; |
| 114 if (env->Getenv("GNOME_DESKTOP_SESSION_ID", &dummy)) { | 116 if (env->Getenv("GNOME_DESKTOP_SESSION_ID", &dummy)) { |
| 115 return DESKTOP_ENVIRONMENT_GNOME; | 117 return DESKTOP_ENVIRONMENT_GNOME; |
| 116 } else if (env->Getenv("KDE_FULL_SESSION", &dummy)) { | 118 } else if (env->Getenv("KDE_FULL_SESSION", &dummy)) { |
| 117 return DESKTOP_ENVIRONMENT_KDE; | 119 if (env->Getenv("KDE_SESSION_VERSION", &dummy)) |
| 120 return DESKTOP_ENVIRONMENT_KDE4; |
| 121 return DESKTOP_ENVIRONMENT_KDE3; |
| 118 } | 122 } |
| 119 | 123 |
| 120 return DESKTOP_ENVIRONMENT_OTHER; | 124 return DESKTOP_ENVIRONMENT_OTHER; |
| 121 } | 125 } |
| 122 | 126 |
| 127 const char* GetDesktopEnvironmentName(DesktopEnvironment env) { |
| 128 switch (env) { |
| 129 case DESKTOP_ENVIRONMENT_OTHER: |
| 130 return NULL; |
| 131 case DESKTOP_ENVIRONMENT_GNOME: |
| 132 return "GNOME"; |
| 133 case DESKTOP_ENVIRONMENT_KDE3: |
| 134 return "KDE3"; |
| 135 case DESKTOP_ENVIRONMENT_KDE4: |
| 136 return "KDE4"; |
| 137 } |
| 138 return NULL; |
| 139 } |
| 140 |
| 141 const char* GetDesktopEnvironmentName(EnvironmentVariableGetter* env) { |
| 142 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); |
| 143 } |
| 144 |
| 123 } // namespace base | 145 } // namespace base |
| OLD | NEW |