summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/api/extension.json
blob: 00cac1746a65a89586fae91f8c9188630e614bbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
// Copyright (c) 2012 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": "extension",
    "nocompile": true,
    "dependencies": [ "events", "tabs" ],
    "types": [
      {
        "id": "MessageSender",
        "type": "object",
        "description": "An object containing information about the script context that sent a message or request.",
        "properties": {
          "tab": {"$ref": "tabs.Tab", "optional": true, "description":"This property will <b>only</b> be present when the connection was opened from a tab or content script."},
          "id": {"type": "string", "description": "The extension ID of the extension that opened the connection."}
        }
      },
      {
        "id": "Port",
        "type": "object",
        "description": "An object which allows two way communication with other pages.",
        "properties": {
          "name": {"type": "string"},
          "onDisconnect": { "$ref": "events.Event" },
          "onMessage": { "$ref": "events.Event" },
          "postMessage": {"type": "function"},
          "sender": {
            "$ref": "MessageSender",
            "optional": true,
            "description": "This property will <b>only</b> be present on ports passed to onConnect/onConnectExternal listeners."
          }
        },
        "additionalProperties": { "type": "any"}
      }
    ],
    "properties": {
      "lastError": {
        "type": "object",
        "optional": true,
        "unprivileged": true,
        "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>.",
        "properties": {
          "message": { "type": "string", "description": "Description of the error that has taken place." }
        }
      },
      "inIncognitoContext": {
        "type": "boolean",
        "optional": true,
        "unprivileged": true,
        "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."
      }
    },
    "functions": [
      {
        "name": "connect",
        "type": "function",
        "unprivileged": true,
        "description": "Attempts to connect to other listeners within the extension (such as the extension's background page). This is primarily 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 content scripts embedded in tabs via $ref:tabs.connect.",
        "parameters": [
          {"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."},
          {
            "type": "object",
            "name": "connectInfo",
            "properties": {
              "name": { "type": "string", "optional": true, "description": "Will be passed into onConnect for extension processes that are listening for the connection event." }
            },
            "optional": true
          }
        ],
        "returns": {
          "$ref": "Port",
          "description": "Port through which messages can be sent and received with the extension. The port's $ref:extension.Port event is fired if extension does not exist. "
        }
      },
      {
        "name": "connectNative",
        "nodoc": true,
        "type": "function",
        "description": "Attempts to connect a native application in the host machine. The native application must have already registered itself in the proper directory.",
        "parameters": [
          {
            "type": "string",
            "name": "appName",
            "description": "The name of the registered app to connect to."
          },
          {
            "name": "connectionMessage",
            "description": "The object that will be passed to the registered native app on connection.",
            "type": "object",
            "additionalProperties": {
              "type": "any"
            }
          }
        ],
        "returns": {
          "$ref": "Port",
          "description": "Port through which messages can be sent and received with the application"
        }
      },
      {
        "name": "sendRequest",
        "nodoc": true,
        "type": "function",
        "allowAmbiguousOptionalArguments": true,
        "unprivileged": true,
        "description": "Deprecated: Please use sendMessage.",
        "parameters": [
          {"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."},
          { "type": "any", "name": "request" },
          {
            "type": "function",
            "name": "responseCallback",
            "optional": true,
            "parameters": [
              {
                "name": "response",
                "type": "any",
                "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."
              }
            ]
          }
        ]
      },
      {
        "name": "sendMessage",
        "type": "function",
        "allowAmbiguousOptionalArguments": true,
        "unprivileged": true,
        "description": "Sends a single message to other listeners within the extension. Similar to chrome.extension.connect, but only sends a single message with an optional response. The $ref:extension.onMessage event is fired in each extension page of the extension. Note that extensions cannot send messages to content scripts using this method. To send messages to content scripts, use $ref:tabs.sendMessage.",
        "parameters": [
          {"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."},
          { "type": "any", "name": "message" },
          {
            "type": "function",
            "name": "responseCallback",
            "optional": true,
            "parameters": [
              {
                "name": "response",
                "type": "any",
                "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."
              }
            ]
          }
        ]
      },
      {
        "name": "sendNativeMessage",
        "nodoc": true,
        "type": "function",
        "description": "Send a single message to a registered native application.",
        "parameters": [
          {
            "name": "registeredNativeApp",
            "description": "The name of the registered native application.",
            "type": "string"
          },
          {
            "name": "message",
            "description": "The message that will be passed to the registered native application.",
            "type": "object",
            "additionalProperties": {
              "type": "any"
            }
          },
          {
            "type": "function",
            "name": "callback",
            "optional": true,
            "description": "Called with the response from the native application.",
            "parameters": [
              {
                "name": "nativeResponse",
                "type": "object",
                "description": "Whatever the native application responds with.",
                "additionalProperties": {
                  "type": "any"
                }
              }
            ]
          }
        ]
      },
      {
        "name": "getURL",
        "type": "function",
        "unprivileged": true,
        "description": "Converts a relative path within an extension install directory to a fully-qualified URL.",
        "parameters": [
          {
            "type": "string",
            "name": "path",
            "description": "A path to a resource within an extension expressed relative to its install directory."
          }
        ],
        "returns": {
          "type": "string",
          "description": "The fully-qualified URL to the resource."
        }
      },
      {
        "name": "getViews",
        "type": "function",
        "description": "Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension.",
        "parameters": [
          {
            "type": "object",
            "name": "fetchProperties",
            "optional": true,
            "properties": {
              "type": {
                "type": "string",
                "enum": ["tab", "infobar", "notification", "popup"],
                "optional": true,
                "description": "The type of view to get. If omitted, returns all views (including background pages and tabs). Valid values: 'tab', 'infobar', 'notification', 'popup'."
              },
              "windowId": {
                "type": "integer",
                "optional": true,
                "description": "The window to restrict the search to. If omitted, returns all views."
              }
            }
          }
        ],
        "returns": {
          "type": "array",
          "description": "Array of global objects",
          "items": { "type": "object", "isInstanceOf": "global", "additionalProperties": { "type": "any" } }
        }
      },
      {
        "name": "getBackgroundPage",
        "type": "function",
        "description": "Returns the JavaScript 'window' object for the background page running inside the current extension. Returns null if the extension has no background page.",
        "parameters": [],
        "returns": {
          "type": "object", "isInstanceOf": "global", "additionalProperties": { "type": "any" }
         }
      },
      {
        "name": "getExtensionTabs",
        "nodoc": true,
        "type": "function",
        "maximumManifestVersion": 1,
        "description": "Deprecated. Please use getViews({type: 'TAB'}). Returns an array of the JavaScript 'window' objects for each of the tabs running inside the current extension. If windowId is specified, returns only the 'window' objects of tabs attached to the specified window.",
        "parameters": [
          {"type": "integer", "name": "windowId", "optional": true}
        ],
        "returns": {
          "type": "array",
          "description": "Array of global window objects",
          "items": { "type": "object", "isInstanceOf": "global", "additionalProperties": { "type": "any" } }
        }
      },
      {
        "name": "isAllowedIncognitoAccess",
        "type": "function",
        "description": "Retrieves the state of the extension's access to Incognito-mode (as determined by the user-controlled 'Allowed in Incognito' checkbox.",
        "min_version": "12.0.706.0",
        "parameters": [
          {
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "isAllowedAccess",
                "type": "boolean",
                "description": "True if the extension has access to Incognito mode, false otherwise."
              }
            ]
          }
        ]
      },
      {
        "name": "isAllowedFileSchemeAccess",
        "type": "function",
        "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.",
        "min_version": "12.0.706.0",
        "parameters": [
          {
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "isAllowedAccess",
                "type": "boolean",
                "description": "True if the extension can access the 'file://' scheme, false otherwise."
              }
            ]
          }
        ]
      },
      {
        "name": "setUpdateUrlData",
        "type": "function",
        "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.",
        "parameters": [
          {"type": "string", "name": "data", "maxLength": 1024}
        ]
      }
    ],
    "events": [
      {
        "name": "onConnect",
        "type": "function",
        "unprivileged": true,
        "anonymous": true,
        "description": "Fired when a connection is made from either an extension process or a content script.",
        "parameters": [
          {"$ref": "Port", "name": "port"}
        ]
      },
      {
        "name": "onConnectExternal",
        "type": "function",
        "anonymous": true,
        "description": "Fired when a connection is made from another extension.",
        "parameters": [
          {"$ref": "Port", "name": "port"}
        ]
      },
      {
        "name": "onRequest",
        "nodoc": true,
        "type": "function",
        "anonymous": true,
        "unprivileged": true,
        "description": "Deprecated: please use onMessage.",
        "parameters": [
          {"name": "request", "type": "any", "description": "The request sent by the calling script."},
          {"name": "sender", "$ref": "MessageSender" },
          {"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." }
        ]
      },
      {
        "name": "onRequestExternal",
        "nodoc": true,
        "type": "function",
        "anonymous": true,
        "description": "Deprecated: please use onMessageExternal.",
        "parameters": [
          {"name": "request", "type": "any", "description": "The request sent by the calling script."},
          {"name": "sender", "$ref": "MessageSender" },
          {"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." }
        ]
      },
      {
        "name": "onMessage",
        "type": "function",
        "anonymous": true,
        "unprivileged": true,
        "description": "Fired when a message is sent from either an extension process or a content script.",
        "parameters": [
          {"name": "message", "type": "any", "description": "The message sent by the calling script."},
          {"name": "sender", "$ref": "MessageSender" },
          {"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)." }
        ],
        "returns": {
          "type": "boolean",
          "optional": "true",
          "description": "Return true from the event listener if you wish to call <code>sendResponse</code> after the event listener returns."
        }
      },
      {
        "name": "onMessageExternal",
        "type": "function",
        "anonymous": true,
        "description": "Fired when a message is sent from another extension. Cannot be used in a content script.",
        "parameters": [
          {"name": "message", "type": "any", "description": "The message sent by the calling script."},
          {"name": "sender", "$ref": "MessageSender" },
          {"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)." }
        ],
        "returns": {
          "type": "boolean",
          "optional": "true",
          "description": "Return true from the event listener if you wish to call <code>sendResponse</code> after the event listener returns."
        }
      }
    ]
  }
]