My intention is to create a chrome plugin for the windows users. Is that possible to call windows api from Native Client /PPAPI. If possible how?
2 Answers
I am answering my question, as after some study, I found the answer from West a bit not right. I tried calling windows APIs in Pepper(PPAPI) Plugin and it works fine with a command line switch "--register-pepper-plugins" (not the --no-sandbox as specified by West). It seems safer to use this command line attribute as it is only registering a plugin in to the Chrome browser and not removing any sandbox. I thought of adding an answer after finding an actual pepper plugin existing in use, which uses the switch (the NetFlix pepper plugin for chromeos ).
Got more information to add. Chrome API is available which provides the multi-monitor information : chrome.systemInfo.display object provides all the necessary information. The chrome documentation is not updated. Important thing to note is that, the permission "systemInfo.display" is to be added in the manifest to use this object. Two bugs are reported in the functionality of this object.
1. The monitor name is same for all monitors "Generic PnP Monitor", the documentation claims to provide the user friendly name of monitors.
2. There is an event which should get invoked on resolution change of monitors, but the event is never getting invoked.
Currently the implementation is only for Windows OS. Support for other OS are on the way. Documentation says that the API is only available for Chrome App, but I haves tested that and the API is available on Chrome Extensions as well.

- 313
- 3
- 14
-
If I've understood you correctly, `--register-pepper-plugins` is useful for making native OS calls. Why would this flag help on Chrome OS itself? Also, do you know if there's a way to specify a path to a dll without using a command line switch (e.g., in the .nmf file)? Thanks a lot for your help! – AbdullahC Oct 24 '13 at 08:28
-
1Pepper plugins are inherently having the permission to use the native api calls. But to use them in Chrome, we need to register them, and that is where the --register-pepper-plugin command line parameter helps in. I was also trying to find another way to get the plugin registered and dll name specified through nmf. So far I didn't came across any such option. – MGR Oct 25 '13 at 09:28
-
Thanks @MGR! Btw, what would be the best way to try out the NetFlix plugin? Will I need Windows or Linux for that? Going by comments online, it seems that only Chrome on Linux requires that command line switch. – AbdullahC Oct 25 '13 at 09:43
-
1@Hippo, I am not sure about that case. By that time I got the information regarding chrome API providing display information and dropped the idea of Pepper plugin. – MGR Oct 28 '13 at 06:03
-
i Am trying to make a windows api call from the ppapi plugin. I could not get any information about this. Can u specify how u got it done ? – Buzz LIghtyear Nov 29 '13 at 11:46
Unfortunately, the short answer is 'no'. Native Client is designed to be OS-independent and as safe as JavaScript. Think of Native Client as native code that has the same capabilities and restrictions as JavaScript. A Native Client module that made Windows API calls would break both of those design principles: it wouldn't run on, e.g., a Mac, and it would be a major security risk (imagine browsing to a web page that decides to erase files from your harddrive).
Since you mention Chrome, it may be interesting to you to know that web apps - whether they use JavaScript or Native Client - can request additional permissions as packaged apps in Chrome Web Store. However, native OS calls are still not possible for the reasons listed above.
NPAPI plugins do not have these restrictions, but the future of NPAPI, at least in Chrome, is uncertain (see the last paragraph of http://blog.chromium.org/2012/07/npapi-plug-ins-in-windows-8-metro-mode.html).
For development purposes, it is possible to turn Chrome's outer sandbox off with the command-line flag --no-sandbox and then run PPAPI plugins that make direct OS calls. This is meant for developers and is not a suitable option to be used by end-users.
If you could say a bit more about what you're trying to achieve, there may be ways to do this with Native Client/Pepper.

- 634
- 3
- 10
-
Thank you for the details, West. I am developing a full screen application on Google Chrome which is supposed to work with multi-monitor. There should be an option for the user to move the application to other monitors. So, my google plugin should be able to collect the information of each monitor, display them, and move my application to user selected monitor as well. It would be great, if getting multimonitor details and browser window moving to another monitor are possible without using Win API. – MGR Dec 28 '12 at 04:25
-
Hmm, that's a tough one. It's not possible to do what you want in JavaScript or Pepper, as neither currently has an API that can reliably detect multiple monitors. The best you can do at this point is probably to exit fullscreen mode and rely on the user to move the window before going back to fullscreen mode - not a great solution. Or there is NPAPI, but that is also not a very attractive choice. – West 39th Dec 28 '12 at 17:34
-
Thanx West. Looking forward for the development of Pepper and Native Client up to a level, where it supports such things also from with in the sandbox. – MGR Dec 31 '12 at 08:37
-
I have an NPAPI plugin that uses Win32 API to create digital signatures. NPAPI is now removed, Pepper/NaCl won't allow access to Win32 API, and as far as I know there's no other API available that can do the same. I wonder if there's any workaround / upgrade path that I miss? (apart from trying to switch all users from Chrome browser to Firefox)? – vond Jun 01 '15 at 10:22