1 // Copyright 2013 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.
7 "namespace": "webviewTag",
8 "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>).",
9 "documentation_options": {
10 "title": "<webview> Tag",
11 "namespace": "<webview>"
15 "id": "InjectDetails",
17 "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.",
22 "description": "JavaScript or CSS code to inject."
27 "description": "JavaScript or CSS file to inject."
32 "id": "ContentWindow",
34 "description": "Messaging handle to a guest window.",
37 "name": "postMessage",
38 "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>",
43 "description": "Message object to send to the guest."
47 "name": "targetOrigin",
48 "description": "Specifies what the origin of the guest window must be for the event to be dispatched."
57 "description": "Interface attached to <code>newwindow</code> DOM events.",
61 "description": "Attach the requested target page to an existing <code>webview</code> element.",
66 "description": "The <code>webview</code> element to which the target page should be attached.",
73 "description": "Cancel the new window request."
78 "id": "MediaPermissionRequest",
80 "description": "The type of <code>request</code> object which accompanies a <code>media</code> <a href=\"#event-permissionrequest\">permissionrequest</a></code> DOM event.",
83 "description": "The URL of the frame requesting access to user media.",
88 { "name": "allow", "description": "Allow the permission request." },
89 { "name": "deny", "description": "Deny the permission request." }
93 "id": "GeolocationPermissionRequest",
95 "description": "The type of <code>request</code> object which accompanies a <code>geolocation</code> <a href=\"#event-permissionrequest\">permissionrequest</a></code> DOM event.",
98 "description": "The URL of the frame requesting access to geolocation data.",
103 { "name": "allow", "description": "Allow the permission request." },
104 { "name": "deny", "description": "Deny the permission request." }
108 "id": "PointerLockPermissionRequest",
110 "description": "The type of <code>request</code> object which accompanies a <code>pointerLock</code> <a href=\"#event-permissionrequest\">permissionrequest</a></code> DOM event.",
113 "description": "Whether or not pointer lock was requested as a result of a user input gesture.",
116 "lastUnlockedBySelf": {
117 "description": "Whether or not the requesting frame was the most recent client to hold pointer lock.",
121 "description": "The URL of the frame requesting pointer lock.",
126 { "name": "allow", "description": "Allow the permission request." },
127 { "name": "deny", "description": "Deny the permission request." }
135 "description": "Navigates backward one history entry if possible. Equivalent to <code>go(-1)</code>."
140 "returns": { "type": "boolean" },
141 "description": "Indicates whether or not it is possible to navigate backward through history."
144 "name": "canGoForward",
146 "returns": { "type": "boolean" },
147 "description": "Indicates whether or not it is possible to navigate forward through history."
150 "name": "executeScript",
152 "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.bgColor = 'red'\" });</pre>",
155 "$ref": "InjectDetails",
157 "description": "Details of the script to run."
163 "description": "Called after all the JavaScript has been executed.",
169 "items": {"type": "any", "minimum": 0},
170 "description": "The result of the script in every injected frame."
179 "description": "Navigates forward one history entry if possible. Equivalent to <code>go(1)</code>.",
183 "name": "getProcessId",
185 "returns": { "type": "integer" },
186 "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.",
192 "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.",
196 "name": "relativeIndex",
197 "description": "Relative history index to which the webview 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."
204 "description": "Injects CSS into the guest page.",
207 "$ref": "InjectDetails",
209 "description": "Details of the CSS to insert."
215 "description": "Called after the CSS has been inserted.",
223 "description": "Reloads the current top-level page.",
229 "description": "Stops loading the current <webview> navigation if in progress.",
235 "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.",
242 "options": { "supportsDom": true },
243 "description": "Fired when the guest window attempts to close itself.<p>The following example code navigates the webview 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>",
247 "name": "consolemessage",
248 "options": { "supportsDom": true },
249 "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>",
253 "description": "The severity level of the log message. Ranges from 0 to 4.",
258 "description": "The logged message contents.",
263 "description": "The line number of the message source.",
268 "description": "A string identifying the resource which logged the message.",
274 "name": "contentload",
275 "options": { "supportsDom": true },
276 "description": "Fired when the guest window fires a <code>load</code> event.<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>",
281 "options": { "supportsDom": true },
282 "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>",
286 "description": "Chrome's interal ID of the process that exited.",
291 "description": "String indicating the reason for the exit.",
293 "enum": ["normal", "abnormal", "crash", "kill"]
299 "options": { "supportsDom": true },
300 "description": "Fired when a top-level load has aborted without committing.",
304 "description": "Requested URL.",
308 "name": "isTopLevel",
309 "description": "Whether the load was top-level or in a subframe.",
314 "description": "String indicating what type of abort occurred.",
316 "enum": ["networkError", "download", "canceled", "sslError", "safeBrowsingError"]
321 "name": "loadcommit",
322 "options": { "supportsDom": true },
323 "description": "Fired when a load has committed.",
327 "description": "The URL that committed.",
331 "name": "isTopLevel",
332 "description": "Whether the load is top-level or in a subframe.",
338 "name": "loadredirect",
339 "options": { "supportsDom": true },
340 "description": "Fired when a top-level load request has redirected to a different URL.",
344 "description": "The requested URL before the redirect.",
349 "description": "The new URL after the redirect.",
353 "name": "isTopLevel",
354 "description": "Whether or not the redirect happened at top-level or in a subframe.",
361 "options": { "supportsDom": true },
362 "description": "Fired when a load has begun.",
366 "description": "Requested URL.",
370 "name": "isTopLevel",
371 "description": "Whether the load is top-level or in a subframe.",
378 "options": { "supportsDom": true },
379 "description": "Fired when all loads in the guest page (including all subframes) have completed. Fires in addition to any related <code>loadcommit</code> or <code>loadabort</code> events, which occur per-frame.",
384 "options": { "supportsDom": true },
385 "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>",
389 "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.",
394 "description": "The target URL requested for the new window.",
398 "name": "initialWidth",
399 "description": "The initial width requested for the new window.",
403 "name": "initialHeight",
404 "description": "The initial height requested for the new window.",
409 "description": "The requested name of the new window.",
413 "name": "windowOpenDisposition",
414 "description": "The requested disposition of the new window.",
416 "enum": ["ignore", "save_to_disk", "current_tab", "new_background_tab", "new_foreground_tab", "new_window", "new_popup"]
421 "name": "permissionrequest",
422 "options": { "supportsDom": true },
423 "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>",
426 "name": "permission",
427 "description": "The type of permission being requested.",
429 "enum": ["media", "geolocation", "pointerLock"]
433 "description": "An number which uniquely identifies this request from the guest.",
440 "description": "An object which holds details of the requested permission. Depending on the type of permission requested, this may be a $ref:MediaPermissionRequest, $ref:GeolocationPermissionRequest, or a $ref:PointerLockPermissionRequest."
445 "name": "responsive",
446 "options": { "supportsDom": true },
447 "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>",
451 "description": "Chrome's internal ID of the process that became responsive.",
457 "name": "sizechanged",
458 "options": { "supportsDom": true },
459 "description": "Fired when the embedded web content has been resized. Only fires if <code>autosize</code> is enabled.",
463 "description": "Old width of embedded web content.",
468 "description": "Old height of embedded web content.",
473 "description": "New width of embedded web content.",
478 "description": "New height of embedded web content.",
484 "name": "unresponsive",
485 "options": { "supportsDom": true },
486 "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.",
490 "description": "Chrome's internal ID of the process that has become unresponsive.",
498 "$ref": "ContentWindow",
499 "description": "Object reference which can be used to post messages into the guest page."