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