The chrome.preferences module contains a prototype for giving other
modules access to manage preferences stored by Chrome. This prototype is used,
for example, for chrome.proxy.settings.
The preferences API provides a common set of functions
(get(), set(), and clear()) as
well as an event publisher (onChange) for various
preferences in Chrome. The proxy settings
examples demonstrate how these functions are intended to be used.
Chrome distinguishes between three different scopes of preferences:
regularregular scope apply to regular
browser windows and are inherited by the incognito windows if they are not
overwritten. These preferences are stored to disk and remain in place until
they are cleared by the governing extension, or the governing extension is
disabled or uninstalled.incognito_persistentincognito_persistent scope apply only
to incognito windows. For these, they override regular
preferences. These preferences are stored to disk and remain in place until
they are cleared by the governing extension, or the governing extension is
disabled or uninstalled.incognito_session_onlyincognito_session_only scope apply only
to incognito windows. For these, they override regular and
incognito_session_only preferences. These preferences are not
stored to disk and are cleared when the last incognito window is closed. They
can only be set when at least one incognito window is open.Chrome manages preferences on different layers. The following list describes the layers that may influence the effective preferences, in increasing order of precedence.
As the list implies, policies might overrule any changes that you specify with
your extension. You can use the get() function to determine whether
your extension is capable of setting a preference or whether this setting would
be overridden.
As discussed above, Chrome allows using different preferences for regular windows and incognito windows. The following example illustrates the behavior. Assume that no policy overrides the preferences and that an extension can set preferences for regular windows (R) and preferences for incognito windows (I).
If two or more extensions want to set the same preference to different values, the extension installed most recently takes precedence over the other extensions. If the most recently installed extension sets only (I), the preference of regular windows can be defined by previously installed extensions.
The effective preference value is the setting that results from considering the preference rules. It is used by Chrome.