Bug 991766 - Webapp uninstallation on Mac through mozapps uninstall function. r=myk, r=smichaud

This commit is contained in:
Marco Castelluccio
2014-04-17 16:54:50 -04:00
parent 65b8900f53
commit ead0e6504b
3 changed files with 58 additions and 10 deletions

View File

@@ -57,3 +57,26 @@ NS_IMETHODIMP nsMacWebAppUtils::LaunchAppWithIdentifier(const nsAString& bundleI
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}
NS_IMETHODIMP nsMacWebAppUtils::TrashApp(const nsAString& path, nsITrashAppCallback* aCallback) {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
if (NS_WARN_IF(!aCallback)) {
return NS_ERROR_INVALID_ARG;
}
nsCOMPtr<nsITrashAppCallback> callback = aCallback;
NSString* tempString = [NSString stringWithCharacters:reinterpret_cast<const unichar*>(((nsString)path).get())
length:path.Length()];
[[NSWorkspace sharedWorkspace] recycleURLs: [NSArray arrayWithObject:[NSURL fileURLWithPath:tempString]]
completionHandler: ^(NSDictionary *newURLs, NSError *error) {
nsresult rv = (error == nil) ? NS_OK : NS_ERROR_FAILURE;
callback->TrashAppFinished(rv);
}];
return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}