Bug 1262009 - Refactor isURILoadedFromFile into a setURI function that sets all relevant properties in one place;r=MattN
MozReview-Commit-ID: rIr2CNBv0E
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6576,32 +6576,20 @@ var gIdentityHandler = {
* Bitmask provided by nsIWebProgressListener.onSecurityChange.
* @param uri
* nsIURI for which the identity UI should be displayed, already
* processed by nsIURIFixup.createExposableURI.
*/
updateIdentity(state, uri) {
let shouldHidePopup = this._uri && (this._uri.spec != uri.spec);
this._state = state;
- this._uri = uri;
- this._isURILoadedFromFile = this.isURILoadedFromFile();
// Firstly, populate the state properties required to display the UI. See
// the documentation of the individual properties for details.
-
- try {
- this._uri.host;
- this._uriHasHost = true;
- } catch (ex) {
- this._uriHasHost = false;
- }
-
- let whitelist = /^(?:accounts|addons|cache|config|crashes|customizing|downloads|healthreport|home|license|newaddon|permissions|preferences|privatebrowsing|rights|sessionrestore|support|welcomeback)(?:[?#]|$)/i;
- this._isSecureInternalUI = uri.schemeIs("about") && whitelist.test(uri.path);
-
+ this.setURI(uri);
this._sslStatus = gBrowser.securityUI
.QueryInterface(Ci.nsISSLStatusProvider)
.SSLStatus;
if (this._sslStatus) {
this._sslStatus.QueryInterface(Ci.nsISSLStatus);
}
// Then, update the user interface with the available data.
@@ -6931,35 +6919,46 @@ var gIdentityHandler = {
this._identityPopupContentOwner.textContent = owner;
this._identityPopupContentSupp.textContent = supplemental;
this._identityPopupContentVerif.textContent = verifier;
// Update per-site permissions section.
this.updateSitePermissions();
},
- isURILoadedFromFile() {
+ setURI(uri) {
+ this._uri = uri;
+
+ try {
+ this._uri.host;
+ this._uriHasHost = true;
+ } catch (ex) {
+ this._uriHasHost = false;
+ }
+
+ let whitelist = /^(?:accounts|addons|cache|config|crashes|customizing|downloads|healthreport|home|license|newaddon|permissions|preferences|privatebrowsing|rights|sessionrestore|support|welcomeback)(?:[?#]|$)/i;
+ this._isSecureInternalUI = uri.schemeIs("about") && whitelist.test(uri.path);
+
// 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;
if (resolvedURI.schemeIs("jar")) {
// Given a URI "jar:<jar-file-uri>!/<jar-entry>"
// create a new URI using <jar-file-uri>!/<jar-entry>
resolvedURI = NetUtil.newURI(resolvedURI.path);
}
+ // Check the URI again after resolving.
+ this._isURILoadedFromFile = resolvedURI.schemeIs("file");
} catch (ex) {
// NetUtil's methods will throw for malformed URIs and the like
- return false;
- }
-
- // Check the URI again after resolving.
- return resolvedURI.schemeIs("file");
+ }
},
/**
* Click handler for the identity-box element in primary chrome.
*/
handleIdentityButtonEvent : function(event) {
event.stopPropagation();