chrome.management
- Description
The
chrome.management
API 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. - Permissions
management
Manifest #
You must declare the "management" permission in the extension manifest to use the management API. For example:
{
"name": "My extension",
...
"permissions": [
"management"
],
...
}
management.getPermissionWarningsByManifest
, management.uninstallSelf
, and management.getSelf
do not require the management permission.
Summary
- Types
- Methods
chrome.management.canInstallReplacementAndroidApp(callback: function)
chrome.management.createAppShortcut(id: string, callback: function)
chrome.management.generateAppForLink(url: string, title: string, callback: function)
chrome.management.get(id: string, callback: function)
chrome.management.getAll(callback: function)
chrome.management.getPermissionWarningsById(id: string, callback: function)
chrome.management.getPermissionWarningsByManifest(manifestStr: string, callback: function)
chrome.management.getSelf(callback: function)
chrome.management.installReplacementAndroidApp(callback: function)
chrome.management.installReplacementWebApp(callback: function)
chrome.management.launchApp(id: string, callback: function)
chrome.management.setEnabled(id: string, enabled: boolean, callback: function)
chrome.management.setLaunchType(id: string, launchType: LaunchType, callback: function)
chrome.management.uninstall(id: string, options: UninstallOptions, callback: function)
chrome.management.uninstallSelf(options: UninstallOptions, callback: function)
- Events
Types
ExtensionInfo
Information about an installed extension, app, or theme.
Properties
- appLaunchUrlstring optional
The launch url (only present for apps).
- availableLaunchTypesLaunchType[] optional
The currently available launch types (only present for apps).
- descriptionstring
The description of this extension, app, or theme.
- disabledReasonExtensionDisabledReason optional
A reason the item is disabled.
- enabledboolean
Whether it is currently enabled or disabled.
- homepageUrlstring optional
The URL of the homepage of this extension, app, or theme.
- hostPermissionsstring[]
Returns a list of host based permissions.
- iconsIconInfo[] optional
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.
- idstring
The extension's unique identifier.
- installType
How the extension was installed.
- isAppboolean
Deprecated. Please use
ExtensionInfo.type
.True if this is an app.
- launchTypeLaunchType optional
The app launch type (only present for apps).
- mayDisableboolean
Whether this extension can be disabled or uninstalled by the user.
- mayEnableboolean optional
Whether this extension can be enabled by the user. This is only returned for extensions which are not enabled.
- namestring
The name of this extension, app, or theme.
- offlineEnabledboolean
Whether the extension, app, or theme declares that it supports offline.
- optionsUrlstring
The url for the item's options page, if it has one.
- permissionsstring[]
Returns a list of API based permissions.
- shortNamestring
A short version of the name of this extension, app, or theme.
- type
The type of this extension, app, or theme.
- updateUrlstring optional
The update URL of this extension, app, or theme.
- versionstring
The version of this extension, app, or theme.
- versionNamestring optional
The version name of this extension, app, or theme if the manifest specified one.
IconInfo
Information about an icon belonging to an extension, app, or theme.
Properties
- sizenumber
A number representing the width and height of the icon. Likely values include (but are not limited to) 128, 48, 24, and 16.
- urlstring
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.
UninstallOptions
Information about an icon belonging to an extension, app, or theme.
Properties
- showConfirmDialogboolean optional
Whether or not a confirm-uninstall dialog should prompt the user. Defaults to false for self uninstalls. If an extension uninstalls another extension, this parameter is ignored and the dialog is always shown.
ExtensionDisabledReason
A reason the item is disabled.
Enum
"unknown"
, or "permissions_increase"
ExtensionInstallType
How the extension was installed. One of
admin: The extension was installed because of an administrative policy,
development: The extension was loaded unpacked in developer mode,
normal: The extension was installed normally via a .crx file,
sideload: The extension was installed by other software on the machine,
other: The extension was installed by other means.
Enum
"admin"
, "development"
, "normal"
, "sideload"
, or "other"
ExtensionType
The type of this extension, app, or theme.
Enum
"extension"
, "hosted_app"
, "packaged_app"
, "legacy_packaged_app"
, "theme"
, or "login_screen_extension"
LaunchType
These are all possible app launch types.
Enum
"OPEN_AS_REGULAR_TAB"
, "OPEN_AS_PINNED_TAB"
, "OPEN_AS_WINDOW"
, or "OPEN_FULL_SCREEN"
Methods
canInstallReplacementAndroidApp
chrome.management.canInstallReplacementAndroidApp(callback: function)
Checks if the replacement android app can be installed. Errors generated by this API are reported by setting runtime.lastError
and executing the function's regular callback.
Parameters
- callbackfunction
The callback parameter should be a function that looks like this:
(result: boolean) => {...}
- resultboolean
createAppShortcut
chrome.management.createAppShortcut(id: string, callback: function)
Display options to create shortcuts for an app. On Mac, only packaged app shortcuts can be created.
Parameters
- idstring
This should be the id from an app item of
ExtensionInfo
. - callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
generateAppForLink
chrome.management.generateAppForLink(url: string, title: string, callback: function)
Generate an app for a URL. Returns the generated bookmark app.
Parameters
- urlstring
The URL of a web page. The scheme of the URL can only be "http" or "https".
- titlestring
The title of the generated app.
- callbackfunction
The callback parameter should be a function that looks like this:
(result: ExtensionInfo) => {...}
- result
get
chrome.management.get(id: string, callback: function)
Returns information about the installed extension, app, or theme that has the given ID.
Parameters
- idstring
The ID from an item of
ExtensionInfo
. - callbackfunction
The callback parameter should be a function that looks like this:
(result: ExtensionInfo) => {...}
- result
getAll
chrome.management.getAll(callback: function)
Returns a list of information about installed extensions and apps.
Parameters
- callbackfunction
The callback parameter should be a function that looks like this:
(result: ExtensionInfo[]) => {...}
- result
getPermissionWarningsById
chrome.management.getPermissionWarningsById(id: string, callback: function)
Returns a list of permission warnings for the given extension id.
Parameters
- idstring
The ID of an already installed extension.
- callbackfunction
The callback parameter should be a function that looks like this:
(permissionWarnings: string[]) => {...}
- permissionWarningsstring[]
getPermissionWarningsByManifest
chrome.management.getPermissionWarningsByManifest(manifestStr: string, callback: function)
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
- manifestStrstring
Extension manifest JSON string.
- callbackfunction
The callback parameter should be a function that looks like this:
(permissionWarnings: string[]) => {...}
- permissionWarningsstring[]
getSelf
chrome.management.getSelf(callback: function)
Returns information about the calling extension, app, or theme. Note: This function can be used without requesting the 'management' permission in the manifest.
Parameters
- callbackfunction
The callback parameter should be a function that looks like this:
(result: ExtensionInfo) => {...}
- result
installReplacementAndroidApp
chrome.management.installReplacementAndroidApp(callback: function)
Prompts the user to install the replacement Android app from the manifest. Errors generated by this API are reported by setting runtime.lastError
and executing the function's regular callback.
Parameters
- callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
installReplacementWebApp
chrome.management.installReplacementWebApp(callback: function)
Launches the replacement_web_app specified in the manifest. Prompts the user to install if not already installed.
Parameters
- callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
launchApp
chrome.management.launchApp(id: string, callback: function)
Launches an application.
Parameters
- idstring
The extension id of the application.
- callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
setEnabled
chrome.management.setEnabled(id: string, enabled: boolean, callback: function)
Enables or disables an app or extension. In most cases this function must be called in the context of a user gesture (e.g. an onclick handler for a button), and may present the user with a native confirmation UI as a way of preventing abuse.
Parameters
- idstring
This should be the id from an item of
ExtensionInfo
. - enabledboolean
Whether this item should be enabled or disabled.
- callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
setLaunchType
chrome.management.setLaunchType(id: string, launchType: LaunchType, callback: function)
Set the launch type of an app.
Parameters
- idstring
This should be the id from an app item of
ExtensionInfo
. - launchType
The target launch type. Always check and make sure this launch type is in
ExtensionInfo.availableLaunchTypes
, because the available launch types vary on different platforms and configurations. - callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
uninstall
chrome.management.uninstall(id: string, options: UninstallOptions, callback: function)
Uninstalls a currently installed app or extension.
Parameters
- idstring
This should be the id from an item of
ExtensionInfo
. - options
- callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
uninstallSelf
chrome.management.uninstallSelf(options: UninstallOptions, callback: function)
Uninstalls the calling extension. Note: This function can be used without requesting the 'management' permission in the manifest.
Parameters
- options
- callbackfunction
The callback parameter should be a function that looks like this:
() => {...}
Events
onDisabled
chrome.management.onDisabled.addListener(listener: function)
Fired when an app or extension has been disabled.
Event
- listenerfunction
onEnabled
chrome.management.onEnabled.addListener(listener: function)
Fired when an app or extension has been enabled.
Event
- listenerfunction
onInstalled
chrome.management.onInstalled.addListener(listener: function)
Fired when an app or extension has been installed.
Event
- listenerfunction
onUninstalled
chrome.management.onUninstalled.addListener(listener: function)
Fired when an app or extension has been uninstalled.
Event
- listenerfunction
The listener parameter should be a function that looks like this:
(id: string) => {...}
- idstring
The id of the extension, app, or theme that was uninstalled.