Upstream version 5.34.104.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
13 /** @type {Object} */
14 chrome.app = {};
15
16 /** @type {Object} */
17 chrome.app.runtime = {
18   /** @type {chrome.Event} */
19   onLaunched: null
20 };
21
22
23 /** @type {Object} */
24 chrome.app.window = {
25   /**
26    * @param {string} name
27    * @param {Object} parameters
28    * @param {function()=} opt_callback
29    */
30   create: function(name, parameters, opt_callback) {},
31   /**
32    * @return {AppWindow}
33    */
34   current: function() {}
35 };
36
37
38 /** @type {Object} */
39 chrome.runtime = {
40   /** @type {Object} */
41   lastError: {
42     /** @type {string} */
43     message: ''
44   },
45   /** @return {{version: string, app: {background: Object}}} */
46   getManifest: function() {}
47 };
48
49 /**
50  * @type {?function(string):chrome.extension.Port}
51  */
52 chrome.runtime.connectNative = function(name) {};
53
54
55 /** @type {Object} */
56 chrome.extension = {};
57
58 /** @constructor */
59 chrome.extension.Port = function() {};
60
61 /** @type {chrome.Event} */
62 chrome.extension.Port.prototype.onMessage;
63
64 /** @type {chrome.Event} */
65 chrome.extension.Port.prototype.onDisconnect;
66
67 /**
68  * @param {Object} message
69  */
70 chrome.extension.Port.prototype.postMessage = function(message) {};
71
72 /**
73  * @param {*} message
74  */
75 chrome.extension.sendMessage = function(message) {}
76
77 /** @type {chrome.Event} */
78 chrome.extension.onMessage;
79
80
81 /** @type {Object} */
82 chrome.i18n = {};
83
84 /**
85  * @param {string} messageName
86  * @param {(string|Array.<string>)=} opt_args
87  * @return {string}
88  */
89 chrome.i18n.getMessage = function(messageName, opt_args) {};
90
91
92 /** @type {Object} */
93 chrome.storage = {};
94
95 /** @type {chrome.Storage} */
96 chrome.storage.local;
97
98 /** @type {chrome.Storage} */
99 chrome.storage.sync;
100
101 /** @constructor */
102 chrome.Storage = function() {};
103
104 /**
105  * @param {string|Array.<string>|Object.<string>} items
106  * @param {function(Object.<string>):void} callback
107  * @return {void}
108  */
109 chrome.Storage.prototype.get = function(items, callback) {};
110
111 /**
112  * @param {Object.<string>} items
113  * @param {function():void=} opt_callback
114  * @return {void}
115  */
116 chrome.Storage.prototype.set = function(items, opt_callback) {};
117
118 /**
119  * @param {string|Array.<string>} items
120  * @param {function():void=} opt_callback
121  * @return {void}
122  */
123 chrome.Storage.prototype.remove = function(items, opt_callback) {};
124
125 /**
126  * @param {function():void=} opt_callback
127  * @return {void}
128  */
129 chrome.Storage.prototype.clear = function(opt_callback) {};
130
131
132 /**
133  * @type {Object}
134  * src/chrome/common/extensions/api/context_menus.json
135  */
136 chrome.contextMenus = {};
137 /** @type {ChromeEvent} */
138 chrome.contextMenus.onClicked;
139 /**
140  * @param {!Object} createProperties
141  * @param {function()=} opt_callback
142  */
143 chrome.contextMenus.create = function(createProperties, opt_callback) {};
144 /**
145  * @param {string|number} id
146  * @param {!Object} updateProperties
147  * @param {function()=} opt_callback
148  */
149 chrome.contextMenus.update = function(id, updateProperties, opt_callback) {};
150 /**
151  * @param {string|number} menuItemId
152  * @param {function()=} opt_callback
153  */
154 chrome.contextMenus.remove = function(menuItemId, opt_callback) {};
155 /**
156  * @param {function()=} opt_callback
157  */
158 chrome.contextMenus.removeAll = function(opt_callback) {};
159
160 /** @constructor */
161 function OnClickData() {}
162 /** @type {string|number} */
163 OnClickData.prototype.menuItemId;
164 /** @type {string|number} */
165 OnClickData.prototype.parentMenuItemId;
166 /** @type {string} */
167 OnClickData.prototype.mediaType;
168 /** @type {string} */
169 OnClickData.prototype.linkUrl;
170 /** @type {string} */
171 OnClickData.prototype.srcUrl;
172 /** @type {string} */
173 OnClickData.prototype.pageUrl;
174 /** @type {string} */
175 OnClickData.prototype.frameUrl;
176 /** @type {string} */
177 OnClickData.prototype.selectionText;
178 /** @type {boolean} */
179 OnClickData.prototype.editable;
180 /** @type {boolean} */
181 OnClickData.prototype.wasChecked;
182 /** @type {boolean} */
183 OnClickData.prototype.checked;
184
185
186 /** @type {Object} */
187 chrome.identity = {
188   /**
189    * @param {Object.<string>} parameters
190    * @param {function(string):void} callback
191    */
192   getAuthToken: function(parameters, callback) {},
193   /**
194    * @param {Object.<string>} parameters
195    * @param {function(string):void} callback
196    */
197   launchWebAuthFlow: function(parameters, callback) {}
198 };
199
200 // TODO(garykac): Combine chrome.Event and ChromeEvent
201 /** @constructor */
202 function ChromeEvent() {}
203 /** @param {Function} callback */
204 ChromeEvent.prototype.addListener = function(callback) {};
205 /** @param {Function} callback */
206 ChromeEvent.prototype.removeListener = function(callback) {};
207 /** @param {Function} callback */
208 ChromeEvent.prototype.hasListener = function(callback) {};
209 /** @param {Function} callback */
210 ChromeEvent.prototype.hasListeners = function(callback) {};
211
212 /** @constructor */
213 chrome.Event = function() {};
214
215 /** @param {function():void} callback */
216 chrome.Event.prototype.addListener = function(callback) {};
217
218 /** @param {function():void} callback */
219 chrome.Event.prototype.removeListener = function(callback) {};
220
221
222 /** @type {Object} */
223 chrome.permissions = {
224   /**
225    * @param {Object.<string>} permissions
226    * @param {function(boolean):void} callback
227    */
228   contains: function(permissions, callback) {},
229   /**
230    * @param {Object.<string>} permissions
231    * @param {function(boolean):void} callback
232    */
233   request: function(permissions, callback) {}
234 };
235
236
237 /** @type {Object} */
238 chrome.tabs;
239
240 /** @param {function(chrome.Tab):void} callback */
241 chrome.tabs.getCurrent = function(callback) {}
242
243 /** @constructor */
244 chrome.Tab = function() {
245   /** @type {boolean} */
246   this.pinned = false;
247   /** @type {number} */
248   this.windowId = 0;
249 };
250
251
252 /** @type {Object} */
253 chrome.windows;
254
255 /** @param {number} id
256  *  @param {Object?} getInfo
257  *  @param {function(chrome.Window):void} callback */
258 chrome.windows.get = function(id, getInfo, callback) {}
259
260 /** @constructor */
261 chrome.Window = function() {
262   /** @type {string} */
263   this.state = '';
264   /** @type {string} */
265   this.type = '';
266 };
267
268 /** @constructor */
269 var AppWindow = function() {
270   /** @type {Window} */
271   this.contentWindow = null;
272   /** @type {chrome.Event} */
273   this.onRestored = null;
274 };
275
276 AppWindow.prototype.close = function() {};
277 AppWindow.prototype.drawAttention = function() {};
278 AppWindow.prototype.minimize = function() {};
279
280 /**
281  * @param {{rects: Array.<ClientRect>}} rects
282  */
283 AppWindow.prototype.setShape = function(rects) {};
284
285 /**
286  * @param {{rects: Array.<ClientRect>}} rects
287  */
288 AppWindow.prototype.setInputRegion = function(rects) {};
289
290 /** @constructor */
291 var LaunchData = function() {
292   /** @type {string} */
293   this.id = '';
294   /** @type {Array.<{type: string, entry: FileEntry}>} */
295   this.items = [];
296 };
297
298 /** @constructor */
299 function ClientRect() {
300   /** @type {number} */
301   this.width = 0;
302   /** @type {number} */
303   this.height = 0;
304   /** @type {number} */
305   this.top = 0;
306   /** @type {number} */
307   this.bottom = 0;
308   /** @type {number} */
309   this.left = 0;
310   /** @type {number} */
311   this.right = 0;
312 };