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

强颜欢笑 提交于 2019-11-30 07:34:21

[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.

There is an easier way... When the checkbox is clicked, run this code from the background page:

chrome.tabs.create({ url:"FILEPATH.crx" } );

The intended extension you want to install, (.crx file) can either be hosted on the net or can be inside your original extension folder... You will need tabs permission in your manifest

"Windows application developers should ask users to install Chrome extensions from within Chrome. A great way to allow users to install a Chrome extension related to your Windows application is to link users to your website and use inline installation."

also see full blog post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!