Changes

Jump to: navigation, search

Real World Mozilla Adding Chrome to FirstXpcom Lab

125 bytes removed, 23:51, 24 November 2008
Integrating with the build systetm
this.initialized = true;
this.firstxpcom = Components.classes["@senecac.on.ca/firstxpcom;1"]
.createInstance(Components.interfaces.IFirstXpcom);
this.firstxpcom.name = "First XPCOM";
},
this.initialized = true;
this.firstxpcom = Components.classes["@senecac.on.ca/firstxpcom;1"]
.createInstance(Components.interfaces.IFirstXpcom);
this.firstxpcom.name = "First XPCOM";
// Use the Alerts Service to display the results to the user.
var alertsService = Components.classes["@mozilla.org/alerts-service;1"]
.getService(Components.interfaces.nsIAlertsService);
alertsService.showAlertNotification(null, this.firstxpcom.name, this.total,
false, "", null);
this.firstxpcom = Components.classes["@senecac.on.ca/firstxpcom;1"]
.'''createInstance'''(Components.interfaces.IFirstXpcom);
var alertsService = Components.classes["@mozilla.org/alerts-service;1"]
.'''getService'''(Components.interfaces.nsIAlertsService);
In the former case we use '''createInstance''', which gives us a new unique instance. In the latter, we use '''getService''', which returns a shared instance of an existing component (i.e., a Singleton). Unlike IFirstXpcom, which can be created many times by different callers, the nsIAlertsService is a shared component, because only one pop-up message at a time can be shown to the user.
The '''onOK''' function occurs when the user clicks the accept button (i.e., OK). When this happens the values from the textboxes are obtained and packaged up in the '''out''' parameter we sent in earlier. This is how we pass values back to the main window, and our extension code in '''firstxpcomchrome'''.
= Integrating with the build systetm =
'''TODO''' -- see http://developer.mozilla.org/en/docs/JAR_Manifests for a discussion of jar.mn files in the build system.
=Reflections=

Navigation menu