Replacement for NPAPI Plugin - google-chrome

As we all know Google announced to remove NPAPI from Chrome on September 2015:
http://www.chromium.org/developers/npapi-deprecation
I have a plugin developed with NPAPI, which allows users to scan using WIA and TWAIN. I also use there WinApi do "draw" controls inside browser. Short research showed that alternatives like Native Client/Pepper and so on, do not allow direct access to WinApi.
As I understand the only alternative is to create separate application(e.g Windows Service) to call WinApi throw it, and use WebSockets for communication between Browser and Service. I also should replace HWND with HTML5 canvas drawing.
Please tell me, are there any other solutions for this situation ?

You're correct that there is no way to access WinAPi from a PPAPI plugin, and that you'll need a separate application to do that. The easiest way to communicate with a native application from a Chrome extension is Native Messaging:
https://developer.chrome.com/extensions/nativeMessaging
If you wish to draw on a page, you will have to use HTML. Alternatively, you could do your own drawing from a PPAPI plugin, but you would have to link a graphics library such as Cairo from NaClPorts:
https://code.google.com/p/naclports/wiki/PortList
It can be done (this is how the PDF plugin works in Chrome) but it is a lot more work.

Related

Chrome 32 - Tab opened with chrome extension doesn't render plug-in correctly

We have a Chrome extension that can be used to open a page into our website. From there the user then continues onto the next page which has a custom NPAPI plug-in embedded in it. This has always worked fine. However, since the version 32 update the plug-in loads and runs (it's a video conferencing plug-in and is clearly running as the other side can see video) however it doesn't show up on the page. Examining the DOM everything looks fine. Grabbing the border and re-sizing the browser will cause the plug-in to suddenly render correctly. I've tried all manner of javascript/css tricks to try and mimic this behavior as a workaround but nothing works. Tabs opened manually (not using chrome.tabs.create) work fine.
This worked up till 32.
Any ideas around this?
Chrome 32 is phasing out NPAPI, read the announcement here.
There is a deprecation guide that you can read here.
It seems like Google wants you to use it's Native Client tech to run native compiled code on user's machines. It is cool stuff...but so far I've found it difficult/more limiting to work with when compared to NPAPI (but there are obvious upsides, security for instance).
You could also build a native app and use native message passing to communicate from extension -> app. Once downside to this is that there is currently no way to bundle a native app into an extension install, so the user will need to download and install your app separately.

How do I enable desktop notifications in Chromium Embedded Framework (CEF)?

How do I enable desktop notifications in Chromium Embedded Framework (CEF)?
When I load my url in Google Chrome, window.webkitNotifications is non-null.
When I load my url in my embedded CEF browser, window.webkitNotifications is null.
if(!window.webkitNotifications) {
alert("You need to use The Google Chrome Browser to get this feature!");
return false;
}
Are desktop notifications supported in CEF? If so, how do I enable them?
As far as I know, current CEF versions don't support this feature.
I also needed this functionality in my project. I ended up implementing it myself, under a different namespace with slightly different functionality.
So you can implement it yourself using JS Extensions. Might take some work, but it'll get you what you need.
You can also try asking that question in the CEF Support Forum, you might get a better answer than "do it yourself".
I'd love to hear a better solution for this.

Masking a plugin (or applet) to show html content over it in Chrome on the Mac

For all other browsers that I've tried in both Windows and MacOSX (including Chrome under Windows) using an "iframe shim" works fine. However, I have not been able to get iframe shims to work over our plugin in Chrome on the Mac.
Having Googled the problem, and done some testing, it appears to depend upon the object. I've found an example using StreetView (a flash object) which works, and another example using a Java Applet which does not work.
Some links:
Here's a description of the method: http://www.oratransplant.nl/2007/10/26/using-iframe-shim-to-partly-cover-a-java-applet/
This example using a Java Applet is from the above article: http://www.oratransplant.nl/files/iframe_shim.html
And here's the working version using Streetview: http://gmaps-samples.googlecode.com/svn/trunk/streetview/iframeshim.html
By inspecting (and editing) elements in Chrome and copying the objects between the two example pages, it appears to be that the flash object just allows iframe shims (in Chrome on the Mac), but that the Java Applet does not.
In our case we are using a custom plugin, built with Firebreath.
It may be that I need to implement extra functionality into our plugin, mimicking whatever flash is doing, but this could well be caused by a bug in the Mac build of Chrome.
Can anyone help? We really do want to be able to show HTML elements over our plugin, and the iframe shim works on almost all browser/OS combinations!
The lack of compositing is a known bug in Mac Chrome with any plugin using Core Animation or Invalidating Core Animation. It will be resolved in some future version--in theory, you should never need an iframe hack on the Mac, and plugins should always composite correctly. If you are interested, you can detect whether compositing of Core Animation is supported dynamically in your plugin using NPN_GetValue with the value 74656 (see WKNVSupportsCompositingCoreAnimationPluginsBool in the WebKit source; this should be added to the formal NPAPI spec soon, but the value won't change, so you can hard-code it now and when Chrome supports it that will start returning true).
In general the iframe hack should work in recent versions of Chrome (what version are you testing?), but there are some bugs where it doesn't get noticed until the page gets a re-layout, so you might want to play with forcing that.
Note that your Streetview example isn't a valid test on Mac Chrome, because it's using wmode=opaque, which means it's using the CG mode, not CA mode, and thus compositing works completely regardless of the iframe hack.
What drawing method are you using? You shouldn't need to use an iframe over a plugin on Mac because all drawing is windowless, unless you're doing strange things that I wouldn't expect to be possible with Chrome (i.e. creating an opengl context over a coregraphics or quickdraw context). If you were doing something like that there would probably not be anything you could do.
One easy setting would be to just resize the plugin to 1x1 to effectively "hide" it.

How do I programatically trigger shortcut keys in Chrome with an Extension? (NPAPI or JavaScript Extensions)

Trying to figure out how to automatically trigger the web developer tools by executing the "Ctrl + Shift + i" via my own extension. There is one stackoverflow question, but none of the answers worked.
It would be awesome, but unfortunately it is not possible with javascript.
An NPAPI plugin will not do what you want; NPAPI plugins don't deal with anything that is of the browser itself, only with the webpage they are placed in. They also can't be automatically loaded.
The best you could do with a NPAPI plugin would be to put it in a Chrome Extension and use it as part of something else; if Chrome Extensions don't natively allow you to capture hotkeys like that it might be possible to use C++ code and some sort of hook to catch the hotkey and pass it on to the browser as a , but it would be a very system specific and completely unsupported hack that you'd have to figure out for each OS that you want to support; there are no NPAPI browser APIs for this sort of thing.

There's a way to convert static HTML to a standalone app?

I need to build a simple presentation in HTML and JS, but it needs to run locally as a standalone and portable app in both Windows and Mac.
There are any ways to do this?
Adobe Air allows you to make native apps that run on both platforms out of HTML, CSS and JavaScript.
In addition, there are already libraries out there to help you create slideshow functionality out of HTML. Erik Meyer's S5 is a popular one: http://meyerweb.com/eric/tools/s5/
There's the MHTML format which is supported by Internet Explorer and Opera out-of-the-box and Firefox via add-on. It let's you save a whole page including images, scripts and so on in a single file.
To create one, you could just open your web page in one of those browsers and choose "save as".
Just save it as bunch of htmls, pictures and JSs and open in your favorite browser!
This is way to create a simple presentation:
http://code.google.com/p/html5slides/
Example:
http://html5slides.googlecode.com/svn/trunk/template/index.html#1
Code of example:
http://code.google.com/p/html5slides/source/browse/trunk/template/index.html
To run it standalone, you need just to save it.
Or, you can use Adobe AIR.
Bit late, but what if you take a Portable Browser? Chrome and Firefox both have a Portable App version. Another option would be to use PDF instead of HTML.