summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/docs/static/bookmarks.html
blob: f03c7c24d68fd89bdf5f8f0a8652f4e5277f3a5a (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<div id="pageData-title" class="pageData">Bookmarks</div>

<!-- BEGIN AUTHORED CONTENT -->
<p id="classSummary">
Use the <code>chrome.bookmarks</code> API to create, organize,
and otherwise manipulate bookmarks.
</p>

<h2 id="description">Description</h2>

<p class="comment">
[PENDING: This section needs to be reviewed and updated.]
</p>

<p>
<a href="#type-BookmarkTreeNode">BookmarkTreeNode</a> objects
are an important part of the <code>chrome.bookmarks</code> API.
Each bookmark tree node represents
either a URL or a group of bookmarks, as you can see in the following figure.
</p>

<img
  alt="2 kinds of bookmark objects"
  width="415"
  height="123"
  src="images/bookmarks.png"></a>
<br />
<span class="comment">
[PENDING: this figure needs to be updated]
</span>


<h3 id="overview-properties">Properties</h3>

<p>
Objects that represent bookmarks can have the following properties:
</p>

<dl>
<dt> <code>id</code> </dt>
<dd> An integer ID that's unique for each bookmark.
     Don't save this ID in persistent storage;
     the ID for a particular bookmark might change
     the next time the browser is started.
     <span class="comment">
     [PENDING: these might be persistent now]
     </span>
     </dd>

<dt> <code>title</code> </dt>
<dd> The name of the bookmark.
     This is the user-visible string that describes the URL or group.
     </dd>

<dt> <code>parentId </code>
     <em>(omitted for the root group)</em>
     </dt>
<dd> The ID of the group that this bookmark is in. </dd>

<dt> <code>index</code>
     <em>(optional; omitted for the root group)</em>
     </dt>
<dd> The 0-based integer position of the bookmark within its group. </dd>

<dt> <code>url</code>
     <em>(omitted for groups)</em>
     </dt>
<dd> The URL of the page that the bookmark points to. </dd>

<dt> ... </dt>
</dl>

<h3 id="overview-examples">Examples</h3>

<p>
The following code creates a bookmark group with the title "Chromium bookmarks".
The last argument defines a function to be executed after the folder is created.
</p>

<pre>
chrome.bookmarks.create({'parentId': bookmarkBar.id,
                         'title': 'Chromium bookmarks'},
                        function(newFolder) {...});
</pre>

<p>
The next snippet creates a bookmark pointing to the Chromium developer doc.
Since nothing too bad will happen if creating the bookmark fails,
this snippet doesn't bother to define a callback function.
</p>

<pre>
chrome.bookmarks.create({'parentId': chromiumBookmarks.id,
                         'title': 'dev doc',
                         'url': 'http://dev.chromium.org'});
</pre>

<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">

<p>
Here's some code you could use to create that hierarchy:</p>

<pre class="example comment">
[PENDING: ...code goes here...]
</pre>


<!-- PENDING: we could have links to source code and sample extensions. E.g.:
<div class="exampleLink">
<a href="http://www.google.com/url?q=http%3A%2F%2Fexample.com&amp;sa=D&amp;sntz=1&amp;usg=AFrqEzd0oeJ1qGwYPoKuq1dTesEchMDLIQ">Full source code</a> |
<a href="http://www.google.com/url?q=http%3A%2F%2Fexample.com&amp;sa=D&amp;sntz=1&amp;usg=AFrqEzd0oeJ1qGwYPoKuq1dTesEchMDLIQ">Install extension</a>
</div>
-->
<!-- END AUTHORED CONTENT -->