Labs/Ubiquity/Ubiquity 0.1.3 Architecture
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.
The objects described in this section are instantiated separately for each window, generally because they encapsulate information about Ubiquity's user interface (and each window has its own Ubiquity UI). The objects described in this section are created in chrome/content/browser.js.
- Command Manager is defined in ubiquity/modules/cmdmanager.js; it's essentially a mediator between Ubiquity's UI elements, its natural-language parser, and the commands themselves.
- Context Popup Menu UI is the user interface for the "Ubiquity" submenu that shows up when the user right-clicks on a selection in Ubiquity. It's contained in chrome/content/popupmenu.js.
- Command Entry UI is the user interface for the command entry mode that's displayed when the user presses a hotkey (usually Ctrl+Space or Apple+Space). It's defined in chrome/content/ubiquity.js and contained in the class Ubiquity, though it should really be renamed to CommandEntryUi or something similar.
- Parser is the natural language parser that is responsible both for interpreting what the user types in the command entry UI, as well as analyzing the user's current selection and mapping it to potential noun types, and combining these two elements to come up with potential "sentences"—verbs with direct and indirect objects—for Ubiquity to execute. It's defined in ubiquity/modules/parser/parser.js.
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. A better name for this object might be CommandFeedSubscriptionService.
- 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.
- 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.