Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: remoting/webapp/js_proto/chrome_proto.js

Issue 450383003: Hangout remote desktop part II - background.html and AppLauncher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 this.listeners_ = [];
15 };
16
17 /** @param {Function} callback */
18 chrome.Event.prototype.addListener = function(callback) {
19 this.listeners_.push(callback);
kelvinp 2014/08/11 18:37:56 I provide a simple implementation of chrome.events
Jamie 2014/08/12 02:24:59 Yes, please do that. Files under js_proto/ should
20 };
21
22 /** @param {Function} callback */
23 chrome.Event.prototype.removeListener = function(callback) {
24 for (var i = 0; i < this.listeners_.length; i++) {
25 if (this.listeners_[i] === callback) {
26 this.listeners_.splice(i, 1);
27 break;
28 }
29 }
30 };
31
32 /** @param {*=} data */
33 chrome.Event.prototype.mock$fire = function(data) {
34 /** @param {Function} listener */
35 this.listeners_.forEach(function(listener){
36 listener(data);
37 });
38 };
12 39
13 /** @type {Object} */ 40 /** @type {Object} */
14 chrome.app = {}; 41 chrome.app = {};
15 42
16 /** @type {Object} */ 43 /** @type {Object} */
17 chrome.app.runtime = { 44 chrome.app.runtime = {
18 /** @type {chrome.Event} */ 45 /** @type {chrome.Event} */
19 onLaunched: null 46 onLaunched: null
20 }; 47 };
21 48
22 49
23 /** @type {Object} */ 50 /** @type {Object} */
24 chrome.app.window = { 51 chrome.app.window = {
25 /** 52 /**
26 * @param {string} name 53 * @param {string} name
27 * @param {Object} parameters 54 * @param {Object} parameters
28 * @param {function()=} opt_callback 55 * @param {function()=} opt_callback
29 */ 56 */
30 create: function(name, parameters, opt_callback) {}, 57 create: function(name, parameters, opt_callback) {},
31 /** 58 /**
32 * @return {AppWindow} 59 * @return {AppWindow}
33 */ 60 */
34 current: function() {} 61 current: function() {},
62 /**
63 * @param {string} id
64 * @param {function()=} opt_callback
65 */
66 get: function(id, opt_callback) {}
35 }; 67 };
36 68
37 69
38 /** @type {Object} */ 70 /** @type {Object} */
39 chrome.runtime = { 71 chrome.runtime = {
40 /** @type {Object} */ 72 /** @type {Object} */
41 lastError: { 73 lastError: {
42 /** @type {string} */ 74 /** @type {string} */
43 message: '' 75 message: ''
44 }, 76 },
45 /** @return {{version: string, app: {background: Object}}} */ 77 /** @return {{version: string, app: {background: Object}}} */
46 getManifest: function() {} 78 getManifest: function() {},
79 /** @type {chrome.Event} */
80 onSuspend: null,
81 /** @type {chrome.Event} */
82 onConnect: null,
83 /** @type {chrome.Event} */
84 onConnectExternal: null,
85 /** @type {chrome.Event} */
86 onMessage: null,
87 /** @type {chrome.Event} */
88 onMessageExternal: null
47 }; 89 };
48 90
49 /** 91 /**
50 * @type {?function(string):chrome.extension.Port} 92 * @type {?function(string):chrome.runtime.Port}
51 */ 93 */
52 chrome.runtime.connectNative = function(name) {}; 94 chrome.runtime.connectNative = function(name) {};
53 95
54 /** 96 /**
55 * @param {{name:string}} connectInfo 97 * @param {{ name: string}} config
56 * @return {chrome.extension.Port} 98 * @return {chrome.runtime.Port}
57 */ 99 */
58 chrome.runtime.connect = function(connectInfo) {}; 100 chrome.runtime.connect = function(config) {};
59 101
60 /** 102 /**
61 * @param {string} extensionId 103 * @param {string} extensionId
62 * @param {*} message 104 * @param {*} message
63 * @param {Object=} opt_options 105 * @param {Object=} opt_options
64 * @param {function(*)=} opt_callback 106 * @param {function(*)=} opt_callback
65 */ 107 */
66 chrome.runtime.sendMessage = function( 108 chrome.runtime.sendMessage = function(
67 extensionId, message, opt_options, opt_callback) {}; 109 extensionId, message, opt_options, opt_callback) {};
68 110
111 /** @constructor */
112 chrome.runtime.MessageSender = function () {
113 /** @type {chrome.Tab} */
114 this.tab = null;
115 /** @type {AppWindow} */
116 this.window = null;
117 };
118
119 /** @constructor */
120 chrome.runtime.Port = function() {
121 this.onMessage = new chrome.Event();
122 this.onDisconnect = new chrome.Event();
123
124 /** @type {string} */
125 this.name = '';
126
127 /** @type {chrome.runtime.MessageSender} */
128 this.sender = null;
129 };
130
131 /** @type {chrome.Event} */
132 chrome.runtime.Port.prototype.onMessage = null;
133
134 /** @type {chrome.Event} */
135 chrome.runtime.Port.prototype.onDisconnect = null;
136
137 chrome.runtime.Port.prototype.disconnect = function() {};
138
139 /**
140 * @param {Object} message
141 */
142 chrome.runtime.Port.prototype.postMessage = function(message) {};
143
144
69 /** @type {Object} */ 145 /** @type {Object} */
70 chrome.extension = {}; 146 chrome.extension = {};
71 147
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 /** 148 /**
87 * @param {*} message 149 * @param {*} message
88 */ 150 */
89 chrome.extension.sendMessage = function(message) {} 151 chrome.extension.sendMessage = function(message) {}
90 152
91 /** @type {chrome.Event} */ 153 /** @type {chrome.Event} */
92 chrome.extension.onMessage; 154 chrome.extension.onMessage;
93 155
94 156
95 /** @type {Object} */ 157 /** @type {Object} */
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 * @return {void} 203 * @return {void}
142 */ 204 */
143 chrome.Storage.prototype.clear = function(opt_callback) {}; 205 chrome.Storage.prototype.clear = function(opt_callback) {};
144 206
145 207
146 /** 208 /**
147 * @type {Object} 209 * @type {Object}
148 * src/chrome/common/extensions/api/context_menus.json 210 * src/chrome/common/extensions/api/context_menus.json
149 */ 211 */
150 chrome.contextMenus = {}; 212 chrome.contextMenus = {};
151 /** @type {ChromeEvent} */ 213 /** @type {chrome.Event} */
152 chrome.contextMenus.onClicked; 214 chrome.contextMenus.onClicked;
153 /** 215 /**
154 * @param {!Object} createProperties 216 * @param {!Object} createProperties
155 * @param {function()=} opt_callback 217 * @param {function()=} opt_callback
156 */ 218 */
157 chrome.contextMenus.create = function(createProperties, opt_callback) {}; 219 chrome.contextMenus.create = function(createProperties, opt_callback) {};
158 /** 220 /**
159 * @param {string|number} id 221 * @param {string|number} id
160 * @param {!Object} updateProperties 222 * @param {!Object} updateProperties
161 * @param {function()=} opt_callback 223 * @param {function()=} opt_callback
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 * @param {function():void} callback 271 * @param {function():void} callback
210 */ 272 */
211 removeCachedAuthToken: function(parameters, callback) {}, 273 removeCachedAuthToken: function(parameters, callback) {},
212 /** 274 /**
213 * @param {Object.<string>} parameters 275 * @param {Object.<string>} parameters
214 * @param {function(string):void} callback 276 * @param {function(string):void} callback
215 */ 277 */
216 launchWebAuthFlow: function(parameters, callback) {} 278 launchWebAuthFlow: function(parameters, callback) {}
217 }; 279 };
218 280
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) {};
239
240 281
241 /** @type {Object} */ 282 /** @type {Object} */
242 chrome.permissions = { 283 chrome.permissions = {
243 /** 284 /**
244 * @param {Object.<string>} permissions 285 * @param {Object.<string>} permissions
245 * @param {function(boolean):void} callback 286 * @param {function(boolean):void} callback
246 */ 287 */
247 contains: function(permissions, callback) {}, 288 contains: function(permissions, callback) {},
248 /** 289 /**
249 * @param {Object.<string>} permissions 290 * @param {Object.<string>} permissions
250 * @param {function(boolean):void} callback 291 * @param {function(boolean):void} callback
251 */ 292 */
252 request: function(permissions, callback) {} 293 request: function(permissions, callback) {}
253 }; 294 };
254 295
255 296
256 /** @type {Object} */ 297 /** @type {Object} */
257 chrome.tabs = {}; 298 chrome.tabs = {};
258 299
259 /** @param {function(chrome.Tab):void} callback */ 300 /** @param {function(chrome.Tab):void} callback */
260 chrome.tabs.getCurrent = function(callback) {}; 301 chrome.tabs.getCurrent = function(callback) {};
261 302
303 /**
304 * @param {Object?} options
305 * @param {function(chrome.Tab)=} opt_callback
306 */
307 chrome.tabs.create = function(options, opt_callback) {};
308
309 /**
310 * @param {string} id
311 * @param {function(chrome.Tab)} callback
312 */
313 chrome.tabs.get = function(id, callback) {};
314
315 /**
316 * @param {string} id
317 * @param {function()=} opt_callback
318 */
319 chrome.tabs.remove = function(id, opt_callback) {};
320
321
262 /** @constructor */ 322 /** @constructor */
263 chrome.Tab = function() { 323 chrome.Tab = function() {
264 /** @type {boolean} */ 324 /** @type {boolean} */
265 this.pinned = false; 325 this.pinned = false;
266 /** @type {number} */ 326 /** @type {number} */
267 this.windowId = 0; 327 this.windowId = 0;
328 /** @type {string} */
329 this.id = '';
268 }; 330 };
269 331
270 332
271 /** @type {Object} */ 333 /** @type {Object} */
272 chrome.windows = {}; 334 chrome.windows = {};
273 335
274 /** @param {number} id 336 /** @param {number} id
275 * @param {Object?} getInfo 337 * @param {Object?} getInfo
276 * @param {function(chrome.Window):void} callback */ 338 * @param {function(chrome.Window):void} callback */
277 chrome.windows.get = function(id, getInfo, callback) {}; 339 chrome.windows.get = function(id, getInfo, callback) {};
278 340
279 /** @constructor */ 341 /** @constructor */
280 chrome.Window = function() { 342 chrome.Window = function() {
281 /** @type {string} */ 343 /** @type {string} */
282 this.state = ''; 344 this.state = '';
283 /** @type {string} */ 345 /** @type {string} */
284 this.type = ''; 346 this.type = '';
285 }; 347 };
286 348
287 /** @constructor */ 349 /** @constructor */
288 var AppWindow = function() { 350 var AppWindow = function() {
289 /** @type {Window} */ 351 /** @type {Window} */
290 this.contentWindow = null; 352 this.contentWindow = null;
291 /** @type {chrome.Event} */ 353 /** @type {chrome.Event} */
292 this.onRestored = null; 354 this.onRestored = null;
293 /** @type {chrome.Event} */ 355 /** @type {chrome.Event} */
294 this.onMaximized = null; 356 this.onMaximized = null;
295 /** @type {chrome.Event} */ 357 /** @type {chrome.Event} */
296 this.onFullscreened = null; 358 this.onFullscreened = null;
359 /** @type {string} */
360 this.id = "";
297 }; 361 };
298 362
299 AppWindow.prototype.close = function() {}; 363 AppWindow.prototype.close = function() {};
300 AppWindow.prototype.drawAttention = function() {}; 364 AppWindow.prototype.drawAttention = function() {};
301 AppWindow.prototype.maximize = function() {}; 365 AppWindow.prototype.maximize = function() {};
302 AppWindow.prototype.minimize = function() {}; 366 AppWindow.prototype.minimize = function() {};
303 AppWindow.prototype.restore = function() {}; 367 AppWindow.prototype.restore = function() {};
304 AppWindow.prototype.fullscreen = function() {}; 368 AppWindow.prototype.fullscreen = function() {};
305 /** @return {boolean} */ 369 /** @return {boolean} */
306 AppWindow.prototype.isFullscreen = function() {}; 370 AppWindow.prototype.isFullscreen = function() {};
(...skipping 26 matching lines...) Expand all
333 this.height = 0; 397 this.height = 0;
334 /** @type {number} */ 398 /** @type {number} */
335 this.top = 0; 399 this.top = 0;
336 /** @type {number} */ 400 /** @type {number} */
337 this.bottom = 0; 401 this.bottom = 0;
338 /** @type {number} */ 402 /** @type {number} */
339 this.left = 0; 403 this.left = 0;
340 /** @type {number} */ 404 /** @type {number} */
341 this.right = 0; 405 this.right = 0;
342 }; 406 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698