| <img src="{{static}}/images/bookmarks.png" |
| width="486" height="211" alt="Clicking the star adds a bookmark" /> |
| |
| <h2 id="manifest">Manifest</h2> |
| <p>You must declare the "bookmarks" permission |
| in the <a href="manifest.html">extension manifest</a> |
| to use the bookmarks API. |
| For example:</p> |
| <pre>{ |
| "name": "My extension", |
| ... |
| <b>"permissions": [ |
| "bookmarks" |
| ]</b>, |
| ... |
| }</pre> |
| |
| <h2 id="description">Objects and properties</h2> |
| |
| <p> |
| Bookmarks are organized in a tree, |
| where each node in the tree |
| is either a bookmark or a folder |
| (sometimes called a <em>group</em>). |
| Each node in the tree |
| is represented by a |
| $ref:bookmarks.BookmarkTreeNode object. |
| </p> |
| |
| <p> |
| <code>BookmarkTreeNode</code> properties |
| are used throughout the <code>chrome.bookmarks</code> API. |
| For example, when you call |
| $ref:bookmarks.create, |
| you pass in the new node's parent (<code>parentId</code>), |
| and, optionally, the node's |
| <code>index</code>, <code>title</code>, and <code>url</code> properties. |
| See $ref:bookmarks.BookmarkTreeNode |
| for information about the properties a node can have. |
| </p> |
| |
| <p class="note"><b>Note:</b> You cannot use this API to add or remove entries |
| in the root folder. You also cannot rename, move, or remove the special |
| "Bookmarks Bar" and "Other Bookmarks" folders.</p> |
| |
| <h2 id="overview-examples">Examples</h2> |
| |
| <p> |
| The following code creates a folder with the title "Extension bookmarks". |
| The first argument to <code>create()</code> specifies properties |
| for the new folder. |
| The second argument defines a function |
| to be executed after the folder is created. |
| </p> |
| |
| <pre> |
| chrome.bookmarks.create({'parentId': bookmarkBar.id, |
| 'title': 'Extension bookmarks'}, |
| function(newFolder) { |
| console.log("added folder: " + newFolder.title); |
| }); |
| </pre> |
| |
| <p> |
| The next snippet creates a bookmark pointing to |
| the developer documentation for extensions. |
| Since nothing bad will happen if creating the bookmark fails, |
| this code doesn't bother to define a callback function. |
| </p> |
| |
| <pre> |
| chrome.bookmarks.create({'parentId': extensionsFolderId, |
| 'title': 'Extensions doc', |
| 'url': 'http://code.google.com/chrome/extensions'}); |
| </pre> |
| |
| <p> |
| For an example of using this API, see the |
| <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/bookmarks/basic/">basic bookmarks sample</a>. |
| For other examples and for help in viewing the source code, see |
| <a href="samples.html">Samples</a>. |
| </p> |