sbDndSourceTracker.js
Go to the documentation of this file.
1 
31 const Cc = Components.classes;
32 const Ci = Components.interfaces;
33 const Cr = Components.results;
34 
35 const CONTRACTID = "@songbirdnest.com/Songbird/DndSourceTracker;1";
36 const CLASSNAME = "Songbird Drag and Drop Source Tracker Service";
37 const CID = Components.ID("{54b21a93-5b1b-46a2-a60f-5378ccf7f65c}");
38 const IID = Ci.sbIDndSourceTracker;
39 
40 function DndSourceTracker() {
41  this._sources = {};
42 }
43 DndSourceTracker.prototype = {
44  _sources: null,
45  _nextHandle: 0,
46 
47  reset: function reset() {
48  this._sources = {};
49  },
50 
51  registerSource: function registerSource(aSource) {
52  var handle = this._nextHandle.toString();
53  this._nextHandle++;
54  this._sources[handle] = aSource;
55  return handle;
56  },
57 
58  getSource: function getSource(aHandle) {
59  if (aHandle in this._sources) {
60  return this._sources[aHandle];
61  }
62  throw Cr.NS_ERROR_NOT_AVAILABLE;
63  },
64 
65  getSourceSupports: function getSourceSupports(aHandle) {
66  return this.getSource(aHandle.data);
67  },
68 
69  QueryInterface: function(iid) {
70  if (!iid.equals(IID) &&
71  !iid.equals(Ci.nsISupports))
72  throw Cr.NS_ERROR_NO_INTERFACE;
73  return this;
74  }
75 };
76 
82 var gModule = {
83  registerSelf: function(componentManager, fileSpec, location, type) {
84  componentManager = componentManager.QueryInterface(Ci.nsIComponentRegistrar);
85  componentManager.registerFactoryLocation(CID, CLASSNAME, CONTRACTID,
86  fileSpec, location, type);
87  },
88 
89  getClassObject: function(componentManager, cid, iid) {
90  if (!iid.equals(Ci.nsIFactory))
91  throw Cr.NS_ERROR_NOT_IMPLEMENTED;
92 
93  if (cid.equals(CID)) {
94  return {
95  createInstance: function(outer, iid) {
96  if (outer != null)
97  throw Cr.NS_ERROR_NO_AGGREGATION;
98  return (new DndSourceTracker()).QueryInterface(iid);;
99  }
100  };
101  }
102 
103  throw Cr.NS_ERROR_NO_INTERFACE;
104  },
105 
106  canUnload: function(componentManager) {
107  return true;
108  }
109 };
110 
111 function NSGetModule(comMgr, fileSpec) {
112  return gModule;
113 }
114 
const CONTRACTID
SafebrowsingApplicationMod prototype registerSelf
function NSGetModule(comMgr, fileSpec)
const Cc
sidebarFactory createInstance
Definition: nsSidebar.js:351
sbOSDControlService prototype QueryInterface
function handle(request, response)
const CID
SafebrowsingApplicationMod prototype getClassObject
function DndSourceTracker()
var gModule
return null
Definition: FeedWriter.js:1143
const Ci
if(DEBUG_DATAREMOTES)
const CLASSNAME
const IID
const Cr