1<img src="{{static}}/images/bookmarks.png" 2 width="486" height="211" alt="Clicking the star adds a bookmark" /> 3 4<h2 id="manifest">Manifest</h2> 5<p>You must declare the "bookmarks" permission 6in the <a href="manifest.html">extension manifest</a> 7to use the bookmarks API. 8For example:</p> 9<pre data-filename="manifest.json"> 10{ 11 "name": "My extension", 12 ... 13 <b>"permissions": [ 14 "bookmarks" 15 ]</b>, 16 ... 17} 18</pre> 19 20<h2 id="description">Objects and properties</h2> 21 22<p> 23Bookmarks are organized in a tree, 24where each node in the tree 25is either a bookmark or a folder 26(sometimes called a <em>group</em>). 27Each node in the tree 28is represented by a 29$ref:bookmarks.BookmarkTreeNode object. 30</p> 31 32<p> 33<code>BookmarkTreeNode</code> properties 34are used throughout the <code>chrome.bookmarks</code> API. 35For example, when you call 36$ref:bookmarks.create, 37you pass in the new node's parent (<code>parentId</code>), 38and, optionally, the node's 39<code>index</code>, <code>title</code>, and <code>url</code> properties. 40See $ref:bookmarks.BookmarkTreeNode 41for information about the properties a node can have. 42</p> 43 44<p class="note"><b>Note:</b> You cannot use this API to add or remove entries 45in the root folder. You also cannot rename, move, or remove the special 46"Bookmarks Bar" and "Other Bookmarks" folders.</p> 47 48<h2 id="overview-examples">Examples</h2> 49 50<p> 51The following code creates a folder with the title "Extension bookmarks". 52The first argument to <code>create()</code> specifies properties 53for the new folder. 54The second argument defines a function 55to be executed after the folder is created. 56</p> 57 58<pre> 59chrome.bookmarks.create({'parentId': bookmarkBar.id, 60 'title': 'Extension bookmarks'}, 61 function(newFolder) { 62 console.log("added folder: " + newFolder.title); 63}); 64</pre> 65 66<p> 67The next snippet creates a bookmark pointing to 68the developer documentation for extensions. 69Since nothing bad will happen if creating the bookmark fails, 70this code doesn't bother to define a callback function. 71</p> 72 73<pre> 74chrome.bookmarks.create({'parentId': extensionsFolderId, 75 'title': 'Extensions doc', 76 'url': 'http://code.google.com/chrome/extensions'}); 77</pre> 78 79<p> 80For an example of using this API, see the 81<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/docs/examples/api/bookmarks/basic/">basic bookmarks sample</a>. 82For other examples and for help in viewing the source code, see 83<a href="samples.html">Samples</a>. 84</p> 85