How to implement Async NPAPI plugin - npapi

I have to implement HTML5 AsyncFileAPI using plain NPAPI. Also Callback mechanism for Microsoft Gamepad key events.
Problem I am facing is how to implement threadcallasync and seemlessly send data to javascript from plain NPAPI plugin. Some useful links or working code will be appreciated. I am new in NPAPI plugin. threadcallasync I have to implement in Linux, have seen some links to implement in windows.

I would definitely recommend using FireBreath for creating your plugin; it would solve most of the hard stuff for you, and you can find tutorials on how to do async calls.
Should you choose not to do that basically you just have to pass in a javascript function, which in NPAPI will be an NPObject, and then when your action is done use NPN_InvokeDefault on the callback NPObject. You will, of course, need to do this on the main thread, which will require some method of sending a message to the main thread to tell it to make the call.
Generally speaking NPN_PluginThreadAsyncCall does this; you give it a function pointer and a void* with the data you'll need and it'll call your function on the main thread. Unfortunately Safari 5.1 on both windows and mac seems to have dropped support for this function. An alternate on windows is to create a message HWND and PostMessage to it with the opaque pointer in the LPARAM. On Mac you can just use PerformSelectorOnMainThread or an NSTimer. I'm not sure how to do that on linux.
Of course, FireBreath takes care of all of that for you and just wraps the callback in a JSObjectPtr which can be called from any thread... you call it and firebreath will make the call on the correct thread for you. it will also work on IE... but that's up to you. I try to give other options, since I wrote most of FireBreath and I'm a bit biased.
(Just because I'm biased does not mean I'm wrong)
good luck!

Related

How can we understand if a worker thread runs webassembly using Puppeteer API?

Using Puppeteer API it is possible to see get the list of worker threads, their URLs and locations. But is it possible to find out if a worker thread runs webassembly or JavaScript using Puppeteer?
Never used Puppeteer, so I am not sure it's appropriate, but I would suspect that if there is a way to polyfill instantiateStreaming and similar JS methods that are needed to compile WebAssembly's modules, to do some logging and then call the proper implementation, you might be able to find whether something is instantiating a WebAssembly module.

Can I get chrome's web page's HWND in Windows?

I want to port a web game from firebreath to ppapi,
the old implemention is:
firebreath plugin pass window's HWND to a other process
in the other process,render and update the game
I read some doc of ppapi, it seems that there is no way to get HWND,
Can some one give me an idea?
There are a couple of important things to know about this:
1) PPAPI by itself is only supported for certain built-in plugins, such as flash. You can enable additional ones but only using command-line flages, so it's not viable for any real use.
2) The one place you can use PPAPI is in a NACL/pNACL plugin, where you generally just talk about using NACL (Native Client) rather than worrying about the name of the API; NACL is designed specifically to not allow you to access system APIs such as the HWND or anything that would use an HWND.
So the short answer is "no, there is no way to do what you want". The longer answer is that most likely what you want to do will require rewriting as needed to use OpenGL ES w/ NACL. The good news is that this is the same OpenGL that is available on mobile platforms, so with a game you might be able to leverage that.

android: how can i access NotificationCompat.Builder using android-support-v4-r6-googlemaps.jar?

In my app I use just one FragmentActivity and implement all other Functions as Fragments. The app should be compatible down to Android 1.6.
Due to the fact that I need a Mapview I implemented the android-support-v4-r6-googlemaps.jar, which works great.
Now I have to implement an alarmsystem with notifications, and then I got stuck. For notifications I seem to need the NotificationCompat.Builder, which is in android-support-v4.jar, but not in my support-library. I can't use both libraries in the same app, but I need at least the Notification package from the android-support-v4.jar. Can I extract this package somehow? Or is there any other solution?
I've been searching for a solution during a lot of hours, but I couldn't find any helpful.
Many thanks in advance for your help!
I've been having the same problem.
For now I'm just checking android versions, using deprecated approaches for older versions and suppressing the deprecation warnings.
Not a very clean way to handle it, but for now, it'll do.

Unix Domain Sockets & NPAPI

I am looking for source code or library to expose Unix Domain Sockets to my Google Chrome's extension via NPAPI.
Does anything similar or related already exist?
Creating something like that generically would be exceptionally dangerous; you could, however, use FireBreath to create a plugin that would do that and it would be prettye easy. Make sure, though, that you are very careful with the security model since if you can instantiate it on your page someone else can on their page too, and they can then use it maliciously.

Using Java/Python libraries in programming Firefox/Chrome Extensions

I have an idea of studying user behavior on the browser, for which I intend to make a Chrome/Firefox extension to study the behavior dynamically. I have some predefined libraries in Java and Python to analyze the results, which will be impossible to program in plain JavaScript.
Now for my question: is it possible to use third party libraries, especially those of Python or Java like plain function calls?
I have a vague idea about something like Java XPCOM or PyXPCOM for Firefox. However, for a beginner, it all looks so scary. I started making Add-On for Firefox, but got lost somewhere in the huge API.
I found Programming Chrome extensions easier than Firefox, but I couldn't come across something similar to XPCOM in Chrome.
How can I decide which one to go for?
Chrome - seems easy but I am not sure of its power.
Firefox - Seems powerful, but is it really possible to use any Java/Python Library?
Additionally, I came across this link that may be useful: How does someone use thirdparty libraries to be included in Firefox addons/extensions?
But seems like it mostly talks about C++ and XPCOM.
I have a vague idea about something like Java XPCOM or PyXPCOM for Firefox. But for a beginner, it all looks so scary.
I am not a beginner and JavaXPCOM/PyXPCOM are very scary (in addition to being barely maintained). As Firefox goes, it should be much easier to wrap your Java/Python library in an application and run it as an external process: https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIProcess. Note that you cannot get data back (other than an exit code) so the application should write it to a file that you can then read in your Firefox extension. Not very elegant but it has the advantage of being doable.
As to Chrome, its extensions run in a sandbox and using Java or Python isn't possible. Only option is adding an NPAPI plugin to your extension. It is binary code meaning that it could do anything.
When writing Chrome extensions, you're limited to JavaScript unless you choose to use an NPAPI plugin, which lets you do pretty much anything, but is not recommended.
The other approach you could take is to implement your Java or Python code on the server and make requests from the chrome extension's JavaScript.