1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Note: Many of these functions and events are implemented by hand and should
6 // not elicit any code generation from the schema compiler. These items are
10 "namespace": "runtime",
11 "description": "Use the <code>chrome.runtime</code> API to retrieve the background page, return details about the manifest, and listen for and respond to events in the app or extension lifecycle. You can also use this API to convert the relative path of URLs to fully-qualified URLs.",
17 "description": "An object which allows two way communication with other pages.",
19 "name": {"type": "string"},
20 "disconnect": { "type": "function" },
21 "onDisconnect": { "$ref": "events.Event" },
22 "onMessage": { "$ref": "events.Event" },
23 "postMessage": {"type": "function"},
25 "$ref": "MessageSender",
27 "description": "This property will <b>only</b> be present on ports passed to onConnect/onConnectExternal listeners."
30 "additionalProperties": { "type": "any"}
33 "id": "MessageSender",
36 "description": "An object containing information about the script context that sent a message or request.",
38 "tab": {"$ref": "tabs.Tab", "optional": true, "description": "The $(ref:tabs.Tab) which opened the connection, if any. This property will <strong>only</strong> be present when the connection was opened from a tab (including content scripts), and <strong>only</strong> if the receiver is an extension, not an app.", "extension_types": ["extension", "legacy_packaged_app"]},
39 "frameId": {"type": "integer", "optional": true, "description": "The <a href='webNavigation#frame_ids'>frame</a> that opened the connection. 0 for top-level frames, positive for child frames. This will only be set when <code>tab</code> is set.", "extension_types": ["extension", "legacy_packaged_app"]},
40 "guestProcessId": {"type": "integer", "optional": true, "nodoc": true, "description": "The guest process id of the requesting webview, if available. Only available for component extensions.", "extension_types": ["extension"]},
41 "guestRenderFrameRoutingId": {"type": "integer", "optional": true, "nodoc": true, "description": "The guest render frame routing id of the requesting webview, if available. Only available for component extensions.", "extension_types": ["extension"]},
42 "id": {"type": "string", "optional": true, "description": "The ID of the extension or app that opened the connection, if any."},
43 "url": {"type": "string", "optional": true, "description": "The URL of the page or frame that opened the connection. If the sender is in an iframe, it will be iframe's URL not the URL of the page which hosts it."},
44 "tlsChannelId": {"type": "string", "optional": true, "description": "The TLS channel ID of the page or frame that opened the connection, if requested by the extension or app, and if available."}
50 "description": "The operating system chrome is running on.",
51 "enum": ["mac", "win", "android", "cros", "linux", "openbsd"]
56 "enum": ["arm", "x86-32", "x86-64"],
57 "description": "The machine's processor architecture."
60 "id": "PlatformNaclArch",
61 "description": "The native client architecture. This may be different from arch on some platforms.",
63 "enum": ["arm", "x86-32", "x86-64"]
68 "description": "An object containing information about the current platform.",
72 "description": "The operating system chrome is running on."
75 "$ref": "PlatformArch",
76 "description": "The machine's processor architecture."
79 "description": "The native client architecture. This may be different from arch on some platforms.",
80 "$ref": "PlatformNaclArch"
85 "id": "RequestUpdateCheckStatus",
87 "enum": ["throttled", "no_update", "update_available"],
88 "description": "Result of the update check."
91 "id": "OnInstalledReason",
93 "enum": ["install", "update", "chrome_update", "shared_module_update"],
94 "description": "The reason that this event is being dispatched."
97 "id": "OnRestartRequiredReason",
99 "description": "The reason that the event is being dispatched. 'app_update' is used when the restart is needed because the application is updated to a newer version. 'os_update' is used when the restart is needed because the browser/OS is updated to a newer version. 'periodic' is used when the system runs for more than the permitted uptime set in the enterprise policy.",
100 "enum": ["app_update", "os_update", "periodic"]
107 "description": "This will be defined during an API method callback if there was an error",
112 "description": "Details about the error which occurred."
118 "description": "The ID of the extension/app."
123 "name": "getBackgroundPage",
125 "description": "Retrieves the JavaScript 'window' object for the background page running inside the current extension/app. If the background page is an event page, the system will ensure it is loaded before calling the callback. If there is no background page, an error is set.",
132 "name": "backgroundPage",
133 // Note: Only optional because we don't support validation
134 // for custom callbacks.
137 "isInstanceOf": "Window",
138 "additionalProperties": { "type": "any" },
139 "description": "The JavaScript 'window' object for the background page."
146 "name": "openOptionsPage",
148 "description": "<p>Open your Extension's options page, if possible.</p><p>The precise behavior may depend on your manifest's <code><a href=\"optionsV2\">options_ui</a></code> or <code><a href=\"options\">options_page</a></code> key, or what Chrome happens to support at the time. For example, the page may be opened in a new tab, within chrome://extensions, within an App, or it may just focus an open options page. It will never cause the caller page to reload.</p><p>If your Extension does not declare an options page, or Chrome failed to create one for some other reason, the callback will set $(ref:lastError).</p>",
157 "name": "getManifest",
158 "description": "Returns details about the app or extension from the manifest. The object returned is a serialization of the full <a href=\"manifest.html\">manifest file</a>.",
165 "additionalProperties": { "type": "any" },
166 "description": "The manifest details."
173 "description": "Converts a relative path within an app/extension install directory to a fully-qualified URL.",
178 "description": "A path to a resource within an app/extension expressed relative to its install directory."
183 "description": "The fully-qualified URL to the resource."
187 "name": "setUninstallURL",
189 "description": "Sets the URL to be visited upon uninstallation. This may be used to clean up server-side data, do analytics, and implement surveys. Maximum 255 characters.",
200 "description": "Reloads the app or extension.",
205 "name": "requestUpdateCheck",
207 "description": "Requests an update check for this app/extension.",
215 "$ref": "RequestUpdateCheckStatus",
216 "description": "Result of the update check."
225 "description": "The version of the available update."
228 "description": "If an update is available, this contains more information about the available update."
236 "description": "Restart the ChromeOS device when the app runs in kiosk mode. Otherwise, it's no-op.",
244 "description": "Attempts to connect to connect listeners within an extension/app (such as the background page), or other extensions/apps. This is useful for content scripts connecting to their extension processes, inter-app/extension communication, and <a href=\"manifest/externally_connectable.html\">web messaging</a>. Note that this does not connect to any listeners in a content script. Extensions may connect to content scripts embedded in tabs via <a href=\"extensions/tabs#method-connect\">tabs.connect</a>.",
246 {"type": "string", "name": "extensionId", "optional": true, "description": "The ID of the extension or app to connect to. If omitted, a connection will be attempted with your own extension. Required if sending messages from a web page for <a href=\"manifest/externally_connectable.html\">web messaging</a>."},
249 "name": "connectInfo",
251 "name": { "type": "string", "optional": true, "description": "Will be passed into onConnect for processes that are listening for the connection event." },
252 "includeTlsChannelId": { "type": "boolean", "optional": true, "description": "Whether the TLS channel ID will be passed into onConnectExternal for processes that are listening for the connection event." }
259 "description": "Port through which messages can be sent and received. The port's $(ref:runtime.Port onDisconnect) event is fired if the extension/app does not exist. "
263 "name": "connectNative",
266 "description": "Connects to a native application in the host machine.",
270 "name": "application",
271 "description": "The name of the registered application to connect to."
276 "description": "Port through which messages can be sent and received with the application"
280 "name": "sendMessage",
283 "allowAmbiguousOptionalArguments": true,
284 "description": "Sends a single message to event listeners within your extension/app or a different extension/app. Similar to $(ref:runtime.connect) but only sends a single message, with an optional response. If sending to your extension, the $(ref:runtime.onMessage) event will be fired in each page, or $(ref:runtime.onMessageExternal), if a different extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use <a href=\"extensions/tabs#method-sendMessage\">tabs.sendMessage</a>.",
286 {"type": "string", "name": "extensionId", "optional": true, "description": "The ID of the extension/app to send the message to. If omitted, the message will be sent to your own extension/app. Required if sending messages from a web page for <a href=\"manifest/externally_connectable.html\">web messaging</a>."},
287 { "type": "any", "name": "message" },
292 "includeTlsChannelId": { "type": "boolean", "optional": true, "description": "Whether the TLS channel ID will be passed into onMessageExternal for processes that are listening for the connection event." }
298 "name": "responseCallback",
304 "description": "The JSON response object sent by the handler of the message. If an error occurs while connecting to the extension, the callback will be called with no arguments and $(ref:runtime.lastError) will be set to the error message."
311 "name": "sendNativeMessage",
314 "description": "Send a single message to a native application.",
317 "name": "application",
318 "description": "The name of the native messaging host.",
323 "description": "The message that will be passed to the native messaging host.",
325 "additionalProperties": {
331 "name": "responseCallback",
337 "description": "The response message sent by the native messaging host. If an error occurs while connecting to the native messaging host, the callback will be called with no arguments and $(ref:runtime.lastError) will be set to the error message.",
338 "additionalProperties": {
347 "name": "getPlatformInfo",
349 "description": "Returns information about the current platform.",
354 "description": "Called with results",
357 "name": "platformInfo",
358 "$ref": "PlatformInfo"
365 "name": "getPackageDirectoryEntry",
367 "description": "Returns a DirectoryEntry for the package directory.",
374 "name": "directoryEntry",
376 "additionalProperties": { "type": "any" },
377 "isInstanceOf": "DirectoryEntry"
388 "description": "Fired when a profile that has this extension installed first starts up. This event is not fired when an incognito profile is started, even if this extension is operating in 'split' incognito mode."
391 "name": "onInstalled",
393 "description": "Fired when the extension is first installed, when the extension is updated to a new version, and when Chrome is updated to a new version.",
400 "$ref": "OnInstalledReason",
401 "description": "The reason that this event is being dispatched."
406 "description": "Indicates the previous version of the extension, which has just been updated. This is present only if 'reason' is 'update'."
411 "description": "Indicates the ID of the imported shared module extension which updated. This is present only if 'reason' is 'shared_module_update'."
420 "description": "Sent to the event page just before it is unloaded. This gives the extension opportunity to do some clean up. Note that since the page is unloading, any asynchronous operations started while handling this event are not guaranteed to complete. If more activity for the event page occurs before it gets unloaded the onSuspendCanceled event will be sent and the page won't be unloaded. "
423 "name": "onSuspendCanceled",
425 "description": "Sent after onSuspend to indicate that the app won't be unloaded after all."
428 "name": "onUpdateAvailable",
430 "description": "Fired when an update is available, but isn't installed immediately because the app is currently running. If you do nothing, the update will be installed the next time the background page gets unloaded, if you want it to be installed sooner you can explicitly call chrome.runtime.reload(). If your extension is using a persistent background page, the background page of course never gets unloaded, so unless you call chrome.runtime.reload() manually in response to this event the update will not get installed until the next time chrome itself restarts. If no handlers are listening for this event, and your extension has a persistent background page, it behaves as if chrome.runtime.reload() is called in response to this event.",
438 "description": "The version number of the available update."
441 "additionalProperties": { "type": "any" },
442 "description": "The manifest details of the available update."
447 // TODO(xiyuan): onBrowserUpdateAvailable is deprecated in favor of
448 // onRestartRequired. We should remove it when we are sure it is unused.
449 "name": "onBrowserUpdateAvailable",
451 "description": "Fired when a Chrome update is available, but isn't installed immediately because a browser restart is required.",
452 "deprecated": "Please use $(ref:runtime.onRestartRequired).",
462 "description": "Fired when a connection is made from either an extension process or a content script.",
464 {"$ref": "Port", "name": "port"}
468 "name": "onConnectExternal",
471 "description": "Fired when a connection is made from another extension.",
473 {"$ref": "Port", "name": "port"}
483 "description": "Fired when a message is sent from either an extension process or a content script.",
485 {"name": "message", "type": "any", "optional": true, "description": "The message sent by the calling script."},
486 {"name": "sender", "$ref": "MessageSender" },
487 {"name": "sendResponse", "type": "function", "description": "Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one <code>onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code>sendResponse</code> is called)." }
492 "description": "Return true from the event listener if you wish to call <code>sendResponse</code> after the event listener returns."
496 "name": "onMessageExternal",
499 "description": "Fired when a message is sent from another extension/app. Cannot be used in a content script.",
501 {"name": "message", "type": "any", "optional": true, "description": "The message sent by the calling script."},
502 {"name": "sender", "$ref": "MessageSender" },
503 {"name": "sendResponse", "type": "function", "description": "Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one <code>onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code>sendResponse</code> is called)." }
508 "description": "Return true from the event listener if you wish to call <code>sendResponse</code> after the event listener returns."
512 "name": "onRestartRequired",
514 "description": "Fired when an app or the device that it runs on needs to be restarted. The app should close all its windows at its earliest convenient time to let the restart to happen. If the app does nothing, a restart will be enforced after a 24-hour grace period has passed. Currently, this event is only fired for Chrome OS kiosk apps.",
517 "$ref": "OnRestartRequiredReason",
519 "description": "The reason that the event is being dispatched."