Rahul Gulati
Rahul Gulati

Reputation: 363

How to install a Chrome extension programmatically?

I've written an extension for Google Chrome that will be released with the next version of our product. I want to understand what properties, paths for extraction, registry entries, etc. should I provide the installer of my product so that the end user doesn't have to install the extension on their own manually, and the installer does the complete job of installing the extension, and also notifies the user that the extension has been installed. As of now, the code that I have written is placed in a folder, and I use the "Load Unpackaged Extension" to load the extension. What should I do to achieve the aforementioned task?

Upvotes: 20

Views: 17708

Answers (4)

xob0t
xob0t

Reputation: 11

Windows

I'm using Dark Reader for this example.

Local crx

Create a registry key with extension id and two properties within: path with string value of full path to to the crx file and version with string value of the version of the extension.

x64

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Google\Chrome\Extensions\eimadpbcbfnmbkopoojfekhnkhdbieeh]
"path"="C:\\Users\\admin\\Desktop\\Dark-Reader.crx"
"version"="4.9.83"

x32

[HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\Extensions\eimadpbcbfnmbkopoojfekhnkhdbieeh]
"path"="C:\\Users\\admin\\Desktop\\Dark-Reader.crx"
"version"="4.9.83"

Web Store

Create a registry key with extension id and update_url property within with the string value of the update url

x64

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Google\Chrome\Extensions\eimadpbcbfnmbkopoojfekhnkhdbieeh]
"update_url"="https://clients2.google.com/service/update2/crx"

x32

[HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\Extensions\eimadpbcbfnmbkopoojfekhnkhdbieeh]
"update_url"="https://clients2.google.com/service/update2/crx"

The current relevant docs for this problem are https://developer.chrome.com/docs/extensions/how-to/distribute/install-extensions and https://www.chromium.org/administrators/pre-installed-extensions/

Upvotes: 1

Scrooge McDuck
Scrooge McDuck

Reputation: 394

If you're using GNU/Linux, this is how you pre-install an extension from the chrome web store for all users:

/etc/chromium/policies/managed/yourextension_policy.json
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
{
    "ExtensionInstallForcelist": [
        "yourextensionuniqueidentifiersup;https://clients2.google.com/service/update2/crx",
        "yourextensionuniqueidentifiersup"
    ]
}

Reference

metamask-chrome - AUR

Upvotes: 1

gengkev
gengkev

Reputation: 1959

Chrome has a couple ways of installing extensions programmatically: http://www.chromium.org/administrators/pre-installed-extensions

Edit: yes, this policy has changed by now, as FuzzyAmi points out.

Upvotes: 7

FuzzyAmi
FuzzyAmi

Reputation: 8119

Google's current policy on installing extensions via the registry (for Windows machines) is this: Only extensions from the Google Extension Gallery (or Chrome Web Store - CWS) can be installed via the registry.

See this link - https://developer.chrome.com/extensions/external_extensions - for information on how this can be done. Keep in mind the following:

-This technique will still pop-up a msgbox to the user. its not completely silent.

-When using this technique, if the user subsequently removes the extension from her Chrome, the extension gets "blacklisted" on that chrome and will not re-auto-install until the user re-install it manually. refer to Auto-installing a google chrome extension won't work ! for details.

Upvotes: 17

Related Questions