tags:

views:

206

answers:

1

How would one enumerate the installed browsers on an OS X system from a local app. I would like to build something like choosy, but different (long story). However, I would like to enumerate all installed browsers on the system.

On windows, I can dive the installed browsers in the Default Programs registries, however, I don't believe there is a similar concept on OS X. Do I have to manually search through all the bundles & their info.plist files?

+6  A: 

Use LSCopyAllHandlersForURLScheme(CFSTR("http")) or LSCopyAllRoleHandlersForContentType(CFSTR("public.html"), kLSRolesViewer), or the set intersection of both.

Those two functions return bundle identifiers; you can use LSFindApplicationForInfo to find the preferred instance on disk of an application by its bundle identifier.

(Don't forget to follow the Core Foundation memory-management rules.)

Edit: In a comment on this answer, smorgan suggests LSCopyAllHandlersForURLScheme(CFSTR("https")) as an alternative to the first call. This is a good suggestion.

Peter Hosey
I noticed these are Carbon APIs. I thought Carbon was being deprecated?
dhopton
Launch Services is part of Core Services, not Carbon. As such, it is not deprecated, and is available on 64-bit. (See the documentation: http://developer.apple.com/documentation/Carbon/Reference/LaunchServicesReference/ )
Peter Hosey
You might want to use "https" instead of "http", as in my experience the latter has more false-positives for things that are really browsers.
smorgan