Skip to content

WIP: installUrl; addon listeners #525

Closed
wants to merge 1 commit into from

4 participants

@gregglind
Mozilla member
  1. stubs for listerner for all addon install events
  2. method for installUrl

TODO:

  1. should these promises resolve with the aAddon, or aAddon.id?
  2. can we trigger the doorhanger ui?
@gregglind gregglind WIP: installUrl; addon listeners
1.  stubs for listerner for all addon install events
2.  method for installUrl

TODO:

1.  should these promises resolve with the aAddon, or aAddon.id?
2.  can we trigger the doorhanger ui?
50c419a
@ochameau ochameau commented on the diff Aug 21, 2012
packages/api-utils/lib/addon/installer.js
@@ -18,6 +30,57 @@ exports.ERROR_CORRUPT_FILE = AddonManager.ERROR_CORRUPT_FILE;
exports.ERROR_FILE_ACCESS = AddonManager.ERROR_FILE_ACCESS;
/**
+ * `install` listener events
+ *
+ * https://developer.mozilla.org/en-US/docs/Addons/Add-on_Manager/InstallListener
+ */
+
+// Listen for various install events. Using a class here is possibly overkill.
+// see git history for when this was a simpler object.
@ochameau
Mozilla member
ochameau added a note Aug 21, 2012

Yes, looks overkill to me.

@gregglind
Mozilla member
gregglind added a note Aug 23, 2012

I am not sure how else to the Listener here without making a class for it. Ideas welcome.

@ochameau
Mozilla member
ochameau added a note Aug 23, 2012

Any standard JS way of doing, like this:

function Listener(defer) {

  return {
    onInstallEnded: function () {
      ... defer.resolve  ...
    },
    ...
  };
}

Or with prototype.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ochameau ochameau commented on the diff Aug 21, 2012
packages/api-utils/lib/addon/installer.js
@@ -68,6 +118,30 @@ exports.install = function install(xpiPath) {
return promise;
};
+
+exports.install = exports.installFile;
+
+exports.installUrl = function installUrl(url,hash,mimetype){
+ let { promise, resolve, reject } = defer();
+
+ if (mimetype === undefined) {mimetype = "application/x-xpinstall"};
+ if (hash === undefined) {hash = ""};
+
+ // TODO, should we download the file ourselves, then go with file?
@ochameau
Mozilla member
ochameau added a note Aug 21, 2012

It seems fine to use AddonManager.getInstallForURL here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ochameau
Mozilla member

It is ok to change the resolution from id to addon if it can help your usage.
But please modify unit test. And it would be really cool to have your new method tested!

@Gozala Gozala commented on the diff Sep 13, 2012
packages/api-utils/lib/addon/installer.js
const { Cc, Ci, Cu } = require("chrome");
const { AddonManager } = Cu.import("resource://gre/modules/AddonManager.jsm");
const { defer } = require("api-utils/promise");
const { setTimeout } = require("api-utils/timer");
+const { Class, mix } = require('api-utils/heritage');
@Gozala
Mozilla member
Gozala added a note Sep 13, 2012

mix is not used, no need to import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Gozala
Mozilla member
Gozala commented Oct 3, 2012

@ochameau @gregglind what's a plan for this change. Do you still intend on implementing such a change ? If not please close a pull request.

@KWierso KWierso closed this Dec 13, 2012
@Gozala
Mozilla member
Gozala commented Dec 13, 2012

Feel free to reopen if you still find it to be relevant

@gregglind gregglind referenced this pull request in mozilla/testpilot2 Mar 28, 2013
Closed

Use the jetpack addon/installer.js once it lands #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.