Backed out changeset 7a79ddc7bedf (bug 834672) for bustage on a CLOSED TREE.

This commit is contained in:
Ryan VanderMeulen 2013-02-27 15:09:12 -05:00
Родитель 426bd4f169
Коммит d4d6530243
1 изменённых файлов: 9 добавлений и 121 удалений

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

@ -7,7 +7,6 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
@ -53,22 +52,19 @@ AppProtocolHandler.prototype = {
newChannel: function app_phNewChannel(aURI) {
// We map app://ABCDEF/path/to/file.ext to
// jar:file:///path/to/profile/webapps/ABCDEF/application.zip!/path/to/file.ext
let url = aURI.QueryInterface(Ci.nsIURL);
let appId = aURI.host;
let fileSpec = url.filePath;
let noScheme = aURI.spec.substring(6);
let firstSlash = noScheme.indexOf("/");
let appId = noScheme;
let fileSpec = aURI.path;
if (firstSlash) {
appId = noScheme.substring(0, firstSlash);
}
// Build a jar channel and masquerade as an app:// URI.
let appInfo = this.getAppInfo(appId);
let uri;
if (!appInfo) {
// That should not happen, so dump() inconditionnally.
// We create a dummy channel instead of throwing to let the
// downstream user get a 404 error.
dump("!! got no appInfo for " + appId + "\n");
return new DummyChannel();
}
if (this._runningInParent || appInfo.isCoreApp) {
// In-parent and CoreApps can directly access files, so use jar:file://
uri = "jar:file://" + appInfo.basePath + appId + "/application.zip!" + fileSpec;
@ -88,112 +84,4 @@ AppProtocolHandler.prototype = {
}
};
/**
* This dummy channel implementation only provides enough functionality
* to return a fake 404 error when the caller asks for an app:// URL
* containing an unknown appId.
*/
function DummyChannel() {
}
DummyChannel.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIRequest,
Ci.nsIChannel,
Ci.nsIJARChannel]),
// nsIRequest
name: "dummy_app_channel",
isPending: function dc_isPending() {
return this._pending;
},
status: Cr.NS_ERROR_FILE_NOT_FOUND,
cancel: function dc_cancel() {
},
suspend: function dc_suspend() {
this._suspendCount++;
},
resume: function dc_resume() {
if (this._suspendCount <= 0)
throw Cr.NS_ERROR_UNEXPECTED;
if (--this._suspendCount == 0 && this._pending) {
this._dispatch();
}
},
loadGroup: null,
loadFlags: Ci.nsIRequest.LOAD_NORMAL,
// nsIChannel
originalURI: Services.io.newURI("app://unknown/nothing.html", null, null),
URI: Services.io.newURI("app://unknown/nothing.html", null, null),
owner: null,
notificationCallbacks: null,
securityInfo: null,
contentType: null,
contentCharset: null,
contentLength: 0,
contentDisposition: Ci.nsIChannel.DISPOSITION_INLINE,
contentDispositionFilename: "",
_pending: false,
_suspendCount: 0,
_listener: null,
_context: null,
open: function dc_open() {
return Cr.NS_ERROR_NOT_IMPLEMENTED;
},
_dispatch: function dc_dispatch() {
let request = this;
Services.tm.currentThread.dispatch(
{
run: function dc_run() {
request._listener.onStartRequest(request, request._context);
request._listener.onStopRequest(request, request._context,
Cr.NS_ERROR_FILE_NOT_FOUND);
if (request.loadGroup) {
request.loadGroup.removeRequest(request, request._context,
Cr.NS_ERROR_FILE_NOT_FOUND);
}
request._pending = false;
request.notificationCallbacks = null;
request._listener = null;
request._context = null;
}
},
Ci.nsIThread.DISPATCH_NORMAL);
},
asyncOpen: function dc_asyncopenfunction(aListener, aContext) {
if (this.loadGroup) {
this.loadGroup.addRequest(this, aContext);
}
this._listener = aListener;
this._context = aContext;
this._pending = true;
if (!this._suspended) {
this._dispatch();
}
},
// nsIJarChannel, needed for XHR to turn NS_ERROR_FILE_NOT_FOUND into
// a 404 error.
isUnsafe: false,
setAppURI: function(aURI) {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([AppProtocolHandler]);