chrome.app.runtime

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.
Availability: Since Chrome 35.

Summary

Events
onEmbedRequested
onLaunched
onRestarted

Events

onEmbedRequested

Since Chrome 38.

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

addListener

chrome.app.runtime.onEmbedRequested.addListener(function callback)
Parameters
function callback

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

function(object request) {...};
object request
string embedderId
any (optional) data

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

function allow

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

Parameters
string url
function deny

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

onLaunched

Fired when an app is launched from the launcher.

addListener

chrome.app.runtime.onLaunched.addListener(function callback)
Parameters
function callback

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

function(object launchData) {...};
object (optional) launchData
string (optional) id

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.

array of object (optional) items

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

Properties of each object

Entry entry

Entry for the item.

string (optional) type

The MIME type of the file.

string (optional) url

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

string (optional) referrerUrl

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

boolean (optional) isKioskSession

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

boolean (optional) isPublicSession

Since Chrome 47.

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

enum of "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" (optional) source

Since Chrome 40.

Where the app is launched from.

object (optional) actionData

Since Chrome 54.

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.

enum of "new_note" actionType
new_note
The user wants to quickly take a new note.

onRestarted

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.

addListener

chrome.app.runtime.onRestarted.addListener(function callback)
Parameters
function callback

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

function() {...};