Management
Management
The chrome.management module provides ways to manage the list of extensions/apps that are installed and running. It is particularly useful for extensions that override the built-in New Tab page.
Manifest
You must declare the "management" permission
in the extension manifest
to use the management API.
For example:
{
"name": "My extension",
...
"permissions": [
"management"
],
...
}
The one method that doesn't require the "management" permission is
getPermissionWarningsByManifest
API reference: chrome.management
Methods
get
chrome.management.get(string
id, function
callback)
Returns information about the installed extension or app that has the given ID.
Parameters
-
callback
(
optional
function
)
-
Undocumented.
Callback function
If you specify the callback parameter, it should
specify a function that looks like this:
function(ExtensionInfo result) {...};
getAll
chrome.management.getAll(function
callback)
Returns a list of information about installed extensions and apps.
Parameters
-
callback
(
optional
function
)
-
Undocumented.
Callback function
If you specify the callback parameter, it should
specify a function that looks like this:
function(array of ExtensionInfo result) {...};
getPermissionWarningsById
chrome.management.getPermissionWarningsById(string
id, function
callback)
Returns a list of permission warnings for the given extension id.
Parameters
-
id
(
string
)
- The ID of an already installed extension.
-
callback
(
optional
function
)
-
Undocumented.
Callback function
If you specify the callback parameter, it should
specify a function that looks like this:
function(array of string permissionWarnings) {...};
-
permissionWarnings
(
array of
string
)
-
Undocumented.
getPermissionWarningsByManifest
chrome.management.getPermissionWarningsByManifest(string
manifestStr, function
callback)
Returns a list of permission warnings for the given extension manifest string. Note: This function can be used without requesting the 'management' permission in the manifest.
Parameters
-
manifestStr
(
string
)
- Extension manifest JSON string.
-
callback
(
optional
function
)
-
Undocumented.
Callback function
If you specify the callback parameter, it should
specify a function that looks like this:
function(array of string permissionWarnings) {...};
-
permissionWarnings
(
array of
string
)
-
Undocumented.
launchApp
chrome.management.launchApp(string
id, function
callback)
Launches an application.
Parameters
-
id
(
string
)
- The extension id of the application.
-
callback
(
optional
function
)
-
Undocumented.
Callback function
If you specify the callback parameter, it should
specify a function that looks like this:
function() {...};
setEnabled
chrome.management.setEnabled(string
id, boolean
enabled, function
callback)
Enables or disables an app or extension.
Parameters
-
id
(
string
)
- This should be the id from an item of ExtensionInfo.
-
enabled
(
boolean
)
- Whether this item should be enabled or disabled.
-
callback
(
optional
function
)
-
Undocumented.
Callback function
If you specify the callback parameter, it should
specify a function that looks like this:
function() {...};
uninstall
chrome.management.uninstall(string
id, function
callback)
Uninstalls a currently installed app or extension.
Parameters
-
id
(
string
)
- This should be the id from an item of ExtensionInfo.
-
callback
(
optional
function
)
-
Undocumented.
Callback function
If you specify the callback parameter, it should
specify a function that looks like this:
function() {...};
Events
onDisabled
chrome.management.onDisabled.addListener(function(ExtensionInfo info) {...});
Fired when an app or extension has been disabled
onEnabled
chrome.management.onEnabled.addListener(function(ExtensionInfo info) {...});
Fired when an app or extension has been enabled.
onInstalled
chrome.management.onInstalled.addListener(function(ExtensionInfo info) {...});
Fired when an app or extension has been installed.
onUninstalled
chrome.management.onUninstalled.addListener(function(string id) {...});
Fired when an app or extension has been uninstalled.
Listener parameters
-
id
(
string
)
- The id of the extension or app that was uninstalled.
Types
IconInfo
(
object
)
Information about an icon belonging to an extension or app.
-
size
(
integer
)
- A number representing the width and height of the icon. Likely values include (but are not limited to) 128, 48, 24, and 16.
-
url
(
string
)
- The URL for this icon image. To display a grayscale version of the icon (to indicate that an extension is disabled, for example), append
?grayscale=true to the URL.
ExtensionInfo
(
object
)
Information about an installed extension or app.
-
id
(
string
)
- The extension's unique identifier.
-
name
(
string
)
- The name of this extension or app.
-
description
(
string
)
- The description of this extension or app.
-
version
(
string
)
- The version of this extension or app.
-
mayDisable
(
boolean
)
- Whether this extension can be disabled or uninstalled by the user.
-
enabled
(
boolean
)
- Whether it is currently enabled or disabled.
-
disabledReason
(
optional
enumerated
string
["unknown", "permissions_increase"]
)
- A reason the item is disabled.
-
isApp
(
boolean
)
- True if this is an app.
-
appLaunchUrl
(
optional
string
)
- The launch url (only present for apps).
-
homepageUrl
(
optional
string
)
- The URL of the homepage of this extension or app.
-
updateUrl
(
optional
string
)
- The update URL of this extension or app.
-
offlineEnabled
(
boolean
)
- Whether the extension or app declares that it supports offline.
-
optionsUrl
(
string
)
- The url for the item's options page, if it has one.
-
icons
- A list of icon information. Note that this just reflects what was declared in the manifest, and the actual image at that url may be larger or smaller than what was declared, so you might consider using explicit width and height attributes on img tags referencing these images. See the manifest documentation on icons for more details.
-
permissions
(
array of
string
)
- Returns a list of API based permissions.
-
hostPermissions
(
array of
string
)
- Returns a list of host based permissions.