Source code

Revision control

Copy as Markdown

Other Tools

[
{
"namespace": "storage",
"allowedContexts": ["content", "devtools"],
"defaultContexts": ["content", "devtools"],
"description": "Use the <code>browser.storage</code> API to store, retrieve, and track changes to user data.",
"permissions": ["storage"],
"types": [
{
"id": "StorageChange",
"type": "object",
"properties": {
"oldValue": {
"type": "any",
"description": "The old value of the item, if there was an old value.",
"optional": true
},
"newValue": {
"type": "any",
"description": "The new value of the item, if there is a new value.",
"optional": true
}
}
},
{
"id": "StorageArea",
"type": "object",
"functions": [
{
"name": "get",
"type": "function",
"description": "Gets one or more items from storage.",
"async": "callback",
"parameters": [
{
"name": "keys",
"choices": [
{ "type": "string" },
{ "type": "array", "items": { "type": "string" } },
{
"type": "object",
"description": "Storage items to return in the callback, where the values are replaced with those from storage if they exist.",
"additionalProperties": { "type": "any" }
}
],
"description": "A single key to get, list of keys to get, or a dictionary specifying default values (see description of the object). An empty list or object will return an empty result object. Pass in <code>null</code> to get the entire contents of storage.",
"optional": true
},
{
"name": "callback",
"type": "function",
"description": "Callback with storage items, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [
{
"name": "items",
"type": "object",
"additionalProperties": { "type": "any" },
"description": "Object with items in their key-value mappings."
}
]
}
]
},
{
"name": "getBytesInUse",
"unsupported": true,
"type": "function",
"description": "Gets the amount of space (in bytes) being used by one or more items.",
"async": "callback",
"parameters": [
{
"name": "keys",
"choices": [
{ "type": "string" },
{ "type": "array", "items": { "type": "string" } }
],
"description": "A single key or list of keys to get the total usage for. An empty list will return 0. Pass in <code>null</code> to get the total usage of all of storage.",
"optional": true
},
{
"name": "callback",
"type": "function",
"description": "Callback with the amount of space being used by storage, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [
{
"name": "bytesInUse",
"type": "integer",
"description": "Amount of space being used in storage, in bytes."
}
]
}
]
},
{
"name": "set",
"type": "function",
"description": "Sets multiple items.",
"async": "callback",
"parameters": [
{
"name": "items",
"type": "object",
"additionalProperties": { "type": "any" },
"description": "<p>An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected.</p><p>Primitive values such as numbers will serialize as expected. Values with a <code>typeof</code> <code>\"object\"</code> and <code>\"function\"</code> will typically serialize to <code>{}</code>, with the exception of <code>Array</code> (serializes as expected), <code>Date</code>, and <code>Regex</code> (serialize using their <code>String</code> representation).</p>"
},
{
"name": "callback",
"type": "function",
"description": "Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [],
"optional": true
}
]
},
{
"name": "remove",
"type": "function",
"description": "Removes one or more items from storage.",
"async": "callback",
"parameters": [
{
"name": "keys",
"choices": [
{ "type": "string" },
{ "type": "array", "items": { "type": "string" } }
],
"description": "A single key or a list of keys for items to remove."
},
{
"name": "callback",
"type": "function",
"description": "Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [],
"optional": true
}
]
},
{
"name": "clear",
"type": "function",
"description": "Removes all items from storage.",
"async": "callback",
"parameters": [
{
"name": "callback",
"type": "function",
"description": "Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [],
"optional": true
}
]
}
],
"events": [
{
"name": "onChanged",
"type": "function",
"description": "Fired when one or more items change.",
"parameters": [
{
"name": "changes",
"type": "object",
"additionalProperties": { "$ref": "StorageChange" },
"description": "Object mapping each key that changed to its corresponding $(ref:storage.StorageChange) for that item."
}
]
}
]
},
{
"id": "StorageAreaSync",
"type": "object",
"functions": [
{
"name": "get",
"type": "function",
"description": "Gets one or more items from storage.",
"async": "callback",
"parameters": [
{
"name": "keys",
"choices": [
{ "type": "string" },
{ "type": "array", "items": { "type": "string" } },
{
"type": "object",
"description": "Storage items to return in the callback, where the values are replaced with those from storage if they exist.",
"additionalProperties": { "type": "any" }
}
],
"description": "A single key to get, list of keys to get, or a dictionary specifying default values (see description of the object). An empty list or object will return an empty result object. Pass in <code>null</code> to get the entire contents of storage.",
"optional": true
},
{
"name": "callback",
"type": "function",
"description": "Callback with storage items, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [
{
"name": "items",
"type": "object",
"additionalProperties": { "type": "any" },
"description": "Object with items in their key-value mappings."
}
]
}
]
},
{
"name": "getBytesInUse",
"type": "function",
"description": "Gets the amount of space (in bytes) being used by one or more items.",
"async": "callback",
"parameters": [
{
"name": "keys",
"choices": [
{ "type": "string" },
{ "type": "array", "items": { "type": "string" } }
],
"description": "A single key or list of keys to get the total usage for. An empty list will return 0. Pass in <code>null</code> to get the total usage of all of storage.",
"optional": true
},
{
"name": "callback",
"type": "function",
"description": "Callback with the amount of space being used by storage, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [
{
"name": "bytesInUse",
"type": "integer",
"description": "Amount of space being used in storage, in bytes."
}
]
}
]
},
{
"name": "set",
"type": "function",
"description": "Sets multiple items.",
"async": "callback",
"parameters": [
{
"name": "items",
"type": "object",
"additionalProperties": { "type": "any" },
"description": "<p>An object which gives each key/value pair to update storage with. Any other key/value pairs in storage will not be affected.</p><p>Primitive values such as numbers will serialize as expected. Values with a <code>typeof</code> <code>\"object\"</code> and <code>\"function\"</code> will typically serialize to <code>{}</code>, with the exception of <code>Array</code> (serializes as expected), <code>Date</code>, and <code>Regex</code> (serialize using their <code>String</code> representation).</p>"
},
{
"name": "callback",
"type": "function",
"description": "Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [],
"optional": true
}
]
},
{
"name": "remove",
"type": "function",
"description": "Removes one or more items from storage.",
"async": "callback",
"parameters": [
{
"name": "keys",
"choices": [
{ "type": "string" },
{ "type": "array", "items": { "type": "string" } }
],
"description": "A single key or a list of keys for items to remove."
},
{
"name": "callback",
"type": "function",
"description": "Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [],
"optional": true
}
]
},
{
"name": "clear",
"type": "function",
"description": "Removes all items from storage.",
"async": "callback",
"parameters": [
{
"name": "callback",
"type": "function",
"description": "Callback on success, or on failure (in which case $(ref:runtime.lastError) will be set).",
"parameters": [],
"optional": true
}
]
}
],
"events": [
{
"name": "onChanged",
"type": "function",
"description": "Fired when one or more items change.",
"parameters": [
{
"name": "changes",
"type": "object",
"additionalProperties": { "$ref": "StorageChange" },
"description": "Object mapping each key that changed to its corresponding $(ref:storage.StorageChange) for that item."
}
]
}
]
}
],
"events": [
{
"name": "onChanged",
"type": "function",
"description": "Fired when one or more items change.",
"parameters": [
{
"name": "changes",
"type": "object",
"additionalProperties": { "$ref": "StorageChange" },
"description": "Object mapping each key that changed to its corresponding $(ref:storage.StorageChange) for that item."
},
{
"name": "areaName",
"type": "string",
"description": "The name of the storage area (<code>\"sync\"</code>, <code>\"local\"</code> or <code>\"managed\"</code>) the changes are for."
}
]
}
],
"properties": {
"sync": {
"$ref": "StorageAreaSync",
"description": "Items in the <code>sync</code> storage area are synced by the browser.",
"properties": {
"QUOTA_BYTES": {
"value": 102400,
"description": "The maximum total amount (in bytes) of data that can be stored in sync storage, as measured by the JSON stringification of every value plus every key's length. Updates that would cause this limit to be exceeded fail immediately and set $(ref:runtime.lastError)."
},
"QUOTA_BYTES_PER_ITEM": {
"value": 8192,
"description": "The maximum size (in bytes) of each individual item in sync storage, as measured by the JSON stringification of its value plus its key length. Updates containing items larger than this limit will fail immediately and set $(ref:runtime.lastError)."
},
"MAX_ITEMS": {
"value": 512,
"description": "The maximum number of items that can be stored in sync storage. Updates that would cause this limit to be exceeded will fail immediately and set $(ref:runtime.lastError)."
},
"MAX_WRITE_OPERATIONS_PER_HOUR": {
"value": 1800,
"description": "<p>The maximum number of <code>set</code>, <code>remove</code>, or <code>clear</code> operations that can be performed each hour. This is 1 every 2 seconds, a lower ceiling than the short term higher writes-per-minute limit.</p><p>Updates that would cause this limit to be exceeded fail immediately and set $(ref:runtime.lastError).</p>"
},
"MAX_WRITE_OPERATIONS_PER_MINUTE": {
"value": 120,
"description": "<p>The maximum number of <code>set</code>, <code>remove</code>, or <code>clear</code> operations that can be performed each minute. This is 2 per second, providing higher throughput than writes-per-hour over a shorter period of time.</p><p>Updates that would cause this limit to be exceeded fail immediately and set $(ref:runtime.lastError).</p>"
},
"MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE": {
"value": 1000000,
"deprecated": "The storage.sync API no longer has a sustained write operation quota.",
"description": ""
}
}
},
"local": {
"$ref": "StorageArea",
"description": "Items in the <code>local</code> storage area are local to each machine.",
"properties": {
"QUOTA_BYTES": {
"value": 5242880,
"description": "The maximum amount (in bytes) of data that can be stored in local storage, as measured by the JSON stringification of every value plus every key's length. This value will be ignored if the extension has the <code>unlimitedStorage</code> permission. Updates that would cause this limit to be exceeded fail immediately and set $(ref:runtime.lastError)."
}
}
},
"managed": {
"$ref": "StorageArea",
"description": "Items in the <code>managed</code> storage area are set by administrators or native applications, and are read-only for the extension; trying to modify this namespace results in an error.",
"properties": {
"QUOTA_BYTES": {
"value": 5242880,
"description": "The maximum size (in bytes) of the managed storage JSON manifest file. Files larger than this limit will fail to load."
}
}
},
"session": {
"allowedContexts": ["devtools"],
"$ref": "StorageArea",
"description": "Items in the <code>session</code> storage area are kept in memory, and only until the either browser or extension is closed or reloaded."
}
}
}
]