Chrome Extension : Custom Protocol?
Chrome does not offer a way to set custom handlers for the xyz:
scheme.
There are some ways to emulate the behavior though:
- Use Content scripts to set up an event listener for clicks on links which point to
xyz:...
. Use the
webRequest
API to intercept and redirect all requests from the default search provider to a custom URL. I'm using this method for catching wildcard search keywords, but it can also be used for supporting fake schemes. Unfortunately, the extension would be quite specific to the user's search settings, because it would do something like this:Redirect http://google.com/search?q=xyz%3Awhatever to chrome-extension://.../whatever
in both cases, you won't see xyz:whatever
in the omnibox, though.
navigator.registerProtocolHandler
should be the best way to register a xyz:
handler. Unfortunately, it is quite limited at the moment. Custom protocols must be prefixed with web+
. Also take a look at the list of open bugs for this API.