Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var async_mg = {
- onLoad: function() {
- // initialization code
- new aSyncMtpAltListener();
- this.initialized = true;
- }
- };
- function aSyncMtpAltListener()
- {
- window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
- .getInterface(Components.interfaces.nsIWebNavigation)
- .QueryInterface(Components.interfaces.nsIDocShell)
- .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
- .getInterface(Components.interfaces.nsIURIContentListener)
- .parentContentListener = this;
- }
- aSyncMtpAltListener.prototype =
- {
- QueryInterface: function(iid)
- {
- if (iid.equals(Components.interfaces.nsIURIContentListener) ||
- iid.equals(Components.interfaces.nsISupportsWeakReference) ||
- iid.equals(Components.interfaces.nsISupports))
- return this;
- throw Components.results.NS_NOINTERFACE;
- },
- onStartURIOpen: function(aUri)
- { // We'll just sit back and wait...
- return false;
- },
- doContent: function(aContentType, aIsContentPreferred, aRequest, aContentHandler )
- { alert('Argh! At last! This is: ' + aContentType);
- //var oChannel = aRequest.QueryInterface(Ci.nsIChannel);
- //alert(oChannel.contentType);
- throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
- },
- canHandleContent: function(aContentType, aIsContentPreferred, aDesiredContentType)
- {
- alert(aContentType);
- return aContentType == 'multipart/alternate';
- throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
- },
- isPreferred: function(aContentType, aDesiredContentType)
- { alert(aContentType);
- return aContentType == 'multipart/alternate';
- try
- {
- var webNavInfo =
- Components.classes["@mozilla.org/webnavigation-info;1"]
- .getService(Components.interfaces.nsIWebNavigationInfo);
- return webNavInfo.isTypeSupported(aContentType, null);
- }
- catch (e)
- {
- return false;
- }
- },
- GetWeakReference : function()
- {
- throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
- }
- };
- window.addEventListener("load", function(e) { async_mg.onLoad(e); }, false);
Add Comment
Please, Sign In to add comment