Bug 595810 Part 6e: addon notification doorhanger implementation r=Ian
This commit is contained in:
Родитель
cb7fcf3a2d
Коммит
520a0ec505
|
@ -69,6 +69,7 @@ panel[for="urlbar"] {
|
||||||
}
|
}
|
||||||
|
|
||||||
#notification-popup-box[anchorid="geo-notification-icon"] > #geo-notification-icon,
|
#notification-popup-box[anchorid="geo-notification-icon"] > #geo-notification-icon,
|
||||||
|
#notification-popup-box[anchorid="addons-notification-icon"] > #addons-notification-icon,
|
||||||
#notification-popup-box[anchorid="password-notification-icon"] > #password-notification-icon {
|
#notification-popup-box[anchorid="password-notification-icon"] > #password-notification-icon {
|
||||||
display: -moz-box;
|
display: -moz-box;
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,6 +315,7 @@
|
||||||
onclick="URLBarClickHandler(event);">
|
onclick="URLBarClickHandler(event);">
|
||||||
<box id="notification-popup-box" hidden="true" align="center">
|
<box id="notification-popup-box" hidden="true" align="center">
|
||||||
<image id="geo-notification-icon" class="notification-anchor-icon" role="button"/>
|
<image id="geo-notification-icon" class="notification-anchor-icon" role="button"/>
|
||||||
|
<image id="addons-notification-icon" class="notification-anchor-icon" role="button"/>
|
||||||
<image id="password-notification-icon" class="notification-anchor-icon" role="button"/>
|
<image id="password-notification-icon" class="notification-anchor-icon" role="button"/>
|
||||||
</box>
|
</box>
|
||||||
<deck id="page-proxy-deck"
|
<deck id="page-proxy-deck"
|
||||||
|
|
|
@ -956,6 +956,181 @@
|
||||||
]]>
|
]]>
|
||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
|
<method name="addonInstallBlocked">
|
||||||
|
<parameter name="installInfo"/>
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
var host;
|
||||||
|
try {
|
||||||
|
// this fails with nsSimpleURIs like data: URIs
|
||||||
|
host = installInfo.originatingURI.host;
|
||||||
|
} catch (ex) {
|
||||||
|
host = this._stringBundle.GetStringFromName("xpinstallHostNotAvailable");
|
||||||
|
}
|
||||||
|
var brandShortName = this._brandStringBundle.GetStringFromName("brandShortName");
|
||||||
|
var messageString = this._stringBundle.formatStringFromName("xpinstallPromptWarning",
|
||||||
|
[brandShortName, host], 2);
|
||||||
|
var action = {
|
||||||
|
label: this._stringBundle.GetStringFromName("xpinstallPromptInstallButton"),
|
||||||
|
accessKey: this._stringBundle.GetStringFromName("xpinstallPromptInstallButton.accesskey"),
|
||||||
|
callback: function allowInstall() {
|
||||||
|
installInfo.install();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Make notifications persist a minimum of 30 seconds
|
||||||
|
var options = {
|
||||||
|
timeout: Date.now() + 30000
|
||||||
|
};
|
||||||
|
PopupNotifications.show(this.activeBrowser,
|
||||||
|
"addon-install-blocked", messageString,
|
||||||
|
"addons-notification-icon", action,
|
||||||
|
null, options);
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<method name="addonInstallComplete">
|
||||||
|
<parameter name="installInfo"/>
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
var tmp = {};
|
||||||
|
Components.utils.import("resource://gre/modules/AddonManager.jsm", tmp);
|
||||||
|
Components.utils.import("resource://gre/modules/PluralForm.jsm", tmp);
|
||||||
|
|
||||||
|
var messageString;
|
||||||
|
var mainAction = null;
|
||||||
|
var secondaryActions = null;
|
||||||
|
|
||||||
|
if ("toEM" in window) {
|
||||||
|
mainAction = {
|
||||||
|
label: this._stringBundle.GetStringFromName("addonInstallManageButton"),
|
||||||
|
accessKey: this._stringBundle.GetStringFromName("addonInstallManageButton.accesskey"),
|
||||||
|
callback: function() {
|
||||||
|
window.toEM("addons://list/extension");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (installInfo.installs.some(function(install)
|
||||||
|
install.addon.pendingOperations &
|
||||||
|
tmp.AddonManager.PENDING_INSTALL)) {
|
||||||
|
messageString = this._stringBundle.GetStringFromName("addonsInstalledNeedsRestart");
|
||||||
|
if (mainAction)
|
||||||
|
secondaryActions = [mainAction];
|
||||||
|
mainAction = {
|
||||||
|
label: this._stringBundle.GetStringFromName("addonInstallRestartButton"),
|
||||||
|
accessKey: this._stringBundle.GetStringFromName("addonInstallRestartButton.accesskey"),
|
||||||
|
callback: function () {
|
||||||
|
Application.restart();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
messageString = this._stringBundle.GetStringFromName("addonsInstalled");
|
||||||
|
}
|
||||||
|
|
||||||
|
var brandShortName = this._brandStringBundle.GetStringFromName("brandShortName");
|
||||||
|
messageString = tmp.PluralForm.get(installInfo.installs.length, messageString)
|
||||||
|
.replace("#1", installInfo.installs[0].name)
|
||||||
|
.replace("#2", installInfo.installs.length)
|
||||||
|
.replace("#3", brandShortName);
|
||||||
|
|
||||||
|
// Make notifications persist a minimum of 30 seconds
|
||||||
|
var options = {
|
||||||
|
timeout: Date.now() + 30000
|
||||||
|
};
|
||||||
|
PopupNotifications.show(this.activeBrowser,
|
||||||
|
"addon-install-complete", messageString,
|
||||||
|
"addons-notification-icon", mainAction,
|
||||||
|
secondaryActions, options);
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<method name="addonInstallDisabled">
|
||||||
|
<parameter name="installInfo"/>
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
var messageString;
|
||||||
|
var action = null;
|
||||||
|
var prefBranch = this._prefs; // used by editPrefs callback
|
||||||
|
|
||||||
|
if (prefBranch.prefIsLocked("xpinstall.enabled"))
|
||||||
|
messageString = this._stringBundle.GetStringFromName("xpinstallDisabledMessageLocked");
|
||||||
|
else {
|
||||||
|
messageString = this._stringBundle.GetStringFromName("xpinstallDisabledMessage");
|
||||||
|
action = {
|
||||||
|
label: this._stringBundle.GetStringFromName("xpinstallDisabledButton"),
|
||||||
|
accessKey: this._stringBundle.GetStringFromName("xpinstallDisabledButton.accesskey"),
|
||||||
|
callback: function editPrefs() {
|
||||||
|
prefBranch.setBoolPref("xpinstall.enabled", true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make notifications persist a minimum of 30 seconds
|
||||||
|
var options = {
|
||||||
|
timeout: Date.now() + 30000
|
||||||
|
};
|
||||||
|
PopupNotifications.show(this.activeBrowser,
|
||||||
|
"addon-install-disabled", messageString,
|
||||||
|
"addons-notification-icon", action,
|
||||||
|
null, options);
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
|
||||||
|
<method name="addonInstallFailed">
|
||||||
|
<parameter name="installInfo"/>
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
var host;
|
||||||
|
try {
|
||||||
|
// this fails with nsSimpleURIs like data: URIs
|
||||||
|
host = installInfo.originatingURI.host;
|
||||||
|
} catch (ex) {
|
||||||
|
host = this._stringBundle.GetStringFromName("xpinstallHostNotAvailable");
|
||||||
|
}
|
||||||
|
|
||||||
|
var error = "addonErrorIncompatible";
|
||||||
|
var name = installInfo.installs[0].name;
|
||||||
|
installInfo.installs.some(function(install) {
|
||||||
|
if (install.error) {
|
||||||
|
name = install.name;
|
||||||
|
error = "addonError" + install.error;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (install.addon.blocklistState ==
|
||||||
|
Components.interfaces.nsIBlocklistService.STATE_BLOCKED) {
|
||||||
|
name = install.name;
|
||||||
|
error = "addonErrorBlocklisted";
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
var brandShortName = this._brandStringBundle.GetStringFromName("brandShortName");
|
||||||
|
var version = Components.classes["@mozilla.org/xre/app-info;1"]
|
||||||
|
.getService(Components.interfaces.nsIXULAppInfo).version;
|
||||||
|
var messageString = this._stringBundle.GetStringFromName(error)
|
||||||
|
.replace("#1", name)
|
||||||
|
.replace("#2", host)
|
||||||
|
.replace("#3", brandShortName)
|
||||||
|
.replace("#4", version);
|
||||||
|
|
||||||
|
// Make notifications persist a minimum of 30 seconds
|
||||||
|
var options = {
|
||||||
|
timeout: Date.now() + 30000
|
||||||
|
};
|
||||||
|
PopupNotifications.show(this.activeBrowser,
|
||||||
|
"addon-install-failed", messageString,
|
||||||
|
"addons-notification-icon", null,
|
||||||
|
null, options);
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
|
||||||
</implementation>
|
</implementation>
|
||||||
</binding>
|
</binding>
|
||||||
|
|
||||||
|
|
|
@ -295,6 +295,15 @@ toolbar[mode="text"] > #window-controls > toolbarbutton > .toolbarbutton-icon {
|
||||||
list-style-image: url("chrome://communicator/skin/icons/geolocation-64.png");
|
list-style-image: url("chrome://communicator/skin/icons/geolocation-64.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.popup-notification-icon[popupid="addon-install-disabled"],
|
||||||
|
.popup-notification-icon[popupid="addon-install-blocked"],
|
||||||
|
.popup-notification-icon[popupid="addon-install-failed"],
|
||||||
|
.popup-notification-icon[popupid="addon-install-complete"] {
|
||||||
|
list-style-image: url("chrome://mozapps/skin/extensions/extensionGeneric.png");
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
.popup-notification-icon[popupid="password-save"] {
|
.popup-notification-icon[popupid="password-save"] {
|
||||||
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-64.png");
|
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-64.png");
|
||||||
}
|
}
|
||||||
|
@ -315,6 +324,12 @@ toolbar[mode="text"] > #window-controls > toolbarbutton > .toolbarbutton-icon {
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#addons-notification-icon {
|
||||||
|
list-style-image: url("chrome://mozapps/skin/extensions/extensionGeneric-16.png");
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
#password-notification-icon {
|
#password-notification-icon {
|
||||||
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-16.png");
|
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-16.png");
|
||||||
width: 16px;
|
width: 16px;
|
||||||
|
|
|
@ -350,6 +350,15 @@ toolbar[mode="text"] > #window-controls > toolbarbutton > .toolbarbutton-icon {
|
||||||
list-style-image: url("chrome://communicator/skin/icons/geolocation-64.png");
|
list-style-image: url("chrome://communicator/skin/icons/geolocation-64.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.popup-notification-icon[popupid="addon-install-disabled"],
|
||||||
|
.popup-notification-icon[popupid="addon-install-blocked"],
|
||||||
|
.popup-notification-icon[popupid="addon-install-failed"],
|
||||||
|
.popup-notification-icon[popupid="addon-install-complete"] {
|
||||||
|
list-style-image: url("chrome://mozapps/skin/extensions/extensionGeneric.png");
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
.popup-notification-icon[popupid="password-save"] {
|
.popup-notification-icon[popupid="password-save"] {
|
||||||
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-64.png");
|
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-64.png");
|
||||||
}
|
}
|
||||||
|
@ -369,6 +378,12 @@ toolbar[mode="text"] > #window-controls > toolbarbutton > .toolbarbutton-icon {
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#addons-notification-icon {
|
||||||
|
list-style-image: url("chrome://mozapps/skin/extensions/extensionGeneric-16.png");
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
#password-notification-icon {
|
#password-notification-icon {
|
||||||
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-16.png");
|
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-16.png");
|
||||||
width: 16px;
|
width: 16px;
|
||||||
|
|
|
@ -525,6 +525,15 @@ toolbar[mode="icons"] #search-button > .button-box > .button-text {
|
||||||
list-style-image: url("chrome://communicator/skin/icons/geolocation-64.png");
|
list-style-image: url("chrome://communicator/skin/icons/geolocation-64.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.popup-notification-icon[popupid="addon-install-disabled"],
|
||||||
|
.popup-notification-icon[popupid="addon-install-blocked"],
|
||||||
|
.popup-notification-icon[popupid="addon-install-failed"],
|
||||||
|
.popup-notification-icon[popupid="addon-install-complete"] {
|
||||||
|
list-style-image: url("chrome://mozapps/skin/extensions/extensionGeneric.png");
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
.popup-notification-icon[popupid="password-save"] {
|
.popup-notification-icon[popupid="password-save"] {
|
||||||
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-64.png");
|
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-64.png");
|
||||||
}
|
}
|
||||||
|
@ -544,6 +553,12 @@ toolbar[mode="icons"] #search-button > .button-box > .button-text {
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#addons-notification-icon {
|
||||||
|
list-style-image: url("chrome://mozapps/skin/extensions/extensionGeneric-16.png");
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
#password-notification-icon {
|
#password-notification-icon {
|
||||||
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-16.png");
|
list-style-image: url("chrome://mozapps/skin/passwordmgr/key-16.png");
|
||||||
width: 16px;
|
width: 16px;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче