Welcome Getting started API Reference Samples
Welcome Getting started API Reference Samples

chrome.app.runtime

Warning
This API is part of the deprecated Chrome Apps platform. Learn more about migrating your app.
  • Description

    Use the chrome.app.runtime API to manage the app lifecycle. The app runtime manages app installation, controls the event page, and can shut down the app at anytime.

Summary

Types

ActionData

Properties

EmbedRequest

Properties

  • allow
    function

    Allows embedderId to embed this app in an <appview> element. The url specifies the content to embed.

    The allow function looks like this:

    allow(url: string) => {...}
    • url
      string
  • data
    any optional

    Optional developer specified data that the app to be embedded can use when making an embedding decision.

  • deny
    function

    Prevents embedderId from embedding this app in an <appview> element.

    The deny function looks like this:

    deny() => {...}
  • embedderId
    string

LaunchData

Properties

  • actionData
    ActionData optional

    Contains data that specifies the ActionType this app was launched with. This is null if the app was not launched with a specific action intent.

  • id
    string optional

    The ID of the file or URL handler that the app is being invoked with. Handler IDs are the top-level keys in the file_handlers and/or url_handlers dictionaries in the manifest.

  • isKioskSession
    boolean optional

    Whether the app is being launched in a Chrome OS kiosk session.

  • isPublicSession
    boolean optional

    Whether the app is being launched in a Chrome OS public session.

  • items
    LaunchItem[] optional

    The file entries for the onLaunched event triggered by a matching file handler in the file_handlers manifest key.

  • referrerUrl
    string optional

    The referrer URL for the onLaunched event triggered by a matching URL handler in the url_handlers manifest key.

  • source
    LaunchSource optional

    Where the app is launched from.

  • url
    string optional

    The URL for the onLaunched event triggered by a matching URL handler in the url_handlers manifest key.

LaunchItem

Properties

  • entry
    Entry

    Entry for the item.

  • type
    string optional

    The MIME type of the file.

ActionType

An app can be launched with a specific action in mind, for example, to create a new note. The type of action the app was launched with is available inside of the |actionData| field from the LaunchData instance.

Enum

"new_note"

LaunchSource

Enumeration of app launch sources. This should be kept in sync with AppLaunchSource in components/services/app_service/public/mojom/types.mojom, and GetLaunchSourceEnum() in extensions/browser/api/app_runtime/app_runtime_api.cc. Note the enumeration is used in UMA histogram so entries should not be re-ordered or removed.

Enum

"untracked", "app_launcher", "new_tab_page", "reload", "restart", "load_and_launch", "command_line", "file_handler", "url_handler", "system_tray", "about_page", "keyboard", "extensions_page", "management_api", "ephemeral_app", "background", "kiosk", "chrome_internal", "test", "installed_notification", "context_menu", "arc", or "intent_url"

Events

onEmbedRequested

chrome.app.runtime.onEmbedRequested.addListener(listener: function)

Fired when an embedding app requests to embed this app. This event is only available on dev channel with the flag --enable-app-view.

Event

  • listener
    function

    The listener parameter should be a function that looks like this:

    (request: EmbedRequest) => {...}

onLaunched

chrome.app.runtime.onLaunched.addListener(listener: function)

Fired when an app is launched from the launcher.

Event

  • listener
    function

    The listener parameter should be a function that looks like this:

    (launchData: LaunchData) => {...}

onRestarted

chrome.app.runtime.onRestarted.addListener(listener: function)

Fired at Chrome startup to apps that were running when Chrome last shut down, or when apps have been requested to restart from their previous state for other reasons (e.g. when the user revokes access to an app's retained files the runtime will restart the app). In these situations if apps do not have an onRestarted handler they will be sent an onLaunched event instead.

Event

  • listener
    function

    The listener parameter should be a function that looks like this:

    () => {...}
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.