[webkit-help] How to handle file downloading in NPAPI plugin

Jianhua Shao alex.sjh at gmail.com
Thu Dec 29 23:18:10 PST 2011


Hi list,
  Maybe I forgot something important. All the things I mentioned in
previous email is tested on my own lighttpd server, with default
configuration.

  As I try with the real server, I found the http response has a head
"Content-Disposition: attachment" when refreshing with the url of
"http://www.example.com/file.jar".
  The result is, the browser on my PC is directly starting
downloading. The npapi plugin has not been invoked at all.

  I will try it on my target board.

On Fri, Dec 30, 2011 at 9:49 AM, Jianhua Shao <alex.sjh at gmail.com> wrote:
> On Thu, Dec 29, 2011 at 11:42 PM, John Yani <vanuan at gmail.com> wrote:
>> On 29 December 2011 15:39, Jianhua Shao <alex.sjh at gmail.com> wrote:
>>> Here, in a html page, there is a <meta> tag like this:
>>> <meta http-equiv="refresh" content="1; url=http://www.example.com/file.jar" />
>>>
>>> I want to download that 'file.jar',  but the webkit browser here (is
>>> very simple) seems to fail to handle .jar file.
>>
>> It's not clear what are you trying to do. As I understood, you want a
>> user to be prompted to download jar file when visiting a specifically
>> designed page, don't you?
>
> Sorry for the confusion. Yes, I want to download the jar file when
> visiting that specifically designed
> page, but I don't want to prompt user anything, because that page
> would show that the file is being downloaded.
> I just want that, the downloading begins in background.
>
>>> And I have no access to webkit source code.
>>
>> What do you mean? Source code of webkit is here:
>> http://trac.webkit.org/browser/trunk
>
> Sorry for the confusion again, our OS is a proprietary system, now,
> there is a webkit porting and a simple browser, but
> no source code is available to me now.
> So, getting the open source version of webkit makes no much help for me.
>
>>>
>>> So, I want to write a NPAPI plugin, which handles the downloading.
>>
>> Why do you need a plugin to download a file?
>
> I could not access the source code of browser and webkit on our
> system. And NPAPI plugin is the only option I could think of.
> Is there any other option?
>
>>> Actually, I have written a download service,
>>> the job of the plugin is throw a URL (aka.
>>> http://www.example.com/file.jar) to that service. Then it is done. The
>>> webpage
>>> should stay at the original page.
>>>
>>> I register "application/x-java-archive" and "application/java-archive"
>>> MIMIType in NPAPI, when I get the url in NPP_NewStream,
>>> and then destroy the stream by calling NPN_DestroyStream, I suppose
>>> the webpage could stay at the orignal page, but it shows a blank page.
>>
>> Of course it does. Because you're using <meta http-equiv="refresh"
>> content="1; url=http://www.example.com/file.jar" />. This meta tag
>> opens url in current window.
>
> That is exactally my problem. Is there any way to let NPAPI plugin
> totally take over the specified MIMEType (in my case,
> applicatoin/x-java-archive)?
> What I want is just let the browser stay at the current page (in
> which, there is a 'refresh' mata tag).
>
>>>
>>> From the log, I found NPP_NewStream has been called by browser.
>>>
>>> So, I wonder how I can handle file downloading and do not refresh the
>>> web page? Could any one give some hint to me? I am not
>>> so familiar with NPAPI APIs.
>>
>> Try opening a file in new window. Why do you need NPAPI for that?
>
> Our system is an embedded system, there is only one full screen page
> could be shown.
> And the html pages is designed by third party. Current no access or
> modification is available.
>
>>>
>>> FYI: I set the plugin windowless by calling
>>> "sBrowserFuncs->setvalue(instance, NPPVpluginWindowBool,
>>> (void*)false);"
>>> _______________________________________________
>>> webkit-help mailing list
>>> webkit-help at lists.webkit.org
>>> http://lists.webkit.org/mailman/listinfo.cgi/webkit-help


More information about the webkit-help mailing list