Development:Opening URLs and Files
There are multiple ways that Camino can receive requests to open URLs or files from external applications, and thus multiple codepaths to handle these requests.
- openURL: in MainController handles URL-only drags to the Dock icon and URLs from our Open URL service.
- The pasteboard gives us unescaped Unicode URLs via this codepath.
- MainController’s init: checks NSUserDefaults for the -url key, i.e.,
./Camino.app/Contents/MacOS/Camino -url http://caminobrowser.org
- Whatever provides that to us also gives us unescaped Unicode URLs.
- GetURLCommand.mm handles the GURL AppleEvent (opening links from external applications, the
opencommand in the Terminal, and the
open locationAppleScript command).
- While the
opencommand in the Terminal and links from external apps come as percent-escaped URLs, the
open locationGURL AppleScript command sends unescaped URLs (at least on 10.5) just like user-defaults and the pasteboard :P
- While the
- NSApplication delegate method application:openFile: in MainController.mm
- openPanelDidEnd: in MainController.mm
In all three cases, we rely on decodeLocalFileURL: in NSURL+Utils.m to parse URLs out of URL-container files (old- and new-style .weblocs, .caminobookmarks, and IE .url files).