Labs/Ubiquity/Ubiquity 0.1.3 Architecture

From MozillaWiki
< Labs‎ | Ubiquity
Revision as of 20:49, 12 December 2008 by Varmaa (talk | contribs) (added more information)
Jump to navigation Jump to search

Back to Labs/Ubiquity.

This is a description of the high-level design of Ubiquity 0.1.3. Its intended use is as a historical document, as opposed to a constantly-maintained accurate representation of the current Ubiquity architecture.

Ubiquity 0.1.3 Architecture.png

Application-wide Objects

The objects described in this section are shared by the entire XULRunner application; many of them are singletons. The construction of most of these objects begins in ubiquity/modules/setup.js.

  • Mixed Code Source Collection and Code Source classes are defined in ubiquity/modules/codesource.js. A better name for MixedCodeSourceCollection would probably be DecoratedCodeSourceCollection, since the general idea is to take a single piece of code—what's commonly referred to as a "command feed" in Ubiquity—and add a header or preamble that contains common utilities, such as the Utils and CmdUtils namespaces, and a footer that contains finalization and post-processing logic. The headers, footers, and built-in (non-unsubscribable) command feeds are contained in ubiquity/feed-parts/, while most the standard (and unsubscribable) feeds are in ubiquity/standard-feeds/. Iterating over a MixedCodeSourceCollection yields Code Sources that are full representations of all code that ultimately gets executed in a command feed's sandbox.
  • LINK REL Code Service is defined in ubiquity/modules/linkrel_codesvc.js and is responsible for detecting <LINK REL="commands"> tags on web pages, displaying notification box messages to the user, and managing command feed subscriptions. When iterated over, it yields a Code Source object for each subscribed-to command feed, each of which are subsequently decorated by MixedCodeSourceCollection.
  • Command Source is defined in ubiquity/modules/cmdsource.js and is responsible for executing command feed code in sandboxes and retrieving commands, noun types, and page load functions from them. It's also responsible for re-loading command feeds when they've changed.
  • Sandbox Factory is a simple abstraction for the creation of JavaScript sandboxes and the evaluation of code within them. It's defined in ubiquity/modules/sandboxfactory.js.
  • Globals Maker is a factory that sets up global variables, such as Application and XMLHttpRequest, in a new sandbox object. It's defined in ubiquity/modules/setup.js.
  • Message Service is a simple abstraction that encapsulates the display of messages and the reporting of errors to the end-user; it's defined in ubiquity/modules/msgservice.js.