mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merged
This commit is contained in:
commit
9805cdce23
@ -63,7 +63,6 @@ function DAVCollection(baseURL, defaultPrefix) {
|
|||||||
this.baseURL = baseURL;
|
this.baseURL = baseURL;
|
||||||
this.defaultPrefix = defaultPrefix;
|
this.defaultPrefix = defaultPrefix;
|
||||||
this._identity = 'DAV:default';
|
this._identity = 'DAV:default';
|
||||||
this._authProvider = new DummyAuthProvider();
|
|
||||||
this._log = Log4Moz.Service.getLogger("Service.DAV");
|
this._log = Log4Moz.Service.getLogger("Service.DAV");
|
||||||
this._log.level =
|
this._log.level =
|
||||||
Log4Moz.Level[Utils.prefs.getCharPref("log.logger.service.dav")];
|
Log4Moz.Level[Utils.prefs.getCharPref("log.logger.service.dav")];
|
||||||
@ -124,15 +123,15 @@ DAVCollection.prototype = {
|
|||||||
|
|
||||||
path = this._defaultPrefix + path;
|
path = this._defaultPrefix + path;
|
||||||
|
|
||||||
let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance();
|
let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
|
||||||
request = request.QueryInterface(Ci.nsIDOMEventTarget);
|
|
||||||
|
|
||||||
request.addEventListener("load", new Utils.EventListener(self.cb, "load"), false);
|
let xhrCb = self.cb;
|
||||||
request.addEventListener("error", new Utils.EventListener(self.cb, "error"), false);
|
|
||||||
request = request.QueryInterface(Ci.nsIXMLHttpRequest);
|
request.onload = new Utils.EventListener(xhrCb, "load");
|
||||||
|
request.onerror = new Utils.EventListener(xhrCb, "error");
|
||||||
|
request.mozBackgroundRequest = true;
|
||||||
request.open(op, this._baseURL + path, true);
|
request.open(op, this._baseURL + path, true);
|
||||||
|
|
||||||
|
|
||||||
// Force cache validation
|
// Force cache validation
|
||||||
let channel = request.channel;
|
let channel = request.channel;
|
||||||
channel = channel.QueryInterface(Ci.nsIRequest);
|
channel = channel.QueryInterface(Ci.nsIRequest);
|
||||||
@ -149,15 +148,10 @@ DAVCollection.prototype = {
|
|||||||
request.setRequestHeader(key, headers[key]);
|
request.setRequestHeader(key, headers[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._authProvider._authFailed = false;
|
|
||||||
request.channel.notificationCallbacks = this._authProvider;
|
|
||||||
|
|
||||||
request.send(data);
|
request.send(data);
|
||||||
let event = yield;
|
let event = yield;
|
||||||
ret = event.target;
|
ret = event.target;
|
||||||
|
|
||||||
if (this._authProvider._authFailed)
|
|
||||||
this._log.warn("_makeRequest: authentication failed");
|
|
||||||
if (ret.status < 200 || ret.status >= 300)
|
if (ret.status < 200 || ret.status >= 300)
|
||||||
this._log.warn("_makeRequest: got status " + ret.status);
|
this._log.warn("_makeRequest: got status " + ret.status);
|
||||||
|
|
||||||
@ -315,8 +309,7 @@ DAVCollection.prototype = {
|
|||||||
this.GET("", self.cb);
|
this.GET("", self.cb);
|
||||||
let resp = yield;
|
let resp = yield;
|
||||||
|
|
||||||
if (this._authProvider._authFailed ||
|
if (resp.status < 200 || resp.status >= 300) {
|
||||||
resp.status < 200 || resp.status >= 300) {
|
|
||||||
self.done(false);
|
self.done(false);
|
||||||
yield;
|
yield;
|
||||||
}
|
}
|
||||||
@ -338,8 +331,7 @@ DAVCollection.prototype = {
|
|||||||
"</D:propfind>", self.cb);
|
"</D:propfind>", self.cb);
|
||||||
let resp = yield;
|
let resp = yield;
|
||||||
|
|
||||||
if (this._authProvider._authFailed ||
|
if (resp.status < 200 || resp.status >= 300) {
|
||||||
resp.status < 200 || resp.status >= 300) {
|
|
||||||
self.done(false);
|
self.done(false);
|
||||||
yield;
|
yield;
|
||||||
}
|
}
|
||||||
@ -375,8 +367,7 @@ DAVCollection.prototype = {
|
|||||||
"</D:lockinfo>", self.cb);
|
"</D:lockinfo>", self.cb);
|
||||||
let resp = yield;
|
let resp = yield;
|
||||||
|
|
||||||
if (this._authProvider._authFailed ||
|
if (resp.status < 200 || resp.status >= 300) {
|
||||||
resp.status < 200 || resp.status >= 300) {
|
|
||||||
self.done();
|
self.done();
|
||||||
yield;
|
yield;
|
||||||
}
|
}
|
||||||
@ -414,8 +405,7 @@ DAVCollection.prototype = {
|
|||||||
this.UNLOCK("lock", self.cb);
|
this.UNLOCK("lock", self.cb);
|
||||||
let resp = yield;
|
let resp = yield;
|
||||||
|
|
||||||
if (this._authProvider._authFailed ||
|
if (resp.status < 200 || resp.status >= 300) {
|
||||||
resp.status < 200 || resp.status >= 300) {
|
|
||||||
self.done(false);
|
self.done(false);
|
||||||
yield;
|
yield;
|
||||||
}
|
}
|
||||||
@ -451,154 +441,3 @@ DAVCollection.prototype = {
|
|||||||
self.done(unlocked);
|
self.done(unlocked);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Auth provider object
|
|
||||||
* Taken from nsMicrosummaryService.js and massaged slightly
|
|
||||||
*/
|
|
||||||
|
|
||||||
function DummyAuthProvider() {}
|
|
||||||
DummyAuthProvider.prototype = {
|
|
||||||
// Implement notification callback interfaces so we can suppress UI
|
|
||||||
// and abort loads for bad SSL certs and HTTP authorization requests.
|
|
||||||
|
|
||||||
// Interfaces this component implements.
|
|
||||||
interfaces: [Ci.nsIBadCertListener,
|
|
||||||
Ci.nsIAuthPromptProvider,
|
|
||||||
Ci.nsIAuthPrompt,
|
|
||||||
Ci.nsIPrompt,
|
|
||||||
Ci.nsIProgressEventSink,
|
|
||||||
Ci.nsIInterfaceRequestor,
|
|
||||||
Ci.nsISupports],
|
|
||||||
|
|
||||||
// Auth requests appear to succeed when we cancel them (since the server
|
|
||||||
// redirects us to a "you're not authorized" page), so we have to set a flag
|
|
||||||
// to let the load handler know to treat the load as a failure.
|
|
||||||
get _authFailed() { return this.__authFailed; },
|
|
||||||
set _authFailed(newValue) { return this.__authFailed = newValue; },
|
|
||||||
|
|
||||||
// nsISupports
|
|
||||||
|
|
||||||
QueryInterface: function DAP_QueryInterface(iid) {
|
|
||||||
if (!this.interfaces.some( function(v) { return iid.equals(v); } ))
|
|
||||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
|
||||||
|
|
||||||
// nsIAuthPrompt and nsIPrompt need separate implementations because
|
|
||||||
// their method signatures conflict. The other interfaces we implement
|
|
||||||
// within DummyAuthProvider itself.
|
|
||||||
switch(iid) {
|
|
||||||
case Ci.nsIAuthPrompt:
|
|
||||||
return this.authPrompt;
|
|
||||||
case Ci.nsIPrompt:
|
|
||||||
return this.prompt;
|
|
||||||
default:
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// nsIInterfaceRequestor
|
|
||||||
|
|
||||||
getInterface: function DAP_getInterface(iid) {
|
|
||||||
return this.QueryInterface(iid);
|
|
||||||
},
|
|
||||||
|
|
||||||
// nsIBadCertListener
|
|
||||||
|
|
||||||
// Suppress UI and abort secure loads from servers with bad SSL certificates.
|
|
||||||
|
|
||||||
confirmUnknownIssuer: function DAP_confirmUnknownIssuer(socketInfo, cert, certAddType) {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
confirmMismatchDomain: function DAP_confirmMismatchDomain(socketInfo, targetURL, cert) {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
confirmCertExpired: function DAP_confirmCertExpired(socketInfo, cert) {
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
notifyCrlNextupdate: function DAP_notifyCrlNextupdate(socketInfo, targetURL, cert) {
|
|
||||||
},
|
|
||||||
|
|
||||||
// nsIAuthPromptProvider
|
|
||||||
|
|
||||||
getAuthPrompt: function(aPromptReason, aIID) {
|
|
||||||
this._authFailed = true;
|
|
||||||
throw Cr.NS_ERROR_NOT_AVAILABLE;
|
|
||||||
},
|
|
||||||
|
|
||||||
// HTTP always requests nsIAuthPromptProvider first, so it never needs
|
|
||||||
// nsIAuthPrompt, but not all channels use nsIAuthPromptProvider, so we
|
|
||||||
// implement nsIAuthPrompt too.
|
|
||||||
|
|
||||||
// nsIAuthPrompt
|
|
||||||
|
|
||||||
get authPrompt() {
|
|
||||||
var resource = this;
|
|
||||||
return {
|
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPrompt]),
|
|
||||||
prompt: function(dialogTitle, text, passwordRealm, savePassword, defaultText, result) {
|
|
||||||
resource._authFailed = true;
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
promptUsernameAndPassword: function(dialogTitle, text, passwordRealm, savePassword, user, pwd) {
|
|
||||||
resource._authFailed = true;
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
promptPassword: function(dialogTitle, text, passwordRealm, savePassword, pwd) {
|
|
||||||
resource._authFailed = true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
// nsIPrompt
|
|
||||||
|
|
||||||
get prompt() {
|
|
||||||
var resource = this;
|
|
||||||
return {
|
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPrompt]),
|
|
||||||
alert: function(dialogTitle, text) {
|
|
||||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
},
|
|
||||||
alertCheck: function(dialogTitle, text, checkMessage, checkValue) {
|
|
||||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
},
|
|
||||||
confirm: function(dialogTitle, text) {
|
|
||||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
},
|
|
||||||
confirmCheck: function(dialogTitle, text, checkMessage, checkValue) {
|
|
||||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
},
|
|
||||||
confirmEx: function(dialogTitle, text, buttonFlags, button0Title, button1Title, button2Title, checkMsg, checkValue) {
|
|
||||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
},
|
|
||||||
prompt: function(dialogTitle, text, value, checkMsg, checkValue) {
|
|
||||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
},
|
|
||||||
promptPassword: function(dialogTitle, text, password, checkMsg, checkValue) {
|
|
||||||
resource._authFailed = true;
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
promptUsernameAndPassword: function(dialogTitle, text, username, password, checkMsg, checkValue) {
|
|
||||||
resource._authFailed = true;
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
select: function(dialogTitle, text, count, selectList, outSelection) {
|
|
||||||
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
// nsIProgressEventSink
|
|
||||||
|
|
||||||
onProgress: function DAP_onProgress(aRequest, aContext,
|
|
||||||
aProgress, aProgressMax) {
|
|
||||||
},
|
|
||||||
|
|
||||||
onStatus: function DAP_onStatus(aRequest, aContext,
|
|
||||||
aStatus, aStatusArg) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
@ -427,15 +427,6 @@ WeaveSvc.prototype = {
|
|||||||
_login: function WeaveSync__login(password, passphrase) {
|
_login: function WeaveSync__login(password, passphrase) {
|
||||||
let self = yield;
|
let self = yield;
|
||||||
|
|
||||||
// XmlHttpRequests fail when the window that triggers them goes away
|
|
||||||
// because of bug 317600, and the first XmlHttpRequest we do happens
|
|
||||||
// just before the login dialog closes itself (for logins prompted by
|
|
||||||
// that dialog), so it triggers the bug. To work around it, we pause
|
|
||||||
// here and then continue after a 0ms timeout.
|
|
||||||
let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
|
||||||
timer.initWithCallback({ notify: self.cb }, 0, Ci.nsITimer.TYPE_ONE_SHOT);
|
|
||||||
yield;
|
|
||||||
|
|
||||||
// cache password & passphrase
|
// cache password & passphrase
|
||||||
// if null, we'll try to get them from the pw manager below
|
// if null, we'll try to get them from the pw manager below
|
||||||
ID.get('WeaveID').setTempPassword(password);
|
ID.get('WeaveID').setTempPassword(password);
|
||||||
|
Loading…
Reference in New Issue
Block a user