我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译
您也可以阅读此文章的English (US)版。

A storage.StorageArea object that represents the managed storage area. Items in managed storage are set by the domain administrator or other native applications installed on user's computer, and are read-only for the extension. Trying to modify this storage area results in an error.

Provisioning managed storage

The procedure for provisioning managed storage is different for different browsers. For Chrome instructions, see the "Manifest for storage areas" article.

For Firefox, you need to create a JSON manifest file in a specific format, in a specific location. For the details of manifest syntax and location, see Native manifests.

Here's an example manifest:

{
  "name": "favourite-colour-examples@mozilla.org",
  "description": "ignored",
  "type": "storage",
  "data":
  {
    "colour": "management thinks it should be blue!"
  }
}

Given this manifest, the "favourite-colour-examples@mozilla.org" extension could access the data using code like this:

var storageItem = browser.storage.managed.get('colour');
storageItem.then((res) => {
  console.log(`Managed colour is: ${res.colour}`);
});

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxOperaFirefox for Android
managedChrome Full support YesEdge No support NoFirefox Full support 57
Notes
Full support 57
Notes
Notes Platform-specific storage backends, such as Windows registry keys, are not supported.
Notes Enforcement of extension-provided storage schemas is not supported.
Notes The onChanged event is not supported.
Opera No support NoFirefox Android No support No

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.

Example extensions

Acknowledgements

This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.

文档标签和贡献者

此页面的贡献者: mdnwebdocs-bot, fscholz, wbamberg, zombie, chrisdavidmills
最后编辑者: mdnwebdocs-bot,