Merge pull request #5072 from sneakypete81/master
Don't wait for xdg-open to exit when OpenExternal is called (Linux)
This commit is contained in:
commit
107d759ea2
1 changed files with 19 additions and 10 deletions
|
@ -13,7 +13,9 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool XDGUtil(const std::string& util, const std::string& arg) {
|
bool XDGUtil(const std::string& util,
|
||||||
|
const std::string& arg,
|
||||||
|
const bool wait_for_exit) {
|
||||||
std::vector<std::string> argv;
|
std::vector<std::string> argv;
|
||||||
argv.push_back(util);
|
argv.push_back(util);
|
||||||
argv.push_back(arg);
|
argv.push_back(arg);
|
||||||
|
@ -30,6 +32,11 @@ bool XDGUtil(const std::string& util, const std::string& arg) {
|
||||||
if (!process.IsValid())
|
if (!process.IsValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (!wait_for_exit) {
|
||||||
|
base::EnsureProcessGetsReaped(process.Pid());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int exit_code = -1;
|
int exit_code = -1;
|
||||||
if (!process.WaitForExit(&exit_code))
|
if (!process.WaitForExit(&exit_code))
|
||||||
return false;
|
return false;
|
||||||
|
@ -37,12 +44,12 @@ bool XDGUtil(const std::string& util, const std::string& arg) {
|
||||||
return (exit_code == 0);
|
return (exit_code == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XDGOpen(const std::string& path) {
|
bool XDGOpen(const std::string& path, const bool wait_for_exit) {
|
||||||
return XDGUtil("xdg-open", path);
|
return XDGUtil("xdg-open", path, wait_for_exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XDGEmail(const std::string& email) {
|
bool XDGEmail(const std::string& email, const bool wait_for_exit) {
|
||||||
return XDGUtil("xdg-email", email);
|
return XDGUtil("xdg-email", email, wait_for_exit);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -57,22 +64,24 @@ void ShowItemInFolder(const base::FilePath& full_path) {
|
||||||
if (!base::DirectoryExists(dir))
|
if (!base::DirectoryExists(dir))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
XDGOpen(dir.value());
|
XDGOpen(dir.value(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenItem(const base::FilePath& full_path) {
|
void OpenItem(const base::FilePath& full_path) {
|
||||||
XDGOpen(full_path.value());
|
XDGOpen(full_path.value(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OpenExternal(const GURL& url, bool activate) {
|
bool OpenExternal(const GURL& url, bool activate) {
|
||||||
|
// Don't wait for exit, since we don't want to wait for the browser/email
|
||||||
|
// client window to close before returning
|
||||||
if (url.SchemeIs("mailto"))
|
if (url.SchemeIs("mailto"))
|
||||||
return XDGEmail(url.spec());
|
return XDGEmail(url.spec(), false);
|
||||||
else
|
else
|
||||||
return XDGOpen(url.spec());
|
return XDGOpen(url.spec(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoveItemToTrash(const base::FilePath& full_path) {
|
bool MoveItemToTrash(const base::FilePath& full_path) {
|
||||||
return XDGUtil("gvfs-trash", full_path.value());
|
return XDGUtil("gvfs-trash", full_path.value(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Beep() {
|
void Beep() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue