Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(614)

Side by Side Diff: base/nix/xdg_util.cc

Issue 550173006: Do not rely on XDG_CURRENT_DESKTOP only when testing for Unity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 path = path.Append(fallback_dir); 50 path = path.Append(fallback_dir);
51 } 51 }
52 return path.StripTrailingSeparators(); 52 return path.StripTrailingSeparators();
53 } 53 }
54 54
55 DesktopEnvironment GetDesktopEnvironment(Environment* env) { 55 DesktopEnvironment GetDesktopEnvironment(Environment* env) {
56 // XDG_CURRENT_DESKTOP is the newest standard circa 2012. 56 // XDG_CURRENT_DESKTOP is the newest standard circa 2012.
57 std::string xdg_current_desktop; 57 std::string xdg_current_desktop;
58 if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) { 58 if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) {
59 // Not all desktop environments set this env var as of this writing. 59 // Not all desktop environments set this env var as of this writing.
60 if (xdg_current_desktop == "Unity") 60 if (xdg_current_desktop == "Unity") {
61 // gnome-fallback sessions set XDG_CURRENT_DESKTOP to Unity
62 // DESKTOP_SESSION can be gnome-fallback or gnome-fallback-compiz
63 std::string desktop_session;
64 if (env->GetVar("DESKTOP_SESSION", &desktop_session) &&
65 desktop_session.find("gnome-fallback") != std::string::npos) {
66 return DESKTOP_ENVIRONMENT_GNOME;
67 }
61 return DESKTOP_ENVIRONMENT_UNITY; 68 return DESKTOP_ENVIRONMENT_UNITY;
62 else if (xdg_current_desktop == "GNOME") 69 } else if (xdg_current_desktop == "GNOME") {
63 return DESKTOP_ENVIRONMENT_GNOME; 70 return DESKTOP_ENVIRONMENT_GNOME;
71 }
64 } 72 }
65 73
66 // DESKTOP_SESSION was what everyone used in 2010. 74 // DESKTOP_SESSION was what everyone used in 2010.
67 std::string desktop_session; 75 std::string desktop_session;
68 if (env->GetVar("DESKTOP_SESSION", &desktop_session)) { 76 if (env->GetVar("DESKTOP_SESSION", &desktop_session)) {
69 if (desktop_session == "gnome") { 77 if (desktop_session == "gnome") {
70 return DESKTOP_ENVIRONMENT_GNOME; 78 return DESKTOP_ENVIRONMENT_GNOME;
71 } else if (desktop_session == "kde4") { 79 } else if (desktop_session == "kde4") {
72 return DESKTOP_ENVIRONMENT_KDE4; 80 return DESKTOP_ENVIRONMENT_KDE4;
73 } else if (desktop_session == "kde") { 81 } else if (desktop_session == "kde") {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 119 }
112 return NULL; 120 return NULL;
113 } 121 }
114 122
115 const char* GetDesktopEnvironmentName(Environment* env) { 123 const char* GetDesktopEnvironmentName(Environment* env) {
116 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); 124 return GetDesktopEnvironmentName(GetDesktopEnvironment(env));
117 } 125 }
118 126
119 } // namespace nix 127 } // namespace nix
120 } // namespace base 128 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698