O'Reilly logo

Firefox Hacks by Nigel McFarlane

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hack #23. Play With the Preference System

Dig underneath Firefox's user interface and hack the preference system directly.

Firefox's preference system holds many of the small configuration items of the Firefox browser. These items are hidden from the user: behind formal user interfaces, unimplemented by user interfaces, or invisible because no default values are recorded anywhere. This hack explains how to work with the preference system directly.

Understanding the Preference Database

The preference system is equivalent to a tiny database. It sits in memory while Firefox runs. The preference database is a thread-safe but single-user database. It consists of a single table of four columns:

Name

Contains a unique string that identifies the preference. This is the primary key.

Value

Contains the data for the preference. It can be a string, number, or true/false (Boolean) value.

Locked Attribute

States whether the preference has been locked. Users cannot change locked preferences.

Default Attribute

Remains true as long as the user does not set (override) the preference.

The last two columns are not set explicitly; they are set indirectly [Section 3.3.4, later in this hack] Here is a typical preference:

Name                                    Value
----                              -----
browser.chrome.site_icons          true   /* not locked, user set */

Any string (within reason) can be used as a preference name. The dots (periods) are not especially meaningful. They are just a convenience for programmers. Programmers can compose a query that pulls out all the preferences ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required