[webkit-gtk] how to download something with webkit ?

Nicolas Jäger jagernicolas at legtux.org
Tue Jan 27 15:27:33 PST 2015


Hi,
I'm struggling to make my web browser able to download.
What I'm doing, is trough the policies, when I got a,

|
|WEBKIT_POLICY_DECISION_TYPE_RESPONSE
|

then I check the mime type to decide to download it or not

|
|WebKitResponsePolicyDecision* responseDecision =
|WEBKIT_RESPONSE_POLICY_DECISION (decision);
|
|response = webkit_response_policy_decision_get_response
|(responseDecision);
|
|mimeType = webkit_uri_response_get_mime_type(response);
|
|if( !webkit_response_policy_decision_is_mime_type_supported( responseDecision)
|     || mimeType == "application/pdf" ) {
|  webkit_policy_decision_download( decision ); 
|}
|

also, I have this function :

|
|static
|void
|downloadRequestedGC( WebKitWebView* webview
|                   , WebKitDownload* download
|                   , gboolean* handled
|                   )
|{
|  std::cout << "downloadRequestedGC" << std::endl;
|  std::string destination = "file:////home/user/test";
| // what to do before ?
| webkit_download_set_destination(download,destination.c_str());
| // what to do next ?
|}
|

First I don't know how to send a signal like "I want to download".
because if I click on file, I never get downloadRequestedGC called.
Second I don't see some function like "start the download" in the API.

regards,
/nicoo


More information about the webkit-gtk mailing list