Home | History | Annotate | Download | only in api
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 [
      6   {
      7     "namespace": "bookmarks",
      8     "description": "Use the <code>chrome.bookmarks</code> API to create, organize, and otherwise manipulate bookmarks. Also see <a href='override.html'>Override Pages</a>, which you can use to create a custom Bookmark Manager page.",
      9     "properties": {
     10       "MAX_WRITE_OPERATIONS_PER_HOUR": {
     11         "value": 100,
     12         "description": "The maximum number of <code>move</code>, <code>update</code>, <code>create</code>, or <code>remove</code> operations that can be performed each hour. Updates that would cause this limit to be exceeded fail."
     13       },
     14       "MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE": {
     15         "value": 2,
     16         "description": "The maximum number of <code>move</code>, <code>update</code>, <code>create</code>, or <code>remove</code> operations that can be performed each minute, sustained over 10 minutes. Updates that would cause this limit to be exceeded fail."
     17       }
     18     },
     19     "types": [
     20       {
     21         "id": "BookmarkTreeNode",
     22         "type": "object",
     23         "description": "A node (either a bookmark or a folder) in the bookmark tree.  Child nodes are ordered within their parent folder.",
     24         "properties": {
     25           "id": {
     26             "type": "string",
     27             "minimum": 0,
     28             "description": "The unique identifier for the node. IDs are unique within the current profile, and they remain valid even after the browser is restarted."
     29           },
     30           "parentId": {
     31             "type": "string",
     32             "minimum": 0,
     33             "optional": true,
     34             "description": "The <code>id</code> of the parent folder.  Omitted for the root node."
     35           },
     36           "index": {
     37             "type": "integer",
     38             "optional": true,
     39             "description": "The 0-based position of this node within its parent folder."
     40           },
     41           "url": {
     42             "type": "string",
     43             "optional": true,
     44             "description": "The URL navigated to when a user clicks the bookmark. Omitted for folders."
     45           },
     46           "title": {
     47             "type": "string",
     48             "description": "The text displayed for the node."
     49           },
     50           "dateAdded": {
     51             "type": "number",
     52             "optional": true,
     53             "description": "When this node was created, in milliseconds since the epoch (<code>new Date(dateAdded)</code>)."
     54           },
     55           "dateGroupModified": {
     56             "type": "number",
     57             "optional": true,
     58             "description": "When the contents of this folder last changed, in milliseconds since the epoch."
     59           },
     60           "children": {
     61             "type": "array",
     62             "optional": true,
     63             "items": { "$ref": "BookmarkTreeNode" },
     64             "description": "An ordered list of children of this node."
     65           }
     66         }
     67       }
     68     ],
     69     "functions": [
     70       {
     71         "name": "get",
     72         "type": "function",
     73         "description": "Retrieves the specified BookmarkTreeNode(s).",
     74         "parameters": [
     75           {
     76             "name": "idOrIdList",
     77             "description": "A single string-valued id, or an array of string-valued ids",
     78             "choices": [
     79               {
     80                 "type": "string",
     81                 "serialized_type": "int64"
     82               },
     83               {
     84                 "type": "array",
     85                 "items": {
     86                   "type": "string",
     87                   "serialized_type": "int64"
     88                 },
     89                 "minItems": 1
     90               }
     91             ]
     92           },
     93           {
     94             "type": "function",
     95             "name": "callback",
     96             "parameters": [
     97               {
     98                 "name": "results",
     99                 "type": "array",
    100                 "items": { "$ref": "BookmarkTreeNode" }
    101               }
    102             ]
    103           }
    104         ]
    105       },
    106       {
    107         "name": "getChildren",
    108         "type": "function",
    109         "description": "Retrieves the children of the specified BookmarkTreeNode id.",
    110         "parameters": [
    111           {
    112             "type": "string",
    113             "serialized_type": "int64",
    114             "name": "id"
    115           },
    116           {
    117             "type": "function",
    118             "name": "callback",
    119             "parameters": [
    120               {
    121                 "name": "results",
    122                 "type": "array",
    123                 "items": { "$ref": "BookmarkTreeNode"}
    124               }
    125             ]
    126           }
    127         ]
    128       },
    129       {
    130         "name": "getRecent",
    131         "type": "function",
    132         "description": "Retrieves the recently added bookmarks.",
    133         "parameters": [
    134           {
    135             "type": "integer",
    136             "minimum": 1,
    137             "name": "numberOfItems",
    138             "description": "The maximum number of items to return."
    139           },
    140           {
    141             "type": "function",
    142             "name": "callback",
    143             "parameters": [
    144               {
    145                 "name": "results",
    146                 "type": "array",
    147                 "items": { "$ref": "BookmarkTreeNode" }
    148               }
    149             ]
    150           }
    151         ]
    152       },
    153       {
    154         "name": "getTree",
    155         "type": "function",
    156         "description": "Retrieves the entire Bookmarks hierarchy.",
    157         "parameters": [
    158           {
    159             "type": "function",
    160             "name": "callback",
    161             "parameters": [
    162               {
    163                 "name": "results",
    164                 "type": "array",
    165                 "items": { "$ref": "BookmarkTreeNode" }
    166               }
    167             ]
    168           }
    169         ]
    170       },
    171       {
    172         "name": "getSubTree",
    173         "type": "function",
    174         "description": "Retrieves part of the Bookmarks hierarchy, starting at the specified node.",
    175         "parameters": [
    176           {
    177             "type": "string",
    178             "serialized_type": "int64",
    179             "name": "id",
    180             "description": "The ID of the root of the subtree to retrieve."
    181           },
    182           {
    183             "type": "function",
    184             "name": "callback",
    185             "parameters": [
    186               {
    187                 "name": "results",
    188                 "type": "array",
    189                 "items": { "$ref": "BookmarkTreeNode" }
    190               }
    191             ]
    192           }
    193         ]
    194       },
    195       {
    196         "name": "search",
    197         "type": "function",
    198         "description": "Searches for BookmarkTreeNodes matching the given query.",
    199         "parameters": [
    200           {
    201             "type": "string",
    202             "name": "query"
    203           },
    204           {
    205             "type": "function",
    206             "name": "callback",
    207             "parameters": [
    208               {
    209                 "name": "results",
    210                 "type": "array",
    211                 "items": { "$ref": "BookmarkTreeNode" }
    212               }
    213             ]
    214           }
    215         ]
    216       },
    217       {
    218         "name": "create",
    219         "type": "function",
    220         "description": "Creates a bookmark or folder under the specified parentId.  If url is NULL or missing, it will be a folder.",
    221         "parameters": [
    222           {
    223             "type": "object",
    224             "name": "bookmark",
    225             "properties": {
    226               "parentId": {
    227                 "type": "string",
    228                 "serialized_type": "int64",
    229                 "optional": true,
    230                 "description": "Defaults to the Other Bookmarks folder."
    231               },
    232               "index": {
    233                 "type": "integer",
    234                 "minimum": 0,
    235                 "optional": true
    236               },
    237               "title": {
    238                 "type": "string",
    239                 "optional": true
    240               },
    241               "url": {
    242                 "type": "string",
    243                 "optional": true
    244               }
    245             }
    246           },
    247           {
    248             "type": "function",
    249             "name": "callback",
    250             "optional": true,
    251             "parameters": [
    252               {
    253                 "name": "result",
    254                 "$ref": "BookmarkTreeNode"
    255               }
    256             ]
    257           }
    258         ]
    259       },
    260       {
    261         "name": "move",
    262         "type": "function",
    263         "description": "Moves the specified BookmarkTreeNode to the provided location.",
    264         "parameters": [
    265           {
    266             "type": "string",
    267             "serialized_type": "int64",
    268             "name": "id"
    269           },
    270           {
    271             "type": "object",
    272             "name": "destination",
    273             "properties": {
    274               "parentId": {
    275                 "type": "string",
    276                 "optional": true
    277               },
    278               "index": {
    279                 "type": "integer",
    280                 "minimum": 0,
    281                 "optional": true
    282               }
    283             }
    284           },
    285           {
    286             "type": "function",
    287             "name": "callback",
    288             "optional": true,
    289             "parameters": [
    290               {
    291                 "name": "result",
    292                 "$ref": "BookmarkTreeNode"
    293               }
    294             ]
    295           }
    296         ]
    297       },
    298       {
    299         "name": "update",
    300         "type": "function",
    301         "description": "Updates the properties of a bookmark or folder. Specify only the properties that you want to change; unspecified properties will be left unchanged.  <b>Note:</b> Currently, only 'title' and 'url' are supported.",
    302         "parameters": [
    303           {
    304             "type": "string",
    305             "serialized_type": "int64",
    306             "name": "id"
    307           },
    308           {
    309             "type": "object",
    310             "name": "changes",
    311             "properties": {
    312               "title": {
    313                 "type": "string",
    314                 "optional": true
    315               },
    316               "url": {
    317                 "type": "string",
    318                 "optional": true
    319               }
    320             }
    321           },
    322           {
    323             "type": "function",
    324             "name": "callback",
    325             "optional": true,
    326             "parameters": [
    327               {
    328                 "name": "result",
    329                 "$ref": "BookmarkTreeNode"
    330               }
    331             ]
    332           }
    333         ]
    334       },
    335       {
    336         "name": "remove",
    337         "type": "function",
    338         "description": "Removes a bookmark or an empty bookmark folder.",
    339         "parameters": [
    340           {
    341             "type": "string",
    342             "serialized_type": "int64",
    343             "name": "id"
    344           },
    345           {
    346             "type": "function",
    347             "name": "callback",
    348             "optional": true,
    349             "parameters": []
    350           }
    351         ]
    352       },
    353       {
    354         "name": "removeTree",
    355         "type": "function",
    356         "description": "Recursively removes a bookmark folder.",
    357         "parameters": [
    358           {
    359             "type": "string",
    360             "serialized_type": "int64",
    361             "name": "id"
    362           },
    363           {
    364             "type": "function",
    365             "name": "callback",
    366             "optional": true,
    367             "parameters": []
    368           }
    369         ]
    370       },
    371       {
    372         "name": "import",
    373         "type": "function",
    374         "description": "Imports bookmarks from a chrome html bookmark file",
    375         "nodoc": "true",
    376         "parameters": [
    377           {
    378             "type": "function",
    379             "name": "callback",
    380             "optional": true,
    381             "parameters": []
    382           }
    383         ]
    384       },
    385       {
    386         "name": "export",
    387         "type": "function",
    388         "description": "Exports bookmarks to a chrome html bookmark file",
    389         "nodoc": "true",
    390         "parameters": [
    391           {
    392             "type": "function",
    393             "name": "callback",
    394             "optional": true,
    395             "parameters": []
    396           }
    397         ]
    398       }
    399     ],
    400     "events": [
    401       {
    402         "name": "onCreated",
    403         "type": "function",
    404         "description": "Fired when a bookmark or folder is created.",
    405         "parameters": [
    406           {
    407             "type": "string",
    408             "name": "id"
    409           },
    410           {
    411             "$ref": "BookmarkTreeNode",
    412             "name": "bookmark"
    413           }
    414         ]
    415       },
    416       {
    417         "name": "onRemoved",
    418         "type": "function",
    419         "description": "Fired when a bookmark or folder is removed.  When a folder is removed recursively, a single notification is fired for the folder, and none for its contents.",
    420         "parameters": [
    421           {
    422             "type": "string",
    423             "name": "id"
    424           },
    425           {
    426             "type": "object",
    427             "name": "removeInfo",
    428             "properties": {
    429               "parentId": { "type": "string" },
    430               "index": { "type": "integer" }
    431             }
    432           }
    433         ]
    434       },
    435       {
    436         "name": "onChanged",
    437         "type": "function",
    438         "description": "Fired when a bookmark or folder changes.  <b>Note:</b> Currently, only title and url changes trigger this.",
    439         "parameters": [
    440           {
    441             "type": "string",
    442             "name": "id"
    443           },
    444           {
    445             "type": "object",
    446             "name": "changeInfo",
    447             "properties": {
    448               "title": { "type": "string" },
    449               "url": {
    450                 "type": "string",
    451                 "optional": true
    452               }
    453             }
    454           }
    455         ]
    456       },
    457       {
    458         "name": "onMoved",
    459         "type": "function",
    460         "description": "Fired when a bookmark or folder is moved to a different parent folder.",
    461         "parameters": [
    462           {
    463             "type": "string",
    464             "name": "id"
    465           },
    466           {
    467             "type": "object",
    468             "name": "moveInfo",
    469             "properties": {
    470               "parentId": { "type": "string" },
    471               "index": { "type": "integer" },
    472               "oldParentId": { "type": "string" },
    473               "oldIndex": { "type": "integer" }
    474             }
    475           }
    476         ]
    477       },
    478       {
    479         "name": "onChildrenReordered",
    480         "type": "function",
    481         "description": "Fired when the children of a folder have changed their order due to the order being sorted in the UI.  This is not called as a result of a move().",
    482         "parameters": [
    483           {
    484             "type": "string",
    485             "name": "id"
    486           },
    487           {
    488             "type": "object",
    489             "name": "reorderInfo",
    490             "properties": {
    491               "childIds": {
    492                 "type": "array",
    493                 "items": { "type": "string" }
    494               }
    495             }
    496           }
    497         ]
    498       },
    499       {
    500         "name": "onImportBegan",
    501         "type": "function",
    502         "description": "Fired when a bookmark import session is begun.  Expensive observers should ignore onCreated updates until onImportEnded is fired.  Observers should still handle other notifications immediately.",
    503         "parameters": []
    504       },
    505       {
    506         "name": "onImportEnded",
    507         "type": "function",
    508         "description": "Fired when a bookmark import session is ended.",
    509         "parameters": []
    510       }
    511     ]
    512   }
    513 ]
    514