nsSafebrowsingApplication.js
Go to the documentation of this file.
1 const Cc = Components.classes;
2 const Ci = Components.interfaces;
3 
4 // This is copied from toolkit/components/content/js/lang.js.
5 // It seems cleaner to copy this rather than #include from so far away.
6 Function.prototype.inherits = function(parentCtor) {
7  var tempCtor = function(){};
8  tempCtor.prototype = parentCtor.prototype;
9  this.superClass_ = parentCtor.prototype;
10  this.prototype = new tempCtor();
11 }
12 
13 #include ../content/application.js
14 #include ../content/globalstore.js
15 #include ../content/list-warden.js
16 #include ../content/phishing-warden.js
17 #include ../content/malware-warden.js
18 
19 var modScope = this;
20 function Init() {
21  var jslib = Cc["@mozilla.org/url-classifier/jslib;1"]
22  .getService().wrappedJSObject;
23  modScope.G_Debug = jslib.G_Debug;
24  modScope.G_Assert = jslib.G_Assert;
25  modScope.G_Alarm = jslib.G_Alarm;
26  modScope.G_ConditionalAlarm = jslib.G_ConditionalAlarm;
27  modScope.G_ObserverWrapper = jslib.G_ObserverWrapper;
28  modScope.G_Preferences = jslib.G_Preferences;
29  modScope.PROT_XMLFetcher = jslib.PROT_XMLFetcher;
30  modScope.BindToObject = jslib.BindToObject;
31  modScope.G_Protocol4Parser = jslib.G_Protocol4Parser;
32  modScope.PROT_UrlCrypto = jslib.PROT_UrlCrypto;
33  modScope.RequestBackoff = jslib.RequestBackoff;
34 
35  // We only need to call Init once
36  modScope.Init = function() {};
37 }
38 
39 // Module object
41  this.firstTime = true;
42  this.cid = Components.ID("{c64d0bcb-8270-4ca7-a0b3-3380c8ffecb5}");
43  this.progid = "@mozilla.org/safebrowsing/application;1";
44 }
45 
46 SafebrowsingApplicationMod.prototype.registerSelf = function(compMgr, fileSpec, loc, type) {
47  if (this.firstTime) {
48  this.firstTime = false;
49  throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
50  }
51  compMgr = compMgr.QueryInterface(Ci.nsIComponentRegistrar);
52  compMgr.registerFactoryLocation(this.cid,
53  "Safebrowsing Application Module",
54  this.progid,
55  fileSpec,
56  loc,
57  type);
58 };
59 
60 SafebrowsingApplicationMod.prototype.getClassObject = function(compMgr, cid, iid) {
61  if (!cid.equals(this.cid))
62  throw Components.results.NS_ERROR_NO_INTERFACE;
63  if (!iid.equals(Ci.nsIFactory))
64  throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
65 
66  return this.factory;
67 }
68 
69 SafebrowsingApplicationMod.prototype.canUnload = function(compMgr) {
70  return true;
71 }
72 
73 SafebrowsingApplicationMod.prototype.factory = {
74  createInstance: function(outer, iid) {
75  if (outer != null)
76  throw Components.results.NS_ERROR_NO_AGGREGATION;
77  Init();
78  return new PROT_Application();
79  }
80 };
81 
83 
84 function NSGetModule(compMgr, fileSpec) {
85  return ApplicationModInst;
86 }
sidebarFactory createInstance
Definition: nsSidebar.js:351
var firstTime
var ApplicationModInst
function Init()
return null
Definition: FeedWriter.js:1143
AddonMetadata prototype
function PROT_Application()
Definition: application.js:54
if(DEBUG_DATAREMOTES)
function NSGetModule(compMgr, fileSpec)
function SafebrowsingApplicationMod()