diff --git a/atom/common/api/atom_api_shell.cc b/atom/common/api/atom_api_shell.cc index d479911fbe32..d0e795e87455 100644 --- a/atom/common/api/atom_api_shell.cc +++ b/atom/common/api/atom_api_shell.cc @@ -12,22 +12,12 @@ namespace { -bool OpenExternal(const GURL& url, mate::Arguments* args) { - bool without_activation = false; - if (args->Length() == 2) { - mate::Dictionary options; - args->GetNext(&options); - options.Get("withoutActivation", &without_activation); - } - return platform_util::OpenExternal(url, without_activation); -} - void Initialize(v8::Local exports, v8::Local unused, v8::Local context, void* priv) { mate::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder); dict.SetMethod("openItem", &platform_util::OpenItem); - dict.SetMethod("openExternal", &OpenExternal); + dict.SetMethod("_openExternal", &platform_util::OpenExternal); dict.SetMethod("moveItemToTrash", &platform_util::MoveItemToTrash); dict.SetMethod("beep", &platform_util::Beep); } diff --git a/atom/common/api/lib/shell.js b/atom/common/api/lib/shell.js index 08cc4e8eb41c..e032a7370762 100644 --- a/atom/common/api/lib/shell.js +++ b/atom/common/api/lib/shell.js @@ -1 +1,17 @@ -module.exports = process.atomBinding('shell'); +'use strict'; + +const bindings = process.atomBinding('shell'); + +exports.beep = bindings.beep; +exports.moveItemToTrash = bindings.moveItemToTrash; +exports.openItem = bindings.openItem; +exports.showItemInFolder = bindings.showItemInFolder; + +exports.openExternal = (url, options) => { + var activate = true; + if (options != null && options.activate != null) { + activate = !!options.activate; + } + + bindings._openExternal(url, activate); +} diff --git a/atom/common/platform_util.h b/atom/common/platform_util.h index 3550c243bb68..4565221e9d84 100644 --- a/atom/common/platform_util.h +++ b/atom/common/platform_util.h @@ -23,7 +23,7 @@ void OpenItem(const base::FilePath& full_path); // Open the given external protocol URL in the desktop's default manner. // (For example, mailto: URLs in the default mail user agent.) -bool OpenExternal(const GURL& url, const bool without_activation); +bool OpenExternal(const GURL& url, bool activate); // Move a file to trash. bool MoveItemToTrash(const base::FilePath& full_path); diff --git a/atom/common/platform_util_linux.cc b/atom/common/platform_util_linux.cc index fd4dcba6973b..1e437b866cc0 100644 --- a/atom/common/platform_util_linux.cc +++ b/atom/common/platform_util_linux.cc @@ -64,7 +64,7 @@ void OpenItem(const base::FilePath& full_path) { XDGOpen(full_path.value()); } -bool OpenExternal(const GURL& url, const bool without_activation) { +bool OpenExternal(const GURL& url, bool activate) { if (url.SchemeIs("mailto")) return XDGEmail(url.spec()); else diff --git a/atom/common/platform_util_mac.mm b/atom/common/platform_util_mac.mm index e84b3fbec307..98bc4e537d89 100644 --- a/atom/common/platform_util_mac.mm +++ b/atom/common/platform_util_mac.mm @@ -119,7 +119,7 @@ void OpenItem(const base::FilePath& full_path) { } } -bool OpenExternal(const GURL& url, const bool without_activation) { +bool OpenExternal(const GURL& url, bool activate) { DCHECK([NSThread isMainThread]); NSURL* ns_url = net::NSURLWithGURL(url); if (!ns_url) { @@ -137,8 +137,8 @@ bool OpenExternal(const GURL& url, const bool without_activation) { CFRelease(openingApp); // NOT A BUG; LSGetApplicationForURL retains for us NSUInteger launchOptions = NSWorkspaceLaunchDefault; - if (without_activation) - launchOptions = launchOptions | NSWorkspaceLaunchWithoutActivation; + if (!activate) + launchOptions |= NSWorkspaceLaunchWithoutActivation; return [[NSWorkspace sharedWorkspace] openURLs: @[ns_url] withAppBundleIdentifier: nil diff --git a/atom/common/platform_util_win.cc b/atom/common/platform_util_win.cc index 76b71cb7f702..12591a94d569 100644 --- a/atom/common/platform_util_win.cc +++ b/atom/common/platform_util_win.cc @@ -301,7 +301,7 @@ void OpenItem(const base::FilePath& full_path) { ui::win::OpenFileViaShell(full_path); } -bool OpenExternal(const GURL& url, const bool without_activation) { +bool OpenExternal(const GURL& url, bool activate) { // Quote the input scheme to be sure that the command does not have // parameters unexpected by the external program. This url should already // have been escaped.