1// Copyright (c) 2012 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. 4 5[ 6 { 7 "namespace": "extension", 8 "description": "The <code>chrome.extension</code> API has utilities that can be used by any extension page. It includes support for exchanging messages between an extension and its content scripts or between extensions, as described in detail in <a href='messaging.html'>Message Passing</a>.", 9 "compiler_options": { 10 "implemented_in": "chrome/browser/extensions/api/module/module.h" 11 }, 12 "properties": { 13 "lastError": { 14 "type": "object", 15 "optional": true, 16 "description": "Set for the lifetime of a callback if an ansychronous extension api has resulted in an error. If no error has occured lastError will be <var>undefined</var>.", 17 "properties": { 18 "message": { "type": "string", "description": "Description of the error that has taken place." } 19 } 20 }, 21 "inIncognitoContext": { 22 "type": "boolean", 23 "optional": true, 24 "description": "True for content scripts running inside incognito tabs, and for extension pages running inside an incognito process. The latter only applies to extensions with 'split' incognito_behavior." 25 } 26 }, 27 "functions": [ 28 { 29 "name": "sendRequest", 30 "nocompile": true, 31 "deprecated": "Please use $ref:runtime.sendMessage.", 32 "type": "function", 33 "allowAmbiguousOptionalArguments": true, 34 "description": "Sends a single request to other listeners within the extension. Similar to $ref:runtime.connect, but only sends a single request with an optional response. The $ref:onRequest event is fired in each page of the extension.", 35 "parameters": [ 36 {"type": "string", "name": "extensionId", "optional": true, "description": "The extension ID of the extension you want to connect to. If omitted, default is your own extension."}, 37 { "type": "any", "name": "request" }, 38 { 39 "type": "function", 40 "name": "responseCallback", 41 "optional": true, 42 "parameters": [ 43 { 44 "name": "response", 45 "type": "any", 46 "description": "The JSON response object sent by the handler of the request. 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." 47 } 48 ] 49 } 50 ] 51 }, 52 { 53 "name": "getURL", 54 "nocompile": true, 55 "type": "function", 56 "description": "Converts a relative path within an extension install directory to a fully-qualified URL.", 57 "parameters": [ 58 { 59 "type": "string", 60 "name": "path", 61 "description": "A path to a resource within an extension expressed relative to its install directory." 62 } 63 ], 64 "returns": { 65 "type": "string", 66 "description": "The fully-qualified URL to the resource." 67 } 68 }, 69 { 70 "name": "getViews", 71 "nocompile": true, 72 "type": "function", 73 "description": "Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension.", 74 "parameters": [ 75 { 76 "type": "object", 77 "name": "fetchProperties", 78 "optional": true, 79 "properties": { 80 "type": { 81 "type": "string", 82 "enum": ["tab", "infobar", "notification", "popup"], 83 "optional": true, 84 "description": "The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: 'tab', 'infobar', 'notification', 'popup'." 85 }, 86 "windowId": { 87 "type": "integer", 88 "optional": true, 89 "description": "The window to restrict the search to. If omitted, returns all views." 90 } 91 } 92 } 93 ], 94 "returns": { 95 "type": "array", 96 "description": "Array of global objects", 97 "items": { 98 "name": "viewGlobals", 99 "type": "object", 100 "isInstanceOf": "Window", 101 "additionalProperties": { "type": "any" } 102 } 103 } 104 }, 105 { 106 "name": "getBackgroundPage", 107 "nocompile": true, 108 "type": "function", 109 "description": "Returns the JavaScript 'window' object for the background page running inside the current extension. Returns null if the extension has no background page.", 110 "parameters": [], 111 "returns": { 112 "type": "object", 113 "optional": true, 114 "name": "backgroundPageGlobal", 115 "isInstanceOf": "Window", 116 "additionalProperties": { "type": "any" } 117 } 118 }, 119 { 120 "name": "getExtensionTabs", 121 "nocompile": true, 122 "deprecated": "Please use $ref:getViews <code>{type: \"tab\"}</code>.", 123 "type": "function", 124 "maximumManifestVersion": 1, 125 "description": "Returns an array of the JavaScript 'window' objects for each of the tabs running inside the current extension. If <code>windowId</code> is specified, returns only the 'window' objects of tabs attached to the specified window.", 126 "parameters": [ 127 {"type": "integer", "name": "windowId", "optional": true} 128 ], 129 "returns": { 130 "type": "array", 131 "description": "Array of global window objects", 132 "items": { 133 "type": "object", 134 "name": "tabGlobals", 135 "isInstanceOf": "Window", 136 "additionalProperties": { "type": "any" } 137 } 138 } 139 }, 140 { 141 "name": "isAllowedIncognitoAccess", 142 "type": "function", 143 "description": "Retrieves the state of the extension's access to Incognito-mode (as determined by the user-controlled 'Allowed in Incognito' checkbox.", 144 "min_version": "12.0.706.0", 145 "parameters": [ 146 { 147 "type": "function", 148 "name": "callback", 149 "parameters": [ 150 { 151 "name": "isAllowedAccess", 152 "type": "boolean", 153 "description": "True if the extension has access to Incognito mode, false otherwise." 154 } 155 ] 156 } 157 ] 158 }, 159 { 160 "name": "isAllowedFileSchemeAccess", 161 "type": "function", 162 "description": "Retrieves the state of the extension's access to the 'file://' scheme (as determined by the user-controlled 'Allow access to File URLs' checkbox.", 163 "min_version": "12.0.706.0", 164 "parameters": [ 165 { 166 "type": "function", 167 "name": "callback", 168 "parameters": [ 169 { 170 "name": "isAllowedAccess", 171 "type": "boolean", 172 "description": "True if the extension can access the 'file://' scheme, false otherwise." 173 } 174 ] 175 } 176 ] 177 }, 178 { 179 "name": "setUpdateUrlData", 180 "type": "function", 181 "description": "Sets the value of the ap CGI parameter used in the extension's update URL. This value is ignored for extensions that are hosted in the Chrome Extension Gallery.", 182 "parameters": [ 183 {"type": "string", "name": "data", "maxLength": 1024} 184 ] 185 } 186 ], 187 "events": [ 188 { 189 "name": "onRequest", 190 "deprecated": "Please use $ref:runtime.onMessage.", 191 "type": "function", 192 "options": { 193 "unmanaged": true 194 }, 195 "description": "Fired when a request is sent from either an extension process or a content script.", 196 "parameters": [ 197 {"name": "request", "type": "any", "optional": true, "description": "The request sent by the calling script."}, 198 {"name": "sender", "$ref": "runtime.MessageSender" }, 199 {"name": "sendResponse", "type": "function", "description": "Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response. If you have more than one <code>onRequest</code> listener in the same document, then only one may send a response." } 200 ] 201 }, 202 { 203 "name": "onRequestExternal", 204 "deprecated": "Please use $ref:runtime.onMessageExternal.", 205 "type": "function", 206 "options": { 207 "unmanaged": true 208 }, 209 "description": "Fired when a request is sent from another extension.", 210 "parameters": [ 211 {"name": "request", "type": "any", "optional": true, "description": "The request sent by the calling script."}, 212 {"name": "sender", "$ref": "runtime.MessageSender" }, 213 {"name": "sendResponse", "type": "function", "description": "Function to call when you have a response. The argument should be any JSON-ifiable object, or undefined if there is no response." } 214 ] 215 } 216 ] 217 } 218]