Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto-installing a google chrome extension won't work !

I am working on a job in relation with this page

  • http://code.google.com/chrome/extensions/external_extensions.html

I wrote a NSIS script that is trying to auto install a chrome extensions. (Why ? because our extension can be offered with another product installation flow through a checkbox, then if user select our extension to be added, it will auto-install on the user chrome browser using NSIS silent installation)

I tried a lot of scenario and I need help, on google website, they say you can do this

  • Using a preferences JSON file
  • Using the Windows registry

They also say that "Using a preferences file" has a bug (Windows note: Until bug 41902 is fixed, you might want to use the Windows registry instead of the preferences file.)

  • http://code.google.com/p/chromium/issues/detail?id=41902#makechanges

Reminder: An extension that's installed automatically is known as an external extension

  • So I tried "Using the Windows registry"

To add a google chrome extensions through registry:

  • add this key: "HKEY_LOCAL_MACHINE\SOFTWARE\Google\Chrome\Extensions(my extension id)"
  • add "path" with the path to a .crx
  • add "version" with the version of the extension

This is what I tried (using NSIS script):

  • If I Add a registry key It will install the extension, BUT if user uninstall manually, chrome turns the blacklist flag on and the extension can't be reinstalled with any other script. The only way left is that user installs, manually. Worst, if user install manually and uninstall manually (it will turn the blacklist flag off), and when chrome will be restarted, it will reinstall the extensions automatically (without any user action) since the registry key is still there.

  • If I remove the registry key when we start or close the browser, through a freaky way (using a dll(NPAPI) within the crx), chrome will auto-delete the extensions directory when browser restarts.

  • If I manage to delete the registry key when user uninstall the extension. We get blacklisted, so the auto-installer won't work anymore until user turn blacklist flag off by manually installing&uninstalling the extension.

  • If I create the directory in "C:\Users\(username)\AppData\Local\Google\Chrome\User Data\Default\Extensions\(extensionID)\(version)_0\(my files here)", I run into a lot of trouble because chrome will delete my files as soon as it restarts the browser.

Does anyone have run into this problem, and what has to be done. I will try with the JSON file but until bug isn't fixed, Registry is the only way.

Thank for anyone who had the time to read all this ! Any help will be appreciated, thanks!

like image 687
developerGuile Avatar asked Nov 05 '22 22:11

developerGuile


1 Answers

[2013-11-11]
[The answers to this question are about to become outdated, so here is a more up-to-date answer.]


According to a recent post on the Chromium Blog, auto-installing a Chrome Extension won't be an option in the near future:

Starting in January [2014] on the Windows stable and beta channels, we’ll require all extensions to be hosted in the Chrome Web Store.

As an alternative, developers and vendors will be able to use the inline installation feature:

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:

  1. Host your extension on the Chrome Web Store (optionaly keeping it hidden from the listings).
  2. Have your installer open a Chrome browser window pointing to a webpage on your site.
  3. 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.

like image 132
gkalpak Avatar answered Nov 11 '22 15:11

gkalpak