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 {HTMLElement} */
10Document.prototype.activeElement;
11
12/** @type {Array.<HTMLElement>} */
13Document.prototype.all;
14
15/** @type {boolean} */
16Document.prototype.hidden;
17
18/** @type {function(string): void} */
19Document.prototype.execCommand = function(command) {};
20
21/** @return {void} Nothing. */
22Document.prototype.webkitCancelFullScreen = function() {};
23
24/** @type {boolean} */
25Document.prototype.webkitIsFullScreen;
26
27/** @type {boolean} */
28Document.prototype.webkitHidden;
29
30/** @type {number} */
31Element.ALLOW_KEYBOARD_INPUT;
32
33/** @param {number} flags
34/** @return {void} Nothing. */
35Element.prototype.webkitRequestFullScreen = function(flags) {};
36
37/** @type {{getRandomValues: function((Uint16Array|Uint8Array)):void}} */
38Window.prototype.crypto;
39
40/** @constructor
41    @extends {HTMLElement} */
42var HTMLEmbedElement = function() { };
43
44/** @type {number} */
45HTMLEmbedElement.prototype.height;
46
47/** @type {number} */
48HTMLEmbedElement.prototype.width;
49
50/** @type {Window} */
51HTMLIFrameElement.prototype.contentWindow;
52
53/** @constructor */
54var MutationRecord = function() {};
55
56/** @type {string} */
57MutationRecord.prototype.attributeName;
58
59/** @type {Element} */
60MutationRecord.prototype.target;
61
62/** @type {string} */
63MutationRecord.prototype.type;
64
65/** @constructor
66    @param {function(Array.<MutationRecord>):void} callback */
67var MutationObserver = function(callback) {};
68
69/** @param {Element} element
70    @param {Object} options */
71MutationObserver.prototype.observe = function(element, options) {};
72
73/** @type {Object} */
74chrome.storage = {};
75
76/** @type {chrome.Storage} */
77chrome.storage.local;
78
79/** @type {chrome.Storage} */
80chrome.storage.sync;
81
82/** @constructor */
83chrome.Storage = function() {};
84
85/**
86 * @param {string|Array.<string>|Object.<string>} items
87 * @param {function(Object.<string>):void} callback
88 * @return {void}
89 */
90chrome.Storage.prototype.get = function(items, callback) {};
91
92/**
93 * @param {Object.<string>} items
94 * @param {function():void=} opt_callback
95 * @return {void}
96 */
97chrome.Storage.prototype.set = function(items, opt_callback) {};
98
99/**
100 * @param {string|Array.<string>} items
101 * @param {function():void=} opt_callback
102 * @return {void}
103 */
104chrome.Storage.prototype.remove = function(items, opt_callback) {};
105
106/**
107 * @param {function():void=} opt_callback
108 * @return {void}
109 */
110chrome.Storage.prototype.clear = function(opt_callback) {};
111
112/** @type {Object} */
113chrome.app.runtime = {
114  /** @type {chrome.Event} */
115  onLaunched: null
116};
117
118/** @type {Object} */
119chrome.app.window = {
120  /**
121   * @param {string} name
122   * @param {Object} parameters
123   */
124  create: function(name, parameters) {}
125};
126
127/**
128 * @type {Object}
129 * @see http://code.google.com/chrome/extensions/dev/contextMenus.html
130 */
131chrome.contextMenus = {
132  /** @type {chrome.Event} */
133  onClicked: null
134};
135
136/** @type {Object} */
137chrome.identity = {
138  /**
139   * @param {Object.<string>} parameters
140   * @param {function(string):void} callback
141   */
142  getAuthToken: function(parameters, callback) {},
143  /**
144   * @param {Object.<string>} parameters
145   * @param {function(string):void} callback
146   */
147  launchWebAuthFlow: function(parameters, callback) {}
148};
149
150/** @constructor */
151chrome.Event = function() {};
152
153/** @param {function():void} callback */
154chrome.Event.prototype.addListener = function(callback) {};
155
156/** @param {function():void} callback */
157chrome.Event.prototype.removeListener = function(callback) {};
158
159/** @constructor */
160chrome.extension.Port = function() {};
161
162/** @type {chrome.Event} */
163chrome.extension.Port.prototype.onMessage;
164
165/** @type {chrome.Event} */
166chrome.extension.Port.prototype.onDisconnect;
167
168/**
169 * @param {Object} message
170 */
171chrome.extension.Port.prototype.postMessage = function(message) {};
172
173/** @type {Object} */
174chrome.runtime = {
175  /** @type {Object} */
176  lastError: {
177    /** @type {string} */
178    message: ''
179  },
180  /** @return {{version: string, app: {background: Object}}} */
181  getManifest: function() {}
182};
183
184/**
185 * @type {?function(string):chrome.extension.Port}
186 */
187chrome.runtime.connectNative = function(name) {};
188
189/** @type {Object} */
190chrome.tabs;
191
192/** @param {function(chrome.Tab):void} callback */
193chrome.tabs.getCurrent = function(callback) {}
194
195/** @constructor */
196chrome.Tab = function() {
197  /** @type {boolean} */
198  this.pinned = false;
199  /** @type {number} */
200  this.windowId = 0;
201};
202
203/** @type {Object} */
204chrome.windows;
205
206/** @param {number} id
207 *  @param {Object?} getInfo
208 *  @param {function(chrome.Window):void} callback */
209chrome.windows.get = function(id, getInfo, callback) {}
210
211/** @constructor */
212chrome.Window = function() {
213  /** @type {string} */
214  this.state = '';
215  /** @type {string} */
216  this.type = '';
217};
218
219/**
220 * @param {*} message
221 */
222chrome.extension.sendMessage = function(message) {}
223
224/** @type {chrome.Event} */
225chrome.extension.onMessage;
226
227/** @type {Object} */
228chrome.permissions = {
229  /**
230   * @param {Object.<string>} permissions
231   * @param {function(boolean):void} callback
232   */
233  contains: function(permissions, callback) {},
234/**
235 * @param {Object.<string>} permissions
236 * @param {function(boolean):void} callback
237 */
238  request: function(permissions, callback) {}
239};
240