Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Version from extension #7

Closed
jawandarajbir opened this issue Dec 15, 2014 · 5 comments
Closed

Get Version from extension #7

jawandarajbir opened this issue Dec 15, 2014 · 5 comments

Comments

@jawandarajbir
Copy link

We need a way for web page to determine the installed extension version number so that it can prompt user to update extension if required.

@DamonOehlman
Copy link
Member

Sure thing. My thoughts on this are that one of the options that should be expressed in the screenshare options is the required extension version string. I'm thinking this should be expressed as a semver (or semver-like) version string, e.g. ^1.0.0

In terms of doing this, we have a couple of node packages that are available to help us do this:

  1. node-semver
  2. slimver

slimver is my own creation (see http://slimver.org/) but I'm not wedded to using it in this instance. Primarily the advantage of using it is that the resulting code (which will be in the clientside code of the extension) will be smaller. The main disadvantage is that you aren't able to express more complicated version range expressions that are supported in node-semver, e.g. 1.x || >=2.5.0 || 5.0.0 - 7.2.3

Let me know what works best for you guys and I'll go with that :)

@jawandarajbir
Copy link
Author

That's perfect. We are happy to use slimver :)
I think, we should add following functions in rtc-screenshare.

isExtensionInstalled() // returns true if extension is found in chrome.
isExtensionEnabled() // returns true if extension is installed and enabled(responding)
getExtensionVersion() // returns the version string
isMinimumVersionMet(minVersion) // returns true if installed version is above provided minVersion

@DamonOehlman
Copy link
Member

Sure thing, we can have functions like this, but they will have to be asynchronous. I'd propose the following:

screenshare.getExtensionInfo(function(err, data) {
  // handle errors, i.e. if the plugin is not installed an error will be raised
  if (err && err.code === 'EXTENSION_UNAVAILABLE') {
     return launchExtensionInstallProcess();
  }
  else if (err) {
     return console.error('Encountered error requesting extension info: ', err);
  }

  console.log('extension available, version: ' + data.version);
});

And the min version function would look something like:

screenshare.extensionVersionMatches('^2.2.0', function(err) {
  if (err) {
    console.error('screenshare extension not installed, or not compatible with requested version');
  }
});

Writing the function in this way would allow you to do something nice, using the async or kgo.

One thing I'm not sure about is how to provide info on how to check whether the extension is enabled, but I'll investigate that.

@jawandarajbir
Copy link
Author

Sure Damon, I like asynchronous approach.

I've done some the investigation with chrome extensions detection. Following approach works even if extension is disabled.

    var imgsrc = "chrome-extension://" + extensionId + "/icon48.png";

    var img;
    img = new Image();
    img.src = imgsrc;
    img.onload = function () {
        isExtensionInstalled = true;
    };
    img.onerror = function () {
        isExtensionInstalled = false;
    };

If the extension is disabled, it won't listen to request message from webpage and hence won't respond, so its easy to detect if extension is enabled or disabled.

@DamonOehlman
Copy link
Member

Implemented in 3.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants