diff options
Diffstat (limited to 'chrome/common/extensions')
11 files changed, 651 insertions, 39 deletions
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json new file mode 100755 index 0000000..b2c30a3 --- /dev/null +++ b/chrome/common/extensions/api/extension_api.json @@ -0,0 +1,486 @@ +[ + { + namespace: "windows", + types: [], + functions: [ + { + name: "get", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "windowId", minimum: 0}, + {type: "function", name: "callback"} + ] + }, + { + name: "getCurrent", + type: "function", + description: "", + parameters: [ + {type: "function", name: "callback"} + ] + }, + { + name: "getLastFocused", + type: "function", + description: "", + parameters: [ + {type: "function", name: "callback"} + ] + }, + { + name: "getAll", + type: "function", + description: "", + parameters: [ + {type: "boolean", name: "populate", optional: true}, + {type: "function", name: "callback"} + ] + }, + { + name: "create", + type: "function", + description: "", + parameters: [ + { + type: "object", + name: "CreateData", + properties: { + url: {type: "string", optional: true}, + left: {type: "integer", optional: true}, + top: {type: "integer", optional: true}, + width: {type: "integer", minimum: 0, optional: true}, + height: {type: "integer", minimum: 0, optional: true} + }, + optional: true + }, + {type: "function", name: "callback", optional: true} + ] + }, + { + name: "update", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "windowId", minimum: 0}, + { + type: "object", + name: "UpdateInfo", + properties: { + left: {type: "integer", optional: true}, + top: {type: "integer", optional: true}, + width: {type: "integer", minimum: 0, optional: true}, + height: {type: "integer", minimum: 0, optional: true} + }, + }, + {type: "function", name: "callback", optional: true} + ] + }, + { + name: "remove", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "windowId", minimum: 0}, + {type: "function", name: "callback", optional: true} + ] + }, + ], + events: [ + { + name: "onCreated", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "windowId", minimum: 0} + ] + }, + { + name: "onRemoved", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "windowId", minimum: 0} + ] + }, + { + name: "onFocusChanged", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "windowId", minimum: 0} + ] + } + ] + }, + { + namespace: "tabs", + types: [], + functions: [ + { + name: "get", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "tabId", minimum: 0}, + {type: "function", name: "callback"} + ] + }, + { + name: "getSelected", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "windowId", minimum: 0, optional: true}, + {type: "function", name: "callback"} + ] + }, + { + name: "getAllInWindow", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "windowId", minimum: 0, optional: true}, + {type: "function", name: "callback"} + ] + }, + { + name: "create", + type: "function", + description: "", + parameters: [ + { + type: "object", + name: "CreateProperties", + properties: { + windowId: {type: "integer", minimum: 0, optional: true}, + index: {type: "integer", minimum: 0, optional: true}, + url: {type: "string", optional: true}, + selected: {type: "boolean", optional: true} + } + }, + {type: "function", name: "callback", optional: true} + ] + }, + { + name: "update", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "tabId", minimum: 0}, + { + type: "object", + name: "UpdateProperties", + properties: { + url: {type: "string", optional: true}, + selected: {type: "boolean", optional: true} + } + }, + {type: "function", name: "callback", optional: true} + ] + }, + { + name: "move", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "tabId", minimum: 0}, + { + type: "object", + name: "MoveProperties", + properties: { + windowId: {type: "integer", minimum: 0, optional: true}, + index: {type: "integer", minimum: 0} + } + }, + {type: "function", name: "callback", optional: true} + ] + }, + { + name: "remove", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "tabId", minimum: 0, optional: true}, + {type: "function", name: "callback", optional: true} + ] + }, + { + name: "detectLanguage", + type: "function", + description: "detect language of tab.", + parameters: [ + {type: "integer", name: "tabId", minimum: 0, optional: true}, + {type: "function", name: "callback"} + ] + } + ], + events: [ + { + name: "onCreated", + type: "function", + description: "", + parameters: [ + {type: "Object", name: "Tab"} + ] + }, + { + name: "onUpdated", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "tabId", minimum: 0}, + {type: "Object", name: "ChangedProps"} + ] + }, + { + name: "onMoved", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "tabId", minimum: 0}, + {type: "Object", name: "MoveInfo"} + ] + }, + { + name: "onSelectionChanged", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "tabId", minimum: 0}, + {type: "Object", name: "SelectionInfo"} + ] + }, + { + name: "onAttached", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "tabId", minimum: 0}, + {type: "Object", name: "AttachInfo"} + ] + }, + { + name: "onDetached", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "tabId", minimum: 0}, + {type: "Object", name: "DetachInfo"} + ] + }, + { + name: "onRemoved", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "tabId", minimum: 0} + ] + } + ] + }, + { + namespace: "pageActions", + types: [], + functions: [ + { + name: "enableForTab", + type: "function", + description: "", + parameters: [ + {type: "string", name: "pageActionId"}, + { + type: "object", + name: "action", + properties: { + tabId: {type: "integer", minimum: 0}, + url: {type: "string"}, + title: {type: "string", optional: true}, + iconId: {type: "integer", minimum: 0, optional: true} + }, + optional: false + } + ] + }, + { + name: "disableForTab", + type: "function", + description: "", + parameters: [ + {type: "string", name: "pageActionId"}, + { + type: "object", + name: "action", + properties: { + tabId: {type: "integer", minimum: 0}, + url: {type: "string"} + }, + optional: false + } + ] + } + ], + events: [ + ] + }, + { + namespace: "bookmarks", + types: [], + functions: [ + { + name: "get", + type: "function", + description: "", + parameters: [ + { + name: "idOrIdList", + choice : [ + {type: "integer", minimum: 0}, + {type: "array", item: {type: "integer", minimum: 0}, minItems: 1} + ] + }, + {type: "function", name: "callback"} + ] + }, + { + name: "getChildren", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "id", minimum: 0}, + {type: "function", name: "callback"} + ] + }, + { + name: "getTree", + type: "function", + description: "", + parameters: [ + {type: "function", name: "callback"} + ] + }, + { + name: "search", + type: "function", + description: "", + parameters: [ + {type: "string", name: "query"}, + {type: "function", name: "callback"} + ] + }, + { + name: "create", + type: "function", + description: "", + parameters: [ + { + type: "object", + name: "bookmark", + properties: { + parentId: {type: "integer", minimum: 0, optional: true}, + index: {type: "integer", minimum: 0, optional: true}, + title: {type: "string", optional: true}, + url: {type: "string", optional: true}, + } + }, + {type: "function", name: "callback", optional: true} + ] + }, + { + name: "move", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "id", minimum: 0}, + { + type: "object", + name: "destination", + properties: { + parentId: {type: "integer", minimum: 0, optional: true}, + index: {type: "integer", minimum: 0, optional: true} + } + }, + {type: "function", name: "callback", optional: true} + ] + }, + { + name: "update", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "id", minimum: 0}, + { + type: "object", + name: "changes", + properties: { + title: {type: "string", optional: true} + } + }, + {type: "function", name: "callback", optional: true} + ] + }, + ], + events: [ + { + name: "onAdded", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "id", minimum: 0}, + { + type: "Object", + name: "bookmark", + } + ] + }, + { + name: "onRemoved", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "id", minimum: 0}, + { + type: "Object", + name: "RemoveInfo", + } + ] + }, + { + name: "onChanged", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "id", minimum: 0}, + { + type: "Object", + name: "ChangeInfo", + } + ] + }, + { + name: "onMoved", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "id", minimum: 0}, + { + type: "Object", + name: "MoveInfo", + } + ] + }, + { + name: "onChildrenReordered", + type: "function", + description: "", + parameters: [ + {type: "integer", name: "id", minimum: 0}, + { + type: "Object", + name: "childIds", + } + ] + } + ] + } +] diff --git a/chrome/common/extensions/docs/css/ApiRefStyles.css b/chrome/common/extensions/docs/css/ApiRefStyles.css index d781b7d..2626359 100755 --- a/chrome/common/extensions/docs/css/ApiRefStyles.css +++ b/chrome/common/extensions/docs/css/ApiRefStyles.css @@ -3,6 +3,10 @@ body { font-size: 13px; } +.todo { + color: red; +} + h2,h3 { margin-top: 2em; } diff --git a/chrome/common/extensions/docs/js/api_page_generator.js b/chrome/common/extensions/docs/js/api_page_generator.js index 3aa87bf..01ff9e2d 100755 --- a/chrome/common/extensions/docs/js/api_page_generator.js +++ b/chrome/common/extensions/docs/js/api_page_generator.js @@ -9,9 +9,8 @@ * * - To have available via XHR (relative path): * 1) API_TEMPLATE which is the main template for the api pages. - * 2) A file located at SCHEMA_PATH + |apiName| + SCHEMA_EXTENSION - * which is shared with the extension system and defines the methods and - * events contained in one api. + * 2) A file located at SCHEMA which is shared with the extension system and + * defines the methods and events contained in one api. * 3) An |apiName| + OVERVIEW_EXTENSION file which contains static authored * content that is inserted into the "overview" slot in the API_TEMPLATE. * @@ -23,8 +22,7 @@ */ var API_TEMPLATE = "../template/api_template.html"; -var SCHEMA_PATH = "../../api/"; -var SCHEMA_EXTENSION = ".json"; +var SCHEMA = "../../api/extension_api.json"; var OVERVIEW_EXTENSION = "_overview.html"; var REQUEST_TIMEOUT = 2000; @@ -34,24 +32,25 @@ Array.prototype.each = function(f) { } } +// name of the api this reference page is describing. i.e. "bookmarks", "tabs". +var apiName; + window.onload = function() { // Determine api module being rendered. Expect ".../<apiName>.html" var pathParts = document.location.href.split(/\/|\./); - var apiName = pathParts[pathParts.length - 2]; - var apiOverviewName = apiName + OVERVIEW_EXTENSION; - var apiSchemaName = SCHEMA_PATH + apiName + SCHEMA_EXTENSION; + apiName = pathParts[pathParts.length - 2]; // Fetch the api template and insert into the <body>. fetchContent(API_TEMPLATE, function(templateContent) { document.getElementsByTagName("body")[0].innerHTML = templateContent; // Fetch the overview and insert into the "overview" <div>. - fetchContent(apiOverviewName, function(overviewContent) { + fetchContent(apiName + OVERVIEW_EXTENSION, function(overviewContent) { document.getElementById("overview").innerHTML = overviewContent; // Now the page is composed with the authored content, we fetch the schema // and populate the templates. - fetchContent(apiSchemaName, renderTemplate); + fetchContent(SCHEMA, renderTemplate); }); }); } @@ -96,12 +95,19 @@ function fetchContent(url, onSuccess) { } /** - * Parses the content in |module| to json, adds any additional required values, - * renders to html via JSTemplate, and unhides the <body>. + * Parses the content in |schema| to json, find appropriate api, adds any + * additional required values, renders to html via JSTemplate, and unhides the + * <body>. * This uses the root <html> element (the entire document) as the template. */ -function renderTemplate(module) { - var apiDefinition = JSON.parse(module); +function renderTemplate(schema) { + var apiDefinition; + + JSON.parse(schema).each(function(module) { + if (module.namespace == apiName) + apiDefinition = module; + }); + preprocessApi(apiDefinition); // Render to template @@ -119,17 +125,58 @@ function renderTemplate(module) { */ function preprocessApi(schema) { schema.functions.each(function(f) { - f.fullName = schema.namespace + "." + f.name; - if (f.callbackParameters) { - f.callbackSignature = generateSignatureString(f.callbackParameters); + f.fullName = "chrome." + schema.namespace + "." + f.name; + assignTypeNames(f); + + // Look for a callback that defines parameters. + if (f.parameters.length > 0) { + var lastParam = f.parameters[f.parameters.length - 1]; + if (lastParam.type == "function" && lastParam.parameters) { + assignTypeNames(lastParam); + f.callbackParameters = lastParam.parameters; + f.callbackSignature = generateSignatureString(lastParam.parameters); + } } }); schema.events.each(function(e) { + assignTypeNames(e); e.callSignature = generateSignatureString(e.parameters); }); } +/** + * Assigns a typeName(param) to each of the parameters of |f|. + */ +function assignTypeNames(f) { + f.parameters.each(function(p) { + p.typeName = typeName(p); + }); +} + +/** + * Generates a short text summary of the |schema| type + */ +function typeName(schema) { + if (schema.$ref) + return schema.$ref; + + if (schema.choice) { + var typeNames = []; + schema.choice.each(function(c) { + typeNames.push(typeName(c)); + }); + + return typeNames.join(" or "); + } + + if (schema.type == "array") { + return "array of " + typeName(schema.item); + } + + return schema.type; +} + /** * Generates a simple string representation of the signature of a function * whose |parameters| are json schemas. @@ -137,7 +184,7 @@ function preprocessApi(schema) { function generateSignatureString(parameters) { var retval = []; parameters.each(function(param, i) { - retval.push(param.type + " " + (param.type ? param.type : param["$ref"])); + retval.push(param.typeName + " " + param.name); }); return retval.join(", "); diff --git a/chrome/common/extensions/docs/reference/bookmarks.html b/chrome/common/extensions/docs/reference/bookmarks.html index 092ef1f..c771bc1 100755 --- a/chrome/common/extensions/docs/reference/bookmarks.html +++ b/chrome/common/extensions/docs/reference/bookmarks.html @@ -29,4 +29,4 @@ and rewritten. --> <body class="hidden"> </body> -</html>
\ No newline at end of file +</html> diff --git a/chrome/common/extensions/docs/reference/pageActions.html b/chrome/common/extensions/docs/reference/pageActions.html new file mode 100755 index 0000000..c05e097 --- /dev/null +++ b/chrome/common/extensions/docs/reference/pageActions.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- This page is a placeholder for generated extensions api doc. Note: + 1) The <head> information in this page is significant, should be uniform + across api docs and should be edited only with knowledge of the + templating mechanism. + 2) The <body> tag *must* retain id="body" + 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a + browser, it will be re-generated from the template, json schema and + authored overview content. + 4) The <body>.innerHTML is also generated by an offline step so that this + page may easily be indexed by search engines. + + TODO(rafaelw): Abstract this into a "pageshell" that becomes the single + version of page template shell and the "instance" pages (bookmarks.html, + etc...) can be generated with a build step. +--> +<!-- <html> must retain id="template --> +<html xmlns="http://www.w3.org/1999/xhtml"> + <!-- <head> data is significant and loads the needed libraries and styles --> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <title jscontent="namespace">chrome.apiname</title> + <link href="../css/ApiRefStyles.css" rel="stylesheet" type="text/css"> + <script type="text/javascript" + src="../../../../third_party/jstemplate/jstemplate_compiled.js"> + </script> + <script type="text/javascript" src="../js/api_page_generator.js"></script> + </head> + <!-- <body> content is completely generated. Do not edit, as it will be + and rewritten. --> + <body class="hidden"> + </body> +</html> diff --git a/chrome/common/extensions/docs/reference/pageActions_overview.html b/chrome/common/extensions/docs/reference/pageActions_overview.html new file mode 100755 index 0000000..997b579 --- /dev/null +++ b/chrome/common/extensions/docs/reference/pageActions_overview.html @@ -0,0 +1,5 @@ +<!-- BEGIN AUTHORED CONTENT --> +<p class="todo"> +[PENDING: API Module Overview Goes Here] +</p> +<!-- END AUTHORED CONTENT --> diff --git a/chrome/common/extensions/docs/reference/tabs.html b/chrome/common/extensions/docs/reference/tabs.html index a2f8a82..c05e097 100755 --- a/chrome/common/extensions/docs/reference/tabs.html +++ b/chrome/common/extensions/docs/reference/tabs.html @@ -30,4 +30,4 @@ and rewritten. --> <body class="hidden"> </body> -</html>
\ No newline at end of file +</html> diff --git a/chrome/common/extensions/docs/reference/tabs_overview.html b/chrome/common/extensions/docs/reference/tabs_overview.html index de647ae..997b579 100755 --- a/chrome/common/extensions/docs/reference/tabs_overview.html +++ b/chrome/common/extensions/docs/reference/tabs_overview.html @@ -1,11 +1,5 @@ <!-- BEGIN AUTHORED CONTENT --> -<p id="classSummary"> -Use the <code>chrome.tabs</code> API to create, organize, and otherwise manipulate bookmarks. -</p> - -<h2 id="description">Description</h2> - -<p> -[PENDING: intro goes here...] +<p class="todo"> +[PENDING: API Module Overview Goes Here] </p> <!-- END AUTHORED CONTENT --> diff --git a/chrome/common/extensions/docs/reference/windows.html b/chrome/common/extensions/docs/reference/windows.html new file mode 100755 index 0000000..c05e097 --- /dev/null +++ b/chrome/common/extensions/docs/reference/windows.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<!-- This page is a placeholder for generated extensions api doc. Note: + 1) The <head> information in this page is significant, should be uniform + across api docs and should be edited only with knowledge of the + templating mechanism. + 2) The <body> tag *must* retain id="body" + 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a + browser, it will be re-generated from the template, json schema and + authored overview content. + 4) The <body>.innerHTML is also generated by an offline step so that this + page may easily be indexed by search engines. + + TODO(rafaelw): Abstract this into a "pageshell" that becomes the single + version of page template shell and the "instance" pages (bookmarks.html, + etc...) can be generated with a build step. +--> +<!-- <html> must retain id="template --> +<html xmlns="http://www.w3.org/1999/xhtml"> + <!-- <head> data is significant and loads the needed libraries and styles --> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + <title jscontent="namespace">chrome.apiname</title> + <link href="../css/ApiRefStyles.css" rel="stylesheet" type="text/css"> + <script type="text/javascript" + src="../../../../third_party/jstemplate/jstemplate_compiled.js"> + </script> + <script type="text/javascript" src="../js/api_page_generator.js"></script> + </head> + <!-- <body> content is completely generated. Do not edit, as it will be + and rewritten. --> + <body class="hidden"> + </body> +</html> diff --git a/chrome/common/extensions/docs/reference/windows_overview.html b/chrome/common/extensions/docs/reference/windows_overview.html new file mode 100755 index 0000000..997b579 --- /dev/null +++ b/chrome/common/extensions/docs/reference/windows_overview.html @@ -0,0 +1,5 @@ +<!-- BEGIN AUTHORED CONTENT --> +<p class="todo"> +[PENDING: API Module Overview Goes Here] +</p> +<!-- END AUTHORED CONTENT --> diff --git a/chrome/common/extensions/docs/template/api_template.html b/chrome/common/extensions/docs/template/api_template.html index afa599d..0aa613d 100755 --- a/chrome/common/extensions/docs/template/api_template.html +++ b/chrome/common/extensions/docs/template/api_template.html @@ -69,13 +69,14 @@ <div class="summary">void <!-- Note: intentionally longer 80 columns --> - <span jscontent="fullName">chrome.module.methodName</span>(<span jsselect="parameters" jsvalues="class:optional ? 'optional' : ''"><span jsdisplay="$index">, </span><span jscontent="type"></span> + <span jscontent="fullName">chrome.module.methodName</span>(<span jsselect="parameters" jsvalues="class:optional ? 'optional' : ''"><span jsdisplay="$index">, </span><span jscontent="typeName"></span> <var><span jscontent="name"></span></var></span>)</div> <div class="description"> - <div jsvalues=".innerHTML:description"> + <p class="todo" jsdisplay="!description">Undocumented.</p> + <p jsdisplay="description" jsvalues=".innerHTML:description"> A description from the json schema def of the function goes here. - </div> + </p> <!-- PARAMETERS --> <h4>Parameters</h4> @@ -84,9 +85,10 @@ <dt> <!-- Note: intentionally longer 80 columns --> <var jscontent="name">paramName</var><em> - (<span class="optional" jsdisplay="optional">optional </span><span jsdisplay="$ref" jscontent="$ref">paramType</span><span jsdisplay="type" jscontent="type">paramType</span>)</em> + (<span class="optional" jsdisplay="optional">optional </span><span jscontent="typeName">paramType</span>)</em> </dt> - <dd jsvalues=".innerHTML:description"> + <dd class="todo" jsdisplay="!$this.description">Undocumented.</dd> + <dd jsdisplay="$this.description" jsvalues=".innerHTML:$this.description"> Description of this parameter from the json schema. </dd> </div> @@ -107,9 +109,10 @@ <dt> <!-- Note: intentionally longer 80 columns --> <var jscontent="name">paramName</var><em> - (<span jsdisplay="$ref" jscontent="$ref">paramType</span><span jsdisplay="type" jscontent="type">paramType</span>)</em> + (<span jscontent="typeName">paramType</span>)</em> </dt> - <dd jsvalues=".innerHMTL:description"> + <dd class="todo" jsdisplay="!$this.description">Undocumented.</dd> + <dd jsdisplay="$this.description" jsvalues=".innerHTML:$this.description"> Description of this parameter from the json schema. </dd> </div> @@ -138,8 +141,9 @@ </div> <div class="description"> - <p jsvalues=".innerHTML:description"> - A description from the json schema def of the function goes here. + <p class="todo" jsdisplay="!description">Undocumented.</p> + <p jsdisplay="description" jsvalues=".innerHTML:description"> + A description from the json schema def of the event goes here. </p> <!-- PARAMETERS --> @@ -148,9 +152,10 @@ <div jsselect="parameters"> <dt> <!-- Note: intentionally longer 80 columns --> - <var jscontent="name">paramName</var><em> (<span jsdisplay="$ref" jscontent="$ref">paramType</span><span jsdisplay="type" jscontent="type">paramType</span>)</em> + <var jscontent="name">paramName</var><em> (<span jscontent="typeName">paramType</span>)</em> </dt> - <dd jsvalues=".innerHTML:description"> + <dd class="todo" jsdisplay="!$this.description">Undocumented.</dd> + <dd jsdisplay="$this.description" jsvalues=".innerHTML:$this.description"> Description of this parameter from the json schema. </dd> </div> |