diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 4d587d9f0b6..d74dd671e90 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -548,6 +548,8 @@ void Initialize(v8::Local exports, v8::Local unused, dict.SetMethod("dockBounce", &DockBounce); dict.SetMethod("dockCancelBounce", base::Bind(&Browser::DockCancelBounce, browser)); + dict.SetMethod("dockDownloadFinished", + base::Bind(&Browser::DockDownloadFinished, browser)); dict.SetMethod("dockSetBadgeText", base::Bind(&Browser::DockSetBadgeText, browser)); dict.SetMethod("dockGetBadgeText", diff --git a/atom/browser/browser.h b/atom/browser/browser.h index eb8d2865ad8..1c70eb87590 100644 --- a/atom/browser/browser.h +++ b/atom/browser/browser.h @@ -111,6 +111,9 @@ class Browser : public WindowListObserver { int DockBounce(BounceType type); void DockCancelBounce(int request_id); + // Bounce the Downloads stack. + void DockDownloadFinished(const std::string& filePath); + // Set/Get dock's badge text. void DockSetBadgeText(const std::string& label); std::string DockGetBadgeText(); diff --git a/atom/browser/browser_mac.mm b/atom/browser/browser_mac.mm index 3cabd98b692..205110d54d3 100644 --- a/atom/browser/browser_mac.mm +++ b/atom/browser/browser_mac.mm @@ -158,6 +158,12 @@ void Browser::DockSetBadgeText(const std::string& label) { [tile setBadgeLabel:base::SysUTF8ToNSString(label)]; } +void Browser::DockDownloadFinished(const std::string& filePath) { + [[NSDistributedNotificationCenter defaultCenter] + postNotificationName: @"com.apple.DownloadFileFinished" + object: base::SysUTF8ToNSString(filePath)]; +} + std::string Browser::DockGetBadgeText() { NSDockTile *tile = [[AtomApplication sharedApplication] dockTile]; return base::SysNSStringToUTF8([tile badgeLabel]); diff --git a/docs/api/app.md b/docs/api/app.md index 36ebab21bed..ef69f9e73fc 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -563,6 +563,12 @@ Returns an ID representing the request. Cancel the bounce of `id`. +### `app.dock.downloadFinished(filePath)` _OS X_ + +* `filePath` String + +Bounces the Downloads stack if the filePath is inside the Downloads folder. + ### `app.dock.setBadge(text)` _OS X_ * `text` String diff --git a/lib/browser/api/app.js b/lib/browser/api/app.js index 0487270ce7b..f8bff4b8a72 100644 --- a/lib/browser/api/app.js +++ b/lib/browser/api/app.js @@ -32,6 +32,7 @@ if (process.platform === 'darwin') { return bindings.dockBounce(type) }, cancelBounce: bindings.dockCancelBounce, + downloadFinished: bindings.dockDownloadFinished, setBadge: bindings.dockSetBadgeText, getBadge: bindings.dockGetBadgeText, hide: bindings.dockHide,