home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2011 November
/
CHIP_2011_11.iso
/
Programy
/
Narzedzia
/
AIMP2
/
aimp_2.61.583.exe
/
$TEMP
/
YandexPackSetup.msi
/
fil430F182886DFD9DBB49CDE67B94F10B9
< prev
next >
Wrap
Text File
|
2010-07-12
|
4KB
|
105 lines
const EXTENSION_PATH = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newFileURI(__LOCATION__.parent.parent).spec;
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader)
.loadSubScript(EXTENSION_PATH + "modules/xb/config.js");
function CustomBarProtocol() {
this._providers = [];
this._observerService.addObserver(this, CommonConsts.APP_ACTION_QUIT_TOPIC, false);
};
CustomBarProtocol.prototype = {
addDataProvider: function CBPH_addDataProvider(aProvider) {
if (this._providers.some(function(handler) { return aProvider === handler; }))
return;
this._providers.push(aProvider);
},
removeDataProvider: function CBPH_removeDataProvider(aProvider) {
this._providers = this._providers.filter(function(handler) { return aProvider !== handler; });
},
get wrappedJSObject() {
return this;
},
observe: function CBPH_observe(aSubject, aTopic, aData) {
switch (aTopic) {
case CommonConsts.APP_ACTION_QUIT_TOPIC:
this._destroy();
break;
}
},
get scheme() {
return this._scheme;
},
get protocolFlags() {
return Ci.nsIProtocolHandler.URI_DANGEROUS_TO_LOAD;
},
get defaultPort() {
return -1;
},
allowPort: function CBPH_allowPort(port, scheme) {
return false;
},
newURI: function CBPH_newURI(aSpec, aOriginalCharset, baseURI) {
let uri = this._handleNewURI(aSpec, aOriginalCharset, baseURI);
if (!uri)
throw Cr.NS_ERROR_MALFORMED_URI;
return uri;
},
newChannel: function CBPH_newChannel(aURI) {
var channel = this._ioService.newChannel("data:,", null, null);
channel.originalURI = aURI;
return channel;
},
_scheme: PROTOCOL_APP_SCHEME,
_ioService: Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService),
_observerService: Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService),
_handleNewURI: function CBPH__handleNewURI(aSpec, aOriginalCharset, aBaseURI) {
let uri = null;
let spec = aSpec.replace(this.scheme + ":", "");
this._providers.some(function(aProvider) {
return (null !== (uri = aProvider.newURI(spec, aOriginalCharset, aBaseURI)));
});
if (uri && typeof uri == "string")
uri = this._ioService.newURI(uri, aOriginalCharset, aBaseURI);
return uri;
},
_destroy: function CBPH__destroy() {
this._observerService.removeObserver(this, CommonConsts.APP_ACTION_QUIT_TOPIC, false);
this._providers.forEach(function(aProvider) aProvider.clear());
this._providers = null;
},
classDescription: "Custom Yandex bar protocol handler JS component for " + APP_NAME,
classID: PROTOCOL_APP_CLASS_ID,
contractID: PROTOCOL_APP_CONTRACT_ID,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler]),
_xpcom_categories: [{
category: "app-startup",
service: true
}]
};
var components = [CustomBarProtocol];
function NSGetModule(compMgr, fileSpec) {
return XPCOMUtils.generateModule(components);
}