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.
10 chrome.Event = function() {};
12 /** @param {Function} callback */
13 chrome.Event.prototype.addListener = function(callback) {};
15 /** @param {Function} callback */
16 chrome.Event.prototype.removeListener = function(callback) {};
22 chrome.app.runtime = {
23 /** @type {chrome.Event} */
31 * @param {string} name
32 * @param {Object} parameters
33 * @param {function(AppWindow)=} opt_callback
35 create: function(name, parameters, opt_callback) {},
39 current: function() {},
46 * @return {Array<AppWindow>}
61 /** @return {{name: string, version: string, app: {background: Object}}} */
62 getManifest: function() {},
63 /** @param {function(Window):void} callback */
64 getBackgroundPage: function(callback) {},
65 /** @type {chrome.Event} */
67 /** @type {chrome.Event} */
68 onSuspendCanceled: null,
69 /** @type {chrome.Event} */
71 /** @type {chrome.Event} */
72 onConnectExternal: null,
73 /** @type {chrome.Event} */
75 /** @type {chrome.Event} */
76 onMessageExternal: null
80 * @type {?function(string):chrome.runtime.Port}
82 chrome.runtime.connectNative = function(name) {};
85 * @param {{ name: string}} config
86 * @return {chrome.runtime.Port}
88 chrome.runtime.connect = function(config) {};
91 * @param {string?} extensionId
93 * @param {Object=} opt_options
94 * @param {function(*)=} opt_callback
96 chrome.runtime.sendMessage = function(
97 extensionId, message, opt_options, opt_callback) {};
100 chrome.runtime.MessageSender = function(){
101 /** @type {chrome.Tab} */
103 /** @type {string} */
105 /** @type {string} */
110 chrome.runtime.Port = function() {
111 this.onMessage = new chrome.Event();
112 this.onDisconnect = new chrome.Event();
114 /** @type {string} */
117 /** @type {chrome.runtime.MessageSender} */
121 /** @type {chrome.Event} */
122 chrome.runtime.Port.prototype.onMessage = null;
124 /** @type {chrome.Event} */
125 chrome.runtime.Port.prototype.onDisconnect = null;
127 chrome.runtime.Port.prototype.disconnect = function() {};
130 * @param {Object} message
132 chrome.runtime.Port.prototype.postMessage = function(message) {};
135 /** @type {Object} */
136 chrome.extension = {};
140 * @param {function(*)=} opt_callback
142 chrome.extension.sendMessage = function(message, opt_callback) {};
144 /** @type {chrome.Event} */
145 chrome.extension.onMessage;
148 /** @type {Object} */
152 * @param {string} messageName
153 * @param {(string|Array<string>)=} opt_args
156 chrome.i18n.getMessage = function(messageName, opt_args) {};
161 chrome.i18n.getUILanguage = function() {};
164 /** @type {Object} */
167 /** @type {chrome.Storage} */
168 chrome.storage.local;
170 /** @type {chrome.Storage} */
174 chrome.Storage = function() {};
177 * @param {string|Array<string>|Object<string>} items
178 * @param {function(Object<string>):void} callback
181 chrome.Storage.prototype.get = function(items, callback) {};
184 * @param {Object<string>} items
185 * @param {function():void=} opt_callback
188 chrome.Storage.prototype.set = function(items, opt_callback) {};
191 * @param {string|Array<string>} items
192 * @param {function():void=} opt_callback
195 chrome.Storage.prototype.remove = function(items, opt_callback) {};
198 * @param {function():void=} opt_callback
201 chrome.Storage.prototype.clear = function(opt_callback) {};
206 * src/chrome/common/extensions/api/context_menus.json
208 chrome.contextMenus = {};
209 /** @type {chrome.Event} */
210 chrome.contextMenus.onClicked;
212 * @param {!Object} createProperties
213 * @param {function()=} opt_callback
215 chrome.contextMenus.create = function(createProperties, opt_callback) {};
217 * @param {string|number} id
218 * @param {!Object} updateProperties
219 * @param {function()=} opt_callback
221 chrome.contextMenus.update = function(id, updateProperties, opt_callback) {};
223 * @param {string|number} menuItemId
224 * @param {function()=} opt_callback
226 chrome.contextMenus.remove = function(menuItemId, opt_callback) {};
228 * @param {function()=} opt_callback
230 chrome.contextMenus.removeAll = function(opt_callback) {};
233 function OnClickData() {};
234 /** @type {string|number} */
235 OnClickData.prototype.menuItemId;
236 /** @type {string|number} */
237 OnClickData.prototype.parentMenuItemId;
238 /** @type {string} */
239 OnClickData.prototype.mediaType;
240 /** @type {string} */
241 OnClickData.prototype.linkUrl;
242 /** @type {string} */
243 OnClickData.prototype.srcUrl;
244 /** @type {string} */
245 OnClickData.prototype.pageUrl;
246 /** @type {string} */
247 OnClickData.prototype.frameUrl;
248 /** @type {string} */
249 OnClickData.prototype.selectionText;
250 /** @type {boolean} */
251 OnClickData.prototype.editable;
252 /** @type {boolean} */
253 OnClickData.prototype.wasChecked;
254 /** @type {boolean} */
255 OnClickData.prototype.checked;
258 /** @type {Object} */
259 chrome.fileSystem = {
261 * @param {Object<string>?} options
262 * @param {function(Entry, Array<FileEntry>):void} callback
264 chooseEntry: function(options, callback) {},
266 * @param {Entry} entry
267 * @param {function(string):void} callback
269 getDisplayPath: function(entry, callback) {}
272 /** @param {function(FileWriter):void} callback */
273 Entry.prototype.createWriter = function(callback) {};
275 /** @type {Object} */
278 * @param {Object<string>} parameters
279 * @param {function(string):void} callback
281 getAuthToken: function(parameters, callback) {},
283 * @param {Object<string>} parameters
284 * @param {function():void} callback
286 removeCachedAuthToken: function(parameters, callback) {},
288 * @param {Object<string>} parameters
289 * @param {function(string):void} callback
291 launchWebAuthFlow: function(parameters, callback) {}
295 /** @type {Object} */
296 chrome.permissions = {
298 * @param {Object<string>} permissions
299 * @param {function(boolean):void} callback
301 contains: function(permissions, callback) {},
303 * @param {Object<string>} permissions
304 * @param {function(boolean):void} callback
306 request: function(permissions, callback) {}
310 /** @type {Object} */
313 /** @param {function(chrome.Tab):void} callback */
314 chrome.tabs.getCurrent = function(callback) {};
317 * @param {Object?} options
318 * @param {function(chrome.Tab)=} opt_callback
320 chrome.tabs.create = function(options, opt_callback) {};
324 * @param {function(chrome.Tab)} callback
326 chrome.tabs.get = function(id, callback) {};
330 * @param {function(*=):void=} opt_callback
332 chrome.tabs.remove = function(id, opt_callback) {};
336 chrome.Tab = function() {
337 /** @type {boolean} */
339 /** @type {number} */
341 /** @type {string} */
346 /** @type {Object} */
349 /** @param {number} id
350 * @param {Object?} getInfo
351 * @param {function(chrome.Window):void} callback */
352 chrome.windows.get = function(id, getInfo, callback) {};
355 chrome.Window = function() {
356 /** @type {string} */
358 /** @type {string} */
363 var AppWindow = function() {
364 /** @type {Window} */
365 this.contentWindow = null;
366 /** @type {chrome.Event} */
367 this.onClosed = null;
368 /** @type {chrome.Event} */
369 this.onRestored = null;
370 /** @type {chrome.Event} */
371 this.onMaximized = null;
372 /** @type {chrome.Event} */
373 this.onMinimized = null;
374 /** @type {chrome.Event} */
375 this.onFullscreened = null;
376 /** @type {string} */
378 /** @type {Bounds} */
379 this.outerBounds = null;
380 /** @type {Bounds} */
381 this.innerBounds = null;
384 AppWindow.prototype.close = function() {};
385 AppWindow.prototype.drawAttention = function() {};
386 AppWindow.prototype.focus = function() {};
387 AppWindow.prototype.maximize = function() {};
388 AppWindow.prototype.minimize = function() {};
390 * @param {number} left
391 * @param {number} top
393 AppWindow.prototype.moveTo = function(left, top) {};
395 * @param {number} width
396 * @param {number} height
398 AppWindow.prototype.resizeTo = function(width, height) {};
400 AppWindow.prototype.restore = function() {};
401 AppWindow.prototype.show = function() {};
402 /** @return {boolean} */
403 AppWindow.prototype.isMinimized = function() {};
404 AppWindow.prototype.fullscreen = function() {};
405 /** @return {boolean} */
406 AppWindow.prototype.isFullscreen = function() {};
407 /** @return {boolean} */
408 AppWindow.prototype.isMaximized = function() {};
411 * @param {{rects: Array<ClientRect>}} rects
413 AppWindow.prototype.setShape = function(rects) {};
416 * @param {{rects: Array<ClientRect>}} rects
418 AppWindow.prototype.setInputRegion = function(rects) {};
421 var LaunchData = function() {
422 /** @type {string} */
424 /** @type {Array<{type: string, entry: FileEntry}>} */
430 /** @type {number} */
432 /** @type {number} */
434 /** @type {number} */
436 /** @type {number} */
440 /** @type {Object} */
444 chrome.cast.AutoJoinPolicy = function() {};
446 /** @type {chrome.cast.AutoJoinPolicy} */
447 chrome.cast.AutoJoinPolicy.PAGE_SCOPED;
449 /** @type {chrome.cast.AutoJoinPolicy} */
450 chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED;
452 /** @type {chrome.cast.AutoJoinPolicy} */
453 chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED;
456 chrome.cast.DefaultActionPolicy = function() {};
458 /** @type {chrome.cast.DefaultActionPolicy} */
459 chrome.cast.DefaultActionPolicy.CAST_THIS_TAB;
461 /** @type {chrome.cast.DefaultActionPolicy} */
462 chrome.cast.DefaultActionPolicy.CREATE_SESSION;
465 chrome.cast.Error = function() {};
468 chrome.cast.ReceiverAvailability = function() {};
470 /** @type {chrome.cast.ReceiverAvailability} */
471 chrome.cast.ReceiverAvailability.AVAILABLE;
473 /** @type {chrome.cast.ReceiverAvailability} */
474 chrome.cast.ReceiverAvailability.UNAVAILABLE;
476 /** @type {Object} */
477 chrome.cast.media = {};
480 chrome.cast.media.Media = function() {
481 /** @type {number} */
482 this.mediaSessionId = 0;
486 chrome.cast.Session = function() {
487 /** @type {Array<chrome.cast.media.Media>} */
490 /** @type {string} */
495 * @param {string} namespace
496 * @param {Object} message
497 * @param {function():void} successCallback
498 * @param {function(chrome.cast.Error):void} errorCallback
500 chrome.cast.Session.prototype.sendMessage =
501 function(namespace, message, successCallback, errorCallback) {};
504 * @param {function(chrome.cast.media.Media):void} listener
506 chrome.cast.Session.prototype.addMediaListener = function(listener) {};
509 * @param {function(boolean):void} listener
511 chrome.cast.Session.prototype.addUpdateListener = function(listener) {};
514 * @param {string} namespace
515 * @param {function(string, string):void} listener
517 chrome.cast.Session.prototype.addMessageListener =
518 function(namespace, listener){};
521 * @param {function():void} successCallback
522 * @param {function(chrome.cast.Error):void} errorCallback
524 chrome.cast.Session.prototype.stop =
525 function(successCallback, errorCallback) {};
529 * @param {string} applicationID
531 chrome.cast.SessionRequest = function(applicationID) {};
535 * @param {chrome.cast.SessionRequest} sessionRequest
536 * @param {function(chrome.cast.Session):void} sessionListener
537 * @param {function(chrome.cast.ReceiverAvailability):void} receiverListener
538 * @param {chrome.cast.AutoJoinPolicy=} opt_autoJoinPolicy
539 * @param {chrome.cast.DefaultActionPolicy=} opt_defaultActionPolicy
541 chrome.cast.ApiConfig = function(sessionRequest,
545 opt_defaultActionPolicy) {};
548 * @param {chrome.cast.ApiConfig} apiConfig
549 * @param {function():void} onInitSuccess
550 * @param {function(chrome.cast.Error):void} onInitError
552 chrome.cast.initialize =
553 function(apiConfig, onInitSuccess, onInitError) {};
556 * @param {function(chrome.cast.Session):void} successCallback
557 * @param {function(chrome.cast.Error):void} errorCallback
559 chrome.cast.requestSession =
560 function(successCallback, errorCallback) {};
562 /** @type {Object} */
565 /** @type {Object} */
566 chrome.sockets.tcp = {};
569 chrome.sockets.tcp.CreateInfo = function() {
570 /** @type {number} */
575 * @param {Object} properties
576 * @param {function(chrome.sockets.tcp.CreateInfo):void} callback
578 chrome.sockets.tcp.create = function(properties, callback) {};
582 chrome.sockets.tcp.ConnectInfo = function() {
583 /** @type {number} */
588 * @param {number} socketId
589 * @param {string} peerAddress
590 * @param {number} peerPort
591 * @param {function(chrome.sockets.tcp.ConnectInfo):void} callback
593 chrome.sockets.tcp.connect =
594 function(socketId, peerAddress, peerPort, callback) {};
598 chrome.sockets.tcp.SendInfo = function() {
599 /** @type {number} */
602 /** @type {number} */
607 * @param {number} socketId
608 * @param {ArrayBuffer} data
609 * @param {function(chrome.sockets.tcp.SendInfo):void} callback
611 chrome.sockets.tcp.send = function(socketId, data, callback) {};
615 * @param {number} socketId
617 chrome.sockets.tcp.close = function(socketId) {};
620 * @param {number} socketId
621 * @param {Object} options
622 * @param {function(number):void} callback
624 chrome.sockets.tcp.secure = function(socketId, options, callback) {};
627 chrome.sockets.tcp.ReceiveInfo = function() {
628 /** @type {number} */
631 /** @type {ArrayBuffer} */
635 /** @type {chrome.Event} */
636 chrome.sockets.tcp.onReceive = null;
639 chrome.sockets.tcp.ReceiveErrorInfo = function() {
640 /** @type {number} */
643 /** @type {number} */
647 /** @type {chrome.Event} */
648 chrome.sockets.tcp.onReceiveError = null;
650 /** @type {Object} */
654 chrome.socket.CreateInfo = function() {
655 /** @type {number} */
660 * @param {string} socketType
661 * @param {Object} options
662 * @param {function(chrome.socket.CreateInfo):void} callback
664 chrome.socket.create = function(socketType, options, callback) {};
667 * @param {number} socketId
668 * @param {string} hostname
669 * @param {number} port
670 * @param {function(number):void} callback
672 chrome.socket.connect =
673 function(socketId, hostname, port, callback) {};
676 chrome.socket.WriteInfo = function() {
677 /** @type {number} */
678 this.bytesWritten = 0;
682 * @param {number} socketId
683 * @param {ArrayBuffer} data
684 * @param {function(chrome.socket.WriteInfo):void} callback
686 chrome.socket.write = function(socketId, data, callback) {};
689 chrome.socket.ReadInfo = function() {
690 /** @type {number} */
693 /** @type {ArrayBuffer} */
698 * @param {number} socketId
699 * @param {function(chrome.socket.ReadInfo):void} callback
701 chrome.socket.read = function(socketId, callback) {};
704 * @param {number} socketId
706 chrome.socket.destroy = function(socketId) {};
709 * @param {number} socketId
710 * @param {Object} options
711 * @param {function(number):void} callback
713 chrome.socket.secure = function(socketId, options, callback) {};