Merge pull request #8528 from Anatzum/patch-1

Use kioclient for MoveItemToTrash on KDE
This commit is contained in:
Cheng Zhao 2017-04-04 12:15:22 +09:00 committed by GitHub
commit 7265a0c1b4

View file

@ -7,7 +7,9 @@
#include <stdio.h>
#include "base/cancelable_callback.h"
#include "base/environment.h"
#include "base/files/file_util.h"
#include "base/nix/xdg_util.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "url/gurl.h"
@ -100,7 +102,18 @@ bool MoveItemToTrash(const base::FilePath& full_path) {
if (getenv(ELECTRON_TRASH) != NULL) {
trash = getenv(ELECTRON_TRASH);
} else {
trash = ELECTRON_DEFAULT_TRASH;
// Determine desktop environment and set accordingly.
std::unique_ptr<base::Environment> env(base::Environment::Create());
base::nix::DesktopEnvironment desktop_env(
base::nix::GetDesktopEnvironment(env.get()));
if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4 ||
desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE5) {
trash = "kioclient5";
} else if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE3) {
trash = "kioclient";
} else {
trash = ELECTRON_DEFAULT_TRASH;
}
}
std::vector<std::string> argv;