Executing HTML on local drive with Chrome Javascript Application - javascript

I am creating a chrome application that needs to open a local file that the user specifies, and this file will need to be opened in which ever browser they so choose. Now with the chrome application I have already thought of the conditional for when they are on a chromebook, so that set aside.
I have some possibilities of file locations for the exe of each browser. here are mine
Chrome Locations
C:\Program Files (x86)\Google\Chrome\Application
Firefox Locations
C:\Program Files (x86)\Mozilla Firefox
IE Locations
C:\Program Files (x86)\Internet Explorer
Edge Locations
C:\Windows\SystemApps\Microsoft.MicrosoftEdge_------- (not sure if the end is a key so removed)
So basically I was thinking maybe using a PNaCl or a NaCl for Google's Native Client to use C++ and using ShellExecute except I'm not sure how to combine the file location and the browser the user specifies.
They want to open Microsoft Edge and run index.html
void main()
{
ShellExecute(NULL, "open", "C:\Windows\SystemApps\Microsoft.MicrosoftEdge_-------",
NULL, NULL, SW_SHOWNORMAL);
}
Seems as though Google allows it in the Manifest so here is the example
{
"name": "My extension",
...
"plugins": [
{ "path": "extension_plugin.dll" }
],
...
}
So really how to write a clean dll file to execute file location and browser locations. And then again reading further I get this,
Marking your NPAPI plugin "public" increase the attack surface of your extension because the plugin is exposed directly to web content, making it easier for a malicious web site to manipulate your plugin. Instead, avoid making your NPAPI plugin public whenever possible.
Which I don't want anyone feeling disgruntled over something that could be malicious, I just need it to run a local browser, also maybe find the file locations easier than checking for every possible locations. Thanks in advanced.
Question repeated in case you got lost.
Running a NPAPI dll program
How to use ShellExecute or a function to run the browser of choice and file determined by the user
Understanding if NPAPI will hurt my users if it is just for them no one else.

You missed an important link at the top of the NPAPI page you quoted from; it's no longer possible to publish extensions than use NPAPI, and the next release will remove all NPAPI support. If you want to communicate with native applications, you'll need to use Native Messaging as a bridge (see other questions about launching applications from Chrome for details).
As for NaCl, it does not allow you to call arbitrary Windows APIs.

Related

Interact with user's file system

I'm working on web application that deals with files of different kinds and stores it's metadata (e. g. if it is Microsoft Word file, then I try to parse it, if JPEG - EXIF, and so on).
General workflow: the user selects a file stored in a database, presses check out file, then default user editor / viewer (e. g. for PSD - Adobe Photoshop) will be opened on user's PC. When user finishes working on file, she presses check in and web application uploads file for further post-processing.
Right know this workflow implemented using Mozilla Firefox AddOn SDK (particularly sdk/io/file and OS.File methods): web application interacts with an extension for downloading / uploading file. So my application is tied to Firefox. But guys from Mozilla is working on WebExtensions API and I'm afraid in future they will deprecate AddOn SDK at all. Unfortunately, WebExtensions API doesn't provide functions for interacting with a file system.
So my question is: is there any other ways to interact with file system from web application? May be WebAssembly will provide such capabilities (bad luck, due lack of documentation, I can not find any sensible information about it)? Anyway I want to write application that will be compatible with major browsers, so I don't want to deal with extensions / addons anymore.

Possible to open link in Chrome Application from javascript?

From the command line, I can open a url as a chrome application by running e.g.
chromium --app=https://www.stackoverflow.com
Is it possible to do open a url in this mode from javascript in an existing page? To be clear, the url should ideally be opened in a new window, which has the properties implied by the --app flag (e.g. no address bar), whether or not the current page is running in that mode.
My reason for asking is that I'd like to integrate this into vimium.
There is no way to do what you need directly from Javascript. I think you'll need to create an Chrome extension to do that.
You still can find an extension called "Open with external application" which do that, but its use NPAPI and NPAPI is not supported anymore by latest Chrome version. The source is hosted on BitBucket.
The new way to do the same thing is using the native messaging API. In this case the external application would have to register a native messaging host in order to exchange messages with your application. You can see more at http://developer.chrome.com/extensions/messaging.html#native-messaging

