Bug 1416074: Remove obsolete extensionNameFromURI helper. r?mixedpuppy
MozReview-Commit-ID: IzaqUZV03rG
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -10,20 +10,16 @@ var Cu = Components.utils;
var Cc = Components.classes;
var Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/NotificationDB.jsm");
-XPCOMUtils.defineLazyGetter(this, "extensionNameFromURI", () => {
- return Cu.import("resource://gre/modules/ExtensionParent.jsm", {}).extensionNameFromURI;
-});
-
// lazy module getters
XPCOMUtils.defineLazyModuleGetters(this, {
AboutHome: "resource:///modules/AboutHome.jsm",
BrowserUITelemetry: "resource:///modules/BrowserUITelemetry.jsm",
BrowserUsageTelemetry: "resource:///modules/BrowserUsageTelemetry.jsm",
BrowserUtils: "resource://gre/modules/BrowserUtils.jsm",
CharsetMenu: "resource://gre/modules/CharsetMenu.jsm",
@@ -7123,19 +7119,19 @@ var gIdentityHandler = {
*
* These URIs, like "about:" and "data:" URIs, will usually be treated as a
* non-secure connection, unless they refer to an internally implemented
* browser page or resolve to "file:" URIs.
*/
_uriHasHost: false,
/**
- * Whether this is a "moz-extension:" page, loaded from a WebExtension.
+ * If this tab belongs to a WebExtension, contains its WebExtensionPolicy.
*/
- _isExtensionPage: false,
+ _pageExtensionPolicy: null,
/**
* Whether this._uri refers to an internally implemented browser page.
*
* Note that this is set for some "about:" pages, but general "chrome:" URIs
* are not included in this category by default.
*/
_isSecureInternalUI: false,
@@ -7566,19 +7562,19 @@ var gIdentityHandler = {
// swap the positions of the organization and country code labels.
// The Unicode ranges reflect the definition of the UCS2_CHAR_IS_BIDI
// macro in intl/unicharutil/util/nsBidiUtils.h. When bug 218823 gets
// fixed, this test should be replaced by one adhering to the
// Unicode Bidirectional Algorithm proper (at the paragraph level).
icon_labels_dir = /^[\u0590-\u08ff\ufb1d-\ufdff\ufe70-\ufefc]/.test(icon_label) ?
"rtl" : "ltr";
}
- } else if (this._isExtensionPage) {
+ } else if (this._pageExtensionPolicy) {
this._identityBox.className = "extensionPage";
- let extensionName = extensionNameFromURI(this._uri);
+ let extensionName = this._pageExtensionPolicy.name;
icon_label = gNavigatorBundle.getFormattedString(
"identity.extension.label", [extensionName]);
} else if (this._uriHasHost && this._isSecure) {
this._identityBox.className = "verifiedDomain";
if (this._isMixedActiveContentBlocked) {
this._identityBox.classList.add("mixedActiveBlocked");
}
if (!this._isCertUserOverridden) {
@@ -7647,18 +7643,18 @@ var gIdentityHandler = {
gBrowser.selectedBrowser.blockedPopups.length) {
let icon = permissionAnchors.popup;
icon.setAttribute("showing", "true");
}
// Push the appropriate strings out to the UI
this._connectionIcon.setAttribute("tooltiptext", tooltip);
- if (this._isExtensionPage) {
- let extensionName = extensionNameFromURI(this._uri);
+ if (this._pageExtensionPolicy) {
+ let extensionName = this._pageExtensionPolicy.name;
this._extensionIcon.setAttribute("tooltiptext",
gNavigatorBundle.getFormattedString("identity.extension.tooltip", [extensionName]));
}
this._identityIconLabels.setAttribute("tooltiptext", tooltip);
this._identityIcon.setAttribute("tooltiptext", gNavigatorBundle.getString("identity.icon.tooltip"));
this._identityIconLabel.setAttribute("value", icon_label);
this._identityIconCountryLabel.setAttribute("value", icon_country_label);
@@ -7684,17 +7680,17 @@ var gIdentityHandler = {
// The expander switches its tooltip when toggled, change it to the default.
this._popupExpander.tooltipText = gNavigatorBundle.getString("identity.showDetails.tooltip");
// Determine connection security information.
let connection = "not-secure";
if (this._isSecureInternalUI) {
connection = "chrome";
- } else if (this._isExtensionPage) {
+ } else if (this._pageExtensionPolicy) {
connection = "extension";
} else if (this._isURILoadedFromFile) {
connection = "file";
} else if (this._isEV) {
connection = "secure-ev";
} else if (this._isCertUserOverridden) {
connection = "secure-cert-user-overridden";
} else if (this._isSecure) {
@@ -7766,18 +7762,18 @@ var gIdentityHandler = {
// Fallback for special protocols.
if (!host) {
host = this._uri.specIgnoringRef;
// Special URIs without a host (eg, about:) should crop the end so
// the protocol can be seen.
hostless = true;
}
- if (this._isExtensionPage) {
- host = extensionNameFromURI(this._uri);
+ if (this._pageExtensionPolicy) {
+ host = this._pageExtensionPolicy.name;
}
// Fill in the CA name if we have a valid TLS certificate.
if (this._isSecure || this._isCertUserOverridden) {
verifier = this._identityIconLabels.tooltipText;
}
// Fill in organization information if we have a valid EV certificate.
@@ -7823,17 +7819,17 @@ var gIdentityHandler = {
this._uriHasHost = true;
} catch (ex) {
this._uriHasHost = false;
}
this._isSecureInternalUI = uri.schemeIs("about") &&
this._secureInternalUIWhitelist.test(uri.pathQueryRef);
- this._isExtensionPage = uri.schemeIs("moz-extension");
+ this._pageExtensionPolicy = WebExtensionPolicy.getByURI(uri);
// Create a channel for the sole purpose of getting the resolved URI
// of the request to determine if it's loaded from the file system.
this._isURILoadedFromFile = false;
let chanOptions = {uri: this._uri, loadUsingSystemPrincipal: true};
let resolvedURI;
try {
resolvedURI = NetUtil.newChannel(chanOptions).URI;
--- a/toolkit/components/extensions/ExtensionParent.jsm
+++ b/toolkit/components/extensions/ExtensionParent.jsm
@@ -1206,34 +1206,16 @@ function watchExtensionProxyContextLoad(
return () => {
extension.off("extension-proxy-context-load", listener);
};
}
// Used to cache the list of WebExtensionManifest properties defined in the BASE_SCHEMA.
let gBaseManifestProperties = null;
-/**
- * Function to obtain the extension name from a moz-extension URI without exposing GlobalManager.
- *
- * @param {Object} uri The URI for the extension to look up.
- * @returns {string} the name of the extension.
- */
-function extensionNameFromURI(uri) {
- let id = null;
- try {
- id = gAddonPolicyService.extensionURIToAddonId(uri);
- } catch (ex) {
- if (ex.name != "NS_ERROR_XPC_BAD_CONVERT_JS") {
- Cu.reportError("Extension cannot be found in AddonPolicyService.");
- }
- }
- return GlobalManager.getExtension(id).name;
-}
-
// Manages icon details for toolbar buttons in the |pageAction| and
// |browserAction| APIs.
let IconDetails = {
// WeakMap<Extension -> Map<url-string -> Map<iconType-string -> object>>>
iconCache: new DefaultWeakMap(() => {
return new DefaultMap(() => new DefaultMap(() => new Map()));
}),
@@ -1562,17 +1544,16 @@ class CacheStore {
}
}
for (let name of StartupCache.STORE_NAMES) {
StartupCache[name] = new CacheStore(name);
}
var ExtensionParent = {
- extensionNameFromURI,
GlobalManager,
HiddenExtensionPage,
IconDetails,
ParentAPIManager,
StartupCache,
WebExtensionPolicy,
apiManager,
get baseManifestProperties() {