Types
For information on how to use experimental APIs, see the chrome.experimental.* APIs page.
Types
The chrome.types
module contains type declarations for Chrome.
Currently this comprises only a prototype for giving other
modules access to manage Chrome browser settings. This prototype is used,
for example, for chrome.proxy.settings
.
Chrome settings
The ChromeSetting
prototype provides a common set of functions
(get()
, set()
, and clear()
) as
well as an event publisher (onChange
) for settings of the
Chrome browser. The proxy settings
examples demonstrate how these functions are intended to be used.
Scope and life cycle
Chrome distinguishes between three different scopes of browser settings:
regular
- Settings set in the
regular
scope apply to regular
browser windows and are inherited by incognito windows if they are not
overwritten. These settings 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_persistent
- Settings set in the
incognito_persistent
scope apply only
to incognito windows. For these, they override regular
settings. These settings 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_only
- Settings set in the
incognito_session_only
scope apply only
to incognito windows. For these, they override regular
and
incognito_session_only
settings. These settings 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.
Precedence
Chrome manages settings on different layers. The following list describes the
layers that may influence the effective settings, in increasing order of
precedence.
- System settings provided by the operating system
- Command-line parameters
- Settings provided by extensions
- Policies
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 providing a setting or whether this setting would
be overridden.
As discussed above, Chrome allows using different settings for regular
windows and incognito windows. The following example illustrates the behavior.
Assume that no policy overrides the settings and that an extension can set
settings for regular windows (R) and settings for incognito windows
(I).
- If only (R) is set, these settings are effective for both
regular and incognito windows.
- If only (I) is set, these settings are effective for only
incognito windows. Regular windows use the settings determined by the lower
layers (command-line options and system settings).
- If both (R) and (I) are set, the respective settings are
used for regular and incognito windows.
If two or more extensions want to set the same setting to different values,
the extension installed most recently takes precedence over the other
extensions. If the most recently installed extension sets only (I), the
settings of regular windows can be defined by previously installed extensions.
The effective value of a setting is the one that results from
considering the precedence rules. It is used by Chrome.
API reference: chrome.types
Properties
getLastError
chrome.extensionlastError
Methods
method name
void
chrome.module.methodName(,
)
Undocumented.
A description from the json schema def of the function goes here.
Parameters
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(Type param1, Type param2) {...};
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Events
event name
chrome.bookmarksonEvent.addListener(function(Type param1, Type param2) {...}, Type opt_param1, Type opt_param2));
Undocumented.
A description from the json schema def of the event goes here.
Extra parameters to addListener
Listener returns
Types
ChromeSetting
paramName
(
optional
enumerated
Type
array of
object
)
Undocumented.
An interface which allows access to a Chrome browser setting.
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Methods of ChromeSetting
clear
void
chromeSetting.clear(, object
details, function
callback)
Undocumented.
Clears the setting. This way default settings can become effective again.
Parameters
-
details
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
- What setting to clear.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
scope
(
optional
enumerated
Type
array of
string
["regular", "incognito_persistent", "incognito_session_only"]
)
-
Undocumented.
- Where to clear the setting (default: regular). One of
regular: setting for regular profile (which is inherited by the incognito profile if not overridden elsewhere),
incognito_persistent: setting for incognito profile that survives browser restarts (overrides regular preferences),
incognito_session_only: setting for incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences).
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
- Called after the setting has been cleared.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function() {...};
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
get
void
chromeSetting.get(, object
details, function
callback)
Undocumented.
Get the value of a setting.
Parameters
-
details
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
- What setting to consider.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
incognito
(
optional
enumerated
Type
array of
boolean
)
-
Undocumented.
- Whether to return the setting that applies to the incognito session (default false).
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function(object details) {...};
-
details
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
- Details of the currently effective value.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
value
(
optional
enumerated
Type
array of
any
)
-
Undocumented.
- The value of the setting.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
levelOfControl
(
optional
enumerated
Type
array of
string
["not_controllable", "controlled_by_other_extensions", "controllable_by_this_extension", "controlled_by_this_extension"]
)
-
Undocumented.
- One of
not_controllable: cannot be controlled by any extension
controlled_by_other_extensions: controlled by extensions with higher precedence
controllable_by_this_extension: can be controlled by this extension
controlled_by_this_extension: controlled by this extension
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
incognitoSpecific
(
optional
enumerated
Type
array of
boolean
)
-
Undocumented.
- Whether the effective value is specific to the incognito session.
This property will only be present if the incognito property in the details parameter of get()
was true.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
-
-
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
set
void
chromeSetting.set(, object
details, function
callback)
Undocumented.
Set the value of a setting.
Parameters
-
details
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
- What setting to change.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
value
(
optional
enumerated
Type
array of
any
)
-
Undocumented.
- The value of the setting.
Note that every setting has a specific value type, which is described together with the setting. An extension should not set a value of a different type.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
scope
(
optional
enumerated
Type
array of
string
["regular", "incognito_persistent", "incognito_session_only"]
)
-
Undocumented.
- Where to set the setting (default: regular). One of
regular: setting for regular profile (which is inherited by the incognito profile if not overridden elsewhere),
incognito_persistent: setting for incognito profile that survives browser restarts (overrides regular preferences),
incognito_session_only: setting for incognito profile that can only be set during an incognito session and is deleted when the incognito session ends (overrides regular and incognito_persistent preferences).
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
-
-
-
callback
(
optional
enumerated
Type
array of
function
)
-
Undocumented.
- Called after the setting has been set.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
Returns
Callback function
The callback parameter should specify a function
that looks like this:
If you specify the callback parameter, it should
specify a function that looks like this:
function() {...};
This function was added in version .
If you require this function, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
Events of ChromeSetting
onChange
chromeSetting.onChange.addListener(function(object details) {...}));
Undocumented.
Fired when the value of the setting changes.
Listener parameters
-
details
(
optional
enumerated
Type
array of
object
)
-
Undocumented.
-
Description of this parameter from the json schema.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
value
(
optional
enumerated
Type
array of
any
)
-
Undocumented.
- The value of the setting.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
levelOfControl
(
optional
enumerated
Type
array of
string
["not_controllable", "controlled_by_other_extensions", "controllable_by_this_extension", "controlled_by_this_extension"]
)
-
Undocumented.
- One of
not_controllable: cannot be controlled by any extension
controlled_by_other_extensions: controlled by extensions with higher precedence
controllable_by_this_extension: can be controlled by this extension
controlled_by_this_extension: controlled by this extension
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
incognitoSpecific
(
optional
enumerated
Type
array of
boolean
)
-
Undocumented.
- Whether the value that has changed is specific to the incognito session.
This property will only be present if the user has enabled the extension in incognito mode.
-
This parameter was added in version
.
You must omit this parameter in earlier versions,
and you may omit it in any version. If you require this
parameter, the manifest key
minimum_chrome_version
can ensure that your extension won't be run in an earlier browser version.
-
-
-
-
-
-
-
Extra parameters to addListener
Listener returns