Skip to content

Commit

Permalink
[Merge to M63] Add a new enum value to base::DesktopEnvironment for P…
Browse files Browse the repository at this point in the history
…antheon

> CL [1] fixed a bug where Chrome wouldn't add any frame buttons on a
> maximized browser window.  The Unity desktop environment draws these
> buttons for us in the top menu bar for maximized windows, so we only
> disabled these buttons on the Unity DE.
>
> However, we were also pretending that the Pantheon DE (used on
> ElementaryOS) was Unity, so that libappindicator would work.  This CL
> adds Pantheon as a new base::DesktopEnvironment to solve both of these
> issues.
>
> [1] https://crrev.com/0960ecfad7787c492f407054c9a9ba1b7134ef5d
>
> BUG=773233
> R=sky@chromium.org
> CC=erg@chromium.org
>
> Change-Id: If66f748e69c202d09c9ed6dfc0490bb2ce0d5609
> Reviewed-on: https://chromium-review.googlesource.com/717479
> Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#508792}

TBR=sky@chromium.org
BUG=773233
NOTRY=true
NOTREECHECKS=true
NOPRESUBMIT=true

Change-Id: I176e570a04d76970830d6ebbf9b1c2cb3f4d2888
Reviewed-on: https://chromium-review.googlesource.com/721694
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/branch-heads/3239@{#14}
Cr-Branched-From: adb61db-refs/heads/master@{#508578}
  • Loading branch information
tanderson-google committed Oct 16, 2017
1 parent ea41cce commit f43e8bd
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 25 deletions.
26 changes: 15 additions & 11 deletions base/nix/xdg_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ DesktopEnvironment GetDesktopEnvironment(Environment* env) {
if (env->GetVar("XDG_CURRENT_DESKTOP", &xdg_current_desktop)) {
// Not all desktop environments set this env var as of this writing.
if (base::StartsWith(xdg_current_desktop, "Unity",
base::CompareCase::SENSITIVE) ||
base::StartsWith(xdg_current_desktop, "Pantheon",
base::CompareCase::SENSITIVE)) {
// gnome-fallback sessions set XDG_CURRENT_DESKTOP to Unity
// DESKTOP_SESSION can be gnome-fallback or gnome-fallback-compiz
Expand All @@ -70,9 +68,10 @@ DesktopEnvironment GetDesktopEnvironment(Environment* env) {
return DESKTOP_ENVIRONMENT_GNOME;
}
return DESKTOP_ENVIRONMENT_UNITY;
} else if (xdg_current_desktop == "GNOME") {
}
if (xdg_current_desktop == "GNOME")
return DESKTOP_ENVIRONMENT_GNOME;
} else if (xdg_current_desktop == "KDE") {
if (xdg_current_desktop == "KDE") {
std::string kde_session;
if (env->GetVar(kKDESessionEnvVar, &kde_session)) {
if (kde_session == "5") {
Expand All @@ -81,31 +80,34 @@ DesktopEnvironment GetDesktopEnvironment(Environment* env) {
}
return DESKTOP_ENVIRONMENT_KDE4;
}
if (xdg_current_desktop == "Pantheon")
return DESKTOP_ENVIRONMENT_PANTHEON;
}

// DESKTOP_SESSION was what everyone used in 2010.
std::string desktop_session;
if (env->GetVar("DESKTOP_SESSION", &desktop_session)) {
if (desktop_session == "gnome" || desktop_session =="mate") {
if (desktop_session == "gnome" || desktop_session == "mate")
return DESKTOP_ENVIRONMENT_GNOME;
} else if (desktop_session == "kde4" || desktop_session == "kde-plasma") {
if (desktop_session == "kde4" || desktop_session == "kde-plasma")
return DESKTOP_ENVIRONMENT_KDE4;
} else if (desktop_session == "kde") {
if (desktop_session == "kde") {
// This may mean KDE4 on newer systems, so we have to check.
if (env->HasVar(kKDESessionEnvVar))
return DESKTOP_ENVIRONMENT_KDE4;
return DESKTOP_ENVIRONMENT_KDE3;
} else if (desktop_session.find("xfce") != std::string::npos ||
desktop_session == "xubuntu") {
}
if (desktop_session.find("xfce") != std::string::npos ||
desktop_session == "xubuntu") {
return DESKTOP_ENVIRONMENT_XFCE;
}
}

// Fall back on some older environment variables.
// Useful particularly in the DESKTOP_SESSION=default case.
if (env->HasVar("GNOME_DESKTOP_SESSION_ID")) {
if (env->HasVar("GNOME_DESKTOP_SESSION_ID"))
return DESKTOP_ENVIRONMENT_GNOME;
} else if (env->HasVar("KDE_FULL_SESSION")) {
if (env->HasVar("KDE_FULL_SESSION")) {
if (env->HasVar(kKDESessionEnvVar))
return DESKTOP_ENVIRONMENT_KDE4;
return DESKTOP_ENVIRONMENT_KDE3;
Expand All @@ -126,6 +128,8 @@ const char* GetDesktopEnvironmentName(DesktopEnvironment env) {
return "KDE4";
case DESKTOP_ENVIRONMENT_KDE5:
return "KDE5";
case DESKTOP_ENVIRONMENT_PANTHEON:
return "PANTHEON";
case DESKTOP_ENVIRONMENT_UNITY:
return "UNITY";
case DESKTOP_ENVIRONMENT_XFCE:
Expand Down
1 change: 1 addition & 0 deletions base/nix/xdg_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ enum DesktopEnvironment {
DESKTOP_ENVIRONMENT_KDE3,
DESKTOP_ENVIRONMENT_KDE4,
DESKTOP_ENVIRONMENT_KDE5,
DESKTOP_ENVIRONMENT_PANTHEON,
DESKTOP_ENVIRONMENT_UNITY,
DESKTOP_ENVIRONMENT_XFCE,
};
Expand Down
10 changes: 10 additions & 0 deletions base/nix/xdg_util_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const char* const kDesktopKDE = "kde";
const char* const kDesktopXFCE = "xfce";
const char* const kXdgDesktopGNOME = "GNOME";
const char* const kXdgDesktopKDE = "KDE";
const char* const kXdgDesktopPantheon = "Pantheon";
const char* const kXdgDesktopUnity = "Unity";
const char* const kXdgDesktopUnity7 = "Unity:Unity7";
const char* const kXdgDesktopUnity8 = "Unity:Unity8";
Expand Down Expand Up @@ -130,6 +131,15 @@ TEST(XDGUtilTest, GetXdgDesktopKDE4) {
EXPECT_EQ(DESKTOP_ENVIRONMENT_KDE4, GetDesktopEnvironment(&getter));
}

TEST(XDGUtilTest, GetXdgDesktopPantheon) {
MockEnvironment getter;
EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false));
EXPECT_CALL(getter, GetVar(Eq(kXdgDesktop), _))
.WillOnce(DoAll(SetArgPointee<1>(kXdgDesktopPantheon), Return(true)));

EXPECT_EQ(DESKTOP_ENVIRONMENT_PANTHEON, GetDesktopEnvironment(&getter));
}

TEST(XDGUtilTest, GetXdgDesktopUnity) {
MockEnvironment getter;
EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false));
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/printing/printer_manager_dialog_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void DetectAndOpenPrinterConfigDialog() {
case base::nix::DESKTOP_ENVIRONMENT_KDE3:
case base::nix::DESKTOP_ENVIRONMENT_KDE4:
case base::nix::DESKTOP_ENVIRONMENT_KDE5:
case base::nix::DESKTOP_ENVIRONMENT_PANTHEON:
case base::nix::DESKTOP_ENVIRONMENT_UNITY:
case base::nix::DESKTOP_ENVIRONMENT_XFCE:
opened = OpenPrinterConfigDialog(kSystemConfigPrinterCommand);
Expand Down
28 changes: 19 additions & 9 deletions chrome/browser/ui/libgtkui/app_indicator_icon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,32 @@ app_indicator_set_icon_full_func app_indicator_set_icon_full = nullptr;
app_indicator_set_icon_theme_path_func app_indicator_set_icon_theme_path =
nullptr;

bool ShouldUseLibAppIndicator() {
// Only use libappindicator where it is needed to support dbus based status
// icons. In particular, libappindicator does not support a click action.
std::unique_ptr<base::Environment> env(base::Environment::Create());
switch (base::nix::GetDesktopEnvironment(env.get())) {
case base::nix::DESKTOP_ENVIRONMENT_KDE4:
case base::nix::DESKTOP_ENVIRONMENT_KDE5:
case base::nix::DESKTOP_ENVIRONMENT_PANTHEON:
case base::nix::DESKTOP_ENVIRONMENT_UNITY:
return true;
case base::nix::DESKTOP_ENVIRONMENT_KDE3:
case base::nix::DESKTOP_ENVIRONMENT_GNOME:
case base::nix::DESKTOP_ENVIRONMENT_OTHER:
case base::nix::DESKTOP_ENVIRONMENT_XFCE:
return false;
}
}

void EnsureMethodsLoaded() {
if (g_attempted_load)
return;

g_attempted_load = true;

// Only use libappindicator where it is needed to support dbus based status
// icons. In particular, libappindicator does not support a click action.
std::unique_ptr<base::Environment> env(base::Environment::Create());
base::nix::DesktopEnvironment environment =
base::nix::GetDesktopEnvironment(env.get());
if (environment != base::nix::DESKTOP_ENVIRONMENT_KDE4 &&
environment != base::nix::DESKTOP_ENVIRONMENT_KDE5 &&
environment != base::nix::DESKTOP_ENVIRONMENT_UNITY) {
if (!ShouldUseLibAppIndicator())
return;
}

void* indicator_lib = nullptr;

Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/libgtkui/gtk_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ bool GtkUi::GetDefaultUsesSystemTheme() const {

switch (base::nix::GetDesktopEnvironment(env.get())) {
case base::nix::DESKTOP_ENVIRONMENT_GNOME:
case base::nix::DESKTOP_ENVIRONMENT_PANTHEON:
case base::nix::DESKTOP_ENVIRONMENT_UNITY:
case base::nix::DESKTOP_ENVIRONMENT_XFCE:
return true;
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/webui/settings_utils_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ void DetectAndStartProxyConfigUtil(int render_process_id,
bool launched = false;
switch (base::nix::GetDesktopEnvironment(env.get())) {
case base::nix::DESKTOP_ENVIRONMENT_GNOME:
case base::nix::DESKTOP_ENVIRONMENT_PANTHEON:
case base::nix::DESKTOP_ENVIRONMENT_UNITY: {
launched = StartProxyConfigUtil(kGNOME2ProxyConfigCommand);
if (!launched) {
Expand Down
2 changes: 1 addition & 1 deletion chrome/installer/linux/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ update-alternatives --install /usr/bin/x-www-browser x-www-browser \
update-alternatives --install /usr/bin/gnome-www-browser gnome-www-browser \
/usr/bin/@@USR_BIN_SYMLINK_NAME@@ $PRIORITY

update-alternatives --install /usr/bin/google-chrome google-chrome \
update-alternatives --install /usr/bin/@@PACKAGE_ORIG@@ @@PACKAGE_ORIG@@ \
/usr/bin/@@USR_BIN_SYMLINK_NAME@@ $PRIORITY

@@include@@../common/apt.include
Expand Down
2 changes: 1 addition & 1 deletion chrome/installer/linux/debian/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ fi
update-alternatives --remove x-www-browser /usr/bin/@@USR_BIN_SYMLINK_NAME@@
update-alternatives --remove gnome-www-browser /usr/bin/@@USR_BIN_SYMLINK_NAME@@

update-alternatives --remove google-chrome /usr/bin/@@USR_BIN_SYMLINK_NAME@@
update-alternatives --remove @@PACKAGE_ORIG@@ /usr/bin/@@USR_BIN_SYMLINK_NAME@@
6 changes: 3 additions & 3 deletions chrome/installer/linux/rpm/chrome.spec.template
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ case $CHANNEL in
;;
esac

%{_sbindir}/update-alternatives --install /usr/bin/google-chrome google-chrome \
/usr/bin/@@USR_BIN_SYMLINK_NAME@@ $PRIORITY
%{_sbindir}/update-alternatives --install /usr/bin/@@PACKAGE_ORIG@@ \
@@PACKAGE_ORIG@@ /usr/bin/@@USR_BIN_SYMLINK_NAME@@ $PRIORITY

exit 0

Expand All @@ -204,7 +204,7 @@ if [ "$mode" = "uninstall" ]; then
remove_nss_symlinks
remove_udev_symlinks

%{_sbindir}/update-alternatives --remove google-chrome \
%{_sbindir}/update-alternatives --remove @@PACKAGE_ORIG@@ \
/usr/bin/@@USR_BIN_SYMLINK_NAME@@
fi

Expand Down
1 change: 1 addition & 0 deletions components/os_crypt/key_storage_util_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ SelectedLinuxBackend SelectBackend(const std::string& type,
case base::nix::DESKTOP_ENVIRONMENT_KDE5:
return SelectedLinuxBackend::KWALLET5;
case base::nix::DESKTOP_ENVIRONMENT_GNOME:
case base::nix::DESKTOP_ENVIRONMENT_PANTHEON:
case base::nix::DESKTOP_ENVIRONMENT_UNITY:
case base::nix::DESKTOP_ENVIRONMENT_XFCE:
return SelectedLinuxBackend::GNOME_ANY;
Expand Down
1 change: 1 addition & 0 deletions net/proxy/proxy_config_service_linux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1539,6 +1539,7 @@ ProxyConfigServiceLinux::Delegate::Delegate(
// Figure out which SettingGetterImpl to use, if any.
switch (base::nix::GetDesktopEnvironment(env_var_getter_.get())) {
case base::nix::DESKTOP_ENVIRONMENT_GNOME:
case base::nix::DESKTOP_ENVIRONMENT_PANTHEON:
case base::nix::DESKTOP_ENVIRONMENT_UNITY:
#if defined(USE_GIO)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ DBusAPI PowerSaveBlocker::Delegate::SelectAPI() {
std::unique_ptr<base::Environment> env(base::Environment::Create());
switch (base::nix::GetDesktopEnvironment(env.get())) {
case base::nix::DESKTOP_ENVIRONMENT_GNOME:
case base::nix::DESKTOP_ENVIRONMENT_PANTHEON:
case base::nix::DESKTOP_ENVIRONMENT_UNITY:
if (DPMSEnabled())
return GNOME_API;
Expand Down

0 comments on commit f43e8bd

Please sign in to comment.