Use LSGetApplicationForURL to search for app
It costs less.
This commit is contained in:
parent
7ce8156691
commit
c97c3fb9a1
1 changed files with 12 additions and 6 deletions
|
@ -125,13 +125,19 @@ bool OpenExternal(const GURL& url) {
|
||||||
if (!ns_url) {
|
if (!ns_url) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
NSArray *appUrls = (NSArray*)LSCopyApplicationURLsForURL((CFURLRef)ns_url, kLSRolesAll);
|
|
||||||
if([appUrls count] > 0){
|
CFURLRef openingApp = NULL;
|
||||||
if([[NSWorkspace sharedWorkspace] openURL:ns_url])
|
OSStatus status = LSGetApplicationForURL((CFURLRef)ns_url,
|
||||||
return true;
|
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) {
|
bool MoveItemToTrash(const base::FilePath& full_path) {
|
||||||
DCHECK([NSThread isMainThread]);
|
DCHECK([NSThread isMainThread]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue