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.Event = function() {};
15 /** @param {Function} callback */
16 chrome.Event.prototype.addListener = function(callback) {};
18 /** @param {Function} callback */
19 chrome.Event.prototype.removeListener = function(callback) {};
25 chrome.app.runtime = {
26 /** @type {chrome.Event} */
34 * @param {string} name
35 * @param {Object} parameters
36 * @param {function()=} opt_callback
38 create: function(name, parameters, opt_callback) {},
42 current: function() {},
45 * @param {function()=} opt_callback
47 get: function(id, opt_callback) {}
60 /** @return {{name: string, version: string, app: {background: Object}}} */
61 getManifest: function() {},
62 /** @param {function(Window):void} callback */
63 getBackgroundPage: function(callback) {},
64 /** @type {chrome.Event} */
66 /** @type {chrome.Event} */
67 onSuspendCanceled: null,
68 /** @type {chrome.Event} */
70 /** @type {chrome.Event} */
71 onConnectExternal: null,
72 /** @type {chrome.Event} */
74 /** @type {chrome.Event} */
75 onMessageExternal: null
79 * @type {?function(string):chrome.runtime.Port}
81 chrome.runtime.connectNative = function(name) {};
84 * @param {{ name: string}} config
85 * @return {chrome.runtime.Port}
87 chrome.runtime.connect = function(config) {};
90 * @param {string} extensionId
92 * @param {Object=} opt_options
93 * @param {function(*)=} opt_callback
95 chrome.runtime.sendMessage = function(
96 extensionId, message, opt_options, opt_callback) {};
99 chrome.runtime.MessageSender = function(){
100 /** @type {chrome.Tab} */
105 chrome.runtime.Port = function() {
106 this.onMessage = new chrome.Event();
107 this.onDisconnect = new chrome.Event();
109 /** @type {string} */
112 /** @type {chrome.runtime.MessageSender} */
116 /** @type {chrome.Event} */
117 chrome.runtime.Port.prototype.onMessage = null;
119 /** @type {chrome.Event} */
120 chrome.runtime.Port.prototype.onDisconnect = null;
122 chrome.runtime.Port.prototype.disconnect = function() {};
125 * @param {Object} message
127 chrome.runtime.Port.prototype.postMessage = function(message) {};
130 /** @type {Object} */
131 chrome.extension = {};
136 chrome.extension.sendMessage = function(message) {}
138 /** @type {chrome.Event} */
139 chrome.extension.onMessage;
142 /** @type {Object} */
146 * @param {string} messageName
147 * @param {(string|Array.<string>)=} opt_args
150 chrome.i18n.getMessage = function(messageName, opt_args) {};
155 chrome.i18n.getUILanguage = function() {};
158 /** @type {Object} */
161 /** @type {chrome.Storage} */
162 chrome.storage.local;
164 /** @type {chrome.Storage} */
168 chrome.Storage = function() {};
171 * @param {string|Array.<string>|Object.<string>} items
172 * @param {function(Object.<string>):void} callback
175 chrome.Storage.prototype.get = function(items, callback) {};
178 * @param {Object.<string>} items
179 * @param {function():void=} opt_callback
182 chrome.Storage.prototype.set = function(items, opt_callback) {};
185 * @param {string|Array.<string>} items
186 * @param {function():void=} opt_callback
189 chrome.Storage.prototype.remove = function(items, opt_callback) {};
192 * @param {function():void=} opt_callback
195 chrome.Storage.prototype.clear = function(opt_callback) {};
200 * src/chrome/common/extensions/api/context_menus.json
202 chrome.contextMenus = {};
203 /** @type {chrome.Event} */
204 chrome.contextMenus.onClicked;
206 * @param {!Object} createProperties
207 * @param {function()=} opt_callback
209 chrome.contextMenus.create = function(createProperties, opt_callback) {};
211 * @param {string|number} id
212 * @param {!Object} updateProperties
213 * @param {function()=} opt_callback
215 chrome.contextMenus.update = function(id, updateProperties, opt_callback) {};
217 * @param {string|number} menuItemId
218 * @param {function()=} opt_callback
220 chrome.contextMenus.remove = function(menuItemId, opt_callback) {};
222 * @param {function()=} opt_callback
224 chrome.contextMenus.removeAll = function(opt_callback) {};
227 function OnClickData() {}
228 /** @type {string|number} */
229 OnClickData.prototype.menuItemId;
230 /** @type {string|number} */
231 OnClickData.prototype.parentMenuItemId;
232 /** @type {string} */
233 OnClickData.prototype.mediaType;
234 /** @type {string} */
235 OnClickData.prototype.linkUrl;
236 /** @type {string} */
237 OnClickData.prototype.srcUrl;
238 /** @type {string} */
239 OnClickData.prototype.pageUrl;
240 /** @type {string} */
241 OnClickData.prototype.frameUrl;
242 /** @type {string} */
243 OnClickData.prototype.selectionText;
244 /** @type {boolean} */
245 OnClickData.prototype.editable;
246 /** @type {boolean} */
247 OnClickData.prototype.wasChecked;
248 /** @type {boolean} */
249 OnClickData.prototype.checked;
252 /** @type {Object} */
253 chrome.fileSystem = {
255 * @param {Object.<string>?} options
256 * @param {function(Entry, Array.<FileEntry>):void} callback
258 chooseEntry: function(options, callback) {},
260 * @param {FileEntry} fileEntry
261 * @param {function(string):void} callback
263 getDisplayPath: function(fileEntry, 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()=} 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.onFullscreened = null;
365 /** @type {string} */
367 /** @type {Bounds} */
368 this.outerBounds = null;
369 /** @type {Bounds} */
370 this.innerBounds = null;
373 AppWindow.prototype.close = function() {};
374 AppWindow.prototype.drawAttention = function() {};
375 AppWindow.prototype.focus = function() {};
376 AppWindow.prototype.maximize = function() {};
377 AppWindow.prototype.minimize = function() {};
378 AppWindow.prototype.restore = function() {};
379 AppWindow.prototype.show = function() {};
380 /** @return {boolean} */
381 AppWindow.prototype.isMinimized = function() {};
382 AppWindow.prototype.fullscreen = function() {};
383 /** @return {boolean} */
384 AppWindow.prototype.isFullscreen = function() {};
385 /** @return {boolean} */
386 AppWindow.prototype.isMaximized = function() {};
389 * @param {{rects: Array.<ClientRect>}} rects
391 AppWindow.prototype.setShape = function(rects) {};
394 * @param {{rects: Array.<ClientRect>}} rects
396 AppWindow.prototype.setInputRegion = function(rects) {};
399 var LaunchData = function() {
400 /** @type {string} */
402 /** @type {Array.<{type: string, entry: FileEntry}>} */
408 /** @type {number} */
410 /** @type {number} */
412 /** @type {number} */
414 /** @type {number} */
419 function ClientRect() {
420 /** @type {number} */
422 /** @type {number} */
424 /** @type {number} */
426 /** @type {number} */
428 /** @type {number} */
430 /** @type {number} */
434 /** @type {Object} */
438 chrome.cast.AutoJoinPolicy = function() {};
440 /** @type {chrome.cast.AutoJoinPolicy} */
441 chrome.cast.AutoJoinPolicy.PAGE_SCOPED;
443 /** @type {chrome.cast.AutoJoinPolicy} */
444 chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED;
446 /** @type {chrome.cast.AutoJoinPolicy} */
447 chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED;
450 chrome.cast.DefaultActionPolicy = function() {};
452 /** @type {chrome.cast.DefaultActionPolicy} */
453 chrome.cast.DefaultActionPolicy.CAST_THIS_TAB;
455 /** @type {chrome.cast.DefaultActionPolicy} */
456 chrome.cast.DefaultActionPolicy.CREATE_SESSION;
459 chrome.cast.Error = function() {};
462 chrome.cast.ReceiverAvailability = function() {};
464 /** @type {chrome.cast.ReceiverAvailability} */
465 chrome.cast.ReceiverAvailability.AVAILABLE;
467 /** @type {chrome.cast.ReceiverAvailability} */
468 chrome.cast.ReceiverAvailability.UNAVAILABLE;
470 /** @type {Object} */
471 chrome.cast.media = {};
474 chrome.cast.media.Media = function() {
475 /** @type {number} */
476 this.mediaSessionId = 0;
480 chrome.cast.Session = function() {
481 /** @type {Array.<chrome.cast.media.Media>} */
484 /** @type {string} */
489 * @param {string} namespace
490 * @param {Object} message
491 * @param {function():void} successCallback
492 * @param {function(chrome.cast.Error):void} errorCallback
494 chrome.cast.Session.prototype.sendMessage =
495 function(namespace, message, successCallback, errorCallback) {};
498 * @param {function(chrome.cast.media.Media):void} listener
500 chrome.cast.Session.prototype.addMediaListener = function(listener) {};
503 * @param {function(boolean):void} listener
505 chrome.cast.Session.prototype.addUpdateListener = function(listener) {};
508 * @param {string} namespace
509 * @param {function(chrome.cast.media.Media):void} listener
511 chrome.cast.Session.prototype.addMessageListener =
512 function(namespace, listener){};
515 * @param {function():void} successCallback
516 * @param {function(chrome.cast.Error):void} errorCallback
518 chrome.cast.Session.prototype.stop =
519 function(successCallback, errorCallback) {};
523 * @param {string} applicationID
525 chrome.cast.SessionRequest = function(applicationID) {};
529 * @param {chrome.cast.SessionRequest} sessionRequest
530 * @param {function(chrome.cast.Session):void} sessionListener
531 * @param {function(chrome.cast.ReceiverAvailability):void} receiverListener
532 * @param {chrome.cast.AutoJoinPolicy=} opt_autoJoinPolicy
533 * @param {chrome.cast.DefaultActionPolicy=} opt_defaultActionPolicy
535 chrome.cast.ApiConfig = function(sessionRequest,
539 opt_defaultActionPolicy) {};
542 * @param {chrome.cast.ApiConfig} apiConfig
543 * @param {function():void} onInitSuccess
544 * @param {function(chrome.cast.Error):void} onInitError
546 chrome.cast.initialize =
547 function(apiConfig, onInitSuccess, onInitError) {};
550 * @param {function(chrome.cast.Session):void} successCallback
551 * @param {function(chrome.cast.Error):void} errorCallback
553 chrome.cast.requestSession =
554 function(successCallback, errorCallback) {};
556 /** @type {Object} */
559 /** @type {Object} */
560 chrome.sockets.tcp = {};
563 chrome.sockets.tcp.CreateInfo = function() {
564 /** @type {number} */
569 * @param {Object} properties
570 * @param {function(chrome.sockets.tcp.CreateInfo):void} callback
572 chrome.sockets.tcp.create = function(properties, callback) {};
576 chrome.sockets.tcp.ConnectInfo = function() {
577 /** @type {number} */
582 * @param {number} socketId
583 * @param {string} peerAddress
584 * @param {number} peerPort
585 * @param {function(chrome.sockets.tcp.ConnectInfo):void} callback
587 chrome.sockets.tcp.connect =
588 function(socketId, peerAddress, peerPort, callback) {};
592 chrome.sockets.tcp.SendInfo = function() {
593 /** @type {number} */
596 /** @type {number} */
601 * @param {number} socketId
602 * @param {ArrayBuffer} data
603 * @param {function(chrome.sockets.tcp.SendInfo):void} callback
605 chrome.sockets.tcp.send = function(socketId, data, callback) {};
609 * @param {number} socketId
611 chrome.sockets.tcp.close = function(socketId) {};
614 * @param {number} socketId
615 * @param {Object} options
616 * @param {function(number):void} callback
618 chrome.sockets.tcp.secure = function(socketId, options, callback) {};
621 chrome.sockets.tcp.ReceiveInfo = function() {
622 /** @type {number} */
625 /** @type {ArrayBuffer} */
629 /** @type {chrome.Event} */
630 chrome.sockets.tcp.onReceive = null;
633 chrome.sockets.tcp.ReceiveErrorInfo = function() {
634 /** @type {number} */
637 /** @type {number} */
641 /** @type {chrome.Event} */
642 chrome.sockets.tcp.onReceiveError = null;
644 /** @type {Object} */
648 chrome.socket.CreateInfo = function() {
649 /** @type {number} */
654 * @param {string} socketType
655 * @param {Object} options
656 * @param {function(chrome.socket.CreateInfo):void} callback
658 chrome.socket.create = function(socketType, options, callback) {};
661 * @param {number} socketId
662 * @param {string} hostname
663 * @param {number} port
664 * @param {function(number):void} callback
666 chrome.socket.connect =
667 function(socketId, hostname, port, callback) {};
670 chrome.socket.WriteInfo = function() {
671 /** @type {number} */
672 this.bytesWritten = 0;
676 * @param {number} socketId
677 * @param {ArrayBuffer} data
678 * @param {function(chrome.socket.WriteInfo):void} callback
680 chrome.socket.write = function(socketId, data, callback) {};
683 chrome.socket.ReadInfo = function() {
684 /** @type {number} */
687 /** @type {ArrayBuffer} */
692 * @param {number} socketId
693 * @param {function(chrome.socket.ReadInfo):void} callback
695 chrome.socket.read = function(socketId, callback) {};
698 * @param {number} socketId
700 chrome.socket.destroy = function(socketId) {};
703 * @param {number} socketId
704 * @param {Object} options
705 * @param {function(number):void} callback
707 chrome.socket.secure = function(socketId, options, callback) {};