6

I have a custom built browser, lets say its similar to a firefox port such as Ice Weasel. I am wondering where I register this so that it will appear in the System Preferences > General > Default Browser menu.

I can view the current defaults on the command line from:

defaults read ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist

However, this only seems to give me what is actually set as my defaults and not as what CAN be set as my defaults. It's the latter portion that I am interested in. What do I need to do in order to register my custom browser so that it can be set as the default?

I'm guessing there is a .plist file somewhere for that?

2
  • Does the defaults read defaults read... have a special reason or is it just an error?
    – klanomath
    Commented Dec 14, 2015 at 18:49
  • it was a typo. thanks for catching it. i fixed it :)
    – Dan
    Commented Dec 14, 2015 at 18:59

2 Answers 2

9

You don't add yourself to this plist—OS X manages this itself. For example, download a new browser and copy it to the Applications folder. Without opening it once, OS X will add it to the list in System Preferences.

This is achieved with the following in the Info.plist in the app:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>http URL</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>http</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleURLName</key>
        <string>Secure http URL</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>https</string>
        </array>
    </dict>
</array>
2
  • if you want the custom browser to open file:// URL schemes, add this as well between the last </dict> and the </array>: <dict> <key>CFBundleURLName</key> <string>Local file URL</string> <key>CFBundleURLSchemes</key> <array> <string>file</string> </array> </dict>
    – jbeldock
    Commented Mar 18, 2017 at 23:35
  • Did you know you can cut and paste this into any apps info.plist. You have to move it out of Applications, then move it back in again, and it will add itself to the possible browser list in the General system preference. Now Notepad is my new default browser!
    – frumbert
    Commented Nov 16, 2018 at 6:45
3

As of macOS 11 (Big Sur) it was not enough by adding the URL types to the Info.plist, it is also necessary to add the document types for HTML and XHTML.

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>HTML document</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.html</string>
        </array>
    </dict>
    <dict>
        <key>CFBundleTypeName</key>
        <string>XHTML document</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.xhtml</string>
        </array>
    </dict>
</array>
<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>Web site URL</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>http</string>
            <string>https</string>
        </array>
    </dict>
</array>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .