OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file contains various hacks needed to inform JSCompiler of various | 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 | 6 // WebKit- and Chrome-specific properties and methods. It is used only with |
7 // JSCompiler to verify the type-correctness of our code. | 7 // JSCompiler to verify the type-correctness of our code. |
8 | 8 |
9 /** @type {Object} */ | 9 /** @type {Object} */ |
10 var chrome = {}; | 10 var chrome = {}; |
11 | 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) {}; | |
12 | 20 |
13 /** @type {Object} */ | 21 /** @type {Object} */ |
14 chrome.app = {}; | 22 chrome.app = {}; |
15 | 23 |
16 /** @type {Object} */ | 24 /** @type {Object} */ |
17 chrome.app.runtime = { | 25 chrome.app.runtime = { |
18 /** @type {chrome.Event} */ | 26 /** @type {chrome.Event} */ |
19 onLaunched: null | 27 onLaunched: null |
20 }; | 28 }; |
21 | 29 |
22 | 30 |
23 /** @type {Object} */ | 31 /** @type {Object} */ |
24 chrome.app.window = { | 32 chrome.app.window = { |
25 /** | 33 /** |
26 * @param {string} name | 34 * @param {string} name |
27 * @param {Object} parameters | 35 * @param {Object} parameters |
28 * @param {function()=} opt_callback | 36 * @param {function()=} opt_callback |
29 */ | 37 */ |
30 create: function(name, parameters, opt_callback) {}, | 38 create: function(name, parameters, opt_callback) {}, |
31 /** | 39 /** |
32 * @return {AppWindow} | 40 * @return {AppWindow} |
33 */ | 41 */ |
34 current: function() {} | 42 current: function() {}, |
43 /** | |
44 * @param {string} id | |
45 * @param {function()=} opt_callback | |
46 */ | |
47 get: function(id, opt_callback) {} | |
35 }; | 48 }; |
36 | 49 |
37 | 50 |
38 /** @type {Object} */ | 51 /** @type {Object} */ |
39 chrome.runtime = { | 52 chrome.runtime = { |
40 /** @type {Object} */ | 53 /** @type {Object} */ |
41 lastError: { | 54 lastError: { |
42 /** @type {string} */ | 55 /** @type {string} */ |
43 message: '' | 56 message: '' |
44 }, | 57 }, |
45 /** @return {{version: string, app: {background: Object}}} */ | 58 /** @return {{version: string, app: {background: Object}}} */ |
46 getManifest: function() {} | 59 getManifest: function() {}, |
60 /** @type {chrome.Event} */ | |
61 onSuspend: null, | |
62 /** @type {chrome.Event} */ | |
63 onConnect: null, | |
64 /** @type {chrome.Event} */ | |
65 onConnectExternal: null, | |
66 /** @type {chrome.Event} */ | |
67 onMessage: null, | |
68 /** @type {chrome.Event} */ | |
69 onMessageExternal: null | |
47 }; | 70 }; |
48 | 71 |
49 /** | 72 /** |
50 * @type {?function(string):chrome.extension.Port} | 73 * @type {?function(string):chrome.runtime.Port} |
51 */ | 74 */ |
52 chrome.runtime.connectNative = function(name) {}; | 75 chrome.runtime.connectNative = function(name) {}; |
53 | 76 |
54 /** | 77 /** |
55 * @param {{name:string}} connectInfo | 78 * @param {{ name: string}} config |
56 * @return {chrome.extension.Port} | 79 * @return {chrome.runtime.Port} |
57 */ | 80 */ |
58 chrome.runtime.connect = function(connectInfo) {}; | 81 chrome.runtime.connect = function(config) {}; |
59 | 82 |
60 /** | 83 /** |
61 * @param {string} extensionId | 84 * @param {string} extensionId |
62 * @param {*} message | 85 * @param {*} message |
63 * @param {Object=} opt_options | 86 * @param {Object=} opt_options |
64 * @param {function(*)=} opt_callback | 87 * @param {function(*)=} opt_callback |
65 */ | 88 */ |
66 chrome.runtime.sendMessage = function( | 89 chrome.runtime.sendMessage = function( |
67 extensionId, message, opt_options, opt_callback) {}; | 90 extensionId, message, opt_options, opt_callback) {}; |
68 | 91 |
92 /** @constructor */ | |
93 chrome.runtime.MessageSender = function(){ | |
94 /** @type {chrome.Tab} */ | |
95 this.tab = null; | |
96 }; | |
97 | |
98 /** @constructor */ | |
99 chrome.runtime.Port = function() { | |
100 this.onMessage = new chrome.Event(); | |
101 this.onDisconnect = new chrome.Event(); | |
102 | |
103 /** @type {string} */ | |
104 this.name = ''; | |
105 | |
106 /** @type {chrome.runtime.MessageSender} */ | |
107 this.sender = null; | |
108 }; | |
109 | |
110 /** @type {chrome.Event} */ | |
111 chrome.runtime.Port.prototype.onMessage = null; | |
112 | |
113 /** @type {chrome.Event} */ | |
114 chrome.runtime.Port.prototype.onDisconnect = null; | |
115 | |
116 chrome.runtime.Port.prototype.disconnect = function() {}; | |
117 | |
118 /** | |
119 * @param {Object} message | |
120 */ | |
121 chrome.runtime.Port.prototype.postMessage = function(message) {}; | |
122 | |
123 | |
69 /** @type {Object} */ | 124 /** @type {Object} */ |
70 chrome.extension = {}; | 125 chrome.extension = {}; |
71 | 126 |
72 /** @constructor */ | |
73 chrome.extension.Port = function() {}; | |
74 | |
75 /** @type {chrome.Event} */ | |
76 chrome.extension.Port.prototype.onMessage; | |
77 | |
78 /** @type {chrome.Event} */ | |
79 chrome.extension.Port.prototype.onDisconnect; | |
80 | |
81 /** | |
82 * @param {Object} message | |
83 */ | |
84 chrome.extension.Port.prototype.postMessage = function(message) {}; | |
85 | |
86 /** | 127 /** |
87 * @param {*} message | 128 * @param {*} message |
88 */ | 129 */ |
89 chrome.extension.sendMessage = function(message) {} | 130 chrome.extension.sendMessage = function(message) {} |
90 | 131 |
91 /** @type {chrome.Event} */ | 132 /** @type {chrome.Event} */ |
92 chrome.extension.onMessage; | 133 chrome.extension.onMessage; |
93 | 134 |
94 | 135 |
95 /** @type {Object} */ | 136 /** @type {Object} */ |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 * @return {void} | 182 * @return {void} |
142 */ | 183 */ |
143 chrome.Storage.prototype.clear = function(opt_callback) {}; | 184 chrome.Storage.prototype.clear = function(opt_callback) {}; |
144 | 185 |
145 | 186 |
146 /** | 187 /** |
147 * @type {Object} | 188 * @type {Object} |
148 * src/chrome/common/extensions/api/context_menus.json | 189 * src/chrome/common/extensions/api/context_menus.json |
149 */ | 190 */ |
150 chrome.contextMenus = {}; | 191 chrome.contextMenus = {}; |
151 /** @type {ChromeEvent} */ | 192 /** @type {chrome.Event} */ |
152 chrome.contextMenus.onClicked; | 193 chrome.contextMenus.onClicked; |
153 /** | 194 /** |
154 * @param {!Object} createProperties | 195 * @param {!Object} createProperties |
155 * @param {function()=} opt_callback | 196 * @param {function()=} opt_callback |
156 */ | 197 */ |
157 chrome.contextMenus.create = function(createProperties, opt_callback) {}; | 198 chrome.contextMenus.create = function(createProperties, opt_callback) {}; |
158 /** | 199 /** |
159 * @param {string|number} id | 200 * @param {string|number} id |
160 * @param {!Object} updateProperties | 201 * @param {!Object} updateProperties |
161 * @param {function()=} opt_callback | 202 * @param {function()=} opt_callback |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 * @param {function():void} callback | 250 * @param {function():void} callback |
210 */ | 251 */ |
211 removeCachedAuthToken: function(parameters, callback) {}, | 252 removeCachedAuthToken: function(parameters, callback) {}, |
212 /** | 253 /** |
213 * @param {Object.<string>} parameters | 254 * @param {Object.<string>} parameters |
214 * @param {function(string):void} callback | 255 * @param {function(string):void} callback |
215 */ | 256 */ |
216 launchWebAuthFlow: function(parameters, callback) {} | 257 launchWebAuthFlow: function(parameters, callback) {} |
217 }; | 258 }; |
218 | 259 |
219 // TODO(garykac): Combine chrome.Event and ChromeEvent | |
220 /** @constructor */ | |
221 function ChromeEvent() {} | |
222 /** @param {Function} callback */ | |
223 ChromeEvent.prototype.addListener = function(callback) {}; | |
224 /** @param {Function} callback */ | |
225 ChromeEvent.prototype.removeListener = function(callback) {}; | |
226 /** @param {Function} callback */ | |
227 ChromeEvent.prototype.hasListener = function(callback) {}; | |
228 /** @param {Function} callback */ | |
229 ChromeEvent.prototype.hasListeners = function(callback) {}; | |
230 | |
231 /** @constructor */ | |
232 chrome.Event = function() {}; | |
233 | |
234 /** @param {function():void} callback */ | |
235 chrome.Event.prototype.addListener = function(callback) {}; | |
236 | |
237 /** @param {function():void} callback */ | |
238 chrome.Event.prototype.removeListener = function(callback) {}; | |
Jamie
2014/08/12 20:42:54
This looks like useful clean-up, but does it belon
kelvinp
2014/08/12 21:42:42
It doesn't have to be in this CL. But since I am
| |
239 | |
240 | 260 |
241 /** @type {Object} */ | 261 /** @type {Object} */ |
242 chrome.permissions = { | 262 chrome.permissions = { |
243 /** | 263 /** |
244 * @param {Object.<string>} permissions | 264 * @param {Object.<string>} permissions |
245 * @param {function(boolean):void} callback | 265 * @param {function(boolean):void} callback |
246 */ | 266 */ |
247 contains: function(permissions, callback) {}, | 267 contains: function(permissions, callback) {}, |
248 /** | 268 /** |
249 * @param {Object.<string>} permissions | 269 * @param {Object.<string>} permissions |
250 * @param {function(boolean):void} callback | 270 * @param {function(boolean):void} callback |
251 */ | 271 */ |
252 request: function(permissions, callback) {} | 272 request: function(permissions, callback) {} |
253 }; | 273 }; |
254 | 274 |
255 | 275 |
256 /** @type {Object} */ | 276 /** @type {Object} */ |
257 chrome.tabs = {}; | 277 chrome.tabs = {}; |
258 | 278 |
259 /** @param {function(chrome.Tab):void} callback */ | 279 /** @param {function(chrome.Tab):void} callback */ |
260 chrome.tabs.getCurrent = function(callback) {}; | 280 chrome.tabs.getCurrent = function(callback) {}; |
261 | 281 |
282 /** | |
283 * @param {Object?} options | |
284 * @param {function(chrome.Tab)=} opt_callback | |
285 */ | |
286 chrome.tabs.create = function(options, opt_callback) {}; | |
287 | |
288 /** | |
289 * @param {string} id | |
290 * @param {function(chrome.Tab)} callback | |
291 */ | |
292 chrome.tabs.get = function(id, callback) {}; | |
293 | |
294 /** | |
295 * @param {string} id | |
296 * @param {function()=} opt_callback | |
297 */ | |
298 chrome.tabs.remove = function(id, opt_callback) {}; | |
299 | |
300 | |
262 /** @constructor */ | 301 /** @constructor */ |
263 chrome.Tab = function() { | 302 chrome.Tab = function() { |
264 /** @type {boolean} */ | 303 /** @type {boolean} */ |
265 this.pinned = false; | 304 this.pinned = false; |
266 /** @type {number} */ | 305 /** @type {number} */ |
267 this.windowId = 0; | 306 this.windowId = 0; |
307 /** @type {string} */ | |
308 this.id = ''; | |
268 }; | 309 }; |
269 | 310 |
270 | 311 |
271 /** @type {Object} */ | 312 /** @type {Object} */ |
272 chrome.windows = {}; | 313 chrome.windows = {}; |
273 | 314 |
274 /** @param {number} id | 315 /** @param {number} id |
275 * @param {Object?} getInfo | 316 * @param {Object?} getInfo |
276 * @param {function(chrome.Window):void} callback */ | 317 * @param {function(chrome.Window):void} callback */ |
277 chrome.windows.get = function(id, getInfo, callback) {}; | 318 chrome.windows.get = function(id, getInfo, callback) {}; |
278 | 319 |
279 /** @constructor */ | 320 /** @constructor */ |
280 chrome.Window = function() { | 321 chrome.Window = function() { |
281 /** @type {string} */ | 322 /** @type {string} */ |
282 this.state = ''; | 323 this.state = ''; |
283 /** @type {string} */ | 324 /** @type {string} */ |
284 this.type = ''; | 325 this.type = ''; |
285 }; | 326 }; |
286 | 327 |
287 /** @constructor */ | 328 /** @constructor */ |
288 var AppWindow = function() { | 329 var AppWindow = function() { |
289 /** @type {Window} */ | 330 /** @type {Window} */ |
290 this.contentWindow = null; | 331 this.contentWindow = null; |
291 /** @type {chrome.Event} */ | 332 /** @type {chrome.Event} */ |
292 this.onRestored = null; | 333 this.onRestored = null; |
293 /** @type {chrome.Event} */ | 334 /** @type {chrome.Event} */ |
294 this.onMaximized = null; | 335 this.onMaximized = null; |
295 /** @type {chrome.Event} */ | 336 /** @type {chrome.Event} */ |
296 this.onFullscreened = null; | 337 this.onFullscreened = null; |
338 /** @type {string} */ | |
339 this.id = ""; | |
Jamie
2014/08/12 20:42:54
Single-quotes for strings, please.
kelvinp
2014/08/12 21:42:42
Done.
| |
297 }; | 340 }; |
298 | 341 |
299 AppWindow.prototype.close = function() {}; | 342 AppWindow.prototype.close = function() {}; |
300 AppWindow.prototype.drawAttention = function() {}; | 343 AppWindow.prototype.drawAttention = function() {}; |
301 AppWindow.prototype.maximize = function() {}; | 344 AppWindow.prototype.maximize = function() {}; |
302 AppWindow.prototype.minimize = function() {}; | 345 AppWindow.prototype.minimize = function() {}; |
303 AppWindow.prototype.restore = function() {}; | 346 AppWindow.prototype.restore = function() {}; |
304 AppWindow.prototype.fullscreen = function() {}; | 347 AppWindow.prototype.fullscreen = function() {}; |
305 /** @return {boolean} */ | 348 /** @return {boolean} */ |
306 AppWindow.prototype.isFullscreen = function() {}; | 349 AppWindow.prototype.isFullscreen = function() {}; |
(...skipping 26 matching lines...) Expand all Loading... | |
333 this.height = 0; | 376 this.height = 0; |
334 /** @type {number} */ | 377 /** @type {number} */ |
335 this.top = 0; | 378 this.top = 0; |
336 /** @type {number} */ | 379 /** @type {number} */ |
337 this.bottom = 0; | 380 this.bottom = 0; |
338 /** @type {number} */ | 381 /** @type {number} */ |
339 this.left = 0; | 382 this.left = 0; |
340 /** @type {number} */ | 383 /** @type {number} */ |
341 this.right = 0; | 384 this.right = 0; |
342 }; | 385 }; |
OLD | NEW |