зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1308296 Show post-install notification r=florian
MozReview-Commit-ID: KenyFW6MyDO --HG-- extra : rebase_source : 08945555c40d131ee97fb927f7786fa2945f7943
This commit is contained in:
Родитель
cbaf11ddbe
Коммит
5686504fb6
|
@ -80,3 +80,10 @@
|
|||
<html:ul id="addon-webext-perm-list" class="addon-webext-perm-list"/>
|
||||
</popupnotificationcontent>
|
||||
</popupnotification>
|
||||
|
||||
<popupnotification id="addon-installed-notification" hidden="true">
|
||||
<popupnotificationcontent orient="vertical">
|
||||
<description id="addon-installed-notification-header"/>
|
||||
<description id="addon-installed-notification-message"/>
|
||||
</popupnotificationcontent>
|
||||
</popupnotification>
|
||||
|
|
|
@ -119,6 +119,20 @@ webextPerms.hostDescription.oneSite=Access your data for %S
|
|||
# hosts for which this webextension is requesting permission.
|
||||
webextPerms.hostDescription.tooManySites=Access your data on #1 other site;Access your data on #1 other sites
|
||||
|
||||
# LOCALIZATION NOTE (addonPostInstall.message)
|
||||
# %1$S is replaced with the localized named of the extension that was
|
||||
# just installed.
|
||||
# %2$S is replaced with the localized name of the application.
|
||||
addonPostInstall.message1=%1$S has been added to %2$S.
|
||||
|
||||
# LOCALIZATION NOTE (addonPostInstall.message2)
|
||||
# %1$S is replaced with the localized name of the extension.
|
||||
# %2$S is replaced with the icon for the add-ons menu.
|
||||
# %3$S is replaced with the icon for the toolbar menu.
|
||||
# Note, this string will be used as raw markup. Avoid characters like <, >, &
|
||||
addonPostInstall.message2=Manage %1$S by clicking %2$S in the %3$S menu.
|
||||
addonPostInstall.okay.label=OK
|
||||
addonPostInstall.okay.key=O
|
||||
|
||||
# LOCALIZATION NOTE (addonDownloadingAndVerifying):
|
||||
# Semicolon-separated list of plural forms. See:
|
||||
|
|
|
@ -22,7 +22,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "Services",
|
|||
XPCOMUtils.defineLazyPreferenceGetter(this, "WEBEXT_PERMISSION_PROMPTS",
|
||||
"extensions.webextPermissionPrompts", false);
|
||||
|
||||
const DEFAULT_EXENSION_ICON = "chrome://mozapps/skin/extensions/extensionGeneric.svg";
|
||||
const DEFAULT_EXTENSION_ICON = "chrome://mozapps/skin/extensions/extensionGeneric.svg";
|
||||
|
||||
const HTML_NS = "http://www.w3.org/1999/xhtml";
|
||||
|
||||
|
@ -33,6 +33,7 @@ this.ExtensionsUI = {
|
|||
init() {
|
||||
Services.obs.addObserver(this, "webextension-permission-prompt", false);
|
||||
Services.obs.addObserver(this, "webextension-update-permissions", false);
|
||||
Services.obs.addObserver(this, "webextension-install-notify", false);
|
||||
|
||||
this._checkForSideloaded();
|
||||
},
|
||||
|
@ -141,6 +142,9 @@ this.ExtensionsUI = {
|
|||
} else if (topic == "webextension-update-permissions") {
|
||||
this.updates.add(subject.wrappedJSObject);
|
||||
this.emit("change");
|
||||
} else if (topic == "webextension-install-notify") {
|
||||
let {target, addon} = subject.wrappedJSObject;
|
||||
this.showInstallNotification(target, addon);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -311,6 +315,47 @@ this.ExtensionsUI = {
|
|||
], popupOptions);
|
||||
});
|
||||
},
|
||||
|
||||
showInstallNotification(target, addon) {
|
||||
let win = target.ownerGlobal;
|
||||
let popups = win.PopupNotifications;
|
||||
|
||||
let addonLabel = `<label class="addon-webext-name">${addon.name}</label>`;
|
||||
let addonIcon = '<image class="addon-addon-icon"/>';
|
||||
let toolbarIcon = '<image class="addon-toolbar-icon"/>';
|
||||
|
||||
let brandBundle = win.document.getElementById("bundle_brand");
|
||||
let appName = brandBundle.getString("brandShortName");
|
||||
|
||||
let bundle = win.gNavigatorBundle;
|
||||
let msg1 = bundle.getFormattedString("addonPostInstall.message1",
|
||||
[addonLabel, appName]);
|
||||
let msg2 = bundle.getFormattedString("addonPostInstall.message2",
|
||||
[addonLabel, addonIcon, toolbarIcon]);
|
||||
|
||||
let action = {
|
||||
label: bundle.getString("addonPostInstall.okay.label"),
|
||||
accessKey: bundle.getString("addonPostInstall.okay.key"),
|
||||
callback: () => {},
|
||||
};
|
||||
|
||||
let options = {
|
||||
hideClose: true,
|
||||
popupIconURL: addon.iconURL || DEFAULT_EXTENSION_ICON,
|
||||
eventCallback(topic) {
|
||||
if (topic == "showing") {
|
||||
let doc = this.browser.ownerDocument;
|
||||
doc.getElementById("addon-installed-notification-header")
|
||||
.innerHTML = msg1;
|
||||
doc.getElementById("addon-installed-notification-message")
|
||||
.innerHTML = msg2;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
popups.show(target, "addon-installed", "", "addons-notification-icon",
|
||||
action, null, options);
|
||||
},
|
||||
};
|
||||
|
||||
EventEmitter.decorate(ExtensionsUI);
|
||||
|
|
|
@ -842,6 +842,20 @@ menuitem.bookmark-item {
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
.addon-addon-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
list-style-image: url("chrome://browser/skin/menuPanel.svg");
|
||||
-moz-image-region: rect(0px, 288px, 32px, 256px);
|
||||
}
|
||||
|
||||
.addon-toolbar-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
list-style-image: url("chrome://browser/skin/Toolbar.png");
|
||||
-moz-image-region: rect(0, 486px, 18px, 468px);
|
||||
}
|
||||
|
||||
/* Notification icon box */
|
||||
|
||||
.notification-anchor-icon:-moz-focusring {
|
||||
|
|
|
@ -3100,6 +3100,20 @@ menulist.translate-infobar-element > .menulist-dropmarker {
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
.addon-addon-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
list-style-image: url("chrome://browser/skin/menuPanel.svg");
|
||||
-moz-image-region: rect(0px, 288px, 32px, 256px);
|
||||
}
|
||||
|
||||
.addon-toolbar-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
list-style-image: url("chrome://browser/skin/Toolbar.png");
|
||||
-moz-image-region: rect(0, 486px, 18px, 468px);
|
||||
}
|
||||
|
||||
/* Status panel */
|
||||
|
||||
.statuspanel-label {
|
||||
|
|
|
@ -2145,6 +2145,20 @@ toolbarbutton.bookmark-item[dragover="true"][open="true"] {
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
.addon-addon-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
list-style-image: url("chrome://browser/skin/menuPanel.svg");
|
||||
-moz-image-region: rect(0px, 288px, 32px, 256px);
|
||||
}
|
||||
|
||||
.addon-toolbar-icon {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
list-style-image: url("chrome://browser/skin/Toolbar.png");
|
||||
-moz-image-region: rect(0, 486px, 18px, 468px);
|
||||
}
|
||||
|
||||
/* Notification icon box */
|
||||
|
||||
.notification-anchor-icon:-moz-focusring {
|
||||
|
|
|
@ -2109,7 +2109,13 @@ var AddonManagerInternal = {
|
|||
install.addon.appDisabled == false) {
|
||||
install.addon.userDisabled = false;
|
||||
}
|
||||
self.installNotifyObservers("addon-install-complete", browser, url, install);
|
||||
|
||||
if (WEBEXT_PERMISSION_PROMPTS) {
|
||||
let subject = {wrappedJSObject: {target: browser, addon: install.addon}};
|
||||
Services.obs.notifyObservers(subject, "webextension-install-notify", null);
|
||||
} else {
|
||||
self.installNotifyObservers("addon-install-complete", browser, url, install);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче