mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
Bug 1698704 - Return early if the created NSURL is nil. r=mac-reviewers,bradwerth
This achieves the same as the previous code, but without an Objective C exception. Before this patch, we could have called [NSArray arrayWithObject:nil], which would have thrown an exception, which we would then have caught and turned into NS_ERROR_FAILURE. Differential Revision: https://phabricator.services.mozilla.com/D108556
This commit is contained in:
parent
2bb63845fa
commit
189716e23c
@ -101,12 +101,15 @@ nsresult nsMacSharingService::GetSharingProviders(const nsAString& aPageUrl, JSC
|
||||
JS::MutableHandleValue aResult) {
|
||||
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
|
||||
|
||||
JS::Rooted<JSObject*> array(aCx, JS::NewArrayObject(aCx, 0));
|
||||
NSURL* url = [NSURL URLWithString:nsCocoaUtils::ToNSString(aPageUrl)];
|
||||
if (!url) {
|
||||
// aPageUrl is not a valid URL.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NSArray* sharingService =
|
||||
[NSSharingService sharingServicesForItems:[NSArray arrayWithObject:url]];
|
||||
NSArray* sharingService = [NSSharingService sharingServicesForItems:@[ url ]];
|
||||
int32_t serviceCount = 0;
|
||||
JS::Rooted<JSObject*> array(aCx, JS::NewArrayObject(aCx, 0));
|
||||
|
||||
for (NSSharingService* currentService in sharingService) {
|
||||
if (ShouldIgnoreProvider([currentService name])) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user