Home | History | Annotate | Download | only in static
      1 <div id="pageData-name" class="pageData">Bookmarks</div>
      2 
      3 <!-- BEGIN AUTHORED CONTENT -->
      4 <p id="classSummary">
      5 Use the <code>chrome.bookmarks</code> module to create, organize,
      6 and otherwise manipulate bookmarks.
      7 Also see <a href="override.html">Override Pages</a>,
      8 which 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
     16 in the <a href="manifest.html">extension manifest</a>
     17 to use the bookmarks API.
     18 For 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>
     31 Bookmarks are organized in a tree,
     32 where each node in the tree
     33 is either a bookmark or a folder
     34 (sometimes called a <em>group</em>).
     35 Each node in the tree
     36 is represented by a
     37 <a href="#type-BookmarkTreeNode"><code>BookmarkTreeNode</code></a> object.
     38 </p>
     39 
     40 <p>
     41 <code>BookmarkTreeNode</code> properties
     42 are used throughout the <code>chrome.bookmarks</code> API.
     43 For example, when you call
     44 <a href="#method-create"><code>create()</code></a>,
     45 you pass in the new node's parent (<code>parentId</code>),
     46 and, optionally, the node's
     47 <code>index</code>, <code>title</code>, and <code>url</code> properties.
     48 See <a href="#type-BookmarkTreeNode"><code>BookmarkTreeNode</code></a>
     49 for 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
     53 in 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>
     59 The following code creates a folder with the title "Extension bookmarks".
     60 The first argument to <code>create()</code> specifies properties
     61 for the new folder.
     62 The second argument defines a function
     63 to be executed after the folder is created.
     64 </p>
     65 
     66 <pre>
     67 chrome.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>
     75 The next snippet creates a bookmark pointing to
     76 the developer documentation for extensions.
     77 Since nothing bad will happen if creating the bookmark fails,
     78 this code doesn't bother to define a callback function.
     79 </p>
     80 
     81 <pre>
     82 chrome.bookmarks.create({'parentId': extensionsFolderId,
     83                          'title': 'Extensions doc',
     84                          'url': 'http://code.google.com/chrome/extensions'});
     85 </pre>
     86 
     87 <p>
     88 For 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>.
     90 For 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