diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 07:17:35 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 07:17:35 +0000 |
commit | 2f3345ff725395b5e8466eb2b4d45e9d8e9024e0 (patch) | |
tree | 1826787800d19277e664558adb43eeb9c998c16b /chrome/common | |
parent | 8d518af0634a01ff4a78479bef43d880259949ca (diff) | |
download | chromium_src-2f3345ff725395b5e8466eb2b4d45e9d8e9024e0.zip chromium_src-2f3345ff725395b5e8466eb2b4d45e9d8e9024e0.tar.gz chromium_src-2f3345ff725395b5e8466eb2b4d45e9d8e9024e0.tar.bz2 |
Fill out the tabs docs. Also, fix a bug where we didn't
honor #anchors in dynamic mode.
TBR=rafaelw@chromium.org,kathyw@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rwxr-xr-x | chrome/common/extensions/api/extension_api.json | 202 | ||||
-rwxr-xr-x | chrome/common/extensions/docs/js/bootstrap.js | 9 | ||||
-rwxr-xr-x | chrome/common/extensions/docs/static/bookmarks.html | 2 | ||||
-rwxr-xr-x | chrome/common/extensions/docs/static/tabs.html | 21 | ||||
-rwxr-xr-x | chrome/common/extensions/docs/static/windows.html | 23 |
5 files changed, 194 insertions, 63 deletions
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index 66e8488..5562553 100755 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -301,14 +301,14 @@ "id": "Tab", "type": "object", "properties": { - "id": {"type": "integer", "minimum": 0}, - "index": {"type": "integer", "minimum": 0}, - "windowId": {"type": "integer", "minimum": 0}, - "selected": {"type": "boolean"}, - "url": {"type": "string"}, - "title": {"type": "string", "optional": true}, - "favIconUrl": {"type": "string", "optional": true}, - "status": {"type": "string", "optional": true} + "id": {"type": "integer", "minimum": 0, "description": "The ID of the tab. Tab IDs are unique within a browser session."}, + "index": {"type": "integer", "minimum": 0, "description": "The zero-based index of the tab within its window."}, + "windowId": {"type": "integer", "minimum": 0, "description": "The ID of the window the tab is contained within."}, + "selected": {"type": "boolean", "description": "Whether the tab is selected."}, + "url": {"type": "string", "description": "The URL the tab is displaying."}, + "title": {"type": "string", "optional": true, "description": "The title of the tab. This may not be available if the tab is loading."}, + "favIconUrl": {"type": "string", "optional": true, "description": "The URL of the tab's favicon. This may not be available if the tab is loading."}, + "status": {"type": "string", "optional": true, "description": "Either <em>loading</em> or <em>complete</em>."} } } ], @@ -316,9 +316,13 @@ { "name": "get", "type": "function", - "description": "", + "description": "Retrieves details about the specified tab.", "parameters": [ - {"type": "integer", "name": "tabId", "minimum": 0}, + { + "type": "integer", + "name": "tabId", + "minimum": 0 + }, { "type": "function", "name": "callback", @@ -331,9 +335,13 @@ { "name": "connect", "type": "function", - "description": "", + "description": "Connects to the content script(s) in the specified tab. The <a href='extension.html#event-onConnect'>chrome.extensions.onConnect</a> is fired in each content script running in the specified tab for the current extension. For more details, see <a href='content_scripts.html#messaging'>Content Script Messaging</a>.", "parameters": [ - {"type": "integer", "name": "tabId", "optional": true, "minimum": 0}, + { + "type": "integer", + "name": "tabId", + "minimum": 0 + }, { "type": "object", "name": "connectInfo", @@ -344,15 +352,22 @@ } ], "returns": { - "$ref": "Port" + "$ref": "Port", + "description": "A port that can be used to communicate with the content scripts running in the specified tab." } }, { "name": "getSelected", "type": "function", - "description": "", + "description": "Gets the tab that is selected in the specified window.", "parameters": [ - {"type": "integer", "name": "windowId", "minimum": 0, "optional": true}, + { + "type": "integer", + "name": "windowId", + "minimum": 0, + "optional": true, + "description": "Defaults to the <a href='windows.html#current-window'>current window</a>." + }, { "type": "function", "name": "callback", @@ -365,9 +380,15 @@ { "name": "getAllInWindow", "type": "function", - "description": "", + "description": "Gets details about all tabs in the specified window.", "parameters": [ - {"type": "integer", "name": "windowId", "minimum": 0, "optional": true}, + { + "type": "integer", + "name": "windowId", + "minimum": 0, + "optional": true, + "description": "Defaults to the <a href='windows.html#current-window'>current window</a>." + }, { "type": "function", "name": "callback", @@ -380,16 +401,34 @@ { "name": "create", "type": "function", - "description": "", + "description": "Creates a new tab.", "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} + "windowId": { + "type": "integer", + "minimum": 0, + "optional": true, + "description": "The window to create the new tab in. Defaults to the <a href='windows.html#current-window'>current window</a>." + }, + "index": { + "type": "integer", + "minimum": 0, + "optional": true, + "description": "The position the tab should take in the window. The provided value will be clamped to between zero and the number of tabs in the window." + }, + "url": { + "type": "string", + "optional": true, + "description": "The URL to navigate the tab to initially. Defaults to the New Tab Page." + }, + "selected": { + "type": "boolean", + "optional": true, + "description": "Whether the tab should become the selected tab in the window. Defaults to <var>true</var>" + } } }, { @@ -397,7 +436,11 @@ "name": "callback", "optional": true, "parameters": [ - {"name": "tab", "$ref": "Tab"} + { + "name": "tab", + "$ref": "Tab", + "description": "Details about the created tab. Will contain the ID of the new tab." + } ] } ] @@ -405,7 +448,7 @@ { "name": "update", "type": "function", - "description": "", + "description": "Modify the properties of a tab. Properties that are not specified in <var>updateProperties</var> are not modified.", "parameters": [ {"type": "integer", "name": "tabId", "minimum": 0}, { @@ -422,15 +465,24 @@ { "name": "move", "type": "function", - "description": "", + "description": "Move a tab to a new position within its window, or to a new window.", "parameters": [ {"type": "integer", "name": "tabId", "minimum": 0}, { "type": "object", "name": "moveProperties", "properties": { - "windowId": {"type": "integer", "minimum": 0, "optional": true}, - "index": {"type": "integer", "minimum": 0} + "windowId": { + "type": "integer", + "minimum": 0, + "optional": true, + "description": "Defaults to the window the tab is currently in." + }, + "index": { + "type": "integer", + "minimum": 0, + "description": "The position to move the window to. The provided value will be clamped to between zero and the number of tabs in the window." + } } }, {"type": "function", "name": "callback", "optional": true, "parameters": []} @@ -439,23 +491,33 @@ { "name": "remove", "type": "function", - "description": "", + "description": "Closes a tab.", "parameters": [ - {"type": "integer", "name": "tabId", "minimum": 0, "optional": true}, + {"type": "integer", "name": "tabId", "minimum": 0}, {"type": "function", "name": "callback", "optional": true, "parameters": []} ] }, { "name": "detectLanguage", "type": "function", - "description": "detect language of tab.", + "description": "Detects the primary language of the content in a tab.", "parameters": [ - {"type": "integer", "name": "tabId", "minimum": 0, "optional": true}, + { + "type": "integer", + "name": "tabId", + "minimum": 0, + "optional": true, + "description": "Defaults to the selected tab of the <a href='windows.html#current-window'>current window</a>." + }, { "type": "function", "name": "callback", "parameters": [ - {"type": "string", "name": "language"} + { + "type": "string", + "name": "language", + "description": "An ISO language code like <var>en</var> or <var>fr</var>." + } ] } ] @@ -463,10 +525,17 @@ { "name": "captureVisibleTab", "type": "function", - "description": "Captures the visible area of the visible tab in the given window.", + "description": "Captures the visible area of the visible tab in a window.", "parameters": [ - {"type": "integer", "name": "windowId", "minimum": 0, "optional": true, "description": "The target window. If <var>null</var> or <var>undefined</var>, the 'current' window will be assumed."}, - {"type": "function", "name": "callback", "parameters": [ + { + "type": "integer", + "name": "windowId", + "minimum": 0, + "optional": true, + "description": "The target window. Defaults to the <a href='windows.html#current-window'>current window</a>." + }, + { + "type": "function", "name": "callback", "parameters": [ {"type": "string", "name": "dataUrl", "description": "a data url encoding of the captured tab."} ] } @@ -477,23 +546,34 @@ { "name": "onCreated", "type": "function", - "description": "", + "description": "Fires when a tab is created.", "parameters": [ - {"$ref": "Tab", "name": "tab"} + { + "$ref": "Tab", + "name": "tab", + "description": "Details of the tab that was created." + } ] }, { "name": "onUpdated", "type": "function", - "description": "", + "description": "Fires when a tab is updated.", "parameters": [ {"type": "integer", "name": "tabId", "minimum": 0}, { "type": "object", "name": "changeInfo", "properties": { - "status": {"type": "string"}, - "url": {"type": "string", "optional": true} + "status": { + "type": "string", + "description": "The status of the tab. Can be either <em>loading</em> or <em>complete</em>." + }, + "url": { + "type": "string", + "optional": true, + "description": "Only specified if the tab's URL changed." + } } } ] @@ -501,7 +581,7 @@ { "name": "onMoved", "type": "function", - "description": "", + "description": "Fires when a tab is moved within a window. Only one move event is fired, representing the tab the user directly moved. Move events are not fired for the other tabs that must move in response. This event is not fired when a tab is moved between windows. For that, see <a href='#event-onDetached'>onDetached</a>.", "parameters": [ {"type": "integer", "name": "tabId", "minimum": 0}, { @@ -518,45 +598,55 @@ { "name": "onSelectionChanged", "type": "function", - "description": "", + "description": "Fires when the selected tab in a window changes.", "parameters": [ - {"type": "integer", "name": "tabId", "minimum": 0}, { - "type": "object", "name": "selectInfo", + "type": "integer", + "name": "tabId", + "minimum": 0, + "description": "The ID of the tab that has become selected." + }, + { + "type": "object", + "name": "selectInfo", "properties": { - "windowId": {"type": "integer", "minimum": 0} + "windowId": { + "type": "integer", + "minimum": 0, + "description": "The ID of the window the selected tab changed inside of." + } } } ] }, { - "name": "onAttached", + "name": "onDetached", "type": "function", - "description": "", + "description": "Fired when a tab is detached from a window, for example because it is being moved between windows.", "parameters": [ {"type": "integer", "name": "tabId", "minimum": 0}, { "type": "object", - "name": "attachInfo", + "name": "detachInfo", "properties": { - "newWindowId": {"type": "integer", "minimum": 0}, - "newPosition": {"type": "integer", "minimum": 0} + "oldWindowId": {"type": "integer", "minimum": 0}, + "oldPosition": {"type": "integer", "minimum": 0} } } ] }, { - "name": "onDetached", + "name": "onAttached", "type": "function", - "description": "", + "description": "Fired when a tab is attached to a window, for example because it was moved between windows.", "parameters": [ {"type": "integer", "name": "tabId", "minimum": 0}, { "type": "object", - "name": "detachInfo", + "name": "attachInfo", "properties": { - "oldWindowId": {"type": "integer", "minimum": 0}, - "oldPosition": {"type": "integer", "minimum": 0} + "newWindowId": {"type": "integer", "minimum": 0}, + "newPosition": {"type": "integer", "minimum": 0} } } ] @@ -564,7 +654,7 @@ { "name": "onRemoved", "type": "function", - "description": "", + "description": "Fires when a tab is closed.", "parameters": [ {"type": "integer", "name": "tabId", "minimum": 0} ] diff --git a/chrome/common/extensions/docs/js/bootstrap.js b/chrome/common/extensions/docs/js/bootstrap.js index 007317f..24bb89c5 100755 --- a/chrome/common/extensions/docs/js/bootstrap.js +++ b/chrome/common/extensions/docs/js/bootstrap.js @@ -18,4 +18,11 @@ window.onload = function() { function postRender() { var elm = document.getElementById("hider"); elm.parentNode.removeChild(elm); -}
\ No newline at end of file + + // Since populating the page is done asynchronously, the DOM doesn't exist + // when the browser tries to resolve any #anchors in the URL. So we reset the + // URL once we're done, which forces the browser to scroll to the anchor as it + // normally would. + if (location.hash.length > 1) + location.href = location.href; +} diff --git a/chrome/common/extensions/docs/static/bookmarks.html b/chrome/common/extensions/docs/static/bookmarks.html index f03c7c2..b9c5101 100755 --- a/chrome/common/extensions/docs/static/bookmarks.html +++ b/chrome/common/extensions/docs/static/bookmarks.html @@ -2,7 +2,7 @@ <!-- BEGIN AUTHORED CONTENT --> <p id="classSummary"> -Use the <code>chrome.bookmarks</code> API to create, organize, +Use the <code>chrome.bookmarks</code> module to create, organize, and otherwise manipulate bookmarks. </p> diff --git a/chrome/common/extensions/docs/static/tabs.html b/chrome/common/extensions/docs/static/tabs.html index 997b579..ba23898 100755 --- a/chrome/common/extensions/docs/static/tabs.html +++ b/chrome/common/extensions/docs/static/tabs.html @@ -1,5 +1,22 @@ +<div id="pageData-title" class="pageData">Tabs</div> + <!-- BEGIN AUTHORED CONTENT --> -<p class="todo"> -[PENDING: API Module Overview Goes Here] +<p id="classSummary"> +Use the <code>chrome.tabs</code> module +to interact with the browser's tab system. +You can use this module to +create, modify, and rearrange tabs in the browser. </p> + +<h2 id="permissions">Permissions</h2> +<p>You must declare the <var>tabs</var> permission in your extension's manifest to use the tabs API.</p> +<p>Example:</p> +<pre>{ + "name": "My extension that uses tabs", + "version": "0.1", +<b> "permissions": [ + "tabs" + ]</b> +}</pre> + <!-- END AUTHORED CONTENT --> diff --git a/chrome/common/extensions/docs/static/windows.html b/chrome/common/extensions/docs/static/windows.html index 997b579..49f5cd1 100755 --- a/chrome/common/extensions/docs/static/windows.html +++ b/chrome/common/extensions/docs/static/windows.html @@ -1,5 +1,22 @@ <!-- BEGIN AUTHORED CONTENT --> -<p class="todo"> -[PENDING: API Module Overview Goes Here] -</p> +<h2 id="current-window">The current window</h2> + +<p>Many functions in the extension system +take an optional <var>windowId</var> parameter +which is documented to default to the <em>current window</em>. + +<p>The current window is the window that +contains the code that is currently executing. +It's important to realize that this can be +different from the topmost or focused window. + +<p>For example, consider code running in a +<a href="toolstrip.html">toolstrip</a>, that +calls <a href="tabs.html#method-getSelected">chrome.tabs.getSelected</a>. +The current window is the window that contains the toolstrip that made +the call, no matter what the topmost window is. + +<p>In the case of the <a href="background_pages.html">background page</a>, +the value of the current window falls back to the topmost window. + <!-- END AUTHORED CONTENT --> |