From e8d50a8258b5b6e65f51f220ca71565920615907 Mon Sep 17 00:00:00 2001 From: diegocr Date: Sun, 23 Feb 2014 07:17:53 +0100 Subject: [PATCH] New 'Native Popup' notification method, closes #8 and fixes #7 --- bootstrap.js | 22 ++++++++++++++++++---- install.rdf | 3 ++- options.xul | 1 + 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index d25b182..3fa21dc 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -15,6 +15,7 @@ Cu.import("resource://gre/modules/NetUtil.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/FileUtils.jsm"); Cu.import("resource://gre/modules/AddonManager.jsm"); +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); function LOG(m) (m = addon.name + ' Message @ ' + (new Date()).toISOString() + "\n> " + m, @@ -39,10 +40,23 @@ let i$ = { let showAlertNotification = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService); showAlertNotification = showAlertNotification.showAlertNotification.bind(showAlertNotification); -function iNotify(aMsg, callback) { +function iNotify(aAddon, aMsg, callback) { let nme = addon.branch.getIntPref('nme'); - if(nme == 2) { + if(nme > 1) { + if(nme == 3) try { + if(aAddon) { + let info = { + installs: [{addon:aAddon,name:aAddon.name + ' ' + aAddon.version}], + originatingWindow: Services.wm.getMostRecentWindow('navigator:browser').gBrowser.contentWindow, + QueryInterface: XPCOMUtils.generateQI([Ci.amIWebInstallInfo]) + }; + Services.obs.notifyObservers(info, 'addon-install-complete', null); + return callback(null); + } + } catch(e) { + Cu.reportError(e); + } showAlertNotification(addon.icon,addon.name,aMsg,!1,"", (s,t) => t == "alertshow" || callback(t)); } else { @@ -136,10 +150,10 @@ function onClickHanlder(ev) { } f.style.animation = null; f.className = f.className.replace('hourglass',c); - iNotify(aMsg, () => { + iNotify(aAddon, aMsg, aResult => { oFile.remove(!1); - if(aAddon && aAddon.pendingOperations) { + if(aResult !== null && aAddon && aAddon.pendingOperations) { let m = aAddon.name + ' requires restart.\n\n' + 'Would you like to restart ' + Services.appinfo.name + ' now?'; diff --git a/install.rdf b/install.rdf index 14d0744..8ec88f5 100644 --- a/install.rdf +++ b/install.rdf @@ -4,9 +4,10 @@ {86054B0A-BD85-42F9-8E58-8794EC6F6EA1} 2 GitHub Extension Installer - 1.5a1 + 1.5a2 Diego Casorran <dcasorran@gmail.com> Install Browser Extensions straight from GitHub Repositories + Jerone Zulkarnain K. true diff --git a/options.xul b/options.xul index ccfb330..d514d6d 100644 --- a/options.xul +++ b/options.xul @@ -6,6 +6,7 @@ +