简体   繁体   中英

Showing a progress dialog for a Chrome extension that interacts with an NPAPI plugin

I'm writing an extension for Google Chrome that converts a page to a PDF file. The extension, written in Javascript, extracts the DOM of the current page, and passes it to an NPAPI DLL, where the conversion happens. I want to show a progress dialog to the user that comes up as soon as the conversion begins, and goes away, or shows a status complete dialog, when the conversion has ended and the PDF file is opened for viewing. I'm a newbie at using Javascript. What should I do to achieve the aforementioned task?

The basic idea would be to:

  • register an event handler on the plugin to receive the completion event (plugin has to implement the (script-)function addEventListener for that)
  • call the plugin telling it to start the conversion
  • the plugin starts a background worker thread for the conversion (as you can't block the main thread)
  • show progress dialog overlay
  • when the plugin is done it fires the completion event (note: NPAPI calls have to occur on the main thread, NPN_PluginThreadAsyncCall helps with that)
  • the JS can now close the progress dialog / show completion dialog / ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM