Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

Extension API Enum Types, Event Reasons and Sentinel Values

What Chrome extension reference enums mean—event causes, danger states, window types, offscreen reasons, and none sentinels—and how to use them in code.

This page summarizes how enumerations and typed constants appear in Chrome extension API reference documentation (browser.* for Manifest V3 and chrome.* for Manifest V2). Almost every API surface exposes small string enums or numeric sentinels that explain why something happened, what kind of object you are looking at, or which variant of a feature applies. Recognizing those patterns helps you handle events correctly and avoid treating documentation labels as free-form strings.

Extension API enums: what they are and where they appear

Section titled “Extension API enums: what they are and where they appear”

Chrome’s extension references define enum types beside methods and events. Each value is a fixed identifier (usually a quoted string) with a short description. Event payloads often include a reason, cause, or type field drawn from one of these enums so your background script or service worker can branch on platform-defined cases instead of guessing.

The same ideas recur across APIs: lifecycle reasons (install, update), security or safety classifications (downloads), UI disposition (where a navigation should open), and sentinel IDs meaning “no tab” or “no window.” Version lines such as Chrome 44+ browser.* since Chrome 148 on a type tell you when the value became available in the browser namespace; older Manifest V2 reference pages document parallel chrome.* shapes.

OnInstalledReason and runtime lifecycle enums

Section titled “OnInstalledReason and runtime lifecycle enums”

Extension lifecycle events distinguish why Chrome fired the handler. For runtime.onInstalled, documented values include installation versus updates driven by the extension, the browser, or a shared module:

“install” — Specifies the event reason as an installation.

“update” — Specifies the event reason as an extension update.

“chrome_update” — Specifies the event reason as a Chrome update.

“shared_module_update” — Specifies the event reason as an update to a shared module.

— Google, browser.runtime

When an extension loads (not only on install), newer Chrome versions expose ExtensionLoadDetails with an OnLoadedReason and optional previousVersion. The docs state that previousVersion is present only when reason is update or enable: for update it is the version before the update; for enable it is the current version.

If Chrome tells the user or the extension that a restart is required, OnRestartRequiredReason explains whether an app update, OS update, or enterprise periodic uptime policy triggered it—see the same runtime reference for the app_update, os_update, and periodic enum members.

Cookie change listeners receive a cause that separates user or extension actions from automatic browser behavior:

The underlying reason behind the cookie’s change. If a cookie was inserted, or removed via an explicit call to “chrome.cookies.remove”, “cause” will be “explicit”. If a cookie was automatically removed due to expiry, “cause” will be “expired”. If a cookie was removed due to being overwritten with an already-expired expiration date, “cause” will be set to “expired_overwrite”. If a cookie was automatically removed due to garbage collection, “cause” will be “evicted”. If a cookie was automatically removed due to a “set” call that overwrote it, “cause” will be “overwrite”. Plan your response accordingly.

— Google, browser.cookies

The closing sentence is intentional guidance: sync or analytics code should treat explicit differently from expired or evicted so you do not fight the storage lifecycle. The MV2 cookies reference documents the same OnChangedCause text.

The downloads API exposes a large enum describing Safe Browsing and enterprise policy outcomes—from suspicious filenames and malicious URLs to deep-scan results and sensitive-content blocks. Representative members:

Value Meaning (from docs)
file The download’s filename is suspicious.
url The download’s URL is known to be malicious.
content The downloaded file is known to be malicious.
safe The download presents no known danger to the user’s computer.
accepted The user has accepted the dangerous download.

Enterprise-oriented entries include forceSaveToGdrive and forceSaveToOnedrive: when required, Chrome blocks saving to disk and sends the file to Google Drive or OneDrive for the Secure Enterprise Browser extension—see the enum list on browser.downloads and chrome.downloads (MV2).

Offscreen document Reasons and lifetime limits

Section titled “Offscreen document Reasons and lifetime limits”

Creating an offscreen document requires declaring a reason that matches what the hidden page will do. Reasons are set at creation time and tie into document lifespan:

