Bug 1099592 - Make JS callers of ios.newChannel call ios.newChannel2 in calendar. r=philipp
This commit is contained in:
Родитель
33e085e9a8
Коммит
2e21e163d9
|
@ -284,7 +284,12 @@ calDNDBaseObserver.prototype = {
|
|||
var uri = Services.io.newURI(data.toString(), null, null);
|
||||
var loader = Components.classes["@mozilla.org/network/unichar-stream-loader;1"]
|
||||
.createInstance(Components.interfaces.nsIUnicharStreamLoader);
|
||||
var channel = Services.io.newChannelFromURI(uri);
|
||||
var channel = Services.io.newChannelFromURI2(uri,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
Components.interfaces.nsILoadInfo.SEC_NORMAL,
|
||||
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
|
||||
channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
|
||||
var self = this;
|
||||
|
|
|
@ -30,7 +30,12 @@ this.EXPORTED_SYMBOLS = ["cal"]; // even though it's defined in calUtils.jsm, im
|
|||
* @param aExisting An existing channel to modify (optional)
|
||||
*/
|
||||
cal.prepHttpChannel = function calPrepHttpChannel(aUri, aUploadData, aContentType, aNotificationCallbacks, aExisting) {
|
||||
let channel = aExisting || Services.io.newChannelFromURI(aUri);
|
||||
let channel = aExisting || Services.io.newChannelFromURI2(aUri,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
Components.interfaces.nsILoadInfo.SEC_NORMAL,
|
||||
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
|
||||
let httpchannel = channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
|
||||
httpchannel.setRequestHeader("Accept", "text/xml", false);
|
||||
|
|
|
@ -33,11 +33,11 @@ calProtocolHandler.prototype = {
|
|||
newURI: function cph_newURI(aSpec, anOriginalCharset, aBaseURI) {
|
||||
var uri = Components.classes["@mozilla.org/network/standard-url;1"].
|
||||
createInstance(Components.interfaces.nsIStandardURL);
|
||||
uri.init(Components.interfaces.nsIStandardURL.URLTYPE_STANDARD,
|
||||
uri.init(Components.interfaces.nsIStandardURL.URLTYPE_STANDARD,
|
||||
this.mHttpProtocol.defaultPort, aSpec, anOriginalCharset, aBaseURI);
|
||||
return uri;
|
||||
},
|
||||
|
||||
|
||||
newChannel: function cph_newChannel(aUri) {
|
||||
return this.newChannel2(aUri, null);
|
||||
},
|
||||
|
@ -46,10 +46,20 @@ calProtocolHandler.prototype = {
|
|||
{
|
||||
// make sure to clone the uri, because we are about to change
|
||||
// it, and we don't want to change the original uri.
|
||||
var uri = aUri.clone();
|
||||
let uri = aUri.clone();
|
||||
uri.scheme = this.mHttpProtocol.scheme;
|
||||
|
||||
var channel = Services.io.newChannelFromURI(uri, null);
|
||||
let channel;
|
||||
if (aLoadInfo) {
|
||||
channel = Services.io.newChannelFromURIWithLoadInfo(uri, aLoadInfo);
|
||||
} else {
|
||||
channel = Services.io.newChannelFromURI2(uri,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
Components.interfaces.nsILoadInfo.SEC_NORMAL,
|
||||
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
|
||||
}
|
||||
channel.originalURI = aUri;
|
||||
return channel;
|
||||
},
|
||||
|
|
|
@ -74,7 +74,15 @@ calTimezoneService.prototype = {
|
|||
cal.LOG("[calTimezoneService] Loading " + aURL);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
NetUtil.asyncFetch(aURL, (inputStream, status) => {
|
||||
let uri = Services.io.newURI(aURL, null, null);
|
||||
let channel = Services.io.newChannelFromURI2(uri,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
Components.interfaces.nsILoadInfo.SEC_NORMAL,
|
||||
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
|
||||
|
||||
NetUtil.asyncFetch(channel, (inputStream, status) => {
|
||||
if (!Components.isSuccessCode(status)) {
|
||||
reject(status);
|
||||
return;
|
||||
|
|
|
@ -197,7 +197,12 @@ calGoogleRequest.prototype = {
|
|||
uristring += "?" + params.join("&");
|
||||
}
|
||||
let uri = Services.io.newURI(uristring, null, null);
|
||||
let channel = Services.io.newChannelFromURI(uri);
|
||||
let channel = Services.io.newChannelFromURI2(uri,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
Components.interfaces.nsILoadInfo.SEC_NORMAL,
|
||||
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
|
||||
cal.LOG("[calGoogleRequest] Requesting " + this.method + " " +
|
||||
channel.URI.spec);
|
||||
|
||||
|
|
|
@ -116,7 +116,12 @@ calICSCalendar.prototype = {
|
|||
|
||||
// Use the ioservice, to create a channel, which makes finding the
|
||||
// right hooks to use easier.
|
||||
var channel = Services.io.newChannelFromURI(this.mUri);
|
||||
var channel = Services.io.newChannelFromURI2(this.mUri,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
Components.interfaces.nsILoadInfo.SEC_NORMAL,
|
||||
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
|
||||
let wHttpChannel = cal.wrapInstance(channel, Components.interfaces.nsIHttpChannel);
|
||||
let wFileChannel = cal.wrapInstance(channel, Components.interfaces.nsIFileChannel);
|
||||
|
||||
|
@ -173,7 +178,12 @@ calICSCalendar.prototype = {
|
|||
.createInstance(Components.interfaces.nsISupportsPRBool);
|
||||
prbForce.data = aForce;
|
||||
|
||||
var channel = Services.io.newChannelFromURI(this.mUri);
|
||||
var channel = Services.io.newChannelFromURI2(this.mUri,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
Components.interfaces.nsILoadInfo.SEC_NORMAL,
|
||||
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
|
||||
this.prepareChannel(channel, aForce);
|
||||
|
||||
var streamLoader = Components.classes["@mozilla.org/network/stream-loader;1"]
|
||||
|
@ -317,7 +327,12 @@ calICSCalendar.prototype = {
|
|||
// All events are returned. Now set up a channel and a
|
||||
// streamloader to upload. onStopRequest will be called
|
||||
// once the write has finished
|
||||
var channel = Services.io.newChannelFromURI(savedthis.mUri);
|
||||
var channel = Services.io.newChannelFromURI2(savedthis.mUri,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
Components.interfaces.nsILoadInfo.SEC_NORMAL,
|
||||
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
|
||||
|
||||
// Allow the hook to add things to the channel, like a
|
||||
// header that checks etags
|
||||
|
@ -451,14 +466,14 @@ calICSCalendar.prototype = {
|
|||
this.adoptItem(aItem.clone(), aListener);
|
||||
},
|
||||
adoptItem: function (aItem, aListener) {
|
||||
if (this.readOnly)
|
||||
if (this.readOnly)
|
||||
throw calIErrors.CAL_IS_READONLY;
|
||||
this.queue.push({action:'add', item:aItem, listener:aListener});
|
||||
this.processQueue();
|
||||
},
|
||||
|
||||
modifyItem: function (aNewItem, aOldItem, aListener) {
|
||||
if (this.readOnly)
|
||||
if (this.readOnly)
|
||||
throw calIErrors.CAL_IS_READONLY;
|
||||
this.queue.push({action:'modify', oldItem: aOldItem,
|
||||
newItem: aNewItem, listener:aListener});
|
||||
|
@ -466,7 +481,7 @@ calICSCalendar.prototype = {
|
|||
},
|
||||
|
||||
deleteItem: function (aItem, aListener) {
|
||||
if (this.readOnly)
|
||||
if (this.readOnly)
|
||||
throw calIErrors.CAL_IS_READONLY;
|
||||
this.queue.push({action:'delete', item:aItem, listener:aListener});
|
||||
this.processQueue();
|
||||
|
@ -767,7 +782,12 @@ calICSCalendar.prototype = {
|
|||
purgeOldBackups();
|
||||
|
||||
// Now go download the remote file, and store it somewhere local.
|
||||
var channel = Services.io.newChannelFromURI(this.mUri);
|
||||
var channel = Services.io.newChannelFromURI2(this.mUri,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
Components.interfaces.nsILoadInfo.SEC_NORMAL,
|
||||
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
|
||||
channel.loadFlags |= Components.interfaces.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
channel.notificationCallbacks = this;
|
||||
|
||||
|
|
|
@ -407,7 +407,12 @@ function issueNetworkRequest(parentRequest, respFunc, url, bLogging) {
|
|||
}
|
||||
try {
|
||||
var uri = Services.io.newURI(url, null, null);
|
||||
var channel = Services.io.newChannelFromURI(uri);
|
||||
var channel = Services.io.newChannelFromURI2(uri,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
Components.interfaces.nsILoadInfo.SEC_NORMAL,
|
||||
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
|
||||
netRequest.prepareChannel(channel);
|
||||
channel = channel.QueryInterface(Components.interfaces.nsIHttpChannel);
|
||||
channel.redirectionLimit = 3;
|
||||
|
|
|
@ -12,10 +12,10 @@ Components.utils.import("resource://gre/modules/Services.jsm");
|
|||
function publishCalendarData()
|
||||
{
|
||||
var args = new Object();
|
||||
|
||||
|
||||
args.onOk = self.publishCalendarDataDialogResponse;
|
||||
|
||||
openDialog("chrome://calendar/content/publishDialog.xul", "caPublishEvents",
|
||||
|
||||
openDialog("chrome://calendar/content/publishDialog.xul", "caPublishEvents",
|
||||
"chrome,titlebar,modal,resizable", args );
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ function publishCalendarData()
|
|||
*/
|
||||
function publishCalendarDataDialogResponse(CalendarPublishObject, aProgressDialog)
|
||||
{
|
||||
publishItemArray(currentView().getSelectedItems({}),
|
||||
publishItemArray(currentView().getSelectedItems({}),
|
||||
CalendarPublishObject.remotePath, aProgressDialog);
|
||||
}
|
||||
|
||||
|
@ -49,12 +49,12 @@ function publishEntireCalendar(aCalendar)
|
|||
} else {
|
||||
// Ask user to select the calendar that should be published.
|
||||
// publishEntireCalendar() will be called again if OK is pressed
|
||||
// in the dialog and the selected calendar will be passed in.
|
||||
// in the dialog and the selected calendar will be passed in.
|
||||
// Therefore return after openDialog().
|
||||
var args = new Object();
|
||||
args.onOk = publishEntireCalendar;
|
||||
args.promptText = calGetString("calendar", "publishPrompt");
|
||||
openDialog("chrome://calendar/content/chooseCalendarDialog.xul",
|
||||
openDialog("chrome://calendar/content/chooseCalendarDialog.xul",
|
||||
"_blank", "chrome,titlebar,modal,resizable", args);
|
||||
return;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ function publishEntireCalendar(aCalendar)
|
|||
}
|
||||
|
||||
args.publishObject = publishObject;
|
||||
openDialog("chrome://calendar/content/publishDialog.xul", "caPublishEvents",
|
||||
openDialog("chrome://calendar/content/publishDialog.xul", "caPublishEvents",
|
||||
"chrome,titlebar,modal,resizable", args );
|
||||
|
||||
return;
|
||||
|
@ -88,7 +88,7 @@ function publishEntireCalendar(aCalendar)
|
|||
function publishEntireCalendarDialogResponse(CalendarPublishObject, aProgressDialog)
|
||||
{
|
||||
// store the selected remote ics path as a calendar preference
|
||||
CalendarPublishObject.calendar.setProperty("remote-ics-path",
|
||||
CalendarPublishObject.calendar.setProperty("remote-ics-path",
|
||||
CalendarPublishObject.remotePath);
|
||||
|
||||
var itemArray = [];
|
||||
|
@ -108,7 +108,7 @@ function publishEntireCalendarDialogResponse(CalendarPublishObject, aProgressDia
|
|||
// Store a (short living) reference to the item.
|
||||
var itemCopy = aItems[i].clone();
|
||||
itemArray.push(itemCopy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -126,7 +126,12 @@ function publishItemArray(aItemArray, aPath, aProgressDialog) {
|
|||
|
||||
var icsURL = makeURL(aPath);
|
||||
|
||||
var channel = Services.io.newChannelFromURI(icsURL);
|
||||
var channel = Services.io.newChannelFromURI2(icsURL,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
Components.interfaces.nsILoadInfo.SEC_NORMAL,
|
||||
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
|
||||
if (icsURL.schemeIs('webcal'))
|
||||
icsURL.scheme = 'http';
|
||||
if (icsURL.schemeIs('webcals'))
|
||||
|
|
|
@ -26,9 +26,17 @@ function run_test() {
|
|||
run_next_test();
|
||||
}
|
||||
|
||||
function check_webcal_uri(uri) {
|
||||
let chan = Services.io.newChannel(uri, null, null);
|
||||
NetUtil.asyncFetch(chan, function(data, status, request) {
|
||||
function check_webcal_uri(aUri) {
|
||||
let uri = Services.io.newURI(aUri, null, null);
|
||||
|
||||
let channel = Services.io.newChannelFromURI2(uri,
|
||||
null,
|
||||
Services.scriptSecurityManager.getSystemPrincipal(),
|
||||
null,
|
||||
Components.interfaces.nsILoadInfo.SEC_NORMAL,
|
||||
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
|
||||
|
||||
NetUtil.asyncFetch(channel, function(data, status, request) {
|
||||
ok(Components.isSuccessCode(status));
|
||||
run_next_test();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче