PDA

View Full Version : Hacking QWebkit



qtfeeder
8th July 2009, 12:28
I working on custom browser and I need to change QWebkit to work as I describe below:
when I load a url into webkit, webkit has to change requests to custom a url
which means NetworkRequest urls has to change to a custom url for example:
if user loads http://www.google.com networkrequests has to send to http://mycustomeserver.com/q?www.google.com

Anyone has idea how can I do this?

Thanks in advance

wysota
8th July 2009, 13:36
Honestly I'd do it through a network (or web) proxy and not through WebKit :) But if you really have to do it this way, then set a custom QNetworkAccessManager on the webview's webpage and reimplement QNetworkAccessManager::createRequest() where you will change the request object and call the base class implementation.

nish
8th July 2009, 13:47
and i was thinking only our boss has weird ideas:)

qtfeeder
8th July 2009, 14:32
Honestly I'd do it through a network (or web) proxy and not through WebKit :) But if you really have to do it this way, then set a custom QNetworkAccessManager on the webview's webpage and reimplement QNetworkAccessManager::createRequest() where you will change the request object and call the base class implementation.

I tried to do this by creating subclass of QNetworkAccessManager and reimplement createRequest and setting my QNetworkAccessManager as QNetworkAccessManager in webview's webpage using setNetworkAccessManager.. but seems Webkit don't use MyAccessManager and does it using original one as i tried to checking by debuging application
but I'm not Qt Expert would you show me how to reimplement QNetworkAccessManager and how to use it in my Webview's webpage instance ( by code)?

Many Thank in advance, you effort will help many ppl

wysota
8th July 2009, 18:54
Please show your code (as you already have it written and I don't) and we will correct it.