1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
<div id="pageData-title" class="pageData">Bookmarks</div>
<!-- BEGIN AUTHORED CONTENT -->
<p id="classSummary">
Use the <code>chrome.bookmarks</code> module to create, organize,
and otherwise manipulate bookmarks.
</p>
<h2 id="manifest">Manifest</h2>
<p>You must declare the "bookmarks" permission
in the <a href="manifest.html">extension manifest</a>
to use the bookmarks API.
For example:</p>
<pre>{
"name": "My extension that uses bookmarks",
"version": "0.1",
<b> "permissions": [
"bookmarks"
]</b>,
...
}</pre>
<h2 id="description">Objects and properties</h2>
<p>
Bookmarks are organized in a tree,
where each node in the tree
is either a bookmark or a group
(a folder that can contain nodes).
Each node in the tree
is represented by a
<a href="#type-BookmarkTreeNode"><code>BookmarkTreeNode</code></a> object.
</p>
<p>
<code>BookmarkTreeNode</code> properties
are used throughout the <code>chrome.bookmarks</code> API.
For example, when you call
<a href="#method-create"><code>create()</code></a>,
you pass in the new node's parent (<code>parentId</code>),
and, optionally, the node's
<code>index</code>, <code>title</code>, and <code>url</code> properties.
See <a href="#type-BookmarkTreeNode"><code>BookmarkTreeNode</code></a>
for information about the properties a node can have.
</p>
<!-- [PENDING: Update and introduce the following image or delete the file.]
<img
alt="2 kinds of bookmark objects"
width="415"
height="123"
src="images/bookmarks.png" />
-->
<!-- [PENDING: The following section needs to be updated or deleted.]
<p>
Say you have bookmark hierarchy that looks like this:</p>
<ul>
<li>Bookmarks</li>
<ul>
<li>Google</li>
<ul>
<li>Apps</li>
<ul>
<li>...</li>
<li>...</li>
<li>...</li>
</ul>
<li>Google homepage</li>
</ul>
<li>Example</li>
</ul>
</ul>
<p>
Here's how those bookmarks might be represented with bookmark objects:</p>
<img
alt="a hierarchy of bookmarks"
width="522"
height="594"
src="images/bookmarks-hierarchy.png">
-->
<h2 id="overview-examples">Examples</h2>
<p>
The following code creates a folder with the title "Extension bookmarks".
The first argument to <code>create()</code> specifies properties
for the new folder.
The second argument defines a function
to be executed after the folder is created.
</p>
<pre>
chrome.bookmarks.create({'parentId': bookmarkBar.id,
'title': 'Extension bookmarks'},
function(newFolder) {
console.log("added folder: " + newFolder.title);
});
</pre>
<p>
The next snippet creates a bookmark pointing to
the developer documentation for extensions.
Since nothing bad will happen if creating the bookmark fails,
this code doesn't bother to define a callback function.
</p>
<pre>
chrome.bookmarks.create({'parentId': extensionsFolderId,
'title': 'Extensions doc',
'url': 'http://code.google.com/chrome/extensions'});
</pre>
<p>
For a full example of using bookmarks, see the
<a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/test/data/extensions/samples/bookmarks/">bookmarks sample</a>.
</p>
<!-- END AUTHORED CONTENT -->
|