upload chrome extension to store including native application

I have my first brand new google chrome extension, which I'd like to upload to the chrome web store. The thing is that my extension is using native messaging via stdio to a c++ exe. The extension also required a registry key to be installed.
Is it possible to upload the required files to the chrome web store (including exe and dll dependency)? Is there a way to automate the installation of the registry key (required to send messages from chrome extension js to exe), and register dll?
The idea behind chrome-extensions (and native messaging) is to limit the giant security hole that is NPAPI: to create a divide between the browser and the desktop that runs it. For this reason, you'll need to perform two separate installations: one for the extension and another for the native code.
To the best of my knowledge, you can't bundle the binary with the extension. But you might be able to (partially) do it the other way around: have the native code also install the extension:
There is a way to partially automate the process of installing the extension: you can pre-load the extension via the registry. This only applies to extensions on the chrome web-store (CWS). I believe this requires to reboot chrome. And of course the user is notified that an extension was installed. see here - https://developer.chrome.com/extensions/external_extensions
There's also something called "inline installation" - not quite "automatic", but this should make it easier for your users to install the extension from "within" your site (as opposed to the CWS). The extension still needs to be hosted on the CWS, but the user needs not navigate there.
see here - https://developer.chrome.com/webstore/inline_installation (and especially the line section - about verified site - which requires that you register your site with Google - and thus may render this technique useless to you)

Specifying Native Messaging Host for Chrome extension

I am using native messaging API in Chrome extension, and I want to ship the native application within my extension.
In Windows, I add a registry key under HKLM\SOFTWARE\Google\Chrome\NativeMessagingHosts. Since my application is inside the extension folder after installed, I reference the full path by "%LOCALAPPDATA%\Google\Chrome\User Data\Default\Extensions\...\....json". But in this way, my extension complains "Specified native messaging host not found.".
If I expand the %LOCALAPPDATA% and write the path as "C:\Users\...\AppData\Local\Google\Chrome\User Data\Default\Extensions\...\....json", then my extension can successfully communicate with the host.
I wonder if this is an intended behavior? Thank you for your help.
There is no expansion of environment variables in the current Chromium code. It sounds like a reasonable feature request, though there might be security reasons not to do it. If you file a bug, we'll have a look and see whether it's feasible.

Chrome Extension installation

I have chrome extension which get installed with using installer which install some process and browser extensions. As per chrome security changes stand alone installation will be blocked.Google to block local Chrome extensions
If we host extension on chrome store what are the ways we can redirect chrome from installer to install extension.
According to the Chromium Blog:
If your extensions are currently hosted outside the Chrome Web Store you should migrate them as soon as possible. There will be no impact to your users, who will still be able to use your extension as if nothing changed. You could keep the extensions hidden from the Web Store listings if you like. And if you have a dedicated installation flow from your own website, you can make use of the existing inline installs feature.
So, basically, what you need to do is:
Host your extension on the Chrome Web Store (optionaly keeping it hidden from the listings).
Have your installer open a Chrome browser window pointing to a webpage on your site.
On that page have all necessary info and data for the user to initiate the extention's installation process. (The key concept here is that the user has to initiate the installation process, e.g. by clicking a button.
How does inline installation work:
The HTML page on your site from which you want inline installation to occur must contain one or more tags in the section referencing the items that the user can install. Each tag must have the following format:
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/itemID">
To actually begin inline installation, the chrome.webstore.install(url, successCallback, failureCallback) function must be called. This function can only be called in response to a user gesture, for example within a click event handler; an exception will be thrown if it is not.
(emphasis mine)
More info on the inline installs feature.

Categories