Use Services.io to access IOService
This commit is contained in:
parent
3f2dd94752
commit
e8cd4c9338
4 changed files with 7 additions and 18 deletions
|
@ -59,9 +59,7 @@ Zotero.File = new function(){
|
||||||
|
|
||||||
this.pathToFileURI = function (path) {
|
this.pathToFileURI = function (path) {
|
||||||
var file = new FileUtils.File(path);
|
var file = new FileUtils.File(path);
|
||||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
return Services.io.newFileURI(file).spec;
|
||||||
.getService(Components.interfaces.nsIIOService);
|
|
||||||
return ios.newFileURI(file).spec;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -833,8 +833,7 @@ Zotero.HTTP = new function() {
|
||||||
* @type Boolean
|
* @type Boolean
|
||||||
*/
|
*/
|
||||||
this.browserIsOffline = function() {
|
this.browserIsOffline = function() {
|
||||||
return Components.classes["@mozilla.org/network/io-service;1"]
|
return Services.io.offline;
|
||||||
.getService(Components.interfaces.nsIIOService).offline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1064,10 +1063,8 @@ Zotero.HTTP = new function() {
|
||||||
if ((secInfo.securityState & Ci.nsIWebProgressListener.STATE_IS_INSECURE)
|
if ((secInfo.securityState & Ci.nsIWebProgressListener.STATE_IS_INSECURE)
|
||||||
== Ci.nsIWebProgressListener.STATE_IS_INSECURE) {
|
== Ci.nsIWebProgressListener.STATE_IS_INSECURE) {
|
||||||
let url = channel.name;
|
let url = channel.name;
|
||||||
let ios = Components.classes["@mozilla.org/network/io-service;1"]
|
|
||||||
.getService(Components.interfaces.nsIIOService);
|
|
||||||
try {
|
try {
|
||||||
var uri = ios.newURI(url, null, null);
|
var uri = Services.io.newURI(url, null, null);
|
||||||
var host = uri.host;
|
var host = uri.host;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|
|
@ -267,10 +267,8 @@ Zotero.Utilities = {
|
||||||
url = url.trim();
|
url = url.trim();
|
||||||
if (!url) return false;
|
if (!url) return false;
|
||||||
|
|
||||||
var ios = Components.classes["@mozilla.org/network/io-service;1"]
|
|
||||||
.getService(Components.interfaces.nsIIOService);
|
|
||||||
try {
|
try {
|
||||||
return ios.newURI(url, null, null).spec; // Valid URI if succeeds
|
return Services.io.newURI(url, null, null).spec; // Valid URI if succeeds
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof Components.Exception
|
if (e instanceof Components.Exception
|
||||||
&& e.result == Components.results.NS_ERROR_MALFORMED_URI
|
&& e.result == Components.results.NS_ERROR_MALFORMED_URI
|
||||||
|
@ -278,7 +276,7 @@ Zotero.Utilities = {
|
||||||
if (tryHttp && /\w\.\w/.test(url)) {
|
if (tryHttp && /\w\.\w/.test(url)) {
|
||||||
// Assume it's a URL missing "http://" part
|
// Assume it's a URL missing "http://" part
|
||||||
try {
|
try {
|
||||||
return ios.newURI('http://' + url, null, null).spec;
|
return Services.io.newURI('http://' + url, null, null).spec;
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -768,9 +768,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||||
}
|
}
|
||||||
// Load More Info page
|
// Load More Info page
|
||||||
else if (index == 2) {
|
else if (index == 2) {
|
||||||
let io = Components.classes['@mozilla.org/network/io-service;1']
|
let uri = Services.io.newURI(kbURL, null, null);
|
||||||
.getService(Components.interfaces.nsIIOService);
|
|
||||||
let uri = io.newURI(kbURL, null, null);
|
|
||||||
let handler = Components.classes['@mozilla.org/uriloader/external-protocol-service;1']
|
let handler = Components.classes['@mozilla.org/uriloader/external-protocol-service;1']
|
||||||
.getService(Components.interfaces.nsIExternalProtocolService)
|
.getService(Components.interfaces.nsIExternalProtocolService)
|
||||||
.getProtocolHandlerInfo('http');
|
.getProtocolHandlerInfo('http');
|
||||||
|
@ -1167,9 +1165,7 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var io = Components.classes['@mozilla.org/network/io-service;1']
|
var uri = Services.io.newURI(url, null, null);
|
||||||
.getService(Components.interfaces.nsIIOService);
|
|
||||||
var uri = io.newURI(url, null, null);
|
|
||||||
var handler = Components.classes['@mozilla.org/uriloader/external-protocol-service;1']
|
var handler = Components.classes['@mozilla.org/uriloader/external-protocol-service;1']
|
||||||
.getService(Components.interfaces.nsIExternalProtocolService)
|
.getService(Components.interfaces.nsIExternalProtocolService)
|
||||||
.getProtocolHandlerInfo('http');
|
.getProtocolHandlerInfo('http');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue