| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/nix/xdg_util.h" | 5 #include "base/nix/xdg_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/strings/string_util.h" |
| 14 #include "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.h" | 15 #include "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // The KDE session version environment variable introduced in KDE 4. | 19 // The KDE session version environment variable introduced in KDE 4. |
| 19 const char kKDESessionEnvVar[] = "KDE_SESSION_VERSION"; | 20 const char kKDESessionEnvVar[] = "KDE_SESSION_VERSION"; |
| 20 | 21 |
| 21 } // namespace | 22 } // namespace |
| 22 | 23 |
| 23 namespace base { | 24 namespace base { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 50 path = path.Append(fallback_dir); | 51 path = path.Append(fallback_dir); |
| 51 } | 52 } |
| 52 return path.StripTrailingSeparators(); | 53 return path.StripTrailingSeparators(); |
| 53 } | 54 } |
| 54 | 55 |
| 55 DesktopEnvironment GetDesktopEnvironment(Environment* env) { | 56 DesktopEnvironment GetDesktopEnvironment(Environment* env) { |
| 56 // XDG_CURRENT_DESKTOP is the newest standard circa 2012. | 57 // XDG_CURRENT_DESKTOP is the newest standard circa 2012. |
| 57 std::string xdg_current_desktop; | 58 std::string xdg_current_desktop; |
| 58 if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) { | 59 if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) { |
| 59 // Not all desktop environments set this env var as of this writing. | 60 // Not all desktop environments set this env var as of this writing. |
| 60 if (xdg_current_desktop == "Unity") { | 61 if (base::StartsWith(xdg_current_desktop, "Unity", |
| 62 base::CompareCase::SENSITIVE)) { |
| 61 // gnome-fallback sessions set XDG_CURRENT_DESKTOP to Unity | 63 // gnome-fallback sessions set XDG_CURRENT_DESKTOP to Unity |
| 62 // DESKTOP_SESSION can be gnome-fallback or gnome-fallback-compiz | 64 // DESKTOP_SESSION can be gnome-fallback or gnome-fallback-compiz |
| 63 std::string desktop_session; | 65 std::string desktop_session; |
| 64 if (env->GetVar("DESKTOP_SESSION", &desktop_session) && | 66 if (env->GetVar("DESKTOP_SESSION", &desktop_session) && |
| 65 desktop_session.find("gnome-fallback") != std::string::npos) { | 67 desktop_session.find("gnome-fallback") != std::string::npos) { |
| 66 return DESKTOP_ENVIRONMENT_GNOME; | 68 return DESKTOP_ENVIRONMENT_GNOME; |
| 67 } | 69 } |
| 68 return DESKTOP_ENVIRONMENT_UNITY; | 70 return DESKTOP_ENVIRONMENT_UNITY; |
| 69 } else if (xdg_current_desktop == "GNOME") { | 71 } else if (xdg_current_desktop == "GNOME") { |
| 70 return DESKTOP_ENVIRONMENT_GNOME; | 72 return DESKTOP_ENVIRONMENT_GNOME; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 131 } |
| 130 return NULL; | 132 return NULL; |
| 131 } | 133 } |
| 132 | 134 |
| 133 const char* GetDesktopEnvironmentName(Environment* env) { | 135 const char* GetDesktopEnvironmentName(Environment* env) { |
| 134 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); | 136 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); |
| 135 } | 137 } |
| 136 | 138 |
| 137 } // namespace nix | 139 } // namespace nix |
| 138 } // namespace base | 140 } // namespace base |
| OLD | NEW |