* Copyright 2013 The Closure Compiler Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* @fileoverview Definitions for globals in Chrome. This file describes the
* externs API for the chrome.* object when running in a normal browser
* context. For APIs available in Chrome Extensions, see chrome_extensions.js
* in this directory.
* @externs
*/
* namespace
* @const
*/
var chrome = {};
* @see http://developer.chrome.com/apps/runtime.html#type-Port
* @constructor
*/
function Port() {}
Port.prototype.name;
Port.prototype.onDisconnect;
Port.prototype.onMessage;
Port.prototype.sender;
* @param {*} obj Message object.
* @return {undefined}
*/
Port.prototype.postMessage = function(obj) {};
Port.prototype.disconnect = function() {};
* Base event type without listener methods.
*
* This interface exists for event interfaces whose addListeners() method takes
* more than one parameter. Those interfaces must inherit from this one, so they
* can supply their own custom listener method declarations.
*
* Event interfaces whose addListeners() method takes just one parameter should
* inherit from ChromeBaseEvent instead. It extends this interface.
*
* @see https://developer.chrome.com/extensions/events
* @interface
*/
function ChromeBaseEventNoListeners() {}
* @param {!Array<!Rule>} rules
* @param {function(!Array<!Rule>): void=} callback
* @see https://developer.chrome.com/extensions/events#method-Event-addRules
*/
ChromeBaseEventNoListeners.prototype.addRules = function(rules, callback) {};
* Returns currently registered rules.
*
* NOTE: The API allows the first argument to be omitted.
* That cannot be correctly represented here, so we end up incorrectly
* allowing 2 callback arguments.
* @param {!Array<string>|function(!Array<!Rule>): void} ruleIdentifiersOrCb
* @param {function(!Array<!Rule>): void=} callback
* @see https://developer.chrome.com/extensions/events#method-Event-getRules
*/
ChromeBaseEventNoListeners.prototype.getRules =
function(ruleIdentifiersOrCb, callback) {};
* Removes currently registered rules.
*
* NOTE: The API allows the either or both arguments to be omitted.
* That cannot be correctly represented here, so we end up incorrectly
* allowing 2 callback arguments.
* @param {(!Array<string>|function(): void)=} ruleIdentifiersOrCb
* @param {function(): void=} callback
* @see https://developer.chrome.com/extensions/events#method-Event-removeRules
*/
ChromeBaseEventNoListeners.prototype.removeRules =
function(ruleIdentifiersOrCb, callback) {};
* @see https://developer.chrome.com/extensions/events#type-Rule
* @record
*/
function Rule() {}
Rule.prototype.id;
Rule.prototype.tags;
Rule.prototype.conditions;
Rule.prototype.actions;
Rule.prototype.priority;
* @see https://developer.chrome.com/extensions/events#type-UrlFilter
* @record
*/
function UrlFilter() {}
UrlFilter.prototype.hostContains;
UrlFilter.prototype.hostEquals;
UrlFilter.prototype.hostPrefix;
UrlFilter.prototype.hostSuffix;
UrlFilter.prototype.pathContains;
UrlFilter.prototype.pathEquals;
UrlFilter.prototype.pathPrefix;
UrlFilter.prototype.pathSuffix;
UrlFilter.prototype.queryContains;
UrlFilter.prototype.queryEquals;
UrlFilter.prototype.queryPrefix;
UrlFilter.prototype.querySuffix;
UrlFilter.prototype.urlContains;
UrlFilter.prototype.urlEquals;
UrlFilter.prototype.urlMatches;
UrlFilter.prototype.originAndPathMatches;
UrlFilter.prototype.urlPrefix;
UrlFilter.prototype.urlSuffix;
UrlFilter.prototype.schemes;
UrlFilter.prototype.ports;
* Base event type from which all others inherit.
*
* LISTENER must be a function type that returns void.
*
* @see https://developer.chrome.com/extensions/events
* @interface
* @extends {ChromeBaseEventNoListeners}
* @template LISTENER
*/
function ChromeBaseEvent() {}
* @param {LISTENER} callback
* @return {undefined}
* @see https://developer.chrome.com/extensions/events#method-Event-addListener
*/
ChromeBaseEvent.prototype.addListener = function(callback) {};
* @param {LISTENER} callback
* @return {undefined}
* @see https://developer.chrome.com/extensions/events#method-Event-removeListener
*/
ChromeBaseEvent.prototype.removeListener = function(callback) {};
* @param {LISTENER} callback
* @return {boolean}
* @see https://developer.chrome.com/extensions/events#method-Event-hasListener
*/
ChromeBaseEvent.prototype.hasListener = function(callback) {};
* @return {boolean}
* @see https://developer.chrome.com/extensions/events#method-Event-hasListeners
*/
ChromeBaseEvent.prototype.hasListeners = function() {};
* Event whose listeners take unspecified parameters.
*
* TODO(bradfordcsmith): Definitions using this type are failing to provide
* information about the parameters that will actually be supplied to the
* listener and should be updated to use a more specific event type.
* @see https://developer.chrome.com/extensions/events
* @interface
* @extends {ChromeBaseEvent<!Function>}
*/
function ChromeEvent() {}
* Event whose listeners take no parameters.
*
* @see https://developer.chrome.com/extensions/events
* @interface
* @extends {ChromeBaseEvent<function()>}
*/
function ChromeVoidEvent() {}
* Event whose listeners take a string parameter.
* @interface
* @extends {ChromeBaseEvent<function(string)>}
*/
function ChromeStringEvent() {}
* Event whose listeners take a boolean parameter.
* @interface
* @extends {ChromeBaseEvent<function(boolean)>}
*/
function ChromeBooleanEvent() {}
* Event whose listeners take a number parameter.
* @interface
* @extends {ChromeBaseEvent<function(number)>}
*/
function ChromeNumberEvent() {}
* Event whose listeners take an Object parameter.
* @interface
* @extends {ChromeBaseEvent<function(!Object)>}
*/
function ChromeObjectEvent() {}
* Event whose listeners take a string array parameter.
* @interface
* @extends {ChromeBaseEvent<function(!Array<string>)>}
*/
function ChromeStringArrayEvent() {}
* Event whose listeners take two strings as parameters.
* @interface
* @extends {ChromeBaseEvent<function(string, string)>}
*/
function ChromeStringStringEvent() {}
* @see http://developer.chrome.com/extensions/runtime.html#type-MessageSender
* @constructor
*/
function MessageSender() {}
MessageSender.prototype.tab;
MessageSender.prototype.frameId;
MessageSender.prototype.id;
MessageSender.prototype.url;
MessageSender.prototype.nativeApplication;
MessageSender.prototype.tlsChannelId;
MessageSender.prototype.origin;
* @enum {string}
* @see https://developer.chrome.com/extensions/tabs#type-MutedInfoReason
*/
var MutedInfoReason = {
USER: '',
CAPTURE: '',
EXTENSION: '',
};
* @see https://developer.chrome.com/extensions/tabs#type-MutedInfo
* @constructor
*/
var MutedInfo = function() {};
MutedInfo.prototype.muted;
MutedInfo.prototype.reason;
MutedInfo.prototype.extensionId;
* @see https://developer.chrome.com/extensions/tabs#type-Tab
* @constructor
*/
function Tab() {}
Tab.prototype.id;
Tab.prototype.index;
Tab.prototype.windowId;
Tab.prototype.openerTabId;
Tab.prototype.highlighted;
Tab.prototype.active;
Tab.prototype.pinned;
Tab.prototype.audible;
Tab.prototype.discarded;
Tab.prototype.autoDiscardable;
Tab.prototype.mutedInfo;
Tab.prototype.url;
Tab.prototype.pendingUrl;
Tab.prototype.title;
Tab.prototype.favIconUrl;
Tab.prototype.status;
Tab.prototype.incognito;
Tab.prototype.width;
Tab.prototype.height;
Tab.prototype.sessionId;
chrome.app = {};
* @see https://developer.chrome.com/webstore/inline_installation#already-installed
* @type {boolean}
*/
chrome.app.isInstalled;
* @const
* @see https://developer.chrome.com/apps/webstore
*/
chrome.webstore = {};
* @param {string|function()|function(string, string=)=}
* opt_urlOrSuccessCallbackOrFailureCallback Either the URL to install or
* the succcess callback taking no arg or the failure callback taking an
* error string arg.
* @param {function()|function(string, string=)=}
* opt_successCallbackOrFailureCallback Either the succcess callback taking
* no arg or the failure callback taking an error string arg.
* @param {function(string, string=)=} opt_failureCallback The failure callback.
* @return {undefined}
*/
chrome.webstore.install = function(
opt_urlOrSuccessCallbackOrFailureCallback,
opt_successCallbackOrFailureCallback,
opt_failureCallback) {};
chrome.webstore.onInstallStageChanged;
chrome.webstore.onDownloadProgress;
* Returns an object representing current load times. Note that the properties
* on the object do not change and the function must be called again to get
* up-to-date data.
*
* @return {!ChromeLoadTimes}
*/
chrome.loadTimes = function() {};
* The data object given by chrome.loadTimes().
* @constructor
*/
function ChromeLoadTimes() {}
ChromeLoadTimes.prototype.requestTime;
ChromeLoadTimes.prototype.startLoadTime;
ChromeLoadTimes.prototype.commitLoadTime;
ChromeLoadTimes.prototype.finishDocumentLoadTime;
ChromeLoadTimes.prototype.finishLoadTime;
ChromeLoadTimes.prototype.firstPaintTime;
ChromeLoadTimes.prototype.firstPaintAfterLoadTime;
ChromeLoadTimes.prototype.navigationType;
* True iff the resource was fetched over SPDY.
* @type {boolean}
*/
ChromeLoadTimes.prototype.wasFetchedViaSpdy;
ChromeLoadTimes.prototype.wasNpnNegotiated;
ChromeLoadTimes.prototype.npnNegotiatedProtocol;
ChromeLoadTimes.prototype.wasAlternateProtocolAvailable;
ChromeLoadTimes.prototype.connectionInfo;
* @param {string|!ArrayBuffer|!Object} message
* @see https://developers.google.com/native-client/devguide/tutorial
* @return {undefined}
*/
HTMLEmbedElement.prototype.postMessage = function(message) {};