Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if Chrome extension has fully installed

Using Chrome Web Store inline installation ( https://developers.google.com/chrome/web-store/docs/inline_installation ) it is possible to specify a callback for chrome.webstore.install() that will be executed when the extension is successfully installed.

Through some very tedious debugging I've learned that extensions are not neccessarily 100% installed when the callback is executed - maybe the background hasn't been loaded or content scripts aren't yet available.

In my particular case the problem presents itself in this way:

  1. User clicks install button with chrome.webstore.install() bound to onclick event.
  2. Success callback injects an iFrame.
  3. Content script is defined for the iFrame and injected to do some finishing work
  4. Content script returns with a completed installation dialog.

Step 3 is the problem. Some times the iFrame will be injected before content script is fully loaded and thus no script will be injected (content scripts are only injected inside newly created iFrames, not iFrames already existing when the extension is installed/enabled).

I know there are possible workarounds such as having the extension itself inject the iFrame or a simple setTimeout(), but for the sake of helping others I think it's worth asking the question:

How can I be certain that the extension is 100% installed, when the chrome.webstore.install() callback doesn't ensure it?

Using the famous <img> load method described in Checking if user has a certain extension installed doesn't work reliably (for those thinking that'd be a solution).

like image 388
Woodgnome Avatar asked Aug 21 '12 08:08

Woodgnome


People also ask

How do I see all my browser extensions?

Click the three stacked dots in the upper right corner of the toolbar > More Tools > Extensions. Or, in the menu bar, go to Window > Extensions. Or, right-click on any extension icon in your toolbar and choose Manage Extensions.


1 Answers

This is the way to do it :

http://code.google.com/chrome/extensions/extension.html#global-events

As mentioned in the last link below , you should be able to do :

var myPort=chrome.extension.connect('yourextensionid_qwerqweroijwefoijwef', some_object_to_send_on_connect);

You can also check Checking if an item is already installed section in the next link :

https://developers.google.com/chrome/web-store/docs/inline_installation

or you can follow what have been done in this post:

Check whether user has a Chrome extension installed

I also saw solutions talking about background page and localstorage:

http://developer.chrome.com/extensions/background_pages.html

Chrome extension post-install hook/API function: does it exist?

like image 88
Mehdi Karamosly Avatar answered Nov 15 '22 21:11

Mehdi Karamosly