Merge pull request #5477 from danhp/download-bounce
Add API: app.dock.downloadFinished(filePath)
This commit is contained in:
		
				commit
				
					
						ed70a11ff8
					
				
			
		
					 5 changed files with 18 additions and 0 deletions
				
			
		|  | @ -548,6 +548,8 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> 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", | ||||
|  |  | |||
|  | @ -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(); | ||||
|  |  | |||
|  | @ -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]); | ||||
|  |  | |||
|  | @ -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 | ||||
|  |  | |||
|  | @ -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, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Cheng Zhao
				Cheng Zhao