Skip to content

Latest commit

 

History

History
224 lines (146 loc) · 5.83 KB

management.md

File metadata and controls

224 lines (146 loc) · 5.83 KB

management

Documentation: Chrome Management API

A promise-based wrapper for the Chrome management API to manage extensions and apps.

Methods

Events


isAvailableManagement

isAvailableManagement(method?: ApiMethodName<typeof chrome.management>): boolean

The optional method is a native function name, for example isAvailableManagement("getSelf"). Import the public ApiMethodName type from @addon-core/browser for your own typed helpers. This checks callable presence without invoking the method; permissions and argument support still require handling.

Returns true when the management namespace is present on the API selected by browser() in the current context. Returns false if the namespace or WebExtension environment is absent, or if accessing it throws. The check is synchronous, does not log, and reads the current API on every call without caching. Without an argument, it checks namespace presence only. Pass a native method name to also check that it is callable. Neither form verifies permissions, argument support, or a successful operation. See method availability.

import {isAvailableManagement} from "@addon-core/browser";

if (isAvailableManagement()) {
    // The namespace is present; handle operation-specific failures when using it.
}

createAppShortcut

createAppShortcut(id: string): Promise<void>

Creates a desktop shortcut for the specified app ID.

generateAppForLink

generateAppForLink(url: string, title: string): Promise<chrome.management.ExtensionInfo>

Generates a Chrome app for the given URL and title, returning its extension info.

getExtensionInfo

getExtensionInfo(id: string): Promise<chrome.management.ExtensionInfo>

Retrieves information about the extension or app with the specified ID.

getAllExtensionInfo

getAllExtensionInfo(): Promise<chrome.management.ExtensionInfo[]>

Retrieves information about all installed extensions and apps.

getPermissionWarningsById

getPermissionWarningsById(id: string): Promise<string[]>

Gets permission warning messages for the specified extension ID.

getPermissionWarningsByManifest

getPermissionWarningsByManifest(manifestStr: string): Promise<string[]>

Gets permission warning messages for the given manifest string.

getCurrentExtension

getCurrentExtension(): Promise<chrome.management.ExtensionInfo>

Retrieves information about the current extension.

launchExtensionApp

launchExtensionApp(id: string): Promise<void>

Launches the specified extension app by ID.

setExtensionEnabled

setExtensionEnabled(id: string, enabled: boolean): Promise<void>

Enables or disables the specified extension or app.

setExtensionLaunchType

setExtensionLaunchType(id: string, launchType: string): Promise<void>

Sets the launch type (for example, regular or pinned) for the specified extension.

uninstallExtension

uninstallExtension(id: string, showConfirmDialog?: boolean): Promise<void>

Uninstalls the extension with the given ID, optionally showing a confirmation dialog.

uninstallCurrentExtension

uninstallCurrentExtension(showConfirmDialog?: boolean): Promise<void>

Uninstalls the current extension, optionally showing a confirmation dialog.

onExtensionDisabled

onExtensionDisabled(
  callback: (info: chrome.management.ExtensionInfo) => void
): () => void

Adds a listener that fires when an extension or app is disabled. Returns an unsubscribe function.

onExtensionEnabled

onExtensionEnabled(
  callback: (info: chrome.management.ExtensionInfo) => void
): () => void

Adds a listener that fires when an extension or app is enabled. Returns an unsubscribe function.

onExtensionInstalled

onExtensionInstalled(
  callback: (info: chrome.management.ExtensionInfo) => void
): () => void

Adds a listener that fires when an extension or app is installed. Returns an unsubscribe function.

onExtensionUninstalled

onExtensionUninstalled(
  callback: (extensionId: string) => void
): () => void

Adds a listener that fires when an extension or app is uninstalled, passing its ID. Returns an unsubscribe function.