| OLD | NEW |
| (Empty) | |
| 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": "runtime", |
| 8 "dependencies": [ "events", "tabs" ], |
| 9 "documentation_permissions_required": ["runtime"], |
| 10 "types": [ |
| 11 { |
| 12 "id": "Port", |
| 13 "type": "object", |
| 14 "description": "An object which allows two way communication with other
pages.", |
| 15 "properties": { |
| 16 "name": {"type": "string"}, |
| 17 "disconnect": { "type": "function" }, |
| 18 "onDisconnect": { "$ref": "events.Event" }, |
| 19 "onMessage": { "$ref": "events.Event" }, |
| 20 "postMessage": {"type": "function"}, |
| 21 "sender": { |
| 22 "$ref": "MessageSender", |
| 23 "optional": true, |
| 24 "description": "This property will <b>only</b> be present on ports p
assed to onConnect/onConnectExternal listeners." |
| 25 } |
| 26 }, |
| 27 "additionalProperties": { "type": "any"} |
| 28 }, |
| 29 { |
| 30 "id": "MessageSender", |
| 31 "type": "object", |
| 32 "description": "An object containing information about the script contex
t that sent a message or request.", |
| 33 "properties": { |
| 34 "tab": {"$ref": "tabs.Tab", "optional": true, "description":"This prop
erty will <b>only</b> be present when the connection was opened from a tab or co
ntent script."}, |
| 35 "id": {"type": "string", "description": "The ID of the extension/app t
hat opened the connection."} |
| 36 } |
| 37 } |
| 38 ], |
| 39 "properties": { |
| 40 "lastError": { |
| 41 "type": "object", |
| 42 "optional": true, |
| 43 "description": "This will be defined during an API method callback if th
ere was an error", |
| 44 "unprivileged": true, |
| 45 "properties": { |
| 46 "message": { |
| 47 "optional": true, |
| 48 "type": "string", |
| 49 "description": "Details about the error which occurred." |
| 50 } |
| 51 } |
| 52 }, |
| 53 "id": { |
| 54 "type": "string", |
| 55 "description": "The ID of the extension/app.", |
| 56 "unprivileged": true |
| 57 } |
| 58 }, |
| 59 "functions": [ |
| 60 { |
| 61 "name": "getBackgroundPage", |
| 62 "type": "function", |
| 63 "description": "Retrieves the JavaScript 'window' object for the backgro
und 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.", |
| 64 "parameters": [ |
| 65 { |
| 66 "type": "function", |
| 67 "name": "callback", |
| 68 "parameters": [ |
| 69 { |
| 70 "name": "backgroundPage", |
| 71 // Note: Only optional because we don't support validation |
| 72 // for custom callbacks. |
| 73 "optional": true, |
| 74 "type": "object", |
| 75 "isInstanceOf": "global", |
| 76 "additionalProperties": { "type": "any" }, |
| 77 "description": "The JavaScript 'window' object for the backgroun
d page." |
| 78 } |
| 79 ] |
| 80 } |
| 81 ] |
| 82 }, |
| 83 { |
| 84 "name": "getManifest", |
| 85 "description": "Returns details about the app or extension from the mani
fest. The object returned is a serialization of the full <a href=\"manifest.html
\">manifest file</a>.", |
| 86 "type": "function", |
| 87 "unprivileged": true, |
| 88 "parameters": [], |
| 89 "returns": { |
| 90 "type": "object", |
| 91 "properties": {}, |
| 92 "additionalProperties": { "type": "any" }, |
| 93 "description": "The manifest details." |
| 94 } |
| 95 }, |
| 96 { |
| 97 "name": "getURL", |
| 98 "type": "function", |
| 99 "unprivileged": true, |
| 100 "description": "Converts a relative path within an app/extension install
directory to a fully-qualified URL.", |
| 101 "parameters": [ |
| 102 { |
| 103 "type": "string", |
| 104 "name": "path", |
| 105 "description": "A path to a resource within an app/extension express
ed relative to its install directory." |
| 106 } |
| 107 ], |
| 108 "returns": { |
| 109 "type": "string", |
| 110 "description": "The fully-qualified URL to the resource." |
| 111 } |
| 112 }, |
| 113 { |
| 114 "name": "reload", |
| 115 "description": "Reloads the app or extension.", |
| 116 "type": "function", |
| 117 "unprivileged": true, |
| 118 "parameters": [] |
| 119 }, |
| 120 { |
| 121 "name": "requestUpdateCheck", |
| 122 "type": "function", |
| 123 "unprivileged": true, |
| 124 "description": "Requests an update check for this app/extension.", |
| 125 "parameters": [ |
| 126 { |
| 127 "type": "function", |
| 128 "name": "callback", |
| 129 "parameters": [ |
| 130 { |
| 131 "name": "status", |
| 132 "type": "string", |
| 133 "enum": ["throttled", "no_update", "update_available"], |
| 134 "description": "Result of the update check." |
| 135 }, |
| 136 { |
| 137 "name": "details", |
| 138 "type": "object", |
| 139 "optional": true, |
| 140 "properties": { |
| 141 "version": { |
| 142 "type": "string", |
| 143 "description": "The version of the available update." |
| 144 } |
| 145 }, |
| 146 "description": "If an update is available, this contains more in
formation about the available update." |
| 147 } |
| 148 ] |
| 149 } |
| 150 ] |
| 151 }, |
| 152 { |
| 153 "name": "connect", |
| 154 "type": "function", |
| 155 "unprivileged": true, |
| 156 "description": "Attempts to connect to other listeners within the extens
ion/app (such as the background page), or other extensions/apps. This is useful
for content scripts connecting to their extension processes. Note that this does
not connect to any listeners in a content script. Extensions may connect to con
tent scripts embedded in tabs via $ref:tabs.connect.", |
| 157 "parameters": [ |
| 158 {"type": "string", "name": "extensionId", "optional": true, "descripti
on": "The ID of the extension/app you want to connect to. If omitted, default is
your own extension."}, |
| 159 { |
| 160 "type": "object", |
| 161 "name": "connectInfo", |
| 162 "properties": { |
| 163 "name": { "type": "string", "optional": true, "description": "Will
be passed into onConnect for processes that are listening for the connection ev
ent." } |
| 164 }, |
| 165 "optional": true |
| 166 } |
| 167 ], |
| 168 "returns": { |
| 169 "$ref": "Port", |
| 170 "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. " |
| 171 } |
| 172 }, |
| 173 { |
| 174 "name": "connectNative", |
| 175 "nodoc": true, |
| 176 "type": "function", |
| 177 "description": "Attempts to connect a native application in the host mac
hine. The native application must have already registered itself in the proper d
irectory.", |
| 178 "parameters": [ |
| 179 { |
| 180 "type": "string", |
| 181 "name": "appName", |
| 182 "description": "The name of the registered app to connect to." |
| 183 } |
| 184 ], |
| 185 "returns": { |
| 186 "$ref": "Port", |
| 187 "description": "Port through which messages can be sent and received w
ith the application" |
| 188 } |
| 189 }, |
| 190 { |
| 191 "name": "sendMessage", |
| 192 "type": "function", |
| 193 "allowAmbiguousOptionalArguments": true, |
| 194 "unprivileged": true, |
| 195 "description": "Sends a single message to onMessage event listeners with
in the extension (or another extension/app). Similar to chrome.runtime.connect,
but only sends a single message with an optional response. The $ref:runtime.onMe
ssage event is fired in each extension page of the extension. Note that extensio
ns cannot send messages to content scripts using this method. To send messages t
o content scripts, use $ref:tabs.sendMessage.", |
| 196 "parameters": [ |
| 197 {"type": "string", "name": "extensionId", "optional": true, "descripti
on": "The extension ID of the extension you want to connect to. If omitted, defa
ult is your own extension."}, |
| 198 { "type": "any", "name": "message" }, |
| 199 { |
| 200 "type": "function", |
| 201 "name": "responseCallback", |
| 202 "optional": true, |
| 203 "parameters": [ |
| 204 { |
| 205 "name": "response", |
| 206 "type": "any", |
| 207 "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 e
rror message." |
| 208 } |
| 209 ] |
| 210 } |
| 211 ] |
| 212 }, |
| 213 { |
| 214 "name": "sendNativeMessage", |
| 215 "nodoc": true, |
| 216 "type": "function", |
| 217 "description": "Send a single message to a registered native application
.", |
| 218 "parameters": [ |
| 219 { |
| 220 "name": "registeredNativeApp", |
| 221 "description": "The name of the registered native application.", |
| 222 "type": "string" |
| 223 }, |
| 224 { |
| 225 "name": "message", |
| 226 "description": "The message that will be passed to the registered na
tive application.", |
| 227 "type": "object", |
| 228 "additionalProperties": { |
| 229 "type": "any" |
| 230 } |
| 231 }, |
| 232 { |
| 233 "type": "function", |
| 234 "name": "callback", |
| 235 "optional": true, |
| 236 "description": "Called with the response from the native application
.", |
| 237 "parameters": [ |
| 238 { |
| 239 "name": "nativeResponse", |
| 240 "type": "object", |
| 241 "description": "Whatever the native application responds with.", |
| 242 "additionalProperties": { |
| 243 "type": "any" |
| 244 } |
| 245 } |
| 246 ] |
| 247 } |
| 248 ] |
| 249 } |
| 250 ], |
| 251 "events": [ |
| 252 { |
| 253 "name": "onStartup", |
| 254 "type": "function", |
| 255 "description": "Fired when the browser first starts up." |
| 256 }, |
| 257 { |
| 258 "name": "onInstalled", |
| 259 "type": "function", |
| 260 "description": "Fired when the extension is first installed, when the ex
tension is updated to a new version, and when Chrome is updated to a new version
.", |
| 261 "parameters": [ |
| 262 { |
| 263 "type": "object", |
| 264 "name": "details", |
| 265 "properties": { |
| 266 "reason": { |
| 267 "type": "string", |
| 268 "enum": ["install", "update", "chrome_update"], |
| 269 "description": "The reason that this event is being dispatched." |
| 270 }, |
| 271 "previousVersion": { |
| 272 "type": "string", |
| 273 "optional": true, |
| 274 "description": "Indicates the previous version of the extension,
which has just been updated. This is present only if 'reason' is 'update'." |
| 275 } |
| 276 } |
| 277 } |
| 278 ] |
| 279 }, |
| 280 { |
| 281 "name": "onSuspend", |
| 282 "type": "function", |
| 283 "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 no
t guaranteed to complete. If more activity for the event page occurs before it g
ets unloaded the onSuspendCanceled event will be sent and the page won't be unlo
aded. " |
| 284 }, |
| 285 { |
| 286 "name": "onSuspendCanceled", |
| 287 "type": "function", |
| 288 "description": "Sent after onSuspend() to indicate that the app won't be
unloaded after all." |
| 289 }, |
| 290 { |
| 291 "name": "onUpdateAvailable", |
| 292 "type": "function", |
| 293 "description": "Fired when an update is available, but isn't installed i
mmediately because the app is currently running. If you do nothing, the update w
ill 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().", |
| 294 "parameters": [ |
| 295 { |
| 296 "type": "object", |
| 297 "name": "details", |
| 298 "properties": { |
| 299 "version": { |
| 300 "type": "string", |
| 301 "description": "The version number of the available update." |
| 302 } |
| 303 }, |
| 304 "additionalProperties": { "type": "any" }, |
| 305 "description": "The manifest details of the available update." |
| 306 } |
| 307 ] |
| 308 }, |
| 309 { |
| 310 "name": "onConnect", |
| 311 "type": "function", |
| 312 "unprivileged": true, |
| 313 "anonymous": true, |
| 314 "description": "Fired when a connection is made from either an extension
process or a content script.", |
| 315 "parameters": [ |
| 316 {"$ref": "Port", "name": "port"} |
| 317 ] |
| 318 }, |
| 319 { |
| 320 "name": "onConnectExternal", |
| 321 "type": "function", |
| 322 "anonymous": true, |
| 323 "description": "Fired when a connection is made from another extension."
, |
| 324 "parameters": [ |
| 325 {"$ref": "Port", "name": "port"} |
| 326 ] |
| 327 }, |
| 328 { |
| 329 "name": "onMessage", |
| 330 "type": "function", |
| 331 "anonymous": true, |
| 332 "unprivileged": true, |
| 333 "description": "Fired when a message is sent from either an extension pr
ocess or a content script.", |
| 334 "parameters": [ |
| 335 {"name": "message", "type": "any", "description": "The message sent by
the calling script."}, |
| 336 {"name": "sender", "$ref": "MessageSender" }, |
| 337 {"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 th
e same document, then only one may send a response. This function becomes invali
d when the event listener returns, unless you return true from the event listene
r to indicate you wish to send a response asynchronously (this will keep the mes
sage channel open to the other end until <code>sendResponse</code> is called)."
} |
| 338 ], |
| 339 "returns": { |
| 340 "type": "boolean", |
| 341 "optional": "true", |
| 342 "description": "Return true from the event listener if you wish to cal
l <code>sendResponse</code> after the event listener returns." |
| 343 } |
| 344 }, |
| 345 { |
| 346 "name": "onMessageExternal", |
| 347 "type": "function", |
| 348 "anonymous": true, |
| 349 "description": "Fired when a message is sent from another extension/app.
Cannot be used in a content script.", |
| 350 "parameters": [ |
| 351 {"name": "message", "type": "any", "description": "The message sent by
the calling script."}, |
| 352 {"name": "sender", "$ref": "MessageSender" }, |
| 353 {"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 th
e same document, then only one may send a response. This function becomes invali
d when the event listener returns, unless you return true from the event listene
r to indicate you wish to send a response asynchronously (this will keep the mes
sage channel open to the other end until <code>sendResponse</code> is called)."
} |
| 354 ], |
| 355 "returns": { |
| 356 "type": "boolean", |
| 357 "optional": "true", |
| 358 "description": "Return true from the event listener if you wish to cal
l <code>sendResponse</code> after the event listener returns." |
| 359 } |
| 360 } |
| 361 |
| 362 |
| 363 |
| 364 ] |
| 365 } |
| 366 ] |
| OLD | NEW |