Configure chrome extension without making custom versions - google-chrome-extension

I have a Chrome, Firefox and Edge extension that I want to configure to use a different api url depending on who is using it.
I don't want to create a new version of the extension every time with a different url.
What options do I have to do this? Ideally it would be set for a whole network of users instead of each user having to configure it.
I can think of a few ways:
Communicate with a native app (complex)
Use a few DNS addresses that could be set in the local network
Are there more options?

Related

Is there a way to register a desktop application as a handler for a custom URL protocol, such that all browsers will honour it?

It looks like Chrome uses xdg-open, so it's sufficient to create a .desktop file for you application and register it via mimeapps.list.
Firefox doesn't appear to honour this. I also tried registering via gconftool as suggested at http://kb.mozillazine.org/Register_protocol#All_Firefox_versions, but Firefox still doesn't seem to recognise the protocol, and entering "myprotocol://foo" just triggers a search rather than launching my application.
Is there a foolproof way to do this on all Linux versions which supports all browsers? Or at least a list of common bases to cover which will work for the majority of distro/browser combinations?
Note: this must be do-able programmatically - I want the application to register itself

Chrome Extension -- externally_connectable and any way to set "matches" entries upon install

We have created a Chrome Extension that is a companion to web sites that we host for our customers. These web sites are hosted under our domain name and interact with the extension using external messaging and relying on the sites being configured in the manifest similar to the following (abcdefg.com is a ficticious domain name):
"externally_connectable": {
"matches": [ "http://*.abcdefg.com/*", "https://*.abcdefg.com/*"]
}
This works great in these cases. However, we have a subset of customers that prefer to host the website themselves under their own domain. The problem is that we do not want to update the extension manifest for the published extension to include all of these sites.
Is there any option of distributing a version of the extension (on Windows) where the "externally_connectable" site list can be set upon installation?
Thanks to kzahel for highlighting the obstacles I was facing and thanks to wOxxOm for providing a solution that will work.
Rather than trying to find a way to override the "externally_connectable" matches configuration upon installation, we found the easiest alternative was to avoid external messaging and use messaging via a content script instead.
The following is a copy of the solution posted above by wOxxOm:
chrome extension - alternative to externally_connectable?
Unfortunately there's no way to do this. You'll need to create a custom extension for every customer with their own domain name. Luckily, there is an API for updating the extension, so you would be able to at least update multiple extensions without too much difficulty. However, the 20 extension limit per account would be a little annoying. I think you can get more extension allowed per account by creating a publishing group and assigning the extensions there.
You could if you are willing to have customers install this in developer mode. That would bypass the 20-extension limit.

Chrome extension security

I am developing a GWT based client server web application.
The application installs a web site on the IIS.
When clients first browse to the web site, they need to run a local installation, which installs a local process and a NPAPI plugin on the client computer.
The client runs in browsers such as IE, Chrome and Firefox,
and uses the NPAPI plugin to send messages to the local process.
The local process is used for accessing the file system, registry, etc.
In order to prevent other web sites from using the NPAPI plugin,
When a user first login, the server sends him a hash of a string which contains the URL of the site + some other data.
The NPAPI plugin has access to the current URL of the browser, and also creates the same hash and compares the two.
Due to Chrome upcoming end of support of NPAPI plugins, I am trying to replace the plugin with a Chrome extension, and a native messaging host.
The extension can't be limited to a certain domain because it can be used from many domains.
I am trying to figure out a way to prevent other web sites from using the extension to send messages to the native host but can't find a way to do it.
Does anyone have an idea how I can accomplish that?
Any advice would be greatly appreciated, thanks.
Have you considered having the extension be limited to a specific domain, and then having the other domains iframe that domain and communicate via postMessage? You could have a whitelist of domains in the JS of the iframe, and validate the message origin against that list.

Can a Chrome extension launch new Chrome windows under different user profiles?

Is there an API for a Chrome extension to launch and control new Chrome windows under different user profiles?
My understanding is that while an extension may be run under multiple user profiles simultaneously, these instances are isolated; they cannot communicate directly and an extension in one profile cannot access the windows/tabs/processes/etc of another profile. Is this the case?
It seems like the best way to launch and control Chrome windows under multiple profiles is to use an approach based on the Remote Debugger API such as the ChromeDriver project.
For context, I'm interested in writing a tool to manage and launch predefined "bundles" of multiple Chrome windows, each with different URLs and screen positions, and each under a different profiles. The attached screenshot shows an example desired state: three browsers, each in a separate profile, each at a different URL, with different devtools states, organized in a specific screen layout. It is conceptually similar to tmuxinator.
If I wanted to provide a Chrome-based UI for designing and managing these presaved layouts, it seems that I would need to provide a native shim that invokes new Chromes via chromedriver, and communicate with them via native messaging. Is there a more direct API that I am missing?
It seems that the proposed Profile Extension API would do exactly what I'm interested in, but I don't see any discussion on the apps-dev#chromium.org list.
If chrome allowed this it would be a huge security hole.
Chrome extensions are installed per user account so they shouldnt be able to see anything from other accounts.

Lauch external program in firefox or chrome

We have a custom web app in our intranet that allow users to browse and search our shared file system in a way more appropriate for our organization. as compared to windows explorer/mac finder. However, when the users click on, for example, a link pointing to a word document the document is downloaded by the browser and then opened. I am trying to provide a better way, namely that the file is opened directly from the shared folder that each user has mapped in his own computer. This will make things faster and will not pollute the browser download folder.
I was planning to create a chrome or firefox extension that recognizes certain css class attached to a link, remaps the link to the shared file system and and launch an external process. Any idea how to achieve this? Is there a better solution?
If you want the URL to be handled by a custom program you could create special URLs using a custom Protocol (ex: MyApp:// instead of http://) and then register that protocol to be opened via a custom program. The links would only work on computers that have your program installed and where the protocol has been registered to be handled by your application.

Resources