How to execute commands from PPAPI plugin on Windows

205 views
Skip to first unread message

Gunjan Gupta

unread,
May 2, 2015, 8:22:12 AM5/2/15
to chromium...@chromium.org
Hi,

We were previously using a NPAPI plugin to execute some commands on windows system from our website. Now that NPAPI is gone, we are trying to port things to PPAPI or NaCl but there seems to be a lot of issues.

1) Google seems to provide vs_addin for Visual Studio 2010 and Visual Studio 2012, but it always give error when trying to compile the code as Pepper Plugin during linking phase. The error is something related to _MSC_VER mismatch as the object files in PPAPI libraries seems to be having that version as 1800 where the value is supposed to be 1600 or 1700 for VS2010 and VS2012 respectively.
2) To get around this issue, we tried downloading a old copy of pepper, but its not available from SDK. somehow we found the pepper_25 version on the internet, but then it seems that postmessage function is not available for plugins.
3) Tried using scriptableobjects but looks like the support for them was actually removed long back sometime in chrome 13?
4) If we are trying to build it as NaCl plugin, then we don't get access to windows functions like ShellExecuteA as the corresponding libraries are not included. Trying to include libraries only results into more errors.
5) This might be possible by having an extension with native messaging, but again a website cannot directly interact with an extension unless the extension places a content script on the webpage. As the users of the website, can install the website on their own systems, we have to scan and add content script on all the web pages which doesn't seem to be a nice option as it can result into system slowdown.

 
TLDR:

Now the question is, how can we build a chrome plugin that can execute commands on windows?

Note : The same question is already posted on Google Chrome Product forum and stack overflow and as suggested on chrome forum, posting here as well. Please help so that we can bring our application back to working status.

PhistucK

unread,
May 2, 2015, 8:37:17 AM5/2/15
to vira...@gmail.com, Chromium-discuss
PPAPI does not have access to the system.

You have to create a Chrome extension and a native host and communicate using native messaging.
The flow for the user is -
- Install your native application.
- Install your extension.
Then you can do whatever you want.

Alternatively, create a native application that listens to a certain localhost port using WebSocket or HTTP(S) and respond to WebSocket frames or HTTP requests (or consume them) with whatever you want to do.


PhistucK

--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discu...@chromium.org.

Gunjan Gupta

unread,
May 2, 2015, 9:46:04 AM5/2/15
to chromium...@chromium.org, vira...@gmail.com
Thanks for the reply. How can I communicate with the extension then from the website? Is there somthing we can do like having a mime type associated with the extension that we can use to communicate with it?

PhistucK

unread,
May 2, 2015, 10:32:25 AM5/2/15
to vira...@gmail.com, Chromium-discuss
You can communicate using chrome.runtime.sendMessage or chrome.runtime.connect.


PhistucK

Gunjan Gupta

unread,
May 2, 2015, 1:08:48 PM5/2/15
to chromium...@chromium.org, vira...@gmail.com
That makes sense, but still have one problem. The url can be dynamic and can be anything as our application is a windows application that has a web interface. Users can host the web interface on any of there servers and we won't be having any idea about their url. The externally connectable can use pattern match to allow a website connecting to it but doesn't allow giving a wild card that allows all sites to connect and hence won't work for us. Do you have a way to work around it?

PhistucK

unread,
May 2, 2015, 1:17:57 PM5/2/15
to Gunjan Gupta, Chromium-discuss
You can run a content script in all of the pages and listen to the message event. Then the page has to send a message to the same window.
Page -
window.postMessage(JSON.stringify({action: "great-action", value: "great-value}), "*");
Content script -
window.addEventListener("message", function (e) { var details = JSON.parse(e.data); if (details.action === "great-action") { ... } });

Also, there is the other option I mentioned - create a native server that processes requests to localhost via HTTP(S) or WebSocket. The added benefit is that it works in all of the browsers.


PhistucK
Reply all
Reply to author
Forward
0 new messages