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