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

Jianhua Shao alex.sjh at gmail.com
Fri Dec 30 05:14:00 PST 2011


On Fri, Dec 30, 2011 at 5:07 PM, John Yani <vanuan at gmail.com> wrote:
>> 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.

> Ok, it is clear now. You want a plugin that implements some kind of
> "save as..." dialog called when a user clicks on a random file in the
> internet. Is it right?

Yes.

>> 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.
>
> You should ask your vendor to provide you the source code. WebKit is
> distributed under LGPL, which means the source code of any WebKit port
> should be distributed with it.

Yes. That is an option. But because the issue of timing and schedule,
we just want to
implement a small plugin to do this at this moment.

>> 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?
>
> I'm afraid, NPAPI plugins are not designed for such use case. NPAPI is
> designed to allow a specific file to be displayed in the browser
> without the need to download and open it with a thirdparty
> application.

After I looked into the document of NPAPI, I think you are right,
NPAPI is not good
choice to do it, but currently, there is no other choice...:(

> As a workaround you could open a previous page after you downloaded a
> file, using NPN_GetURL method or using scripting plugin to call
> "history.back()" method.

I have thought about it. But I guess if I call "history.back()", it
would again refresh with
the jar file link. Then it will dead lock. Anyway, I will have a try.

> Additionally, to implement what you want you'll need to return all the
> MIME types you could think of from NP_GetMimeDescription. And still,
> there's no guarantee you won't forgot some. I really recommend making
> a feature request to your vendor to implement file downloading on the
> browser side. Or you can request the source code of WebKit and
> reimplement a simple browser using provided sources. NPAPI plugins is
> really a bad option for that.

I agree with you that NPAPI plugin is a bad option, but what I want to
do is a function demo, not for real
product. So, if NPAPI could achieve this target, I will give it a try.
But I did not understand what you said "you'll need to return all the
MIME types you could think of from NP_GetMimeDescription".
I only want to download jar files, only jar files would appear in the
refresh links. I guess I only need to return MIME Type of jar files.
Am I wrong about it?


More information about the webkit-help mailing list