DCHECK([NSThread isMainThread]);
NSString* url_string = base::SysUTF8ToNSString(url.spec());
NSURL* ns_url = [NSURL URLWithString:url_string];
- if (!ns_url){
+ if (!ns_url) {
return false;
}
- NSArray *appUrls = (NSArray*)LSCopyApplicationURLsForURL((CFURLRef)ns_url, kLSRolesAll);
- if([appUrls count] > 0){
- if([[NSWorkspace sharedWorkspace] openURL:ns_url])
- return true;
+
+ CFURLRef openingApp = NULL;
+ OSStatus status = LSGetApplicationForURL((CFURLRef)ns_url,
+ kLSRolesAll,
+ NULL,
+ &openingApp);
+ if (status != noErr) {
+ return false;
}
- return false;
+ CFRelease(openingApp); // NOT A BUG; LSGetApplicationForURL retains for us
+
+ return [[NSWorkspace sharedWorkspace] openURL:ns_url];
}
bool MoveItemToTrash(const base::FilePath& full_path) {