1 |
commit: a307a6b20508519da3a6f038a301334191f62b36 |
2 |
Author: Pacho Ramos <pacho <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Apr 18 21:34:56 2019 +0000 |
4 |
Commit: Pacho Ramos <pacho <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Apr 18 21:35:10 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a307a6b2 |
7 |
|
8 |
www-client/chromium: Backport XDG_CURRENT_DESKTOP parsing fix |
9 |
|
10 |
Closes: https://bugs.gentoo.org/683792 |
11 |
Package-Manager: Portage-2.3.62, Repoman-2.3.12 |
12 |
Signed-off-by: Pacho Ramos <pacho <AT> gentoo.org> |
13 |
|
14 |
www-client/chromium/chromium-73.0.3683.86.ebuild | 1 + |
15 |
.../files/chromium-73-xdg-current-desktop.patch | 124 +++++++++++++++++++++ |
16 |
2 files changed, 125 insertions(+) |
17 |
|
18 |
diff --git a/www-client/chromium/chromium-73.0.3683.86.ebuild b/www-client/chromium/chromium-73.0.3683.86.ebuild |
19 |
index e02966e7154..9131002b447 100644 |
20 |
--- a/www-client/chromium/chromium-73.0.3683.86.ebuild |
21 |
+++ b/www-client/chromium/chromium-73.0.3683.86.ebuild |
22 |
@@ -149,6 +149,7 @@ PATCHES=( |
23 |
"${FILESDIR}/chromium-73-gcc-4.patch" |
24 |
"${FILESDIR}/chromium-73-gcc-5.patch" |
25 |
"${FILESDIR}/chromium-73-gcc-6.patch" |
26 |
+ "${FILESDIR}/chromium-73-xdg-current-desktop.patch" |
27 |
) |
28 |
|
29 |
pre_build_checks() { |
30 |
|
31 |
diff --git a/www-client/chromium/files/chromium-73-xdg-current-desktop.patch b/www-client/chromium/files/chromium-73-xdg-current-desktop.patch |
32 |
new file mode 100644 |
33 |
index 00000000000..09e3b1d2aec |
34 |
--- /dev/null |
35 |
+++ b/www-client/chromium/files/chromium-73-xdg-current-desktop.patch |
36 |
@@ -0,0 +1,124 @@ |
37 |
+Correct the parsing of the XDG_CURRENT_DESKTOP |
38 |
+ |
39 |
+The XDG_CURRENT_DESKTOP could contain multiple values in priority order |
40 |
+separated by colon. Go through them in the loop and return on the first |
41 |
+one that we recognize/support. |
42 |
+ |
43 |
+The previous state was causing problems with Chrome on the GNOME Classic |
44 |
+mode (used in Red Hat Enterprise Linux 7) where the users with multiple |
45 |
+Google accounts set in Chrome couldn't switch between them - only one was |
46 |
+shown in the account switcher in i.e. GMail. The reason for that was that |
47 |
+the XDG_CURRENT_DESKTOP's value GNOME:GNOME-Classic was parsed as |
48 |
+not as base::nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_GNOME. |
49 |
+ |
50 |
+base: :nix::DesktopEnvironment::DESKTOP_ENVIRONMENT_OTHER and |
51 |
+Change-Id: I122f24fd1cf5a0f932c3fccd5220152a9944609d |
52 |
+Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1541077 |
53 |
+Reviewed-by: Lei Zhang <thestig@××××××××.org> |
54 |
+Reviewed-by: Thomas Anderson <thomasanderson@××××××××.org> |
55 |
+Commit-Queue: Tomáš Popela <tomas.popela@×××××.com> |
56 |
+Cr-Commit-Position: refs/heads/master@{#645224} |
57 |
+diff --git a/base/nix/xdg_util.cc b/base/nix/xdg_util.cc |
58 |
+index 9ff4d88..f051080 100644 |
59 |
+--- a/base/nix/xdg_util.cc |
60 |
++++ b/base/nix/xdg_util.cc |
61 |
+@@ -11,6 +11,7 @@ |
62 |
+ #include "base/files/file_path.h" |
63 |
+ #include "base/files/file_util.h" |
64 |
+ #include "base/path_service.h" |
65 |
++#include "base/strings/string_split.h" |
66 |
+ #include "base/strings/string_util.h" |
67 |
+ #include "base/third_party/xdg_user_dirs/xdg_user_dir_lookup.h" |
68 |
+ |
69 |
+@@ -57,35 +58,37 @@ |
70 |
+ // XDG_CURRENT_DESKTOP is the newest standard circa 2012. |
71 |
+ std::string xdg_current_desktop; |
72 |
+ if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) { |
73 |
+- // Not all desktop environments set this env var as of this writing. |
74 |
+- if (base::StartsWith(xdg_current_desktop, "Unity", |
75 |
+- base::CompareCase::SENSITIVE)) { |
76 |
+- // gnome-fallback sessions set XDG_CURRENT_DESKTOP to Unity |
77 |
+- // DESKTOP_SESSION can be gnome-fallback or gnome-fallback-compiz |
78 |
+- std::string desktop_session; |
79 |
+- if (env->GetVar("DESKTOP_SESSION", &desktop_session) && |
80 |
+- desktop_session.find("gnome-fallback") != std::string::npos) { |
81 |
+- return DESKTOP_ENVIRONMENT_GNOME; |
82 |
+- } |
83 |
+- return DESKTOP_ENVIRONMENT_UNITY; |
84 |
+- } |
85 |
+- if (xdg_current_desktop == "GNOME") |
86 |
+- return DESKTOP_ENVIRONMENT_GNOME; |
87 |
+- if (xdg_current_desktop == "X-Cinnamon") |
88 |
+- return DESKTOP_ENVIRONMENT_CINNAMON; |
89 |
+- if (xdg_current_desktop == "KDE") { |
90 |
+- std::string kde_session; |
91 |
+- if (env->GetVar(kKDESessionEnvVar, &kde_session)) { |
92 |
+- if (kde_session == "5") { |
93 |
+- return DESKTOP_ENVIRONMENT_KDE5; |
94 |
++ // It could have multiple values separated by colon in priority order. |
95 |
++ for (const auto& value : SplitStringPiece( |
96 |
++ xdg_current_desktop, ":", TRIM_WHITESPACE, SPLIT_WANT_NONEMPTY)) { |
97 |
++ if (value == "Unity") { |
98 |
++ // gnome-fallback sessions set XDG_CURRENT_DESKTOP to Unity |
99 |
++ // DESKTOP_SESSION can be gnome-fallback or gnome-fallback-compiz |
100 |
++ std::string desktop_session; |
101 |
++ if (env->GetVar("DESKTOP_SESSION", &desktop_session) && |
102 |
++ desktop_session.find("gnome-fallback") != std::string::npos) { |
103 |
++ return DESKTOP_ENVIRONMENT_GNOME; |
104 |
+ } |
105 |
++ return DESKTOP_ENVIRONMENT_UNITY; |
106 |
+ } |
107 |
+- return DESKTOP_ENVIRONMENT_KDE4; |
108 |
++ if (value == "GNOME") |
109 |
++ return DESKTOP_ENVIRONMENT_GNOME; |
110 |
++ if (value == "X-Cinnamon") |
111 |
++ return DESKTOP_ENVIRONMENT_CINNAMON; |
112 |
++ if (value == "KDE") { |
113 |
++ std::string kde_session; |
114 |
++ if (env->GetVar(kKDESessionEnvVar, &kde_session)) { |
115 |
++ if (kde_session == "5") { |
116 |
++ return DESKTOP_ENVIRONMENT_KDE5; |
117 |
++ } |
118 |
++ } |
119 |
++ return DESKTOP_ENVIRONMENT_KDE4; |
120 |
++ } |
121 |
++ if (value == "Pantheon") |
122 |
++ return DESKTOP_ENVIRONMENT_PANTHEON; |
123 |
++ if (value == "XFCE") |
124 |
++ return DESKTOP_ENVIRONMENT_XFCE; |
125 |
+ } |
126 |
+- if (xdg_current_desktop == "Pantheon") |
127 |
+- return DESKTOP_ENVIRONMENT_PANTHEON; |
128 |
+- if (xdg_current_desktop == "XFCE") |
129 |
+- return DESKTOP_ENVIRONMENT_XFCE; |
130 |
+ } |
131 |
+ |
132 |
+ // DESKTOP_SESSION was what everyone used in 2010. |
133 |
+diff --git a/base/nix/xdg_util_unittest.cc b/base/nix/xdg_util_unittest.cc |
134 |
+index e195303..ad81836 100644 |
135 |
+--- a/base/nix/xdg_util_unittest.cc |
136 |
++++ b/base/nix/xdg_util_unittest.cc |
137 |
+@@ -34,6 +34,7 @@ |
138 |
+ const char* const kDesktopXFCE = "xfce"; |
139 |
+ const char* const kXdgDesktopCinnamon = "X-Cinnamon"; |
140 |
+ const char* const kXdgDesktopGNOME = "GNOME"; |
141 |
++const char* const kXdgDesktopGNOMEClassic = "GNOME:GNOME-Classic"; |
142 |
+ const char* const kXdgDesktopKDE = "KDE"; |
143 |
+ const char* const kXdgDesktopPantheon = "Pantheon"; |
144 |
+ const char* const kXdgDesktopUnity = "Unity"; |
145 |
+@@ -110,6 +111,15 @@ |
146 |
+ EXPECT_EQ(DESKTOP_ENVIRONMENT_GNOME, GetDesktopEnvironment(&getter)); |
147 |
+ } |
148 |
+ |
149 |
++TEST(XDGUtilTest, GetXdgDesktopGnomeClassic) { |
150 |
++ MockEnvironment getter; |
151 |
++ EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false)); |
152 |
++ EXPECT_CALL(getter, GetVar(Eq(kXdgDesktop), _)) |
153 |
++ .WillOnce(DoAll(SetArgPointee<1>(kXdgDesktopGNOMEClassic), Return(true))); |
154 |
++ |
155 |
++ EXPECT_EQ(DESKTOP_ENVIRONMENT_GNOME, GetDesktopEnvironment(&getter)); |
156 |
++} |
157 |
++ |
158 |
+ TEST(XDGUtilTest, GetXdgDesktopGnomeFallback) { |
159 |
+ MockEnvironment getter; |
160 |
+ EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false)); |