Guest User

Untitled

a guest
Jun 21st, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. var async_mg = {
  2. onLoad: function() {
  3. // initialization code
  4.  
  5. new aSyncMtpAltListener();
  6.  
  7. this.initialized = true;
  8. }
  9. };
  10.  
  11.  
  12.  
  13. function aSyncMtpAltListener()
  14. {
  15. window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
  16. .getInterface(Components.interfaces.nsIWebNavigation)
  17. .QueryInterface(Components.interfaces.nsIDocShell)
  18. .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
  19. .getInterface(Components.interfaces.nsIURIContentListener)
  20. .parentContentListener = this;
  21. }
  22.  
  23.  
  24. aSyncMtpAltListener.prototype =
  25. {
  26. QueryInterface: function(iid)
  27. {
  28. if (iid.equals(Components.interfaces.nsIURIContentListener) ||
  29. iid.equals(Components.interfaces.nsISupportsWeakReference) ||
  30. iid.equals(Components.interfaces.nsISupports))
  31. return this;
  32. throw Components.results.NS_NOINTERFACE;
  33. },
  34. onStartURIOpen: function(aUri)
  35. { // We'll just sit back and wait...
  36. return false;
  37. },
  38. doContent: function(aContentType, aIsContentPreferred, aRequest, aContentHandler )
  39. { alert('Argh! At last! This is: ' + aContentType);
  40. //var oChannel = aRequest.QueryInterface(Ci.nsIChannel);
  41. //alert(oChannel.contentType);
  42. throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  43. },
  44. canHandleContent: function(aContentType, aIsContentPreferred, aDesiredContentType)
  45. {
  46. alert(aContentType);
  47. return aContentType == 'multipart/alternate';
  48. throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  49. },
  50. isPreferred: function(aContentType, aDesiredContentType)
  51. { alert(aContentType);
  52. return aContentType == 'multipart/alternate';
  53. try
  54. {
  55. var webNavInfo =
  56. Components.classes["@mozilla.org/webnavigation-info;1"]
  57. .getService(Components.interfaces.nsIWebNavigationInfo);
  58. return webNavInfo.isTypeSupported(aContentType, null);
  59. }
  60. catch (e)
  61. {
  62. return false;
  63. }
  64. },
  65. GetWeakReference : function()
  66. {
  67. throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
  68. }
  69. };
  70.  
  71.  
  72.  
  73. window.addEventListener("load", function(e) { async_mg.onLoad(e); }, false);
Add Comment
Please, Sign In to add comment