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.
5 // This file contains various hacks needed to inform JSCompiler of various
6 // WebKit- and Chrome-specific properties and methods. It is used only with
7 // JSCompiler to verify the type-correctness of our code.
13 chrome.app.runtime = {
14 /** @type {chrome.Event} */
22 * @param {string} name
23 * @param {Object} parameters
24 * @param {function(AppWindow)=} opt_callback
26 create: function(name, parameters, opt_callback) {},
30 current: function() {},
37 * @return {Array<AppWindow>}
52 /** @return {{name: string, version: string, app: {background: Object}}} */
53 getManifest: function() {},
54 /** @param {function(Window):void} callback */
55 getBackgroundPage: function(callback) {},
56 /** @type {chrome.Event} */
58 /** @type {chrome.Event} */
59 onSuspendCanceled: null,
60 /** @type {chrome.Event} */
62 /** @type {chrome.Event} */
63 onConnectExternal: null,
64 /** @type {chrome.Event} */
66 /** @type {chrome.Event} */
67 onMessageExternal: null
71 * @type {?function(string):chrome.runtime.Port}
73 chrome.runtime.connectNative = function(name) {};
76 * @param {{ name: string}} config
77 * @return {chrome.runtime.Port}
79 chrome.runtime.connect = function(config) {};
82 * @param {string?} extensionId
84 * @param {Object=} opt_options
85 * @param {function(*)=} opt_callback
87 chrome.runtime.sendMessage = function(
88 extensionId, message, opt_options, opt_callback) {};
91 chrome.runtime.MessageSender = function(){
92 /** @type {chrome.Tab} */
101 chrome.runtime.Port = function() {
102 this.onMessage = new chrome.Event();
103 this.onDisconnect = new chrome.Event();
105 /** @type {string} */
108 /** @type {chrome.runtime.MessageSender} */
112 /** @type {chrome.Event} */
113 chrome.runtime.Port.prototype.onMessage = null;
115 /** @type {chrome.Event} */
116 chrome.runtime.Port.prototype.onDisconnect = null;
118 chrome.runtime.Port.prototype.disconnect = function() {};
121 * @param {Object} message
123 chrome.runtime.Port.prototype.postMessage = function(message) {};
126 /** @type {Object} */
127 chrome.extension = {};
131 * @param {function(*)=} opt_callback
133 chrome.extension.sendMessage = function(message, opt_callback) {};
135 /** @type {chrome.Event} */
136 chrome.extension.onMessage;
139 /** @type {Object} */
143 * @param {string} messageName
144 * @param {(string|Array<string>)=} opt_args
147 chrome.i18n.getMessage = function(messageName, opt_args) {};
152 chrome.i18n.getUILanguage = function() {};
155 /** @type {Object} */
158 /** @type {chrome.Storage} */
159 chrome.storage.local;
161 /** @type {chrome.Storage} */
165 chrome.Storage = function() {};
168 * @param {string|Array<string>|Object<string>} items
169 * @param {function(Object<string>):void} callback
172 chrome.Storage.prototype.get = function(items, callback) {};
175 * @param {Object<string>} items
176 * @param {function():void=} opt_callback
179 chrome.Storage.prototype.set = function(items, opt_callback) {};
182 * @param {string|Array<string>} items
183 * @param {function():void=} opt_callback
186 chrome.Storage.prototype.remove = function(items, opt_callback) {};
189 * @param {function():void=} opt_callback
192 chrome.Storage.prototype.clear = function(opt_callback) {};
197 * src/chrome/common/extensions/api/context_menus.json
199 chrome.contextMenus = {};
200 /** @type {chrome.Event} */
201 chrome.contextMenus.onClicked;
203 * @param {!Object} createProperties
204 * @param {function()=} opt_callback
206 chrome.contextMenus.create = function(createProperties, opt_callback) {};
208 * @param {string|number} id
209 * @param {!Object} updateProperties
210 * @param {function()=} opt_callback
212 chrome.contextMenus.update = function(id, updateProperties, opt_callback) {};
214 * @param {string|number} menuItemId
215 * @param {function()=} opt_callback
217 chrome.contextMenus.remove = function(menuItemId, opt_callback) {};
219 * @param {function()=} opt_callback
221 chrome.contextMenus.removeAll = function(opt_callback) {};
224 function OnClickData() {};
225 /** @type {string|number} */
226 OnClickData.prototype.menuItemId;
227 /** @type {string|number} */
228 OnClickData.prototype.parentMenuItemId;
229 /** @type {string} */
230 OnClickData.prototype.mediaType;
231 /** @type {string} */
232 OnClickData.prototype.linkUrl;
233 /** @type {string} */
234 OnClickData.prototype.srcUrl;
235 /** @type {string} */
236 OnClickData.prototype.pageUrl;
237 /** @type {string} */
238 OnClickData.prototype.frameUrl;
239 /** @type {string} */
240 OnClickData.prototype.selectionText;
241 /** @type {boolean} */
242 OnClickData.prototype.editable;
243 /** @type {boolean} */
244 OnClickData.prototype.wasChecked;
245 /** @type {boolean} */
246 OnClickData.prototype.checked;
249 /** @type {Object} */
250 chrome.fileSystem = {
252 * @param {Object<string>?} options
253 * @param {function(Entry, Array<FileEntry>):void} callback
255 chooseEntry: function(options, callback) {},
257 * @param {Entry} entry
258 * @param {function(string):void} callback
260 getDisplayPath: function(entry, callback) {}
263 /** @param {function(FileWriter):void} callback */
264 Entry.prototype.createWriter = function(callback) {};
266 /** @type {Object} */
269 * @param {Object<string>} parameters
270 * @param {function(string):void} callback
272 getAuthToken: function(parameters, callback) {},
274 * @param {Object<string>} parameters
275 * @param {function():void} callback
277 removeCachedAuthToken: function(parameters, callback) {},
279 * @param {Object<string>} parameters
280 * @param {function(string):void} callback
282 launchWebAuthFlow: function(parameters, callback) {}
286 /** @type {Object} */
287 chrome.permissions = {
289 * @param {Object<string>} permissions
290 * @param {function(boolean):void} callback
292 contains: function(permissions, callback) {},
294 * @param {Object<string>} permissions
295 * @param {function(boolean):void} callback
297 request: function(permissions, callback) {}
301 /** @type {Object} */
304 /** @param {function(chrome.Tab):void} callback */
305 chrome.tabs.getCurrent = function(callback) {};
308 * @param {Object?} options
309 * @param {function(chrome.Tab)=} opt_callback
311 chrome.tabs.create = function(options, opt_callback) {};
315 * @param {function(chrome.Tab)} callback
317 chrome.tabs.get = function(id, callback) {};
321 * @param {function(*=):void=} opt_callback
323 chrome.tabs.remove = function(id, opt_callback) {};
327 chrome.Tab = function() {
328 /** @type {boolean} */
330 /** @type {number} */
332 /** @type {string} */
337 /** @type {Object} */
340 /** @param {number} id
341 * @param {Object?} getInfo
342 * @param {function(chrome.Window):void} callback */
343 chrome.windows.get = function(id, getInfo, callback) {};
346 chrome.Window = function() {
347 /** @type {string} */
349 /** @type {string} */
354 var AppWindow = function() {
355 /** @type {Window} */
356 this.contentWindow = null;
357 /** @type {chrome.Event} */
358 this.onClosed = null;
359 /** @type {chrome.Event} */
360 this.onRestored = null;
361 /** @type {chrome.Event} */
362 this.onMaximized = null;
363 /** @type {chrome.Event} */
364 this.onMinimized = null;
365 /** @type {chrome.Event} */
366 this.onFullscreened = null;
367 /** @type {string} */
369 /** @type {Bounds} */
370 this.outerBounds = null;
371 /** @type {Bounds} */
372 this.innerBounds = null;
375 AppWindow.prototype.close = function() {};
376 AppWindow.prototype.drawAttention = function() {};
377 AppWindow.prototype.focus = function() {};
378 AppWindow.prototype.maximize = function() {};
379 AppWindow.prototype.minimize = function() {};
381 * @param {number} left
382 * @param {number} top
384 AppWindow.prototype.moveTo = function(left, top) {};
386 * @param {number} width
387 * @param {number} height
389 AppWindow.prototype.resizeTo = function(width, height) {};
391 AppWindow.prototype.restore = function() {};
392 AppWindow.prototype.show = function() {};
393 /** @return {boolean} */
394 AppWindow.prototype.isMinimized = function() {};
395 AppWindow.prototype.fullscreen = function() {};
396 /** @return {boolean} */
397 AppWindow.prototype.isFullscreen = function() {};
398 /** @return {boolean} */
399 AppWindow.prototype.isMaximized = function() {};
402 * @param {{rects: Array<ClientRect>}} rects
404 AppWindow.prototype.setShape = function(rects) {};
407 * @param {{rects: Array<ClientRect>}} rects
409 AppWindow.prototype.setInputRegion = function(rects) {};
412 var LaunchData = function() {
413 /** @type {string} */
415 /** @type {Array<{type: string, entry: FileEntry}>} */
421 /** @type {number} */
423 /** @type {number} */
425 /** @type {number} */
427 /** @type {number} */
431 /** @type {Object} */
434 /** @type {Object} */
435 chrome.sockets.tcp = {};
438 chrome.sockets.tcp.CreateInfo = function() {
439 /** @type {number} */
444 * @param {Object} properties
445 * @param {function(chrome.sockets.tcp.CreateInfo):void} callback
447 chrome.sockets.tcp.create = function(properties, callback) {};
451 * @param {number} socketId
452 * @param {string} peerAddress
453 * @param {number} peerPort
454 * @param {function(number):void} callback
456 chrome.sockets.tcp.connect =
457 function(socketId, peerAddress, peerPort, callback) {};
461 chrome.sockets.tcp.SendInfo = function() {
462 /** @type {number} */
465 /** @type {number} */
470 * @param {number} socketId
471 * @param {ArrayBuffer} data
472 * @param {function(chrome.sockets.tcp.SendInfo):void} callback
474 chrome.sockets.tcp.send = function(socketId, data, callback) {};
478 * @param {number} socketId
480 chrome.sockets.tcp.close = function(socketId) {};
483 * @param {number} socketId
484 * @param {boolean} paused
485 * @param {function(number):void=} callback
487 chrome.sockets.tcp.setPaused = function(socketId, paused, callback) {};
490 * @param {number} socketId
491 * @param {Object} options
492 * @param {function(number):void} callback
494 chrome.sockets.tcp.secure = function(socketId, options, callback) {};
497 chrome.sockets.tcp.ReceiveInfo = function() {
498 /** @type {number} */
501 /** @type {ArrayBuffer} */
505 /** @type {chrome.Event} */
506 chrome.sockets.tcp.onReceive = null;
509 chrome.sockets.tcp.ReceiveErrorInfo = function() {
510 /** @type {number} */
513 /** @type {number} */
517 /** @type {chrome.Event} */
518 chrome.sockets.tcp.onReceiveError = null;
520 /** @type {Object} */
524 chrome.socket.CreateInfo = function() {
525 /** @type {number} */
530 * @param {string} socketType
531 * @param {Object} options
532 * @param {function(chrome.socket.CreateInfo):void} callback
534 chrome.socket.create = function(socketType, options, callback) {};
537 * @param {number} socketId
538 * @param {string} hostname
539 * @param {number} port
540 * @param {function(number):void} callback
542 chrome.socket.connect =
543 function(socketId, hostname, port, callback) {};
546 chrome.socket.WriteInfo = function() {
547 /** @type {number} */
548 this.bytesWritten = 0;
552 * @param {number} socketId
553 * @param {ArrayBuffer} data
554 * @param {function(chrome.socket.WriteInfo):void} callback
556 chrome.socket.write = function(socketId, data, callback) {};
559 chrome.socket.ReadInfo = function() {
560 /** @type {number} */
563 /** @type {ArrayBuffer} */
568 * @param {number} socketId
569 * @param {function(chrome.socket.ReadInfo):void} callback
571 chrome.socket.read = function(socketId, callback) {};
574 * @param {number} socketId
576 chrome.socket.destroy = function(socketId) {};
579 * @param {number} socketId
580 * @param {Object} options
581 * @param {function(number):void} callback
583 chrome.socket.secure = function(socketId, options, callback) {};