ストレージ領域のマニフェスト

local ストレージ領域や sync ストレージ領域とは異なり、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 Education から できます。storage.onChanged イベントは、ポリシーの変更が検出されると発生します。 拡張機能がイベントページを使用している場合は、ブラウザが実行されていない間も含む。Chrome が読み込んだポリシーは、chrome://policy で確認できます。

スキーマの形式

JSON スキーマ形式には、Chrome からの追加要件がいくつかあります。

  • 最上位スキーマの型は object にする必要があります。
  • 最上位の objectadditionalProperties を含めることはできません。宣言された properties は、この拡張機能のポリシーです。
  • 各スキーマには、$ref 値または type を 1 つ指定する必要があります。

スキーマが無効な場合、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" }
       
}
     
}
   
}
 
}
}