[webkit-qt] How to register an application as a specific urlschema handler in QtWebKit

colin121 colin121 at 163.com
Wed Apr 28 22:58:37 PDT 2010


Hi,
Benjamin, thank you for your tips.  I tested following code, and it worked very well.

bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request,
                                      NavigationType type)
{
...

    QString scheme = request.url().scheme();
    if (scheme == QLatin1String("mailto")
        || scheme == QLatin1String("ftp")) {
        BrowserApplication::instance()->askDesktopToOpenUrl(request.url());
        return false;
    }
    else if (scheme == QLatin1String("abc")) {
        QString abcCommand = QLatin1String("abc");
        QStringList abcParameters(request.url().toString());
        QProcess abcProcess;
        abcProcess.startDetached(abcCommand, abcParameters);
        return false;
    }

...
}

2010-04-29 



colin121 



From:  Benjamin Poulain 
Sent:  2010-04-28  19:49:53 
To:  ext colin121 
Cc:  webkit-qt 
Subject:  Re: [webkit-qt] How to register an application as a specific urlschema handler in QtWebKit 
 
Hi,
ext colin121 wrote:
> Does anybody know how to register an application as your custom protocol 
> handler in WebKit/QtWebKit/arora?
> Please let me know if there is an easy one, really appreciate your work.
> I'm considering using QtWebkit in an embed device to demonstrate my own 
> web page.
> In my page, I have some links which have specific shema, like: 
> custom://abc.com/xxx.
> when users click such link, I want to launch a local application to 
> handle this url.
> I know in Windows, browsers usually read these configures from registry. 
> So how about the implementation of WebKit in Linux?
>  
> implementing PolicyDecisions ?  
> http://diotavelli.net/PyQtWiki/Adding%20the%20Gopher%20Protocol%20to%20QtWebKit
> Netscape-Style Plug-ins£¿
> WebKit¨CBased Plug-ins£¿ 
>  
> any suggestions would be usable :-) 
In Arora, have a look at
webpage.cpp->WebPage::acceptNavigationRequest(). You can also use
handleUnsupportedontent().
To open an url with the default application register on the platform,
you can use QDesktopServices::openUrl().
cheers,
Benjamin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-qt/attachments/20100429/6afda62f/attachment.html>


More information about the webkit-qt mailing list