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