Skip to content

Commit e8d50a8

Browse files
committed
New 'Native Popup' notification method, closes #8 and fixes #7
1 parent cec1418 commit e8d50a8

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

bootstrap.js

+18-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Cu.import("resource://gre/modules/NetUtil.jsm");
1515
Cu.import("resource://gre/modules/Services.jsm");
1616
Cu.import("resource://gre/modules/FileUtils.jsm");
1717
Cu.import("resource://gre/modules/AddonManager.jsm");
18+
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
1819

1920
function LOG(m) (m = addon.name + ' Message @ '
2021
+ (new Date()).toISOString() + "\n> " + m,
@@ -39,10 +40,23 @@ let i$ = {
3940
let showAlertNotification = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
4041
showAlertNotification = showAlertNotification.showAlertNotification.bind(showAlertNotification);
4142

42-
function iNotify(aMsg, callback) {
43+
function iNotify(aAddon, aMsg, callback) {
4344
let nme = addon.branch.getIntPref('nme');
4445

45-
if(nme == 2) {
46+
if(nme > 1) {
47+
if(nme == 3) try {
48+
if(aAddon) {
49+
let info = {
50+
installs: [{addon:aAddon,name:aAddon.name + ' ' + aAddon.version}],
51+
originatingWindow: Services.wm.getMostRecentWindow('navigator:browser').gBrowser.contentWindow,
52+
QueryInterface: XPCOMUtils.generateQI([Ci.amIWebInstallInfo])
53+
};
54+
Services.obs.notifyObservers(info, 'addon-install-complete', null);
55+
return callback(null);
56+
}
57+
} catch(e) {
58+
Cu.reportError(e);
59+
}
4660
showAlertNotification(addon.icon,addon.name,aMsg,!1,"",
4761
(s,t) => t == "alertshow" || callback(t));
4862
} else {
@@ -136,10 +150,10 @@ function onClickHanlder(ev) {
136150
}
137151
f.style.animation = null;
138152
f.className = f.className.replace('hourglass',c);
139-
iNotify(aMsg, () => {
153+
iNotify(aAddon, aMsg, aResult => {
140154
oFile.remove(!1);
141155

142-
if(aAddon && aAddon.pendingOperations) {
156+
if(aResult !== null && aAddon && aAddon.pendingOperations) {
143157
let m = aAddon.name + ' requires restart.\n\n'
144158
+ 'Would you like to restart '
145159
+ Services.appinfo.name + ' now?';

install.rdf

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
<em:id>{86054B0A-BD85-42F9-8E58-8794EC6F6EA1}</em:id>
55
<em:type>2</em:type>
66
<em:name>GitHub Extension Installer</em:name>
7-
<em:version>1.5a1</em:version>
7+
<em:version>1.5a2</em:version>
88
<em:creator>Diego Casorran &lt;[email protected]&gt;</em:creator>
99
<em:description>Install Browser Extensions straight from GitHub Repositories</em:description>
10+
<em:contributor>Jerone</em:contributor>
1011
<em:contributor>Zulkarnain K.</em:contributor>
1112
<em:bootstrap>true</em:bootstrap>
1213
<em:targetApplication>

options.xul

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<menuitem value="0" label="None"/>
77
<menuitem value="1" label="Modal Dialog"/>
88
<menuitem value="2" label="Alerts Service"/>
9+
<menuitem value="3" label="Native Popup"/>
910
</menupopup>
1011
</menulist>
1112
</setting>

0 commit comments

Comments
 (0)