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
) {}
58 /** @return {{version: string, app: {background: Object}}} */
59 getManifest: function() {},
60 /** @type {chrome.Event} */
62 /** @type {chrome.Event} */
63 onSuspendCanceled
: null,
64 /** @type {chrome.Event} */
66 /** @type {chrome.Event} */
67 onConnectExternal
: null,
68 /** @type {chrome.Event} */
70 /** @type {chrome.Event} */
71 onMessageExternal
: null
75 * @type {?function(string):chrome.runtime.Port}
77 chrome
.runtime
.connectNative = function(name
) {};
80 * @param {{ name: string}} config
81 * @return {chrome.runtime.Port}
83 chrome
.runtime
.connect = function(config
) {};
86 * @param {string} extensionId
88 * @param {Object=} opt_options
89 * @param {function(*)=} opt_callback
91 chrome
.runtime
.sendMessage = function(
92 extensionId
, message
, opt_options
, opt_callback
) {};
95 chrome
.runtime
.MessageSender = function(){
96 /** @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
= {};
132 chrome
.extension
.sendMessage = function(message
) {}
134 /** @type {chrome.Event} */
135 chrome
.extension
.onMessage
;
138 /** @type {Object} */
142 * @param {string} messageName
143 * @param {(string|Array.<string>)=} opt_args
146 chrome
.i18n
.getMessage = function(messageName
, opt_args
) {};
149 /** @type {Object} */
152 /** @type {chrome.Storage} */
153 chrome
.storage
.local
;
155 /** @type {chrome.Storage} */
159 chrome
.Storage = function() {};
162 * @param {string|Array.<string>|Object.<string>} items
163 * @param {function(Object.<string>):void} callback
166 chrome
.Storage
.prototype.get = function(items
, callback
) {};
169 * @param {Object.<string>} items
170 * @param {function():void=} opt_callback
173 chrome
.Storage
.prototype.set = function(items
, opt_callback
) {};
176 * @param {string|Array.<string>} items
177 * @param {function():void=} opt_callback
180 chrome
.Storage
.prototype.remove = function(items
, opt_callback
) {};
183 * @param {function():void=} opt_callback
186 chrome
.Storage
.prototype.clear = function(opt_callback
) {};
191 * src/chrome/common/extensions/api/context_menus.json
193 chrome
.contextMenus
= {};
194 /** @type {chrome.Event} */
195 chrome
.contextMenus
.onClicked
;
197 * @param {!Object} createProperties
198 * @param {function()=} opt_callback
200 chrome
.contextMenus
.create = function(createProperties
, opt_callback
) {};
202 * @param {string|number} id
203 * @param {!Object} updateProperties
204 * @param {function()=} opt_callback
206 chrome
.contextMenus
.update = function(id
, updateProperties
, opt_callback
) {};
208 * @param {string|number} menuItemId
209 * @param {function()=} opt_callback
211 chrome
.contextMenus
.remove = function(menuItemId
, opt_callback
) {};
213 * @param {function()=} opt_callback
215 chrome
.contextMenus
.removeAll = function(opt_callback
) {};
218 function OnClickData() {}
219 /** @type {string|number} */
220 OnClickData
.prototype.menuItemId
;
221 /** @type {string|number} */
222 OnClickData
.prototype.parentMenuItemId
;
223 /** @type {string} */
224 OnClickData
.prototype.mediaType
;
225 /** @type {string} */
226 OnClickData
.prototype.linkUrl
;
227 /** @type {string} */
228 OnClickData
.prototype.srcUrl
;
229 /** @type {string} */
230 OnClickData
.prototype.pageUrl
;
231 /** @type {string} */
232 OnClickData
.prototype.frameUrl
;
233 /** @type {string} */
234 OnClickData
.prototype.selectionText
;
235 /** @type {boolean} */
236 OnClickData
.prototype.editable
;
237 /** @type {boolean} */
238 OnClickData
.prototype.wasChecked
;
239 /** @type {boolean} */
240 OnClickData
.prototype.checked
;
243 /** @type {Object} */
244 chrome
.fileSystem
= {
246 * @param {Object.<string>?} options
247 * @param {function(Entry, Array.<FileEntry>):void} callback
249 chooseEntry: function(options
, callback
) {},
251 * @param {FileEntry} fileEntry
252 * @param {function(string):void} callback
254 getDisplayPath: function(fileEntry
, callback
) {}
257 /** @type {Object} */
260 * @param {Object.<string>} parameters
261 * @param {function(string):void} callback
263 getAuthToken: function(parameters
, callback
) {},
265 * @param {Object.<string>} parameters
266 * @param {function():void} callback
268 removeCachedAuthToken: function(parameters
, callback
) {},
270 * @param {Object.<string>} parameters
271 * @param {function(string):void} callback
273 launchWebAuthFlow: function(parameters
, callback
) {}
277 /** @type {Object} */
278 chrome
.permissions
= {
280 * @param {Object.<string>} permissions
281 * @param {function(boolean):void} callback
283 contains: function(permissions
, callback
) {},
285 * @param {Object.<string>} permissions
286 * @param {function(boolean):void} callback
288 request: function(permissions
, callback
) {}
292 /** @type {Object} */
295 /** @param {function(chrome.Tab):void} callback */
296 chrome
.tabs
.getCurrent = function(callback
) {};
299 * @param {Object?} options
300 * @param {function(chrome.Tab)=} opt_callback
302 chrome
.tabs
.create = function(options
, opt_callback
) {};
306 * @param {function(chrome.Tab)} callback
308 chrome
.tabs
.get = function(id
, callback
) {};
312 * @param {function()=} opt_callback
314 chrome
.tabs
.remove = function(id
, opt_callback
) {};
318 chrome
.Tab = function() {
319 /** @type {boolean} */
321 /** @type {number} */
323 /** @type {string} */
328 /** @type {Object} */
331 /** @param {number} id
332 * @param {Object?} getInfo
333 * @param {function(chrome.Window):void} callback */
334 chrome
.windows
.get = function(id
, getInfo
, callback
) {};
337 chrome
.Window = function() {
338 /** @type {string} */
340 /** @type {string} */
345 var AppWindow = function() {
346 /** @type {Window} */
347 this.contentWindow
= null;
348 /** @type {chrome.Event} */
349 this.onClosed
= null;
350 /** @type {chrome.Event} */
351 this.onRestored
= null;
352 /** @type {chrome.Event} */
353 this.onMaximized
= null;
354 /** @type {chrome.Event} */
355 this.onFullscreened
= null;
356 /** @type {string} */
360 AppWindow
.prototype.close = function() {};
361 AppWindow
.prototype.drawAttention = function() {};
362 AppWindow
.prototype.maximize = function() {};
363 AppWindow
.prototype.minimize = function() {};
364 AppWindow
.prototype.restore = function() {};
365 AppWindow
.prototype.show = function() {};
366 AppWindow
.prototype.fullscreen = function() {};
367 /** @return {boolean} */
368 AppWindow
.prototype.isFullscreen = function() {};
369 /** @return {boolean} */
370 AppWindow
.prototype.isMaximized = function() {};
373 * @param {{rects: Array.<ClientRect>}} rects
375 AppWindow
.prototype.setShape = function(rects
) {};
378 * @param {{rects: Array.<ClientRect>}} rects
380 AppWindow
.prototype.setInputRegion = function(rects
) {};
383 var LaunchData = function() {
384 /** @type {string} */
386 /** @type {Array.<{type: string, entry: FileEntry}>} */
391 function ClientRect() {
392 /** @type {number} */
394 /** @type {number} */
396 /** @type {number} */
398 /** @type {number} */
400 /** @type {number} */
402 /** @type {number} */
406 /** @type {Object} */
410 chrome
.cast
.AutoJoinPolicy = function() {};
412 /** @type {chrome.cast.AutoJoinPolicy} */
413 chrome
.cast
.AutoJoinPolicy
.PAGE_SCOPED
;
415 /** @type {chrome.cast.AutoJoinPolicy} */
416 chrome
.cast
.AutoJoinPolicy
.ORIGIN_SCOPED
;
418 /** @type {chrome.cast.AutoJoinPolicy} */
419 chrome
.cast
.AutoJoinPolicy
.TAB_AND_ORIGIN_SCOPED
;
422 chrome
.cast
.DefaultActionPolicy = function() {};
424 /** @type {chrome.cast.DefaultActionPolicy} */
425 chrome
.cast
.DefaultActionPolicy
.CAST_THIS_TAB
;
427 /** @type {chrome.cast.DefaultActionPolicy} */
428 chrome
.cast
.DefaultActionPolicy
.CREATE_SESSION
;
431 chrome
.cast
.Error = function() {};
434 chrome
.cast
.ReceiverAvailability = function() {};
436 /** @type {chrome.cast.ReceiverAvailability} */
437 chrome
.cast
.ReceiverAvailability
.AVAILABLE
;
439 /** @type {chrome.cast.ReceiverAvailability} */
440 chrome
.cast
.ReceiverAvailability
.UNAVAILABLE
;
442 /** @type {Object} */
443 chrome
.cast
.media
= {};
446 chrome
.cast
.media
.Media = function() {
447 /** @type {number} */
448 this.mediaSessionId
= 0;
452 chrome
.cast
.Session = function() {
453 /** @type {Array.<chrome.cast.media.Media>} */
456 /** @type {string} */
461 * @param {string} namespace
462 * @param {Object} message
463 * @param {function():void} successCallback
464 * @param {function(chrome.cast.Error):void} errorCallback
466 chrome
.cast
.Session
.prototype.sendMessage
=
467 function(namespace, message
, successCallback
, errorCallback
) {};
470 * @param {function(chrome.cast.media.Media):void} listener
472 chrome
.cast
.Session
.prototype.addMediaListener = function(listener
) {};
475 * @param {function(boolean):void} listener
477 chrome
.cast
.Session
.prototype.addUpdateListener = function(listener
) {};
480 * @param {string} namespace
481 * @param {function(chrome.cast.media.Media):void} listener
483 chrome
.cast
.Session
.prototype.addMessageListener
=
484 function(namespace, listener
){};
487 * @param {function():void} successCallback
488 * @param {function(chrome.cast.Error):void} errorCallback
490 chrome
.cast
.Session
.prototype.stop
=
491 function(successCallback
, errorCallback
) {};
495 * @param {string} applicationID
497 chrome
.cast
.SessionRequest = function(applicationID
) {};
501 * @param {chrome.cast.SessionRequest} sessionRequest
502 * @param {function(chrome.cast.Session):void} sessionListener
503 * @param {function(chrome.cast.ReceiverAvailability):void} receiverListener
504 * @param {chrome.cast.AutoJoinPolicy=} opt_autoJoinPolicy
505 * @param {chrome.cast.DefaultActionPolicy=} opt_defaultActionPolicy
507 chrome
.cast
.ApiConfig = function(sessionRequest
,
511 opt_defaultActionPolicy
) {};
514 * @param {chrome.cast.ApiConfig} apiConfig
515 * @param {function():void} onInitSuccess
516 * @param {function(chrome.cast.Error):void} onInitError
518 chrome
.cast
.initialize
=
519 function(apiConfig
, onInitSuccess
, onInitError
) {};
522 * @param {function(chrome.cast.Session):void} successCallback
523 * @param {function(chrome.cast.Error):void} errorCallback
525 chrome
.cast
.requestSession
=
526 function(successCallback
, errorCallback
) {};
528 /** @type {Object} */
531 /** @type {Object} */
532 chrome
.sockets
.tcp
= {};
535 chrome
.sockets
.tcp
.CreateInfo = function() {
536 /** @type {number} */
541 * @param {Object} properties
542 * @param {function(chrome.sockets.tcp.CreateInfo):void} callback
544 chrome
.sockets
.tcp
.create = function(properties
, callback
) {};
548 chrome
.sockets
.tcp
.ConnectInfo = function() {
549 /** @type {number} */
554 * @param {number} socketId
555 * @param {string} peerAddress
556 * @param {number} peerPort
557 * @param {function(chrome.sockets.tcp.ConnectInfo):void} callback
559 chrome
.sockets
.tcp
.connect
=
560 function(socketId
, peerAddress
, peerPort
, callback
) {};
564 chrome
.sockets
.tcp
.SendInfo = function() {
565 /** @type {number} */
568 /** @type {number} */
573 * @param {number} socketId
574 * @param {ArrayBuffer} data
575 * @param {function(chrome.sockets.tcp.SendInfo):void} callback
577 chrome
.sockets
.tcp
.send = function(socketId
, data
, callback
) {};
581 * @param {number} socketId
583 chrome
.sockets
.tcp
.close = function(socketId
) {};
586 * @param {number} socketId
587 * @param {Object} options
588 * @param {function(number):void} callback
590 chrome
.sockets
.tcp
.secure = function(socketId
, options
, callback
) {};
593 chrome
.sockets
.tcp
.ReceiveInfo = function() {
594 /** @type {number} */
597 /** @type {ArrayBuffer} */
601 /** @type {chrome.Event} */
602 chrome
.sockets
.tcp
.onReceive
= null;
605 chrome
.sockets
.tcp
.ReceiveErrorInfo = function() {
606 /** @type {number} */
609 /** @type {number} */
613 /** @type {chrome.Event} */
614 chrome
.sockets
.tcp
.onReceiveError
= null;
616 /** @type {Object} */
620 chrome
.socket
.CreateInfo = function() {
621 /** @type {number} */
626 * @param {string} socketType
627 * @param {Object} options
628 * @param {function(chrome.socket.CreateInfo):void} callback
630 chrome
.socket
.create = function(socketType
, options
, callback
) {};
633 * @param {number} socketId
634 * @param {string} hostname
635 * @param {number} port
636 * @param {function(number):void} callback
638 chrome
.socket
.connect
=
639 function(socketId
, hostname
, port
, callback
) {};
642 chrome
.socket
.WriteInfo = function() {
643 /** @type {number} */
644 this.bytesWritten
= 0;
648 * @param {number} socketId
649 * @param {ArrayBuffer} data
650 * @param {function(chrome.socket.WriteInfo):void} callback
652 chrome
.socket
.write = function(socketId
, data
, callback
) {};
655 chrome
.socket
.ReadInfo = function() {
656 /** @type {number} */
659 /** @type {ArrayBuffer} */
664 * @param {number} socketId
665 * @param {function(chrome.socket.ReadInfo):void} callback
667 chrome
.socket
.read = function(socketId
, callback
) {};
670 * @param {number} socketId
672 chrome
.socket
.destroy = function(socketId
) {};
675 * @param {number} socketId
676 * @param {Object} options
677 * @param {function(number):void} callback
679 chrome
.socket
.secure = function(socketId
, options
, callback
) {};