For a list of valid reasons, see the Reasons section. Reasons are set during document creation to determine the document’s lifespan. The AUDIO_PLAYBACK reason sets the document to close after 30 seconds without audio playing. All other reasons don’t set lifetime limits.

— Google, browser.offscreen

Documented reason strings include AUDIO_PLAYBACK, CLIPBOARD, DOM_SCRAPING, WEB_RTC, WORKERS, and others on that page. Choosing the wrong reason can violate Chrome’s offscreen eligibility rules even if your code technically runs—match the reason to the APIs you call (USER_MEDIA, LOCAL_STORAGE, etc.).

History and webNavigation APIs classify how the user arrived at a URL. browser.history defines TransitionType for a visit from its referrer. browser.webNavigation states that transition types align with the history API, except start_page replaces auto_toplevel for backwards compatibility:

Cause of the navigation. The same transition types as defined in the history API are used. These are the same transition types as defined in the history API except with “start_page” in place of “auto_toplevel” (for backwards compatibility).

— Google, browser.webNavigation

Use these enums when filtering analytics or distinguishing typed URL bar navigations from link clicks—not as security boundaries on their own.

Several APIs label browser chrome structures:

  • browser.windows — WindowType includes normal, popup, devtools, and deprecated panel / app types; CreateType notes that panel is deprecated and only available to allowlisted extensions on Chrome OS.
  • browser.tabs — MutedInfoReason is user, capture, or extension (with extensionId when an extension muted the tab).
  • browser.omnibox — OnInputEnteredDisposition recommends where to show results (e.g. newForegroundTab for navigation in a new selected tab).

Sentinel constants avoid magic numbers: TAB_ID_NONE represents the absence of a browser tab; WINDOW_ID_NONE the absence of a window (tabs, windows). MV2 tabs also documents TAB_INDEX_NONE for missing strip indices.

Settings exposed through privacy or content APIs often include a LevelOfControl field:

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

— Google, browser.types

Check this before calling set methods: if another extension already controls the setting, your extension may only read values or need higher install precedence per Chrome’s extension ordering rules.

Management, bookmarks, and enterprise-only types

Section titled “Management, bookmarks, and enterprise-only types”

management enums describe how an item was installed (admin, development, normal, sideload, other) and why it is disabled (ExtensionDisabledReason). bookmarks uses BookmarkTreeNodeUnmodifiable when managed policy locked a node—omitted when the user and extension can edit it.

Enterprise-focused references add narrower enums—for example enterprise.platformKeys Algorithm for key generation types, and MV2 Scope for Enterprise User Key versus Machine Key.

Common mistakes when reading enum reference pages

Section titled “Common mistakes when reading enum reference pages”
  • Treating MV2 and MV3 pages as interchangeable — Compare browser.runtime with chrome.runtime (MV2); shapes usually match, but availability lines differ.
  • Ignoring version gates — Types marked Chrome 157+ or Chrome 151+ (e.g. AutofillBlockedType on browser.privacy) are absent or undefined on older clients.
  • Parsing unstable debug strings — webviewTag LoadAbortReason explicitly warns the string is not guaranteed backwards compatible; do not build logic that depends on parsing it.
  • Using deprecated window types — panel and app window types are deprecated in extension window APIs; new code should use supported normal / popup / devtools patterns.
  1. Load your unpacked or packed extension in Chrome, open the service worker or background page DevTools console, and log event payloads (runtime.onInstalled, cookies.onChanged, etc.) to confirm enum strings match the current Chrome extension reference.

  2. Cross-check each reason, cause, or type value against the enum section on the linked API page (for example downloads for danger states).

  3. If you support both Manifest V2 and V3, repeat the check against the corresponding MV2 reference entry for the same API.

  4. For offscreen documents, verify the declared reason matches APIs in use and observe whether AUDIO_PLAYBACK closes the document after 30 seconds without audio per browser.offscreen.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page does not match the current Chrome documentation, or you need a clarification on a specific enum, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about.