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