代管式存储空间的清单

localsync 存储区域不同,managed 存储区域的结构必须为 声明为 JSON 架构,并经过 Chrome 的严格验证。此架构必须存储在 (由 "storage" 清单键的 "managed_schema" 属性指示)文件,并声明 支持的企业政策。

政策类似于选项 由系统管理员配置 针对安装了政策的扩展程序,允许针对 组织内的所有用户有关示例,请参阅 Chrome 如何处理政策

声明政策后,您可以通过 storage.managed API 读取政策。这取决于 扩展程序以强制执行管理员配置的政策。

manifest.json 示例

storage.managed_schema 属性表示扩展名中包含该政策的文件 架构。

{
  "name": "My enterprise extension",
  "storage": {
    "managed_schema": "schema.json"
  },
  ...
}

然后,Chrome 会从基础操作系统和 Google Apps for Business 加载这些政策。 已登录的用户只要检测到政策更改,就会触发 storage.onChanged 事件。 您可以访问 chrome://policy 验证 Chrome 已加载的政策。

架构格式

对于 JSON 架构格式,Chrome 还需遵循一些额外要求:

  • 顶级架构的类型必须为 object
  • 顶级 object 不能包含 additionalProperties。声明的 properties 是 政策。
  • 每个架构必须有一个 $ref 值或只有一个 type

如果架构无效,则 Chrome 不会加载该扩展程序,并会说明 架构未经过验证。如果政策值不符合架构,则不会 由 storage.managed API 发布。

示例架构

{
  "type": "object",

  // "properties" maps an optional key of this object to its schema. At the
  // top-level object, these keys are the policy names supported.
  "properties": {

    // The policy name "AutoSave" is mapped to its schema, which in this case
    // declares it as a simple boolean value.
    // "title" and "description" are optional and are used to show a
    // user-friendly name and documentation to the administrator.
    "AutoSave": {
      "title": "Automatically save changes.",
      "description": "If set to true then changes will be automatically saved.",
      "type": "boolean"
    },

    // Other simple types supported include "integer", "string" and "number".
    "PollRefreshRate": {
      "type": "integer"
    },

    "DefaultServiceUrl": {
      "type": "string"
    },

    // "array" is a list of items that conform to another schema, described
    // in "items". An example to this schema is [ "one", "two" ].
    "ServiceUrls": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },

    // A more complex example that describes a list of bookmarks. Each bookmark
    // has a "title", and can have a "url" or a list of "children" bookmarks.
    // The "id" attribute is used to name a schema, and other schemas can reuse
    // it using the "$ref" attribute.
    "Bookmarks": {
      "type": "array",
      "id": "ListOfBookmarks",
      "items": {
        "type": "object",
        "properties": {
          "title": { "type": "string" },
          "url": { "type": "string" },
          "children": { "$ref": "ListOfBookmarks" }
        }
      }
    },

    // An "object" can have known properties listed as "properties", and can
    // optionally have "additionalProperties" indicating a schema to apply to
    // keys that aren't found in "properties".
    // This example policy could map a URL to its settings. An example value:
    // {
    //   "youtube.com": {
    //     "blocklisted": true
    //   },
    //   "google.com": {
    //     "bypass_proxy": true
    //   }
    // }
    "SettingsForUrls": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "blocklisted": { "type": "boolean" },
          "bypass_proxy": { "type": "boolean" }
        }
      }
    }
  }
}