blob: cf62c9d6eee33e8ed3ea12802bce971f1f545252 [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[
{
"namespace": "webviewTag",
"description": "Use the <code>webview</code> tag to actively load live content from the web over the network and embed it in your Chrome App. Your app can control the appearance of the <code>webview</code> and interact with the web content, initiate navigations in an embedded web page, react to error events that happen within it, and more (see <a href=\"#usage\">Usage</a>).",
"documentation_options": {
"title": "<webview> Tag",
"namespace": "<webview>",
"documented_in": "tags/webview"
},
"types": [
{
"id": "ClearDataOptions",
"type": "object",
"description": "Options that determine what data should be cleared by <code>clearData</code>.",
"properties": {
"since": {
"type": "number",
"optional": true,
"description": "Clear data accumulated on or after this date, represented in milliseconds since the epoch (accessible via the getTime method of the JavaScript <code>Date</code> object). If absent, defaults to <code>0</code> (which would remove all browsing data)."
}
}
},
{
"id": "ClearDataTypeSet",
"type": "object",
"description": "A set of data types. Missing properties are interpreted as <code>false</code>.",
"properties": {
"appcache": { "type": "boolean", "optional": true, "description": "Websites' appcaches." },
"cache": { "type": "boolean", "optional": true, "description": "Since Chrome 43.<br>The browser's cache. Note: when removing data, this clears the entire cache; it is not limited to the range you specify." },
"cookies": { "type": "boolean", "optional": true, "description": "The partition's cookies." },
"sessionCookies": { "type": "boolean", "optional": true, "description": "The partition's session cookies." },
"persistentCookies": { "type": "boolean", "optional": true, "description": "The partition's persistent cookies." },
"fileSystems": { "type": "boolean", "optional": true, "description": "Websites' filesystems." },
"indexedDB": { "type": "boolean", "optional": true, "description": "Websites' IndexedDB data." },
"localStorage": { "type": "boolean", "optional": true, "description": "Websites' local storage data." },
"webSQL": { "type": "boolean", "optional": true, "description": "Websites' WebSQL data." }
}
},
{
"id": "ContextType",
"type": "string",
"enum": ["all", "page", "frame", "selection", "link", "editable", "image", "video", "audio"],
"description": "The different contexts a menu can appear in. Specifying 'all' is equivalent to the combination of all other contexts."
},
{
"id": "InjectDetails",
"type": "object",
"description": "Details of the script or CSS to inject. Either the code or the file property must be set, but both may not be set at the same time.",
"properties": {
"code": {
"type": "string",
"optional": true,
"description": "JavaScript or CSS code to inject.<br><br><b>Warning:</b><br>Be careful using the <code>code</code> parameter. Incorrect use of it may open your app to <a href=\"https://en.wikipedia.org/wiki/Cross-site_scripting\">cross site scripting</a> attacks."
},
"file": {
"type": "string",
"optional": true,
"description": "JavaScript or CSS file to inject."
}
}
},
{
"id": "InjectionItems",
"type": "object",
"description": "The type of injection item: code or a set of files.",
"properties": {
"code": {
"type": "string",
"optional": true,
"description": "JavaScript code or CSS to be injected into matching pages."
},
"files": {
"type": "array",
"items": { "type": "string"},
"optional": true,
"description": "The list of JavaScript or CSS files to be injected into matching pages. These are injected in the order they appear in this array."
}
}
},
{
"id": "ContentScriptDetails",
"type": "object",
"description": "Details of the content script to inject. Refer to the <a href='/extensions/content_scripts'>content scripts</a> documentation for more details.",
"properties": {
"name": {
"type": "string",
"description": "The name of the content script to inject."
},
"matches": {
"type": "array",
"items": { "type": "string"},
"description": "Specifies which pages this content script will be injected into."
},
"exclude_matches": {
"type": "array",
"items": { "type": "string"},
"optional": true,
"description": "Excludes pages that this content script would otherwise be injected into."
},
"match_about_blank": {
"type": "boolean",
"optional": true,
"description": "Whether to insert the content script on about:blank and about:srcdoc. Content scripts will only be injected on pages when their inherit URL is matched by one of the declared patterns in the matches field. The inherit URL is the URL of the document that created the frame or window. Content scripts cannot be inserted in sandboxed frames."
},
"css": {
"$ref": "InjectionItems",
"optional": true,
"description": "The CSS code or a list of CSS files to be injected into matching pages. These are injected in the order they appear, before any DOM is constructed or displayed for the page."
},
"js": {
"$ref": "InjectionItems",
"optional": true,
"description": "The JavaScript code or a list of JavaScript files to be injected into matching pages. These are injected in the order they appear."
},
"run_at": {
"$ref": "extensionTypes.RunAt",
"optional": true,
"description": "The soonest that the JavaScript or CSS will be injected into the tab. Defaults to \"document_idle\"."
},
"all_frames": {
"type": "boolean",
"optional": true,
"description": "If <code>all_frames</code> is <code>true</code>, this implies that the JavaScript or CSS should be injected into all frames of current page. By default, <code>all_frames</code> is <code>false</code> and the JavaScript or CSS is only injected into the top frame."
},
"include_globs": {
"type": "array",
"items": { "type": "string"},
"optional": true,
"description": "Applied after matches to include only those URLs that also match this glob. Intended to emulate the @include Greasemonkey keyword."
},
"exclude_globs": {
"type": "array",
"items": { "type": "string"},
"optional": true,
"description": "Applied after matches to exclude URLs that match this glob. Intended to emulate the @exclude Greasemonkey keyword."
}
},
"required": ["name", "matches"]
},
{
"id": "ContextMenuCreateProperties",
"type": "object",
"properties": {
"type": {
"$ref": "contextMenus.ItemType",
"optional": true,
"description": "The type of menu item. Defaults to 'normal' if not specified."
},
"id": {
"type": "string",
"optional": true,
"description": "The unique ID to assign to this item. Mandatory for event pages. Cannot be the same as another ID for this extension."
},
"title": {
"type": "string",
"optional": true,
"description": "The text to be displayed in the item; this is <em>required</em> unless <code>type</code> is 'separator'. When the context is 'selection', you can use <code>%s</code> within the string to show the selected text. For example, if this parameter's value is \"Translate '%s' to Pig Latin\" and the user selects the word \"cool\", the context menu item for the selection is \"Translate 'cool' to Pig Latin\"."
},
"checked": {
"type": "boolean",
"optional": true,
"description": "The initial state of a checkbox or radio item: true for selected and false for unselected. Only one radio item can be selected at a time in a given group of radio items."
},
"contexts": {
"type": "array",
"items": {
"$ref": "ContextType"
},
"minItems": 1,
"optional": true,
"description": "List of contexts this menu item will appear in. Defaults to ['page'] if not specified."
},
"onclick": {
"type": "function",
"optional": true,
"description": "A function that will be called back when the menu item is clicked.",
"parameters": [
{
"name": "info",
"$ref": "contextMenusInternal.OnClickData",
"description": "Information about the item clicked and the context where the click happened."
}
]
},
"parentId": {
"choices": [
{ "type": "integer" },
{ "type": "string" }
],
"optional": true,
"description": "The ID of a parent menu item; this makes the item a child of a previously added item."
},
"documentUrlPatterns": {
"type": "array",
"items": {"type": "string"},
"optional": true,
"description": "Lets you restrict the item to apply only to documents whose URL matches one of the given patterns. (This applies to frames as well.) For details on the format of a pattern, see <a href='match_patterns'>Match Patterns</a>."
},
"targetUrlPatterns": {
"type": "array",
"items": {"type": "string"},
"optional": true,
"description": "Similar to documentUrlPatterns, but lets you filter based on the <code>src</code> attribute of img/audio/video tags and the <code>href</code> of anchor tags."
},
"enabled": {
"type": "boolean",
"optional": true,
"description": "Whether this context menu item is enabled or disabled. Defaults to <code>true</code>."
}
}
},
{
"id": "ContextMenuUpdateProperties",
"type": "object",
"name": "updateProperties",
"properties": {
"type": {
"$ref": "contextMenus.ItemType",
"optional": true,
"description": "The type of menu item."
},
"title": {
"type": "string",
"optional": true,
"description": "The text to be displayed in the item"
},
"checked": {
"type": "boolean",
"optional": true,
"description": "The state of a checkbox or radio item: true for selected and false for unselected. Only one radio item can be selected at a time in a given group of radio items."
},
"contexts": {
"type": "array",
"items": {
"$ref": "ContextType"
},
"minItems": 1,
"optional": true,
"description": "List of contexts this menu item will appear in."
},
"onclick": {
"type": "function",
"optional": true,
"description": "A function that will be called back when the menu item is clicked.",
"parameters": [
{
"name": "info",
"$ref": "contextMenusInternal.OnClickData",
"description": "Information about the item clicked and the context where the click happened."
}
]
},
"parentId": {
"choices": [
{ "type": "integer" },
{ "type": "string" }
],
"optional": true,
"description": "The ID of a parent menu item; this makes the item a child of a previously added item. <em>Note:</em> You cannot change an item to be a child of one of its own descendants."
},
"documentUrlPatterns": {
"type": "array",
"items": {"type": "string"},
"optional": true,
"description": "Lets you restrict the item to apply only to documents whose URL matches one of the given patterns. (This applies to frames as well.) For details on the format of a pattern, see <a href='match_patterns'>Match Patterns</a>."
},
"targetUrlPatterns": {
"type": "array",
"items": {"type": "string"},
"optional": true,
"description": "Similar to documentUrlPatterns, but lets you filter based on the <code>src</code> attribute of img/audio/video tags and the <code>href</code> of anchor tags."
},
"enabled": {
"type": "boolean",
"optional": true,
"description": "Whether this context menu item is enabled or disabled."
}
}
},
{
"id": "ContextMenus",
"type": "object",
"functions": [
{
"name": "create",
"type": "function",
"description": "Creates a new context menu item. Note that if an error occurs during creation, you may not find out until the creation callback fires (the details will be in <code>chrome.runtime.lastError</code>).",
"returns": {
"choices": [
{ "type": "integer" },
{ "type": "string" }
],
"description": "The ID of the newly created item."
},
"parameters": [
{
"type": "object",
"name": "createProperties",
"$ref": "ContextMenuCreateProperties",
"description": "The properties used to create the item"
},
{
"type": "function",
"name": "callback",
"optional": true,
"description": "Called when the item has been created in the browser. If there were any problems creating the item, details will be available in <code>chrome.runtime.lastError</code>.",
"parameters": []
}
]
},
{
"name": "update",
"type": "function",
"description": "Updates a previously created context menu item.",
"parameters": [
{
"choices": [
{ "type": "integer" },
{ "type": "string" }
],
"name": "id",
"description": "The ID of the item to update."
},
{
"type": "object",
"name": "updateProperties",
"$ref": "ContextMenuUpdateProperties",
"description": "The properties to update. Accepts the same values as the create function."
},
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": [],
"description": "Called when the context menu has been updated."
}
]
},
{
"name": "remove",
"type": "function",
"description": "Removes a context menu item.",
"parameters": [
{
"choices": [
{ "type": "integer" },
{ "type": "string" }
],
"name": "menuItemId",
"description": "The ID of the context menu item to remove."
},
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": [],
"description": "Called when the context menu has been removed."
}
]
},
{
"name": "removeAll",
"type": "function",
"description": "Removes all context menu items added to this <code>webview</code>.",
"parameters": [
{
"type": "function",
"name": "callback",
"optional": true,
"parameters": [],
"description": "Called when removal is complete."
}
]
}
],
"events": [
{
"name": "onShow",
"type": "function",
"description": "Fired before showing a context menu on this <code>webview</code>. Can be used to disable this context menu by calling <code>event.preventDefault()</code>.",
"parameters": [
{
"name": "event",
"type": "object",
"properties": {
"preventDefault": {
"type": "function",
"description": "Call this to prevent showing the context menu."
}
}
}
]
}
]
},
{
"id": "ContentWindow",
"type": "object",
"description": "Messaging handle to a guest window.",
"functions": [
{
"name": "postMessage",
"description": "<p>Posts a message to the embedded web content as long as the embedded content is displaying a page from the target origin. This method is available once the page has completed loading. Listen for the <a href=\"#event-contentload\">contentload</a> event and then call the method.</p><p>The guest will be able to send replies to the embedder by posting message to <code>event.source</code> on the message event it receives.</p><p>This API is identical to the <a href=\"https://developer.mozilla.org/en-US/docs/DOM/window.postMessage\">HTML5 postMessage API</a> for communication between web pages. The embedder may listen for replies by adding a <code>message</code> event listener to its own frame.</p>",
"parameters": [
{
"type": "any",
"name": "message",
"description": "Message object to send to the guest."
},
{
"type": "string",
"name": "targetOrigin",
"description": "Specifies what the origin of the guest window must be for the event to be dispatched."
}
]
}
]
},
{
"id": "DialogController",
"type": "object",
"description": "Interface attached to <code>dialog</code> DOM events.",
"functions": [
{
"name": "ok",
"description": "Accept the dialog. Equivalent to clicking OK in an <code>alert</code>, <code>confirm</code>, or <code>prompt</code> dialog.",
"parameters": [
{
"type": "string",
"optional": true,
"name": "response",
"description": "The response string to provide to the guest when accepting a <code>prompt</code> dialog."
}
]
},
{
"name": "cancel",
"description": "Reject the dialog. Equivalent to clicking Cancel in a <code>confirm</code> or <code>prompt</code> dialog."
}
]
},
{
"id": "FindCallbackResults",
"type": "object",
"description": "Contains all of the results of the find request.",
"properties": {
"numberOfMatches": {
"type": "integer",
"description": "The number of times <code>searchText</code> was matched on the page."
},
"activeMatchOrdinal": {
"type": "integer",
"description": "The ordinal number of the current match."
},
"selectionRect": {
"$ref": "SelectionRect",
"description": "Describes a rectangle around the active match in screen coordinates."
},
"canceled": {
"type": "boolean",
"description": "Indicates whether this find request was canceled."
}
}
},
{
"id": "FindOptions",
"type": "object",
"description": "Options for the find request.",
"properties": {
"backward": {
"type": "boolean",
"description": "Flag to find matches in reverse order. The default value is <code>false</code>.",
"optional": true
},
"matchCase": {
"type": "boolean",
"description": "Flag to match with case-sensitivity. The default value is <code>false</code>.",
"optional": true
}
}
},
{
"id": "NewWindow",
"type": "object",
"description": "Interface attached to <code>newwindow</code> DOM events.",
"functions": [
{
"name": "attach",
"description": "Attach the requested target page to an existing <code>webview</code> element.",
"parameters": [
{
"type": "object",
"name": "webview",
"description": "The <code>webview</code> element to which the target page should be attached.",
"properties": {}
}
]
},
{
"name": "discard",
"description": "Cancel the new window request."
}
]
},
{
"id": "MediaPermissionRequest",
"type": "object",
"description": "The type of <code>request</code> object which accompanies a <code>media</code> <a href=\"#event-permissionrequest\">permissionrequest</a></code> DOM event.",
"properties": {
"url": {
"description": "The URL of the frame requesting access to user media.",
"type": "string"
}
},
"functions": [
{ "name": "allow", "description": "Allow the permission request." },
{ "name": "deny", "description": "Deny the permission request. This is the default behavior if <code>allow</code> is not called." }
]
},
{
"id": "GeolocationPermissionRequest",
"type": "object",
"description": "The type of <code>request</code> object which accompanies a <code>geolocation</code> <a href=\"#event-permissionrequest\">permissionrequest</a></code> DOM event.",
"properties": {
"url": {
"description": "The URL of the frame requesting access to geolocation data.",
"type": "string"
}
},
"functions": [
{ "name": "allow", "description": "Allow the permission request." },
{ "name": "deny", "description": "Deny the permission request. This is the default behavior if <code>allow</code> is not called." }
]
},
{
"id": "PointerLockPermissionRequest",
"type": "object",
"description": "The type of <code>request</code> object which accompanies a <code>pointerLock</code> <a href=\"#event-permissionrequest\">permissionrequest</a></code> DOM event.",
"properties": {
"userGesture": {
"description": "Whether or not pointer lock was requested as a result of a user input gesture.",
"type": "boolean"
},
"lastUnlockedBySelf": {
"description": "Whether or not the requesting frame was the most recent client to hold pointer lock.",
"type": "boolean"
},
"url": {
"description": "The URL of the frame requesting pointer lock.",
"type": "string"
}
},
"functions": [
{ "name": "allow", "description": "Allow the permission request." },
{ "name": "deny", "description": "Deny the permission request. This is the default behavior if <code>allow</code> is not called." }
]
},
{
"id": "DownloadPermissionRequest",
"type": "object",
"description": "The type of <code>request</code> object which accompanies a <code>download</code> <a href=\"#event-permissionrequest\">permissionrequest</a></code> DOM event.",
"properties": {
"requestMethod": {
"description": "The HTTP request type (e.g. <code>GET</code>) associated with the download request.",
"type": "string"
},
"url": {
"description": "The requested download URL.",
"type": "string"
}
},
"functions": [
{ "name": "allow", "description": "Allow the permission request." },
{ "name": "deny", "description": "Deny the permission request. This is the default behavior if <code>allow</code> is not called." }
]
},
{
"id": "FileSystemPermissionRequest",
"type": "object",
"description": "The type of <code>request</code> object which accompanies a <code>filesystem</code> <a href=\"#event-permissionrequest\">permissionrequest</a></code> DOM event.",
"properties": {
"url": {
"description": "The URL of the frame requesting access to local file system.",
"type": "string"
}
},
"functions": [
{ "name": "allow", "description": "Allow the permission request." },
{ "name": "deny", "description": "Deny the permission request." }
]
},
{
"id": "FullscreenPermissionRequest",
"type": "object",
"description": "The type of <code>request</code> object which accompanies a <code>fullscreen</code> <a href=\"#event-permissionrequest\">permissionrequest</a> DOM event.<p>",
"properties": {
"origin": {
"description": "The origin of the frame inside the <code>webview</code> that initiated the fullscreen request.",
"type": "string"
}
},
"functions": [
{ "name": "allow", "description": "Allow the permission request." },
{ "name": "deny", "description": "Deny the permission request." }
]
},
{
"id": "LoadPluginPermissionRequest",
"type": "object",
"description": "The type of <code>request</code> object which accompanies a <code>loadplugin</code> <a href=\"#event-permissionrequest\">permissionrequest</a> DOM event.<p>",
"properties": {
"identifier": {
"description": "The plugin's identifier string.",
"type": "string"
},
"name": {
"description": "The plugin's display name.",
"type": "string"
}
},
"functions": [
{ "name": "allow", "description": "Allow the permission request. This is the default behavior if <code>deny</code> is not called.." },
{ "name": "deny", "description": "Deny the permission request." }
]
},
{
"id": "SelectionRect",
"type": "object",
"description": "<p>Describes a rectangle in screen coordinates.</p><p>The containment semantics are array-like; that is, the coordinate <code>(left, top)</code> is considered to be contained by the rectangle, but the coordinate <code>(left + width, top)</code> is not.</p>",
"properties": {
"left": {
"type": "integer",
"description": "Distance from the left edge of the screen to the left edge of the rectangle."
},
"top": {
"type": "integer",
"description": "Distance from the top edge of the screen to the top edge of the rectangle."
},
"width": {
"type": "integer",
"description": "Width of the rectangle."
},
"height": {
"type": "integer",
"description": "Height of the rectangle."
}
}
},
{
"id": "WebRequestEventInterface",
"type": "object",
"description": "Interface which provides access to webRequest events on the guest page. See the <a href=\"http://developer.chrome.com/extensions/webRequest\">chrome.webRequest</a> extensions API for details on webRequest life cycle and related concepts. Note: The <a href=\"/extensions/webRequest#event-onActionIgnored\">chrome.webRequest.onActionIgnored</a> event is not supported for webviews. <p>To illustrate how usage differs from the extensions webRequest API, consider the following example code which blocks any guest requests for URLs which match <code>*://www.evil.com/*</code>:</p><pre>webview.request.onBeforeRequest.addListener(\r function(details) { return {cancel: true}; },\r {urls: [\"*://www.evil.com/*\"]},\r [\"blocking\"]);</pre><p>Additionally, this interface supports declarative webRequest rules through <code>onRequest</code> and <code>onMessage</code> events. See <a href=\"http://developer.chrome.com/extensions/declarativeWebRequest.html\">declarativeWebRequest</a> for API details.</p>Note that conditions and actions for declarative webview webRequests should be instantiated from their <code>chrome.webViewRequest.*</code> counterparts. The following example code declaratively blocks all requests to <code>\"example.com\"</code> on the webview <code>myWebview</code>:</p><pre>var rule = {\r conditions: [\r new chrome.webViewRequest.RequestMatcher({ url: { hostSuffix: 'example.com' } })\r ],\r actions: [ new chrome.webViewRequest.CancelRequest() ]\r};\rmyWebview.request.onRequest.addRules([rule]);</pre>",
"properties": {}
},
{
"id": "ZoomMode",
"type": "string",
"description": "Defines the how zooming is handled in the <code>webview</code>.",
"enum": [
{
"name": "per-origin",
"description": "Zoom changes will persist in the zoomed page's origin, i.e. all other webviews in the same partition that are navigated to that same origin will be zoomed as well. Moreover, <code>per-origin</code> zoom changes are saved with the origin, meaning that when navigating to other pages in the same origin, they will all be zoomed to the same zoom factor."
},
{
"name": "per-view",
"description": "Zoom changes only take effect in this webview, and zoom changes in other webviews will not affect the zooming of this webview. Also, <code>per-view</code> zoom changes are reset on navigation; navigating a webview will always load pages with their per-origin zoom factors (within the scope of the partition)."
},
{
"name": "disabled",
"description": "Disables all zooming in the webview. The content will revert to the default zoom level, and all attempted zoom changes will be ignored."
}
]
}
],
"functions": [
{
"name": "getAudioState",
"type": "function",
"description": "Queries audio state.",
"parameters": [
{
"type": "function",
"name": "callback",
"parameters": [
{
"name": "audible",
"type": "boolean"
}
]
}
]
},
{
"name": "setAudioMuted",
"type": "function",
"description": "Sets audio mute state of the webview.",
"parameters": [
{
"type": "boolean",
"name": "mute",
"description": "Mute audio value"
}
]
},
{
"name": "isAudioMuted",
"type": "function",
"description": "Queries whether audio is muted.",
"parameters": [
{
"type": "function",
"name": "callback",
"parameters": [
{
"name": "muted",
"type": "boolean"
}
]
}
]
},
{
"name": "captureVisibleRegion",
"type": "function",
"description": "Captures the visible region of the webview.",
"parameters": [
{
"$ref": "extensionTypes.ImageDetails",
"name": "options",
"optional": true
},
{
"type": "function",
"name": "callback",
"parameters": [
{"type": "string",
"name": "dataUrl",
"description": "A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display."
}
]
}
]
},
{
"name": "addContentScripts",
"type": "function",
"description": "<p>Adds content script injection rules to the <code>webview</code>. When the <code>webview</code> navigates to a page matching one or more rules, the associated scripts will be injected. You can programmatically add rules or update existing rules.</p><p>The following example adds two rules to the <code>webview</code>: 'myRule' and 'anotherRule'.</p><pre>webview.addContentScripts([\r {\r name: 'myRule',\r matches: ['http://www.foo.com/*'],\r css: { files: ['mystyles.css'] },\r js: { files: ['jquery.js', 'myscript.js'] },\r run_at: 'document_start'\r },\r {\r name: 'anotherRule',\r matches: ['http://www.bar.com/*'],\r js: { code: \"document.body.style.backgroundColor = 'red';\" },\r run_at: 'document_end'\r }]);\r ...\r\r// Navigates webview.\rwebview.src = 'http://www.foo.com';</pre><p>You can defer addContentScripts call until you needs to inject scripts.</p><p>The following example shows how to overwrite an existing rule.</p><pre>webview.addContentScripts([{\r name: 'rule',\r matches: ['http://www.foo.com/*'],\r js: { files: ['scriptA.js'] },\r run_at: 'document_start'}]);\r\r// Do something.\rwebview.src = 'http://www.foo.com/*';\r ...\r// Overwrite 'rule' defined before.\rwebview.addContentScripts([{\r name: 'rule',\r matches: ['http://www.bar.com/*'],\r js: { files: ['scriptB.js'] },\r run_at: 'document_end'}]);</pre><p>If <code>webview</code> has been naviagted to the origin (e.g., foo.com) and calls <code>webview.addContentScripts</code> to add 'myRule', you need to wait for next navigation to make the scripts injected. If you want immediate injection, <code>executeScript</code> will do the right thing.</p><p>Rules are preserved even if the guest process crashes or is killed or even if the <code>webview</code> is reparented.</p><p>Refer to the <a href='/extensions/content_scripts'>content scripts</a> documentation for more details.</p>",
"parameters": [
{
"type": "array",
"name": "contentScriptList",
"items": {
"$ref": "ContentScriptDetails",
"name": "contentScriptDetails"
},
"description": "Details of the content scripts to add.",
"minItems": 1
}
]
},
{
"name": "back",
"type": "function",
"description": "Navigates backward one history entry if possible. Equivalent to <code>go(-1)</code>.",
"parameters": [
{
"type": "function",
"name": "callback",
"description": "Called after the navigation has either failed or completed successfully.",
"optional": true,
"parameters": [
{
"name": "success",
"type": "boolean",
"description": "Indicates whether the navigation was successful."
}
]
}
]
},
{
"name": "canGoBack",
"type": "function",
"returns": { "type": "boolean" },
"description": "Indicates whether or not it is possible to navigate backward through history. The state of this function is cached, and updated before each <code>loadcommit</code>, so the best place to call it is on <code>loadcommit</code>."
},
{
"name": "canGoForward",
"type": "function",
"returns": { "type": "boolean" },
"description": "Indicates whether or not it is possible to navigate forward through history. The state of this function is cached, and updated before each <code>loadcommit</code>, so the best place to call it is on <code>loadcommit</code>."
},
{
"name": "clearData",
"type": "function",
"description": "<p>Clears browsing data for the <code>webview</code> partition.</p>",
"parameters": [
{
"name": "options",
"$ref": "ClearDataOptions",
"description": "Options determining which data to clear."
},
{
"name": "types",
"$ref": "ClearDataTypeSet",
"description": "The types of data to be cleared."
},
{
"type": "function",
"name": "callback",
"optional": true,
"description": "Called after the data has been successfully cleared.",
"parameters": []
}
]
},
{
"name": "executeScript",
"type": "function",
"description": "<p>Injects JavaScript code into the guest page.</p><p>The following sample code uses script injection to set the guest page's background color to red:</p><pre>webview.executeScript({ code: \"document.body.style.backgroundColor = 'red'\" });</pre>",
"parameters": [
{
"$ref": "InjectDetails",
"name": "details",
"description": "Details of the script to run."
},
{
"type": "function",
"name": "callback",
"optional": true,
"description": "Called after all the JavaScript has been executed.",
"parameters": [
{
"name": "result",
"optional": true,
"type": "array",
"items": {"type": "any", "minimum": 0},
"description": "The result of the script in every injected frame."
}
]
}
]
},
{
"name": "find",
"type": "function",
"description": "Initiates a find-in-page request.",
"parameters": [
{
"type": "string",
"name": "searchText",
"description": "The string to find in the page."
},
{
"$ref": "FindOptions",
"name": "options",
"optional": true,
"description": "Options for the find request."
},
{
"type": "function",
"name": "callback",
"description": "Called after all find results have been returned for this find request.",
"optional": true,
"parameters": [
{
"$ref": "FindCallbackResults",
"name": "results",
"description": "Contains all of the results of the find request. <code>results</code> can be omitted if it is not utilized in the callback function body; for example, if the callback is only used to discern when the find request has completed.",
"optional": true
}
]
}
]
},
{
"name": "forward",
"type": "function",
"description": "Navigates forward one history entry if possible. Equivalent to <code>go(1)</code>.",
"parameters": [
{
"type": "function",
"name": "callback",
"description": "Called after the navigation has either failed or completed successfully.",
"optional": true,
"parameters": [
{
"name": "success",
"type": "boolean",
"description": "Indicates whether the navigation was successful."
}
]
}
]
},
{
"name": "getProcessId",
"type": "function",
"returns": { "type": "integer" },
"description": "Returns Chrome's internal process ID for the guest web page's current process, allowing embedders to know how many guests would be affected by terminating the process. Two guests will share a process only if they belong to the same app and have the same <a href=\"#partition\">storage partition ID</a>. The call is synchronous and returns the embedder's cached notion of the current process ID. The process ID isn't the same as the operating system's process ID.",
"parameters": []
},
{
"name": "getUserAgent",
"type": "function",
"returns": { "type": "string" },
"description": "Returns the user agent string used by the <code>webview</code> for guest page requests.",
"parameters": []
},
{
"name": "getZoom",
"type": "function",
"description": "Gets the current zoom factor.",
"parameters": [
{
"type": "function",
"name": "callback",
"description": "Called after the current zoom factor is retrieved.",
"parameters": [
{
"type": "number",
"name": "zoomFactor",
"description": "The current zoom factor."
}
]
}
]
},
{
"name": "getZoomMode",
"type": "function",
"description": "Gets the current zoom mode.",
"parameters": [
{
"type": "function",
"name": "callback",
"description": "Called with the <code>webview</code>'s current zoom mode.",
"parameters": [
{
"$ref": "ZoomMode",
"name": "ZoomMode",
"description": "The <code>webview</code>'s current zoom mode."
}
]
}
]
},
{
"name": "go",
"type": "function",
"description": "Navigates to a history entry using a history index relative to the current navigation. If the requested navigation is impossible, this method has no effect.",
"parameters": [
{
"type": "integer",
"name": "relativeIndex",
"description": "Relative history index to which the <code>webview</code> should be navigated. For example, a value of <code>2</code> will navigate forward 2 history entries if possible; a value of <code>-3</code> will navigate backward 3 entries."
},
{
"type": "function",
"name": "callback",
"description": "Called after the navigation has either failed or completed successfully.",
"optional": true,
"parameters": [
{
"name": "success",
"type": "boolean",
"description": "Indicates whether the navigation was successful."
}
]
}
]
},
{
"name": "insertCSS",
"type": "function",
"description": "Injects CSS into the guest page.",
"parameters": [
{
"$ref": "InjectDetails",
"name": "details",
"description": "Details of the CSS to insert."
},
{
"type": "function",
"name": "callback",
"optional": true,
"description": "Called after the CSS has been inserted.",
"parameters": []
}
]
},
{
"name": "isUserAgentOverridden",
"type": "function",
"description": "Indicates whether or not the <code>webview</code>'s user agent string has been overridden by $(ref:webviewTag.setUserAgentOverride)."
},
{
"name": "print",
"type": "function",
"description": "Prints the contents of the <code>webview</code>. This is equivalent to calling scripted print function from the <code>webview</code> itself."
},
{
"name": "reload",
"type": "function",
"description": "Reloads the current top-level page.",
"parameters": []
},
{
"name": "removeContentScripts",
"type": "function",
"description": "<p>Removes content scripts from a <code>webview</code>.</p><p>The following example removes \"myRule\" which was added before.</p><pre>webview.removeContentScripts(['myRule']);</pre><p>You can remove all the rules by calling:</p><pre>webview.removeContentScripts();</pre>",
"parameters": [
{
"type": "array",
"name": "scriptNameList",
"items": {
"type": "string",
"description": "The name of a content script that will be removed."
},
"optional": true,
"description": "A list of names of content scripts that will be removed. If the list is empty, all the content scripts added to the <code>webview</code> will be removed."
}
]
},
{
"name": "setUserAgentOverride",
"type": "function",
"description": "Override the user agent string used by the <code>webview</code> for guest page requests.",
"parameters": [
{
"name": "userAgent",
"type": "string",
"description": "The user agent string to use."
}
]
},
{
"name": "setZoom",
"type": "function",
"description": "Changes the zoom factor of the page. The scope and persistence of this change are determined by the webview's current zoom mode (see $(ref:webviewTag.ZoomMode)).",
"parameters": [
{
"type": "number",
"name": "zoomFactor",
"description" : "The new zoom factor."
},
{
"type": "function",
"name": "callback",
"description": "Called after the page has been zoomed.",
"optional": true,
"parameters": []
}
]
},
{
"name": "setZoomMode",
"type": "function",
"description": "Sets the zoom mode of the <code>webview</code>.",
"parameters": [
{
"$ref": "ZoomMode",
"name": "ZoomMode",
"description": "Defines how zooming is handled in the <code>webview</code>."
},
{
"type": "function",
"name": "callback",
"description": "Called after the zoom mode has been changed.",
"optional": true,
"parameters": []
}
]
},
{
"name": "stop",
"type": "function",
"description": "Stops loading the current <code>webview</code> navigation if in progress.",
"parameters": []
},
{
"name": "stopFinding",
"type": "function",
"description": "Ends the current find session (clearing all highlighting) and cancels all find requests in progress.",
"parameters": [
{
"type": "string",
"name": "action",
"description": "Determines what to do with the active match after the find session has ended. <code>clear</code> will clear the highlighting over the active match; <code>keep</code> will keep the active match highlighted; <code>activate</code> will keep the active match highlighted and simulate a user click on that match. The default action is <code>keep</code>.",
"optional": true,
"enum": ["clear", "keep", "activate"]
}
]
},
{
"name": "loadDataWithBaseUrl",
"type": "function",
"description": "Loads a data URL with a specified base URL used for relative links. Optionally, a virtual URL can be provided to be shown to the user instead of the data URL.",
"parameters": [
{
"type": "string",
"name": "dataUrl",
"description" : "The data URL to load."
},
{
"type": "string",
"name": "baseUrl",
"description": "The base URL that will be used for relative links."
},
{
"type": "string",
"name": "virtualUrl",
"description": "The URL that will be displayed to the user (in the address bar).",
"optional": true
}
]
},
{
"name": "setSpatialNavigationEnabled",
"type": "function",
"description": "Sets spatial navigation state of the webview.",
"parameters": [
{
"type": "boolean",
"name": "enabled",
"description": "Spatial navigation state value."
}
]
},
{
"name": "isSpatialNavigationEnabled",
"type": "function",
"description": "Queries whether spatial navigation is enabled for the webview.",
"parameters": [
{
"type": "function",
"name": "callback",
"parameters": [
{
"name": "enabled",
"type": "boolean"
}
]
}
]
},
{
"name": "terminate",
"type": "function",
"description": "Forcibly kills the guest web page's renderer process. This may affect multiple <code>webview</code> tags in the current app if they share the same process, but it will not affect <code>webview</code> tags in other apps.",
"parameters": []
}
],
"events": [
{
"name": "close",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when the guest window attempts to close itself.<p>The following example code navigates the <code>webview</code> to <code>about:blank</code> when the guest attempts to close itself.</p><pre>webview.addEventListener('close', function() {\r webview.src = 'about:blank';\r});</pre>",
"parameters": []
},
{
"name": "consolemessage",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when the guest window logs a console message.<p>The following example code forwards all log messages to the embedder's console without regard for log level or other properties.</p><pre>webview.addEventListener('consolemessage', function(e) {\r console.log('Guest page logged a message: ', e.message);\r});</pre>",
"parameters": [
{
"name": "level",
"description": "The severity level of the log message. Ranges from -1 to 2. LOG_VERBOSE (console.debug) = -1, LOG_INFO (console.log, console.info) = 0, LOG_WARNING (console.warn) = 1, LOG_ERROR (console.error) = 2.",
"type": "integer"
},
{
"name": "message",
"description": "The logged message contents.",
"type": "string"
},
{
"name": "line",
"description": "The line number of the message source.",
"type": "integer"
},
{
"name": "sourceId",
"description": "A string identifying the resource which logged the message.",
"type": "string"
}
]
},
{
"name": "contentload",
"options": { "supportsDom": true, "supportsLazyListeners": false},
"description": "Fired when the guest window fires a <code>load</code> event, i.e., when a new document is loaded. This does <em>not</em> include page navigation within the current document or asynchronous resource loads. <p>The following example code modifies the default font size of the guest's <code>body</code> element after the page loads:</p><pre>webview.addEventListener('contentload', function() {\r webview.executeScript({ code: 'document.body.style.fontSize = \"42px\"' });\r});</pre>",
"parameters": []
},
{
"name": "dialog",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when the guest window attempts to open a modal dialog via <code>window.alert</code>, <code>window.confirm</code>, or <code>window.prompt</code>.<p>Handling this event will block the guest process until each event listener returns or the <code>dialog</code> object becomes unreachable (if <code>preventDefault()</code> was called.)</p><p>The default behavior is to cancel the dialog.</p>",
"parameters": [
{
"name": "messageType",
"type": "string",
"enum": ["alert", "confirm", "prompt"],
"description": "The type of modal dialog requested by the guest."
},
{
"name": "messageText",
"type": "string",
"description": "The text the guest attempted to display in the modal dialog."
},
{
"name": "dialog",
"$ref": "DialogController",
"description": "An interface that can be used to respond to the guest's modal request."
}
]
},
{
"name": "exit",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when the process rendering the guest web content has exited.<p>The following example code will show a farewell message whenever the guest page crashes:</p><pre>webview.addEventListener('exit', function(e) {\r if (e.reason === 'crash') {\r webview.src = 'data:text/plain,Goodbye, world!';\r }\r});</pre>",
"parameters": [
{
"name": "processID",
"description": "Chrome's internal ID of the process that exited.",
"type": "integer"
},
{
"name": "reason",
"description": "String indicating the reason for the exit.",
"type": "string",
"enum": ["normal", "abnormal", "crash", "kill"]
}
]
},
{
"name": "findupdate",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when new find results are available for an active find request. This might happen multiple times for a single find request as matches are found.",
"parameters": [
{
"name": "searchText",
"type": "string",
"description": "The string that is being searched for in the page."
},
{
"name": "numberOfMatches",
"type": "integer",
"description": "The number of matches found for <code>searchText</code> on the page so far."
},
{
"name": "activeMatchOrdinal",
"type": "integer",
"description": "The ordinal number of the current active match, if it has been found. This will be <code>0</code> until then."
},
{
"name": "selectionRect",
"$ref": "SelectionRect",
"description": "Describes a rectangle around the active match, if it has been found, in screen coordinates."
},
{
"name": "canceled",
"type": "boolean",
"description": "Indicates whether the find request was canceled."
},
{
"name": "finalUpdate",
"type": "string",
"description": "Indicates that all find requests have completed and that no more <code>findupdate</code> events will be fired until more find requests are made."
}
]
},
{
"name": "loadabort",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when a top-level load has aborted without committing. An error message will be printed to the console unless the event is default-prevented. <p class=\"note\"><strong>Note:</strong> When a resource load is aborted, a <code>loadabort</code> event will eventually be followed by a <code>loadstop</code> event, even if all committed loads since the last <code>loadstop</code> event (if any) were aborted.</p><p class=\"note\"><strong>Note:</strong> When the load of either an about URL or a JavaScript URL is aborted, <code>loadabort</code> will be fired and then the <code>webview</code> will be navigated to 'about:blank'.</p>",
"parameters": [
{
"name": "url",
"description": "Requested URL.",
"type": "string"
},
{
"name": "isTopLevel",
"description": "Whether the load was top-level or in a subframe.",
"type": "boolean"
},
{
"name": "code",
"description": "Unique integer ID for the type of abort. Note that this ID is <em>not</em> guaranteed to remain backwards compatible between releases. You must not act based upon this specific integer.",
"type": "integer"
},
{
"name": "reason",
"description": "String indicating what type of abort occurred. This string is <em>not</em> guaranteed to remain backwards compatible between releases. You must not parse and act based upon its content. It is also possible that, in some cases, an error not listed here could be reported.",
"type": "string",
"enum": ["ERR_ABORTED", "ERR_INVALID_URL", "ERR_DISALLOWED_URL_SCHEME", "ERR_BLOCKED_BY_CLIENT", "ERR_ADDRESS_UNREACHABLE", "ERR_EMPTY_RESPONSE", "ERR_FILE_NOT_FOUND", "ERR_UNKNOWN_URL_SCHEME"]
}
]
},
{
"name": "loadcommit",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when a load has committed. This includes navigation within the current document as well as subframe document-level loads, but does <em>not</em> include asynchronous resource loads.",
"parameters": [
{
"name": "url",
"description": "The URL that committed.",
"type": "string"
},
{
"name": "isTopLevel",
"description": "Whether the load is top-level or in a subframe.",
"type": "boolean"
}
]
},
{
"name": "loadredirect",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when a top-level load request has redirected to a different URL.",
"parameters": [
{
"name": "oldUrl",
"description": "The requested URL before the redirect.",
"type": "string"
},
{
"name": "newUrl",
"description": "The new URL after the redirect.",
"type": "string"
},
{
"name": "isTopLevel",
"description": "Whether or not the redirect happened at top-level or in a subframe.",
"type": "boolean"
}
]
},
{
"name": "loadstart",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when a load has begun.",
"parameters": [
{
"name": "url",
"description": "Requested URL.",
"type": "string"
},
{
"name": "isTopLevel",
"description": "Whether the load is top-level or in a subframe.",
"type": "boolean"
}
]
},
{
"name": "loadstop",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when all frame-level loads in a guest page (including all its subframes) have completed. This includes navigation within the current document as well as subframe document-level loads, but does <em>not</em> include asynchronous resource loads. This event fires every time the number of document-level loads transitions from one (or more) to zero. For example, if a page that has already finished loading (i.e., <code>loadstop</code> already fired once) creates a new iframe which loads a page, then a second <code>loadstop</code> will fire when the iframe page load completes. This pattern is commonly observed on pages that load ads. <p class=\"note\"><strong>Note:</strong> When a committed load is aborted, a <code>loadstop</code> event will eventually follow a <code>loadabort</code> event, even if all committed loads since the last <code>loadstop</code> event (if any) were aborted.</p>",
"parameters": []
},
{
"name": "newwindow",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when the guest page attempts to open a new browser window.<p>The following example code will create and navigate a new <code>webview</code> in the embedder for each requested new window:</p><pre>webview.addEventListener('newwindow', function(e) {\r var newWebview = document.createElement('webview');\r document.body.appendChild(newWebview);\r e.window.attach(newWebview);\r});</pre>",
"parameters": [
{
"name": "window",
"description": "An interface that can be used to either attach the requested target page to an existing <code>webview</code> element or explicitly discard the request.",
"$ref": "NewWindow"
},
{
"name": "targetUrl",
"description": "The target URL requested for the new window.",
"type": "string"
},
{
"name": "initialWidth",
"description": "The initial width requested for the new window.",
"type": "number"
},
{
"name": "initialHeight",
"description": "The initial height requested for the new window.",
"type": "number"
},
{
"name": "name",
"description": "The requested name of the new window.",
"type": "string"
},
{
"name": "windowOpenDisposition",
"description": "The requested disposition of the new window.",
"type": "string",
"enum": ["ignore", "save_to_disk", "current_tab", "new_background_tab", "new_foreground_tab", "new_window", "new_popup"]
}
]
},
{
"name": "permissionrequest",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when the guest page needs to request special permission from the embedder.<p>The following example code will grant the guest page access to the <code>webkitGetUserMedia</code> API. Note that an app using this example code must itself specify <code>audioCapture</code> and/or <code>videoCapture</code> manifest permissions:</p><pre>webview.addEventListener('permissionrequest', function(e) {\r if (e.permission === 'media') {\r e.request.allow();\r }\r});</pre>",
"parameters": [
{
"name": "permission",
"description": "The type of permission being requested.",
"type": "string",
"enum": ["media", "geolocation", "pointerLock", "download", "loadplugin", "filesystem", "fullscreen"]
},
{
"name": "request",
"type": "object",
"properties": {},
"description": "An object which holds details of the requested permission. Depending on the type of permission requested, this may be a $(ref:webviewTag.MediaPermissionRequest), $(ref:webviewTag.GeolocationPermissionRequest), $(ref:webviewTag.PointerLockPermissionRequest), $(ref:webviewTag.DownloadPermissionRequest), $(ref:webviewTag.LoadPluginPermissionRequest), or $(ref:webviewTag.FullscreenPermissionRequest)."
}
]
},
{
"name": "responsive",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when the process rendering the guest web content has become responsive again after being unresponsive.<p>The following example code will fade the <code>webview</code> element in or out as it becomes responsive or unresponsive:</p><pre>webview.style.webkitTransition = 'opacity 250ms';\rwebview.addEventListener('unresponsive', function() {\r webview.style.opacity = '0.5';\r});\rwebview.addEventListener('responsive', function() {\r webview.style.opacity = '1';\r});</pre>",
"parameters": [
{
"name": "processID",
"description": "Chrome's internal ID of the process that became responsive.",
"type": "integer"
}
]
},
{
"name": "sizechanged",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when the embedded web content has been resized via <code>autosize</code>. Only fires if <code>autosize</code> is enabled.",
"parameters": [
{
"name": "oldWidth",
"description": "Old width of embedded web content.",
"type": "number"
},
{
"name": "oldHeight",
"description": "Old height of embedded web content.",
"type": "number"
},
{
"name": "newWidth",
"description": "New width of embedded web content.",
"type": "number"
},
{
"name": "newHeight",
"description": "New height of embedded web content.",
"type": "number"
}
]
},
{
"name": "unresponsive",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when the process rendering the guest web content has become unresponsive. This event will be generated once with a matching responsive event if the guest begins to respond again.",
"parameters": [
{
"name": "processID",
"description": "Chrome's internal ID of the process that has become unresponsive.",
"type": "integer"
}
]
},
{
"name": "zoomchange",
"options": { "supportsDom": true, "supportsLazyListeners": false },
"description": "Fired when the page's zoom changes.",
"parameters": [
{
"name": "oldZoomFactor",
"type": "number",
"description": "The page's previous zoom factor."
},
{
"name": "newZoomFactor",
"type": "number",
"description": "The new zoom factor that the page was zoomed to."
}
]
}
],
"properties": {
"contentWindow": {
"$ref": "ContentWindow",
"description": "Object reference which can be used to post messages into the guest page."
},
"request": {
"$ref": "WebRequestEventInterface",
"description": "Interface which provides access to webRequest events on the guest page."
},
"contextMenus": {
"$ref": "ContextMenus",
"description": "Similar to <a href='contextMenus'>chrome's ContextMenus API</a>, but applies to <code>webview</code> instead of browser. Use the <code>webview.contextMenus</code> API to add items to <code>webview</code>'s context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages."
}
}
}
]