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

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

Issue 10735034: Linux: Detect Unity as a desktop environment. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: add a comment Created 8 years, 5 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 | Annotate | Revision Log
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/environment.h" 9 #include "base/environment.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 30 matching lines...) Expand all
41 if (xdg_dir) { 41 if (xdg_dir) {
42 path = FilePath(xdg_dir); 42 path = FilePath(xdg_dir);
43 free(xdg_dir); 43 free(xdg_dir);
44 } else { 44 } else {
45 path = file_util::GetHomeDir().Append(fallback_dir); 45 path = file_util::GetHomeDir().Append(fallback_dir);
46 } 46 }
47 return path.StripTrailingSeparators(); 47 return path.StripTrailingSeparators();
48 } 48 }
49 49
50 DesktopEnvironment GetDesktopEnvironment(Environment* env) { 50 DesktopEnvironment GetDesktopEnvironment(Environment* env) {
51 // XDG_CURRENT_DESKTOP is the newest standard circa 2012.
52 std::string xdg_current_desktop;
53 if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) {
54 // Not all desktop environments set this env var as of this writing.
55 if (xdg_current_desktop == "Unity") {
56 return DESKTOP_ENVIRONMENT_UNITY;
57 } else if (xdg_current_desktop == "GNOME") {
58 return DESKTOP_ENVIRONMENT_GNOME;
59 }
Mike Mammarella 2012/07/12 01:15:55 Looks like in this file we leave these {} off when
Lei Zhang 2012/07/12 02:27:02 Done.
60 }
61
62 // DESKTOP_SESSION was what everyone used in 2010.
51 std::string desktop_session; 63 std::string desktop_session;
52 if (env->GetVar("DESKTOP_SESSION", &desktop_session)) { 64 if (env->GetVar("DESKTOP_SESSION", &desktop_session)) {
53 if (desktop_session == "gnome") { 65 if (desktop_session == "gnome") {
54 return DESKTOP_ENVIRONMENT_GNOME; 66 return DESKTOP_ENVIRONMENT_GNOME;
55 } else if (desktop_session == "kde4") { 67 } else if (desktop_session == "kde4") {
56 return DESKTOP_ENVIRONMENT_KDE4; 68 return DESKTOP_ENVIRONMENT_KDE4;
57 } else if (desktop_session == "kde") { 69 } else if (desktop_session == "kde") {
58 // This may mean KDE4 on newer systems, so we have to check. 70 // This may mean KDE4 on newer systems, so we have to check.
59 if (env->HasVar(kKDE4SessionEnvVar)) 71 if (env->HasVar(kKDE4SessionEnvVar))
60 return DESKTOP_ENVIRONMENT_KDE4; 72 return DESKTOP_ENVIRONMENT_KDE4;
(...skipping 20 matching lines...) Expand all
81 const char* GetDesktopEnvironmentName(DesktopEnvironment env) { 93 const char* GetDesktopEnvironmentName(DesktopEnvironment env) {
82 switch (env) { 94 switch (env) {
83 case DESKTOP_ENVIRONMENT_OTHER: 95 case DESKTOP_ENVIRONMENT_OTHER:
84 return NULL; 96 return NULL;
85 case DESKTOP_ENVIRONMENT_GNOME: 97 case DESKTOP_ENVIRONMENT_GNOME:
86 return "GNOME"; 98 return "GNOME";
87 case DESKTOP_ENVIRONMENT_KDE3: 99 case DESKTOP_ENVIRONMENT_KDE3:
88 return "KDE3"; 100 return "KDE3";
89 case DESKTOP_ENVIRONMENT_KDE4: 101 case DESKTOP_ENVIRONMENT_KDE4:
90 return "KDE4"; 102 return "KDE4";
103 case DESKTOP_ENVIRONMENT_UNITY:
104 return "UNITY";
91 case DESKTOP_ENVIRONMENT_XFCE: 105 case DESKTOP_ENVIRONMENT_XFCE:
92 return "XFCE"; 106 return "XFCE";
93 } 107 }
94 return NULL; 108 return NULL;
95 } 109 }
96 110
97 const char* GetDesktopEnvironmentName(Environment* env) { 111 const char* GetDesktopEnvironmentName(Environment* env) {
98 return GetDesktopEnvironmentName(GetDesktopEnvironment(env)); 112 return GetDesktopEnvironmentName(GetDesktopEnvironment(env));
99 } 113 }
100 114
101 } // namespace nix 115 } // namespace nix
102 } // namespace base 116 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698