fix: set XDG_CURRENT_DESKTOP
env var back to original value before invoking xdg utils (#46789)
fix: set `XDG_CURRENT_DESKTOP` env var back to original value before invoking xdg utils (#45310) * Fix XDG_CURRENT_DESKTOP before invoking XDGUtil * apply suggestion * use existing XDG_CURRENT_DESKTOP const Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Evan Simkowitz <esimkowitz@users.noreply.github.com>
This commit is contained in:
parent
ffe6656d2f
commit
96db57f36f
1 changed files with 9 additions and 0 deletions
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "base/cancelable_callback.h"
|
#include "base/cancelable_callback.h"
|
||||||
#include "base/containers/contains.h"
|
#include "base/containers/contains.h"
|
||||||
|
#include "base/containers/map_util.h"
|
||||||
#include "base/environment.h"
|
#include "base/environment.h"
|
||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
#include "base/files/scoped_file.h"
|
#include "base/files/scoped_file.h"
|
||||||
|
@ -58,6 +59,8 @@ const char kFreedesktopPortalName[] = "org.freedesktop.portal.Desktop";
|
||||||
const char kFreedesktopPortalPath[] = "/org/freedesktop/portal/desktop";
|
const char kFreedesktopPortalPath[] = "/org/freedesktop/portal/desktop";
|
||||||
const char kFreedesktopPortalOpenURI[] = "org.freedesktop.portal.OpenURI";
|
const char kFreedesktopPortalOpenURI[] = "org.freedesktop.portal.OpenURI";
|
||||||
|
|
||||||
|
const char kOriginalXdgCurrentDesktopEnvVar[] = "ORIGINAL_XDG_CURRENT_DESKTOP";
|
||||||
|
|
||||||
const char kMethodOpenDirectory[] = "OpenDirectory";
|
const char kMethodOpenDirectory[] = "OpenDirectory";
|
||||||
|
|
||||||
class ShowItemHelper {
|
class ShowItemHelper {
|
||||||
|
@ -282,6 +285,12 @@ bool XDGUtil(const std::vector<std::string>& argv,
|
||||||
base::nix::CreateLaunchOptionsWithXdgActivation(base::BindOnce(
|
base::nix::CreateLaunchOptionsWithXdgActivation(base::BindOnce(
|
||||||
[](base::RepeatingClosure quit_loop, base::LaunchOptions* options_out,
|
[](base::RepeatingClosure quit_loop, base::LaunchOptions* options_out,
|
||||||
base::LaunchOptions options) {
|
base::LaunchOptions options) {
|
||||||
|
// Correct the XDG_CURRENT_DESKTOP environment variable before calling
|
||||||
|
// XDG, in case it was changed for compatibility.
|
||||||
|
if (const auto* orig = base::FindOrNull(
|
||||||
|
options.environment, kOriginalXdgCurrentDesktopEnvVar))
|
||||||
|
options.environment.emplace(base::nix::kXdgCurrentDesktopEnvVar,
|
||||||
|
*orig);
|
||||||
*options_out = std::move(options);
|
*options_out = std::move(options);
|
||||||
std::move(quit_loop).Run();
|
std::move(quit_loop).Run();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue