Home | History | Annotate | Download | only in webapp
      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 {boolean} */
     16 Document.prototype.hidden;
     17 
     18 /** @type {function(string): void} */
     19 Document.prototype.execCommand = function(command) {};
     20 
     21 /** @return {void} Nothing. */
     22 Document.prototype.webkitCancelFullScreen = function() {};
     23 
     24 /** @type {boolean} */
     25 Document.prototype.webkitIsFullScreen;
     26 
     27 /** @type {boolean} */
     28 Document.prototype.webkitHidden;
     29 
     30 /** @type {number} */
     31 Element.ALLOW_KEYBOARD_INPUT;
     32 
     33 /** @param {number} flags
     34 /** @return {void} Nothing. */
     35 Element.prototype.webkitRequestFullScreen = function(flags) {};
     36 
     37 /** @type {{getRandomValues: function((Uint16Array|Uint8Array)):void}} */
     38 Window.prototype.crypto;
     39 
     40 /** @constructor
     41     @extends {HTMLElement} */
     42 var HTMLEmbedElement = function() { };
     43 
     44 /** @type {number} */
     45 HTMLEmbedElement.prototype.height;
     46 
     47 /** @type {number} */
     48 HTMLEmbedElement.prototype.width;
     49 
     50 /** @type {Window} */
     51 HTMLIFrameElement.prototype.contentWindow;
     52 
     53 /** @constructor */
     54 var MutationRecord = function() {};
     55 
     56 /** @type {string} */
     57 MutationRecord.prototype.attributeName;
     58 
     59 /** @type {Element} */
     60 MutationRecord.prototype.target;
     61 
     62 /** @type {string} */
     63 MutationRecord.prototype.type;
     64 
     65 /** @constructor
     66     @param {function(Array.<MutationRecord>):void} callback */
     67 var MutationObserver = function(callback) {};
     68 
     69 /** @param {Element} element
     70     @param {Object} options */
     71 MutationObserver.prototype.observe = function(element, options) {};
     72 
     73 /** @type {Object} */
     74 chrome.storage = {};
     75 
     76 /** @type {chrome.Storage} */
     77 chrome.storage.local;
     78 
     79 /** @type {chrome.Storage} */
     80 chrome.storage.sync;
     81 
     82 /** @constructor */
     83 chrome.Storage = function() {};
     84 
     85 /**
     86  * @param {string|Array.<string>|Object.<string>} items
     87  * @param {function(Object.<string>):void} callback
     88  * @return {void}
     89  */
     90 chrome.Storage.prototype.get = function(items, callback) {};
     91 
     92 /**
     93  * @param {Object.<string>} items
     94  * @param {function():void=} opt_callback
     95  * @return {void}
     96  */
     97 chrome.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  */
    104 chrome.Storage.prototype.remove = function(items, opt_callback) {};
    105 
    106 /**
    107  * @param {function():void=} opt_callback
    108  * @return {void}
    109  */
    110 chrome.Storage.prototype.clear = function(opt_callback) {};
    111 
    112 /** @type {Object} */
    113 chrome.app.runtime = {
    114   /** @type {chrome.Event} */
    115   onLaunched: null
    116 };
    117 
    118 /** @type {Object} */
    119 chrome.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  */
    131 chrome.contextMenus = {
    132   /** @type {chrome.Event} */
    133   onClicked: null
    134 };
    135 
    136 /** @type {Object} */
    137 chrome.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 */
    151 chrome.Event = function() {};
    152 
    153 /** @param {function():void} callback */
    154 chrome.Event.prototype.addListener = function(callback) {};
    155 
    156 /** @param {function():void} callback */
    157 chrome.Event.prototype.removeListener = function(callback) {};
    158 
    159 /** @constructor */
    160 chrome.extension.Port = function() {};
    161 
    162 /** @type {chrome.Event} */
    163 chrome.extension.Port.prototype.onMessage;
    164 
    165 /** @type {chrome.Event} */
    166 chrome.extension.Port.prototype.onDisconnect;
    167 
    168 /**
    169  * @param {Object} message
    170  */
    171 chrome.extension.Port.prototype.postMessage = function(message) {};
    172 
    173 /** @type {Object} */
    174 chrome.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  */
    187 chrome.runtime.connectNative = function(name) {};
    188 
    189 /** @type {Object} */
    190 chrome.tabs;
    191 
    192 /** @param {function(chrome.Tab):void} callback */
    193 chrome.tabs.getCurrent = function(callback) {}
    194 
    195 /** @constructor */
    196 chrome.Tab = function() {
    197   /** @type {boolean} */
    198   this.pinned = false;
    199   /** @type {number} */
    200   this.windowId = 0;
    201 };
    202 
    203 /** @type {Object} */
    204 chrome.windows;
    205 
    206 /** @param {number} id
    207  *  @param {Object?} getInfo
    208  *  @param {function(chrome.Window):void} callback */
    209 chrome.windows.get = function(id, getInfo, callback) {}
    210 
    211 /** @constructor */
    212 chrome.Window = function() {
    213   /** @type {string} */
    214   this.state = '';
    215   /** @type {string} */
    216   this.type = '';
    217 };
    218 
    219 /**
    220  * @param {*} message
    221  */
    222 chrome.extension.sendMessage = function(message) {}
    223 
    224 /** @type {chrome.Event} */
    225 chrome.extension.onMessage;
    226 
    227 /** @type {Object} */
    228 chrome.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