зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1423687 - show warning in about:debugging when loading a temporary legacy extension;r=aswan,pbro
MozReview-Commit-ID: I9U5zzwZCSj --HG-- extra : rebase_source : 72a8141a50d4420910a6e1051a56b38579ec14e8
This commit is contained in:
Родитель
2c43d71711
Коммит
38f14b6373
|
@ -9,8 +9,14 @@
|
|||
const { Component } = require("devtools/client/shared/vendor/react");
|
||||
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
|
||||
const dom = require("devtools/client/shared/vendor/react-dom-factories");
|
||||
const { debugLocalAddon, debugRemoteAddon, isTemporaryID, parseFileUri, uninstallAddon } =
|
||||
require("../../modules/addon");
|
||||
const {
|
||||
debugLocalAddon,
|
||||
debugRemoteAddon,
|
||||
isLegacyTemporaryExtension,
|
||||
isTemporaryID,
|
||||
parseFileUri,
|
||||
uninstallAddon
|
||||
} = require("../../modules/addon");
|
||||
const Services = require("Services");
|
||||
|
||||
loader.lazyImporter(this, "BrowserToolboxProcess",
|
||||
|
@ -24,6 +30,7 @@ const Strings = Services.strings.createBundle(
|
|||
|
||||
const TEMP_ID_URL = "https://developer.mozilla.org/Add-ons" +
|
||||
"/WebExtensions/WebExtensions_and_the_Add-on_ID";
|
||||
const LEGACY_WARNING_URL = "https://wiki.mozilla.org/Add-ons/Future_of_Bootstrap";
|
||||
|
||||
function filePathForTarget(target) {
|
||||
// Only show file system paths, and only for temporarily installed add-ons.
|
||||
|
@ -90,7 +97,7 @@ function internalIDForTarget(target) {
|
|||
|
||||
function showMessages(target) {
|
||||
const messages = [
|
||||
...warningMessages(target.warnings),
|
||||
...warningMessages(target),
|
||||
...infoMessages(target),
|
||||
];
|
||||
if (messages.length > 0) {
|
||||
|
@ -112,15 +119,37 @@ function infoMessages(target) {
|
|||
Strings.GetStringFromName("temporaryID.learnMore")
|
||||
)));
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
function warningMessages(warnings = []) {
|
||||
return warnings.map((warning) => {
|
||||
function warningMessages(target) {
|
||||
let messages = [];
|
||||
|
||||
if (isLegacyTemporaryExtension(target.form)) {
|
||||
messages.push(dom.li(
|
||||
{
|
||||
className: "addon-target-warning-message addon-target-message"
|
||||
},
|
||||
Strings.GetStringFromName("legacyExtensionWarning"),
|
||||
" ",
|
||||
dom.a(
|
||||
{
|
||||
href: LEGACY_WARNING_URL,
|
||||
target: "_blank"
|
||||
},
|
||||
Strings.GetStringFromName("legacyExtensionWarning.learnMore"))
|
||||
));
|
||||
}
|
||||
|
||||
let warnings = target.warnings || [];
|
||||
messages = messages.concat(warnings.map((warning) => {
|
||||
return dom.li(
|
||||
{ className: "addon-target-warning-message addon-target-message" },
|
||||
warning);
|
||||
});
|
||||
}));
|
||||
|
||||
return messages;
|
||||
}
|
||||
|
||||
class AddonTarget extends Component {
|
||||
|
|
|
@ -81,6 +81,19 @@ exports.isTemporaryID = function (addonID) {
|
|||
return AddonManagerPrivate.isTemporaryInstallID(addonID);
|
||||
};
|
||||
|
||||
exports.isLegacyTemporaryExtension = function (addonForm) {
|
||||
if (!addonForm.type) {
|
||||
// If about:debugging is connected to an older then 59 remote Firefox, and type is
|
||||
// not available on the addon/webextension actors, return false to avoid showing
|
||||
// irrelevant warning messages.
|
||||
return false;
|
||||
}
|
||||
return addonForm.type == "extension" &&
|
||||
addonForm.temporarilyInstalled &&
|
||||
!addonForm.isWebExtension &&
|
||||
!addonForm.isAPIExtension;
|
||||
};
|
||||
|
||||
exports.parseFileUri = function (url) {
|
||||
// Strip a leading slash from Windows drive letter URIs.
|
||||
// file:///home/foo ~> /home/foo
|
||||
|
|
|
@ -106,6 +106,15 @@ temporaryID = This WebExtension has a temporary ID.
|
|||
# the user to MDN.
|
||||
temporaryID.learnMore = Learn more
|
||||
|
||||
# LOCALIZATION NOTE (legacyExtensionWarning):
|
||||
# This string is displayed as a warning message when loading a temporary legacy extension.
|
||||
legacyExtensionWarning = This is a legacy extension, be aware that these are no longer fully supported. Please read the linked documentation and then proceed with caution.
|
||||
|
||||
# LOCALIZATION NOTE (temporaryID.learnMore):
|
||||
# This string is displayed as a link next to the legacyExtensionWarning message and leads
|
||||
# the user to https://wiki.mozilla.org/Add-ons/Future_of_Bootstrap.
|
||||
legacyExtensionWarning.learnMore = Learn more
|
||||
|
||||
# LOCALIZATION NOTE (selectAddonFromFile2):
|
||||
# This string is displayed as the title of the file picker that appears when
|
||||
# the user clicks the 'Load Temporary Add-on' button
|
||||
|
|
|
@ -85,6 +85,9 @@ BrowserAddonActor.prototype = {
|
|||
iconURL: this._addon.iconURL,
|
||||
debuggable: this._addon.isDebuggable,
|
||||
temporarilyInstalled: this._addon.temporarilyInstalled,
|
||||
type: this._addon.type,
|
||||
isWebExtension: this._addon.isWebExtension,
|
||||
isAPIExtension: this._addon.isAPIExtension,
|
||||
consoleActor: this._consoleActor.actorID,
|
||||
|
||||
traits: {
|
||||
|
|
|
@ -73,7 +73,9 @@ const WebExtensionParentActor = protocol.ActorClassWithSpec(webExtensionSpec, {
|
|||
iconURL: this.addon.iconURL,
|
||||
debuggable: this.addon.isDebuggable,
|
||||
temporarilyInstalled: this.addon.temporarilyInstalled,
|
||||
isWebExtension: true,
|
||||
type: this.addon.type,
|
||||
isWebExtension: this.addon.isWebExtension,
|
||||
isAPIExtension: this.addon.isAPIExtension,
|
||||
manifestURL: policy && policy.getURL("manifest.json"),
|
||||
warnings: ExtensionParent.DebugUtils.getExtensionManifestWarnings(this.id),
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче