Development:Opening URLs and Files

From Camino Wiki
Jump to navigation Jump to search

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.

URLs

  1. 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.
  1. 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.
  1. GetURLCommand.mm handles the GURL AppleEvent (opening links from external applications, the open command in the Terminal, and the open location AppleScript command).
    • While the open command in the Terminal and links from external apps come as percent-escaped URLs, the open location GURL AppleScript command sends unescaped URLs (at least on 10.5) just like user-defaults and the pasteboard :P

Files

  1. NSApplication delegate method application:openFile: in MainController.mm
  2. openPanelDidEnd: in MainController.mm
  3. GetURLCommand.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).