| 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 <dirent.h> | 7 #include <dirent.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <glib.h> | 9 #include <glib.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 return DESKTOP_ENVIRONMENT_GNOME; | 267 return DESKTOP_ENVIRONMENT_GNOME; |
| 268 else if (desktop_session == "kde4") | 268 else if (desktop_session == "kde4") |
| 269 return DESKTOP_ENVIRONMENT_KDE4; | 269 return DESKTOP_ENVIRONMENT_KDE4; |
| 270 else if (desktop_session == "kde") { | 270 else if (desktop_session == "kde") { |
| 271 // This may mean KDE4 on newer systems, so we have to check. | 271 // This may mean KDE4 on newer systems, so we have to check. |
| 272 std::string dummy; | 272 std::string dummy; |
| 273 if (env->Getenv("KDE_SESSION_VERSION", &dummy)) | 273 if (env->Getenv("KDE_SESSION_VERSION", &dummy)) |
| 274 return DESKTOP_ENVIRONMENT_KDE4; | 274 return DESKTOP_ENVIRONMENT_KDE4; |
| 275 return DESKTOP_ENVIRONMENT_KDE3; | 275 return DESKTOP_ENVIRONMENT_KDE3; |
| 276 } | 276 } |
| 277 else if (desktop_session == "xfce4") |
| 278 return DESKTOP_ENVIRONMENT_XFCE; |
| 277 } | 279 } |
| 278 | 280 |
| 279 // Fall back on some older environment variables. | 281 // Fall back on some older environment variables. |
| 280 // Useful particularly in the DESKTOP_SESSION=default case. | 282 // Useful particularly in the DESKTOP_SESSION=default case. |
| 281 std::string dummy; | 283 std::string dummy; |
| 282 if (env->Getenv("GNOME_DESKTOP_SESSION_ID", &dummy)) { | 284 if (env->Getenv("GNOME_DESKTOP_SESSION_ID", &dummy)) { |
| 283 return DESKTOP_ENVIRONMENT_GNOME; | 285 return DESKTOP_ENVIRONMENT_GNOME; |
| 284 } else if (env->Getenv("KDE_FULL_SESSION", &dummy)) { | 286 } else if (env->Getenv("KDE_FULL_SESSION", &dummy)) { |
| 285 if (env->Getenv("KDE_SESSION_VERSION", &dummy)) | 287 if (env->Getenv("KDE_SESSION_VERSION", &dummy)) |
| 286 return DESKTOP_ENVIRONMENT_KDE4; | 288 return DESKTOP_ENVIRONMENT_KDE4; |
| 287 return DESKTOP_ENVIRONMENT_KDE3; | 289 return DESKTOP_ENVIRONMENT_KDE3; |
| 288 } | 290 } |
| 289 | 291 |
| 290 return DESKTOP_ENVIRONMENT_OTHER; | 292 return DESKTOP_ENVIRONMENT_OTHER; |
| 291 } | 293 } |
| 292 | 294 |
| 293 const char* GetDesktopEnvironmentName(DesktopEnvironment env) { | 295 const char* GetDesktopEnvironmentName(DesktopEnvironment env) { |
| 294 switch (env) { | 296 switch (env) { |
| 295 case DESKTOP_ENVIRONMENT_OTHER: | 297 case DESKTOP_ENVIRONMENT_OTHER: |
| 296 return NULL; | 298 return NULL; |
| 297 case DESKTOP_ENVIRONMENT_GNOME: | 299 case DESKTOP_ENVIRONMENT_GNOME: |
| 298 return "GNOME"; | 300 return "GNOME"; |
| 299 case DESKTOP_ENVIRONMENT_KDE3: | 301 case DESKTOP_ENVIRONMENT_KDE3: |
| 300 return "KDE3"; | 302 return "KDE3"; |
| 301 case DESKTOP_ENVIRONMENT_KDE4: | 303 case DESKTOP_ENVIRONMENT_KDE4: |
| 302 return "KDE4"; | 304 return "KDE4"; |
| 305 case DESKTOP_ENVIRONMENT_XFCE: |
| 306 return "XFCE"; |
| 303 } | 307 } |
| 304 return NULL; | 308 return NULL; |
| 305 } | 309 } |
| 306 | 310 |
| 307 const char* GetDesktopEnvironmentName(EnvironmentVariableGetter* env) { | 311 const char* GetDesktopEnvironmentName(EnvironmentVariableGetter* env) { |
| 308 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); | 312 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); |
| 309 } | 313 } |
| 310 | 314 |
| 311 bool FileDescriptorGetInode(ino_t* inode_out, int fd) { | 315 bool FileDescriptorGetInode(ino_t* inode_out, int fd) { |
| 312 DCHECK(inode_out); | 316 DCHECK(inode_out); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 } | 378 } |
| 375 } | 379 } |
| 376 | 380 |
| 377 closedir(fd); | 381 closedir(fd); |
| 378 } | 382 } |
| 379 | 383 |
| 380 return already_found; | 384 return already_found; |
| 381 } | 385 } |
| 382 | 386 |
| 383 } // namespace base | 387 } // namespace base |
| OLD | NEW |