Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / remoting / webapp / js_proto / chrome_proto.js
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.
4
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.
8
9 /** @type {Object} */
10 var chrome = {};
11
12 /** @constructor */
13 chrome.Event = function() {};
14
15 /** @param {Function} callback */
16 chrome.Event.prototype.addListener = function(callback) {};
17
18 /** @param {Function} callback */
19 chrome.Event.prototype.removeListener = function(callback) {};
20
21 /** @type {Object} */
22 chrome.app = {};
23
24 /** @type {Object} */
25 chrome.app.runtime = {
26   /** @type {chrome.Event} */
27   onLaunched: null
28 };
29
30
31 /** @type {Object} */
32 chrome.app.window = {
33   /**
34    * @param {string} name
35    * @param {Object} parameters
36    * @param {function()=} opt_callback
37    */
38   create: function(name, parameters, opt_callback) {},
39   /**
40    * @return {AppWindow}
41    */
42   current: function() {},
43   /**
44    * @param {string} id
45    * @param {function()=} opt_callback
46    */
47   get: function(id, opt_callback) {}
48 };
49
50
51 /** @type {Object} */
52 chrome.runtime = {
53   /** @type {Object} */
54   lastError: {
55     /** @type {string} */
56     message: ''
57   },
58   /** @type {string} */
59   id: '',
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} */
65   onSuspend: null,
66   /** @type {chrome.Event} */
67   onSuspendCanceled: null,
68   /** @type {chrome.Event} */
69   onConnect: null,
70   /** @type {chrome.Event} */
71   onConnectExternal: null,
72   /** @type {chrome.Event} */
73   onMessage: null,
74   /** @type {chrome.Event} */
75   onMessageExternal: null
76 };
77
78 /**
79  * @type {?function(string):chrome.runtime.Port}
80  */
81 chrome.runtime.connectNative = function(name) {};
82
83 /**
84  * @param {{ name: string}} config
85  * @return {chrome.runtime.Port}
86  */
87 chrome.runtime.connect = function(config) {};
88
89 /**
90  * @param {string} extensionId
91  * @param {*} message
92  * @param {Object=} opt_options
93  * @param {function(*)=} opt_callback
94  */
95 chrome.runtime.sendMessage = function(
96     extensionId, message, opt_options, opt_callback) {};
97
98 /** @constructor */
99 chrome.runtime.MessageSender = function(){
100   /** @type {chrome.Tab} */
101   this.tab = null;
102 };
103
104 /** @constructor */
105 chrome.runtime.Port = function() {
106   this.onMessage = new chrome.Event();
107   this.onDisconnect = new chrome.Event();
108
109   /** @type {string} */
110   this.name = '';
111
112   /** @type {chrome.runtime.MessageSender} */
113   this.sender = null;
114 };
115
116 /** @type {chrome.Event} */
117 chrome.runtime.Port.prototype.onMessage = null;
118
119 /** @type {chrome.Event} */
120 chrome.runtime.Port.prototype.onDisconnect = null;
121
122 chrome.runtime.Port.prototype.disconnect = function() {};
123
124 /**
125  * @param {Object} message
126  */
127 chrome.runtime.Port.prototype.postMessage = function(message) {};
128
129
130 /** @type {Object} */
131 chrome.extension = {};
132
133 /**
134  * @param {*} message
135  */
136 chrome.extension.sendMessage = function(message) {}
137
138 /** @type {chrome.Event} */
139 chrome.extension.onMessage;
140
141
142 /** @type {Object} */
143 chrome.i18n = {};
144
145 /**
146  * @param {string} messageName
147  * @param {(string|Array.<string>)=} opt_args
148  * @return {string}
149  */
150 chrome.i18n.getMessage = function(messageName, opt_args) {};
151
152 /**
153  * @return {string}
154  */
155 chrome.i18n.getUILanguage = function() {};
156
157
158 /** @type {Object} */
159 chrome.storage = {};
160
161 /** @type {chrome.Storage} */
162 chrome.storage.local;
163
164 /** @type {chrome.Storage} */
165 chrome.storage.sync;
166
167 /** @constructor */
168 chrome.Storage = function() {};
169
170 /**
171  * @param {string|Array.<string>|Object.<string>} items
172  * @param {function(Object.<string>):void} callback
173  * @return {void}
174  */
175 chrome.Storage.prototype.get = function(items, callback) {};
176
177 /**
178  * @param {Object.<string>} items
179  * @param {function():void=} opt_callback
180  * @return {void}
181  */
182 chrome.Storage.prototype.set = function(items, opt_callback) {};
183
184 /**
185  * @param {string|Array.<string>} items
186  * @param {function():void=} opt_callback
187  * @return {void}
188  */
189 chrome.Storage.prototype.remove = function(items, opt_callback) {};
190
191 /**
192  * @param {function():void=} opt_callback
193  * @return {void}
194  */
195 chrome.Storage.prototype.clear = function(opt_callback) {};
196
197
198 /**
199  * @type {Object}
200  * src/chrome/common/extensions/api/context_menus.json
201  */
202 chrome.contextMenus = {};
203 /** @type {chrome.Event} */
204 chrome.contextMenus.onClicked;
205 /**
206  * @param {!Object} createProperties
207  * @param {function()=} opt_callback
208  */
209 chrome.contextMenus.create = function(createProperties, opt_callback) {};
210 /**
211  * @param {string|number} id
212  * @param {!Object} updateProperties
213  * @param {function()=} opt_callback
214  */
215 chrome.contextMenus.update = function(id, updateProperties, opt_callback) {};
216 /**
217  * @param {string|number} menuItemId
218  * @param {function()=} opt_callback
219  */
220 chrome.contextMenus.remove = function(menuItemId, opt_callback) {};
221 /**
222  * @param {function()=} opt_callback
223  */
224 chrome.contextMenus.removeAll = function(opt_callback) {};
225
226 /** @constructor */
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;
250
251
252 /** @type {Object} */
253 chrome.fileSystem = {
254   /**
255    * @param {Object.<string>?} options
256    * @param {function(Entry, Array.<FileEntry>):void} callback
257    */
258   chooseEntry: function(options, callback) {},
259   /**
260    * @param {FileEntry} fileEntry
261    * @param {function(string):void} callback
262    */
263   getDisplayPath: function(fileEntry, callback) {}
264 };
265
266 /** @type {Object} */
267 chrome.identity = {
268   /**
269    * @param {Object.<string>} parameters
270    * @param {function(string):void} callback
271    */
272   getAuthToken: function(parameters, callback) {},
273   /**
274    * @param {Object.<string>} parameters
275    * @param {function():void} callback
276    */
277   removeCachedAuthToken: function(parameters, callback) {},
278   /**
279    * @param {Object.<string>} parameters
280    * @param {function(string):void} callback
281    */
282   launchWebAuthFlow: function(parameters, callback) {}
283 };
284
285
286 /** @type {Object} */
287 chrome.permissions = {
288   /**
289    * @param {Object.<string>} permissions
290    * @param {function(boolean):void} callback
291    */
292   contains: function(permissions, callback) {},
293   /**
294    * @param {Object.<string>} permissions
295    * @param {function(boolean):void} callback
296    */
297   request: function(permissions, callback) {}
298 };
299
300
301 /** @type {Object} */
302 chrome.tabs = {};
303
304 /** @param {function(chrome.Tab):void} callback */
305 chrome.tabs.getCurrent = function(callback) {};
306
307 /**
308  * @param {Object?} options
309  * @param {function(chrome.Tab)=} opt_callback
310  */
311 chrome.tabs.create = function(options, opt_callback) {};
312
313 /**
314  * @param {string} id
315  * @param {function(chrome.Tab)} callback
316  */
317 chrome.tabs.get = function(id, callback) {};
318
319 /**
320  * @param {string} id
321  * @param {function()=} opt_callback
322  */
323 chrome.tabs.remove = function(id, opt_callback) {};
324
325
326 /** @constructor */
327 chrome.Tab = function() {
328   /** @type {boolean} */
329   this.pinned = false;
330   /** @type {number} */
331   this.windowId = 0;
332   /** @type {string} */
333   this.id = '';
334 };
335
336
337 /** @type {Object} */
338 chrome.windows = {};
339
340 /** @param {number} id
341  *  @param {Object?} getInfo
342  *  @param {function(chrome.Window):void} callback */
343 chrome.windows.get = function(id, getInfo, callback) {};
344
345 /** @constructor */
346 chrome.Window = function() {
347   /** @type {string} */
348   this.state = '';
349   /** @type {string} */
350   this.type = '';
351 };
352
353 /** @constructor */
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} */
366   this.id = '';
367   /** @type {Bounds} */
368   this.outerBounds = null;
369   /** @type {Bounds} */
370   this.innerBounds = null;
371 };
372
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() {};
387
388 /**
389  * @param {{rects: Array.<ClientRect>}} rects
390  */
391 AppWindow.prototype.setShape = function(rects) {};
392
393 /**
394  * @param {{rects: Array.<ClientRect>}} rects
395  */
396 AppWindow.prototype.setInputRegion = function(rects) {};
397
398 /** @constructor */
399 var LaunchData = function() {
400   /** @type {string} */
401   this.id = '';
402   /** @type {Array.<{type: string, entry: FileEntry}>} */
403   this.items = [];
404 };
405
406 /** @constructor */
407 function Bounds() {
408   /** @type {number} */
409   this.left = 0;
410   /** @type {number} */
411   this.top = 0;
412   /** @type {number} */
413   this.width = 0;
414   /** @type {number} */
415   this.height = 0;
416 };
417
418 /** @constructor */
419 function ClientRect() {
420   /** @type {number} */
421   this.width = 0;
422   /** @type {number} */
423   this.height = 0;
424   /** @type {number} */
425   this.top = 0;
426   /** @type {number} */
427   this.bottom = 0;
428   /** @type {number} */
429   this.left = 0;
430   /** @type {number} */
431   this.right = 0;
432 };
433
434 /** @type {Object} */
435 chrome.cast = {};
436
437 /** @constructor */
438 chrome.cast.AutoJoinPolicy = function() {};
439
440 /** @type {chrome.cast.AutoJoinPolicy} */
441 chrome.cast.AutoJoinPolicy.PAGE_SCOPED;
442
443 /** @type {chrome.cast.AutoJoinPolicy} */
444 chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED;
445
446 /** @type {chrome.cast.AutoJoinPolicy} */
447 chrome.cast.AutoJoinPolicy.TAB_AND_ORIGIN_SCOPED;
448
449 /** @constructor */
450 chrome.cast.DefaultActionPolicy = function() {};
451
452 /** @type {chrome.cast.DefaultActionPolicy} */
453 chrome.cast.DefaultActionPolicy.CAST_THIS_TAB;
454
455 /** @type {chrome.cast.DefaultActionPolicy} */
456 chrome.cast.DefaultActionPolicy.CREATE_SESSION;
457
458 /** @constructor */
459 chrome.cast.Error = function() {};
460
461 /** @constructor */
462 chrome.cast.ReceiverAvailability = function() {};
463
464 /** @type {chrome.cast.ReceiverAvailability} */
465 chrome.cast.ReceiverAvailability.AVAILABLE;
466
467 /** @type {chrome.cast.ReceiverAvailability} */
468 chrome.cast.ReceiverAvailability.UNAVAILABLE;
469
470 /** @type {Object} */
471 chrome.cast.media = {};
472
473 /** @constructor */
474 chrome.cast.media.Media = function() {
475   /** @type {number} */
476   this.mediaSessionId = 0;
477 };
478
479 /** @constructor */
480 chrome.cast.Session = function() {
481   /** @type {Array.<chrome.cast.media.Media>} */
482   this.media = [];
483
484   /** @type {string} */
485   this.sessionId = '';
486 };
487
488 /**
489  * @param {string} namespace
490  * @param {Object} message
491  * @param {function():void} successCallback
492  * @param {function(chrome.cast.Error):void} errorCallback
493  */
494 chrome.cast.Session.prototype.sendMessage =
495     function(namespace, message, successCallback, errorCallback) {};
496
497 /**
498  * @param {function(chrome.cast.media.Media):void} listener
499  */
500 chrome.cast.Session.prototype.addMediaListener = function(listener) {};
501
502 /**
503  * @param {function(boolean):void} listener
504  */
505 chrome.cast.Session.prototype.addUpdateListener = function(listener) {};
506
507 /**
508  * @param {string} namespace
509  * @param {function(chrome.cast.media.Media):void} listener
510  */
511 chrome.cast.Session.prototype.addMessageListener =
512     function(namespace, listener){};
513
514 /**
515  * @param {function():void} successCallback
516  * @param {function(chrome.cast.Error):void} errorCallback
517  */
518 chrome.cast.Session.prototype.stop =
519     function(successCallback, errorCallback) {};
520
521 /**
522  * @constructor
523  * @param {string} applicationID
524  */
525 chrome.cast.SessionRequest = function(applicationID) {};
526
527 /**
528  * @constructor
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
534  */
535 chrome.cast.ApiConfig = function(sessionRequest,
536                                  sessionListener,
537                                  receiverListener,
538                                  opt_autoJoinPolicy,
539                                  opt_defaultActionPolicy) {};
540
541 /**
542  * @param {chrome.cast.ApiConfig} apiConfig
543  * @param {function():void} onInitSuccess
544  * @param {function(chrome.cast.Error):void} onInitError
545  */
546 chrome.cast.initialize =
547     function(apiConfig, onInitSuccess, onInitError) {};
548
549 /**
550  * @param {function(chrome.cast.Session):void} successCallback
551  * @param {function(chrome.cast.Error):void} errorCallback
552  */
553 chrome.cast.requestSession =
554     function(successCallback, errorCallback) {};
555
556 /** @type {Object} */
557 chrome.sockets = {};
558
559 /** @type {Object} */
560 chrome.sockets.tcp = {};
561
562 /** @constructor */
563 chrome.sockets.tcp.CreateInfo = function() {
564   /** @type {number} */
565   this.socketId = 0;
566 }
567
568 /**
569  * @param {Object} properties
570  * @param {function(chrome.sockets.tcp.CreateInfo):void} callback
571  */
572 chrome.sockets.tcp.create = function(properties, callback) {};
573
574
575 /** @constructor */
576 chrome.sockets.tcp.ConnectInfo = function() {
577   /** @type {number} */
578   this.result = 0;
579 }
580
581 /**
582  * @param {number} socketId
583  * @param {string} peerAddress
584  * @param {number} peerPort
585  * @param {function(chrome.sockets.tcp.ConnectInfo):void} callback
586  */
587 chrome.sockets.tcp.connect =
588     function(socketId, peerAddress, peerPort, callback) {};
589
590
591 /** @constructor */
592 chrome.sockets.tcp.SendInfo = function() {
593   /** @type {number} */
594   this.resultCode = 0;
595
596   /** @type {number} */
597   this.bytesSent = 0;
598 }
599
600 /**
601  * @param {number} socketId
602  * @param {ArrayBuffer} data
603  * @param {function(chrome.sockets.tcp.SendInfo):void} callback
604  */
605 chrome.sockets.tcp.send = function(socketId, data, callback) {};
606
607
608 /**
609  * @param {number} socketId
610  */
611 chrome.sockets.tcp.close = function(socketId) {};
612
613 /**
614  * @param {number} socketId
615  * @param {Object} options
616  * @param {function(number):void} callback
617  */
618 chrome.sockets.tcp.secure = function(socketId, options, callback) {};
619
620 /** @constructor */
621 chrome.sockets.tcp.ReceiveInfo = function() {
622   /** @type {number} */
623   this.socketId = 0;
624
625   /** @type {ArrayBuffer} */
626   this.data = null;
627 }
628
629 /** @type {chrome.Event} */
630 chrome.sockets.tcp.onReceive = null;
631
632 /** @constructor */
633 chrome.sockets.tcp.ReceiveErrorInfo = function() {
634   /** @type {number} */
635   this.socketId = 0;
636
637   /** @type {number} */
638   this.resultCode = 0;
639 }
640
641 /** @type {chrome.Event} */
642 chrome.sockets.tcp.onReceiveError = null;
643
644 /** @type {Object} */
645 chrome.socket = {};
646
647 /** @constructor */
648 chrome.socket.CreateInfo = function() {
649   /** @type {number} */
650   this.socketId = 0;
651 }
652
653 /**
654  * @param {string} socketType
655  * @param {Object} options
656  * @param {function(chrome.socket.CreateInfo):void} callback
657  */
658 chrome.socket.create = function(socketType, options, callback) {};
659
660 /**
661  * @param {number} socketId
662  * @param {string} hostname
663  * @param {number} port
664  * @param {function(number):void} callback
665  */
666 chrome.socket.connect =
667     function(socketId, hostname, port, callback) {};
668
669 /** @constructor */
670 chrome.socket.WriteInfo = function() {
671   /** @type {number} */
672   this.bytesWritten = 0;
673 }
674
675 /**
676  * @param {number} socketId
677  * @param {ArrayBuffer} data
678  * @param {function(chrome.socket.WriteInfo):void} callback
679  */
680 chrome.socket.write = function(socketId, data, callback) {};
681
682 /** @constructor */
683 chrome.socket.ReadInfo = function() {
684   /** @type {number} */
685   this.resultCode = 0;
686
687   /** @type {ArrayBuffer} */
688   this.data = null;
689 }
690
691 /**
692  * @param {number} socketId
693  * @param {function(chrome.socket.ReadInfo):void} callback
694  */
695 chrome.socket.read = function(socketId, callback) {};
696
697 /**
698  * @param {number} socketId
699  */
700 chrome.socket.destroy = function(socketId) {};
701
702 /**
703  * @param {number} socketId
704  * @param {Object} options
705  * @param {function(number):void} callback
706  */
707 chrome.socket.secure = function(socketId, options, callback) {};