fix: set Wayland application ID (#34855)

* refactor: extract XDG app ID logic into a method

* fix: set application ID on Wayland
This commit is contained in:
Valentin Hăloiu 2022-07-11 21:26:18 +03:00 committed by GitHub
parent 8f3fb8db09
commit f63bba8ce2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 8 deletions

View file

@ -56,6 +56,10 @@ bool SetLoginItemEnabled(bool enabled);
// Returns a success flag.
// Unlike libgtkui, does *not* use "chromium-browser.desktop" as a fallback.
bool GetDesktopName(std::string* setme);
// The XDG application ID must match the name of the desktop entry file without
// the .desktop extension.
std::string GetXdgAppId();
#endif
} // namespace platform_util

View file

@ -20,6 +20,7 @@
#include "base/posix/eintr_wrapper.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
#include "components/dbus/thread_linux/dbus_thread_linux.h"
#include "content/public/browser/browser_thread.h"
@ -403,4 +404,18 @@ bool GetDesktopName(std::string* setme) {
return base::Environment::Create()->GetVar("CHROME_DESKTOP", setme);
}
std::string GetXdgAppId() {
std::string desktop_file_name;
if (GetDesktopName(&desktop_file_name)) {
const std::string kDesktopExtension{".desktop"};
if (base::EndsWith(desktop_file_name, kDesktopExtension,
base::CompareCase::INSENSITIVE_ASCII)) {
desktop_file_name.resize(desktop_file_name.size() -
kDesktopExtension.size());
}
}
return desktop_file_name;
}
} // namespace platform_util