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