Bug 1262009 - Refactor isURILoadedFromFile into a setURI function that sets all relevant properties in one place;r=MattN

MozReview-Commit-ID: rIr2CNBv0E
This commit is contained in:
Brian Grinstead 2016-04-13 10:43:09 -07:00
Родитель 04db85aa39
Коммит ba21337580
1 изменённых файлов: 17 добавлений и 18 удалений

Просмотреть файл

@ -6615,22 +6615,10 @@ var gIdentityHandler = {
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;
@ -6970,9 +6958,22 @@ var gIdentityHandler = {
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 {
@ -6982,13 +6983,11 @@ var gIdentityHandler = {
// 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");
},
/**