Bug 595810 Part 6b: break out addonInstallBlocked into its own method r=IanN
This commit is contained in:
Родитель
c49c76b8f4
Коммит
a21b99718b
|
@ -151,57 +151,8 @@
|
|||
switch (aTopic) {
|
||||
case "addon-install-blocked":
|
||||
var installInfo = aSubject.QueryInterface(Components.interfaces.amIWebInstallInfo);
|
||||
if (installInfo.originatingWindow.top != browser.contentWindow)
|
||||
return;
|
||||
|
||||
var notificationName, messageString, buttons, host;
|
||||
try {
|
||||
// this fails with nsSimpleURIs like data: URIs
|
||||
host = installInfo.originatingURI.host;
|
||||
} catch (ex) {
|
||||
host = this._stringBundle.GetStringFromName("xpinstallHostNotAvailable");
|
||||
}
|
||||
|
||||
if (!this._prefs.getBoolPref("xpinstall.enabled")) {
|
||||
notificationName = "xpinstall-disabled";
|
||||
if (this._prefs.prefIsLocked("xpinstall.enabled")) {
|
||||
messageString = this._stringBundle.GetStringFromName("xpinstallDisabledMessageLocked");
|
||||
buttons = [];
|
||||
} else {
|
||||
var prefBranch = this._prefs;
|
||||
messageString = this._stringBundle.GetStringFromName("xpinstallDisabledMessage");
|
||||
buttons = [{
|
||||
label: this._stringBundle.GetStringFromName("xpinstallDisabledButton"),
|
||||
accessKey: this._stringBundle.GetStringFromName("xpinstallDisabledButton.accesskey"),
|
||||
popup: null,
|
||||
callback: function editPrefs() {
|
||||
prefBranch.setBoolPref("xpinstall.enabled", true);
|
||||
return false;
|
||||
}
|
||||
}];
|
||||
}
|
||||
} else {
|
||||
notificationName = "xpinstall";
|
||||
var brandShortName = this._brandStringBundle.GetStringFromName("brandShortName");
|
||||
messageString = this._stringBundle.formatStringFromName("xpinstallPromptWarning",
|
||||
[brandShortName, host], 2);
|
||||
buttons = [{
|
||||
label: this._stringBundle.GetStringFromName("xpinstallPromptInstallButton"),
|
||||
accessKey: this._stringBundle.GetStringFromName("xpinstallPromptInstallButton.accesskey"),
|
||||
popup: null,
|
||||
callback: function allowInstall() {
|
||||
installInfo.install();
|
||||
return false;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
if (!this.getNotificationWithValue(notificationName)) {
|
||||
const priority = this.PRIORITY_WARNING_MEDIUM;
|
||||
const iconURL = "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png";
|
||||
this.appendNotification(messageString, notificationName,
|
||||
iconURL, priority, buttons);
|
||||
}
|
||||
if (installInfo.originatingWindow.top == browser.contentWindow)
|
||||
this.addonInstallBlocked(installInfo);
|
||||
break;
|
||||
|
||||
case "nsPref:changed":
|
||||
|
@ -465,6 +416,63 @@
|
|||
</body>
|
||||
</method>
|
||||
|
||||
<method name="addonInstallBlocked">
|
||||
<parameter name="installInfo"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var notificationName, messageString, buttons;
|
||||
var prefBranch = this._prefs; // used by editPrefs callback
|
||||
|
||||
if (!prefBranch.getBoolPref("xpinstall.enabled")) {
|
||||
notificationName = "xpinstall-disabled";
|
||||
if (prefBranch.prefIsLocked("xpinstall.enabled")) {
|
||||
messageString = this._stringBundle.GetStringFromName("xpinstallDisabledMessageLocked");
|
||||
buttons = [];
|
||||
} else {
|
||||
messageString = this._stringBundle.GetStringFromName("xpinstallDisabledMessage");
|
||||
buttons = [{
|
||||
label: this._stringBundle.GetStringFromName("xpinstallDisabledButton"),
|
||||
accessKey: this._stringBundle.GetStringFromName("xpinstallDisabledButton.accesskey"),
|
||||
popup: null,
|
||||
callback: function editPrefs() {
|
||||
prefBranch.setBoolPref("xpinstall.enabled", true);
|
||||
return false;
|
||||
}
|
||||
}];
|
||||
}
|
||||
} else {
|
||||
var host;
|
||||
try {
|
||||
// this fails with nsSimpleURIs like data: URIs
|
||||
host = installInfo.originatingURI.host;
|
||||
} catch (ex) {
|
||||
host = this._stringBundle.GetStringFromName("xpinstallHostNotAvailable");
|
||||
}
|
||||
notificationName = "xpinstall";
|
||||
var brandShortName = this._brandStringBundle.GetStringFromName("brandShortName");
|
||||
messageString = this._stringBundle.formatStringFromName("xpinstallPromptWarning",
|
||||
[brandShortName, host], 2);
|
||||
buttons = [{
|
||||
label: this._stringBundle.GetStringFromName("xpinstallPromptInstallButton"),
|
||||
accessKey: this._stringBundle.GetStringFromName("xpinstallPromptInstallButton.accesskey"),
|
||||
popup: null,
|
||||
callback: function allowInstall() {
|
||||
installInfo.install();
|
||||
return false;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
if (!this.getNotificationWithValue(notificationName)) {
|
||||
var priority = this.PRIORITY_WARNING_MEDIUM;
|
||||
var iconURL = "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png";
|
||||
this.appendNotification(messageString, notificationName,
|
||||
iconURL, priority, buttons);
|
||||
}
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
|
|
Загрузка…
Ссылка в новой задаче