chrome.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. // SSSSSSSSSSSSSSS TTTTTTTTTTTTTTTTTTTTTTT OOOOOOOOO PPPPPPPPPPPPPPPPP
  2. // SS:::::::::::::::ST:::::::::::::::::::::T OO:::::::::OO P::::::::::::::::P
  3. // S:::::SSSSSS::::::ST:::::::::::::::::::::T OO:::::::::::::OO P::::::PPPPPP:::::P
  4. // S:::::S SSSSSSST:::::TT:::::::TT:::::TO:::::::OOO:::::::OPP:::::P P:::::P
  5. // S:::::S TTTTTT T:::::T TTTTTTO::::::O O::::::O P::::P P:::::P
  6. // S:::::S T:::::T O:::::O O:::::O P::::P P:::::P
  7. // S::::SSSS P::::PPPPPP:::::P
  8. // SS::::::SSSSS This file is generated. To update it, P:::::::::::::PP
  9. // SSS::::::::SS run roll_closure_compiler. P::::PPPPPPPPP
  10. // SSSSSS::::S P::::P
  11. // S:::::S T:::::T O:::::O O:::::O P::::P
  12. // S:::::S T:::::T O::::::O O::::::O P::::P
  13. // SSSSSSS S:::::S TT:::::::TT O:::::::OOO:::::::OPP::::::PP
  14. // S::::::SSSSSS:::::S T:::::::::T OO:::::::::::::OO P::::::::P
  15. // S:::::::::::::::SS T:::::::::T OO:::::::::OO P::::::::P
  16. // SSSSSSSSSSSSSSS TTTTTTTTTTT OOOOOOOOO PPPPPPPPPP
  17. /*
  18. * Copyright 2013 The Closure Compiler Authors
  19. *
  20. * Licensed under the Apache License, Version 2.0 (the "License");
  21. * you may not use this file except in compliance with the License.
  22. * You may obtain a copy of the License at
  23. *
  24. * http://www.apache.org/licenses/LICENSE-2.0
  25. *
  26. * Unless required by applicable law or agreed to in writing, software
  27. * distributed under the License is distributed on an "AS IS" BASIS,
  28. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  29. * See the License for the specific language governing permissions and
  30. * limitations under the License.
  31. */
  32. /**
  33. * @fileoverview Definitions for globals in Chrome. This file describes the
  34. * externs API for the chrome.* object when running in a normal browser
  35. * context. For APIs available in Chrome Extensions, see chrome_extensions.js
  36. * in this directory.
  37. * @externs
  38. */
  39. /**
  40. * namespace
  41. * @const
  42. */
  43. var chrome = {};
  44. /**
  45. * @see http://developer.chrome.com/apps/runtime.html#type-Port
  46. * @constructor
  47. */
  48. function Port() {}
  49. /** @type {string} */
  50. Port.prototype.name;
  51. /** @type {!ChromeEvent} */
  52. Port.prototype.onDisconnect;
  53. /** @type {!ChromeEvent} */
  54. Port.prototype.onMessage;
  55. /** @type {!MessageSender|undefined} */
  56. Port.prototype.sender;
  57. /**
  58. * @param {*} obj Message object.
  59. * @return {undefined}
  60. */
  61. Port.prototype.postMessage = function(obj) {};
  62. /** @return {undefined} */
  63. Port.prototype.disconnect = function() {};
  64. /**
  65. * Base event type without listener methods.
  66. *
  67. * This interface exists for event interfaces whose addListeners() method takes
  68. * more than one parameter. Those interfaces must inherit from this one, so they
  69. * can supply their own custom listener method declarations.
  70. *
  71. * Event interfaces whose addListeners() method takes just one parameter should
  72. * inherit from ChromeBaseEvent instead. It extends this interface.
  73. *
  74. * @see https://developer.chrome.com/extensions/events
  75. * @interface
  76. */
  77. function ChromeBaseEventNoListeners() {}
  78. /**
  79. * @param {!Array<!Rule>} rules
  80. * @param {function(!Array<!Rule>): void=} callback
  81. * @see https://developer.chrome.com/extensions/events#method-Event-addRules
  82. */
  83. ChromeBaseEventNoListeners.prototype.addRules = function(rules, callback) {};
  84. /**
  85. * Returns currently registered rules.
  86. *
  87. * NOTE: The API allows the first argument to be omitted.
  88. * That cannot be correctly represented here, so we end up incorrectly
  89. * allowing 2 callback arguments.
  90. * @param {!Array<string>|function(!Array<!Rule>): void} ruleIdentifiersOrCb
  91. * @param {function(!Array<!Rule>): void=} callback
  92. * @see https://developer.chrome.com/extensions/events#method-Event-getRules
  93. */
  94. ChromeBaseEventNoListeners.prototype.getRules =
  95. function(ruleIdentifiersOrCb, callback) {};
  96. /**
  97. * Removes currently registered rules.
  98. *
  99. * NOTE: The API allows the either or both arguments to be omitted.
  100. * That cannot be correctly represented here, so we end up incorrectly
  101. * allowing 2 callback arguments.
  102. * @param {(!Array<string>|function(): void)=} ruleIdentifiersOrCb
  103. * @param {function(): void=} callback
  104. * @see https://developer.chrome.com/extensions/events#method-Event-removeRules
  105. */
  106. ChromeBaseEventNoListeners.prototype.removeRules =
  107. function(ruleIdentifiersOrCb, callback) {};
  108. /**
  109. * @see https://developer.chrome.com/extensions/events#type-Rule
  110. * @record
  111. */
  112. function Rule() {}
  113. /** @type {string|undefined} */
  114. Rule.prototype.id;
  115. /** @type {!Array<string>|undefined} */
  116. Rule.prototype.tags;
  117. /** @type {!Array<*>} */
  118. Rule.prototype.conditions;
  119. /** @type {!Array<*>} */
  120. Rule.prototype.actions;
  121. /** @type {number|undefined} */
  122. Rule.prototype.priority;
  123. /**
  124. * @see https://developer.chrome.com/extensions/events#type-UrlFilter
  125. * @record
  126. */
  127. function UrlFilter() {}
  128. /** @type {string|undefined} */
  129. UrlFilter.prototype.hostContains;
  130. /** @type {string|undefined} */
  131. UrlFilter.prototype.hostEquals;
  132. /** @type {string|undefined} */
  133. UrlFilter.prototype.hostPrefix;
  134. /** @type {string|undefined} */
  135. UrlFilter.prototype.hostSuffix;
  136. /** @type {string|undefined} */
  137. UrlFilter.prototype.pathContains;
  138. /** @type {string|undefined} */
  139. UrlFilter.prototype.pathEquals;
  140. /** @type {string|undefined} */
  141. UrlFilter.prototype.pathPrefix;
  142. /** @type {string|undefined} */
  143. UrlFilter.prototype.pathSuffix;
  144. /** @type {string|undefined} */
  145. UrlFilter.prototype.queryContains;
  146. /** @type {string|undefined} */
  147. UrlFilter.prototype.queryEquals;
  148. /** @type {string|undefined} */
  149. UrlFilter.prototype.queryPrefix;
  150. /** @type {string|undefined} */
  151. UrlFilter.prototype.querySuffix;
  152. /** @type {string|undefined} */
  153. UrlFilter.prototype.urlContains;
  154. /** @type {string|undefined} */
  155. UrlFilter.prototype.urlEquals;
  156. /** @type {string|undefined} */
  157. UrlFilter.prototype.urlMatches;
  158. /** @type {string|undefined} */
  159. UrlFilter.prototype.originAndPathMatches;
  160. /** @type {string|undefined} */
  161. UrlFilter.prototype.urlPrefix;
  162. /** @type {string|undefined} */
  163. UrlFilter.prototype.urlSuffix;
  164. /** @type {!Array<string>|undefined} */
  165. UrlFilter.prototype.schemes;
  166. /** @type {!Array<(number|!Array<number>)>|undefined} */
  167. UrlFilter.prototype.ports;
  168. /**
  169. * Base event type from which all others inherit.
  170. *
  171. * LISTENER must be a function type that returns void.
  172. *
  173. * @see https://developer.chrome.com/extensions/events
  174. * @interface
  175. * @extends {ChromeBaseEventNoListeners}
  176. * @template LISTENER
  177. */
  178. function ChromeBaseEvent() {}
  179. /**
  180. * @param {LISTENER} callback
  181. * @return {undefined}
  182. * @see https://developer.chrome.com/extensions/events#method-Event-addListener
  183. */
  184. ChromeBaseEvent.prototype.addListener = function(callback) {};
  185. /**
  186. * @param {LISTENER} callback
  187. * @return {undefined}
  188. * @see https://developer.chrome.com/extensions/events#method-Event-removeListener
  189. */
  190. ChromeBaseEvent.prototype.removeListener = function(callback) {};
  191. /**
  192. * @param {LISTENER} callback
  193. * @return {boolean}
  194. * @see https://developer.chrome.com/extensions/events#method-Event-hasListener
  195. */
  196. ChromeBaseEvent.prototype.hasListener = function(callback) {};
  197. /**
  198. * @return {boolean}
  199. * @see https://developer.chrome.com/extensions/events#method-Event-hasListeners
  200. */
  201. ChromeBaseEvent.prototype.hasListeners = function() {};
  202. /**
  203. * Event whose listeners take unspecified parameters.
  204. *
  205. * TODO(bradfordcsmith): Definitions using this type are failing to provide
  206. * information about the parameters that will actually be supplied to the
  207. * listener and should be updated to use a more specific event type.
  208. * @see https://developer.chrome.com/extensions/events
  209. * @interface
  210. * @extends {ChromeBaseEvent<!Function>}
  211. */
  212. function ChromeEvent() {}
  213. /**
  214. * Event whose listeners take no parameters.
  215. *
  216. * @see https://developer.chrome.com/extensions/events
  217. * @interface
  218. * @extends {ChromeBaseEvent<function()>}
  219. */
  220. function ChromeVoidEvent() {}
  221. /**
  222. * Event whose listeners take a string parameter.
  223. * @interface
  224. * @extends {ChromeBaseEvent<function(string)>}
  225. */
  226. function ChromeStringEvent() {}
  227. /**
  228. * Event whose listeners take a boolean parameter.
  229. * @interface
  230. * @extends {ChromeBaseEvent<function(boolean)>}
  231. */
  232. function ChromeBooleanEvent() {}
  233. /**
  234. * Event whose listeners take a number parameter.
  235. * @interface
  236. * @extends {ChromeBaseEvent<function(number)>}
  237. */
  238. function ChromeNumberEvent() {}
  239. /**
  240. * Event whose listeners take an Object parameter.
  241. * @interface
  242. * @extends {ChromeBaseEvent<function(!Object)>}
  243. */
  244. function ChromeObjectEvent() {}
  245. /**
  246. * Event whose listeners take a string array parameter.
  247. * @interface
  248. * @extends {ChromeBaseEvent<function(!Array<string>)>}
  249. */
  250. function ChromeStringArrayEvent() {}
  251. /**
  252. * Event whose listeners take two strings as parameters.
  253. * @interface
  254. * @extends {ChromeBaseEvent<function(string, string)>}
  255. */
  256. function ChromeStringStringEvent() {}
  257. /**
  258. * @see http://developer.chrome.com/extensions/runtime.html#type-MessageSender
  259. * @constructor
  260. */
  261. function MessageSender() {}
  262. /** @type {!Tab|undefined} */
  263. MessageSender.prototype.tab;
  264. /** @type {number|undefined} */
  265. MessageSender.prototype.frameId;
  266. /** @type {string|undefined} */
  267. MessageSender.prototype.id;
  268. /** @type {string|undefined} */
  269. MessageSender.prototype.url;
  270. /** @type {string|undefined} */
  271. MessageSender.prototype.nativeApplication;
  272. /** @type {string|undefined} */
  273. MessageSender.prototype.tlsChannelId;
  274. /** @type {string|undefined} */
  275. MessageSender.prototype.origin;
  276. /**
  277. * @enum {string}
  278. * @see https://developer.chrome.com/extensions/tabs#type-MutedInfoReason
  279. */
  280. var MutedInfoReason = {
  281. USER: '',
  282. CAPTURE: '',
  283. EXTENSION: '',
  284. };
  285. /**
  286. * @see https://developer.chrome.com/extensions/tabs#type-MutedInfo
  287. * @constructor
  288. */
  289. var MutedInfo = function() {};
  290. /** @type {boolean} */
  291. MutedInfo.prototype.muted;
  292. /** @type {!MutedInfoReason|string|undefined} */
  293. MutedInfo.prototype.reason;
  294. /** @type {string|undefined} */
  295. MutedInfo.prototype.extensionId;
  296. /**
  297. * @see https://developer.chrome.com/extensions/tabs#type-Tab
  298. * @constructor
  299. */
  300. function Tab() {}
  301. // TODO: Make this field optional once dependent projects have been updated.
  302. /** @type {number} */
  303. Tab.prototype.id;
  304. /** @type {number} */
  305. Tab.prototype.index;
  306. /** @type {number} */
  307. Tab.prototype.windowId;
  308. // TODO: Make this field optional once dependent projects have been updated.
  309. /** @type {number} */
  310. Tab.prototype.openerTabId;
  311. /** @type {boolean} */
  312. Tab.prototype.highlighted;
  313. /** @type {boolean} */
  314. Tab.prototype.active;
  315. /** @type {boolean} */
  316. Tab.prototype.pinned;
  317. /** @type {boolean|undefined} */
  318. Tab.prototype.audible;
  319. /** @type {boolean} */
  320. Tab.prototype.discarded;
  321. /** @type {boolean} */
  322. Tab.prototype.autoDiscardable;
  323. /** @type {!MutedInfo|undefined} */
  324. Tab.prototype.mutedInfo;
  325. // TODO: Make this field optional once dependent projects have been updated.
  326. /** @type {string} */
  327. Tab.prototype.url;
  328. /** @type {string|undefined} */
  329. Tab.prototype.pendingUrl;
  330. // TODO: Make this field optional once dependent projects have been updated.
  331. /** @type {string} */
  332. Tab.prototype.title;
  333. // TODO: Make this field optional once dependent projects have been updated.
  334. /** @type {string} */
  335. Tab.prototype.favIconUrl;
  336. // TODO: Make this field optional once dependent projects have been updated.
  337. /** @type {string} */
  338. Tab.prototype.status;
  339. /** @type {boolean} */
  340. Tab.prototype.incognito;
  341. /** @type {number|undefined} */
  342. Tab.prototype.width;
  343. /** @type {number|undefined} */
  344. Tab.prototype.height;
  345. /** @type {string|undefined} */
  346. Tab.prototype.sessionId;
  347. /** @const */
  348. chrome.app = {};
  349. /**
  350. * @see https://developer.chrome.com/webstore/inline_installation#already-installed
  351. * @type {boolean}
  352. */
  353. chrome.app.isInstalled;
  354. /**
  355. * @const
  356. * @see https://developer.chrome.com/apps/webstore
  357. */
  358. chrome.webstore = {};
  359. /**
  360. * @param {string|function()|function(string, string=)=}
  361. * opt_urlOrSuccessCallbackOrFailureCallback Either the URL to install or
  362. * the succcess callback taking no arg or the failure callback taking an
  363. * error string arg.
  364. * @param {function()|function(string, string=)=}
  365. * opt_successCallbackOrFailureCallback Either the succcess callback taking
  366. * no arg or the failure callback taking an error string arg.
  367. * @param {function(string, string=)=} opt_failureCallback The failure callback.
  368. * @return {undefined}
  369. */
  370. chrome.webstore.install = function(
  371. opt_urlOrSuccessCallbackOrFailureCallback,
  372. opt_successCallbackOrFailureCallback,
  373. opt_failureCallback) {};
  374. /** @type {!ChromeStringEvent} */
  375. chrome.webstore.onInstallStageChanged;
  376. /** @type {!ChromeNumberEvent} */
  377. chrome.webstore.onDownloadProgress;
  378. /**
  379. * Returns an object representing current load times. Note that the properties
  380. * on the object do not change and the function must be called again to get
  381. * up-to-date data.
  382. *
  383. * @return {!ChromeLoadTimes}
  384. */
  385. chrome.loadTimes = function() {};
  386. /**
  387. * The data object given by chrome.loadTimes().
  388. * @constructor
  389. */
  390. function ChromeLoadTimes() {}
  391. /** @type {number} */
  392. ChromeLoadTimes.prototype.requestTime;
  393. /** @type {number} */
  394. ChromeLoadTimes.prototype.startLoadTime;
  395. /** @type {number} */
  396. ChromeLoadTimes.prototype.commitLoadTime;
  397. /** @type {number} */
  398. ChromeLoadTimes.prototype.finishDocumentLoadTime;
  399. /** @type {number} */
  400. ChromeLoadTimes.prototype.finishLoadTime;
  401. /** @type {number} */
  402. ChromeLoadTimes.prototype.firstPaintTime;
  403. /** @type {number} */
  404. ChromeLoadTimes.prototype.firstPaintAfterLoadTime;
  405. /** @type {number} */
  406. ChromeLoadTimes.prototype.navigationType;
  407. /**
  408. * True iff the resource was fetched over SPDY.
  409. * @type {boolean}
  410. */
  411. ChromeLoadTimes.prototype.wasFetchedViaSpdy;
  412. /** @type {boolean} */
  413. ChromeLoadTimes.prototype.wasNpnNegotiated;
  414. /** @type {string} */
  415. ChromeLoadTimes.prototype.npnNegotiatedProtocol;
  416. /** @type {boolean} */
  417. ChromeLoadTimes.prototype.wasAlternateProtocolAvailable;
  418. /** @type {string} */
  419. ChromeLoadTimes.prototype.connectionInfo;
  420. /**
  421. * @param {string|!ArrayBuffer|!Object} message
  422. * @see https://developers.google.com/native-client/devguide/tutorial
  423. * @return {undefined}
  424. */
  425. HTMLEmbedElement.prototype.postMessage = function(message) {};