Open address in external application from inside Chrome Browser

Solution 1:

One cannot any more directly call on Chrome an external application except via a dedicated extension, but I could not find one that does not use NPAPI.

There is still one method that should work, that needs to be set up in the operating system: Custom Protocols, called also Custom URI Schemes.

A URI scheme is the part that one find at the beginning of the URL. Some common ones are : http(s)://, ftp://, feed://, mailto:, news:. The list of all known ones can be found in the IANA list of Uniform Resource Identifier (URI) Schemes.

All that these protocols do is launch an application that handles the parameter. Once the application has successfully launched, it can use command-line parameters to retrieve the URI that launched it. The usual method is to call a known script that processes its argument and launches the required program.

Including here a tutorial for Windows, Linux and Mac is much too heavy, but here are some useful references :

  • Registering an Application to a URI Scheme - for Windows
  • How to launch external applications using custom protocols - for Windows and Linux
  • Launching External Applications using Custom Protocols under OSX

To answer the request by the poster, below is a Linux KDE script that sets /path/prog as handler for the protocol xyz://. It creates for KDE the file $KDEDIR/share/services/xyz.protocol and populates it. The Gnome settings are also set (if possible) since some applications still use them even if running on KDE. The script is adapted from github.

#!/usr/bin/env bash
#
#    This script attempts to register a protocol handler for
#    links that look like sgaction://blah.  
#
#    It should be sufficient for gnome apps like pidgin and kde apps
#    like konqueror.  Firefox seems to pay attention to the gnome
#    settings at least to the degree that it recognizes links of the
#    form $protocol://blah as hot-links, but it may still ask you to
#    select the application the first time you click on one.

protocol=xyz
handler="/path/prog"

echo "Installing $protocol protocol handler for Gnome."

gconfTool="$(which gconftool-2)"
if [[ "$gconfTool" ]]; then
    gconftool-2 --set --type=string /desktop/gnome/url-handlers/$protocol/command "$handler \"%s\""
    gconftool-2 --set --type=bool /desktop/gnome/url-handlers/$protocol/enabled true
    gconftool-2 --set --type=bool /desktop/gnome/url-handlers/$protocol/need-terminal false
else
    echo "WARNING: gconftool-2 not found: skipping gnome url-handler registration."
fi


echo "Installing $protocol protocol handler for KDE."

kdeProtoDir=~/.kde/share/services

if [[ "$KDEDIR" ]]; then
    kdeProtoDir="$KDEDIR/share/services"
fi

if [[ ! -e "$kdeProtoDir" ]]; then
    mkdir -p "$kdeProtoDir"
fi

if [[ -e "$kdeProtoDir" ]]; then
    kdeProtoFile="$kdeProtoDir/$protocol.protocol"
    rm -f $kdeProtoFile
    cat > $kdeProtoFile << EOF
[Protocol]
exec=$handler "%u"
protocol=$protocol
input=none
output=none
helper=true
listing=false
reading=false
writing=false
makedir=false
deleting=false
EOF
else
    echo "WARNING: can't find or create KDE protocol directory: $kdeProtoDir:  skipping KDE url-handler registration."
fi


echo "Done."