저장소 영역에 관한 매니페스트

localsync 저장소 영역과 달리 managed 저장소 영역은 그 구조를 JSON 스키마로 선언해야 하며 Chrome에서 엄격하게 검증됩니다. 이 스키마는 "storage" 매니페스트 키의 "managed_schema" 속성으로 지정된 파일에 저장되어야 하며 앱에서 지원하는 엔터프라이즈 정책을 선언합니다.

정책은 옵션과 유사하지만 사용자 대신 시스템 관리자가 구성하므로 조직의 모든 사용자를 위해 앱을 사전 구성할 수 있습니다. Chrome 자체의 예시를 보려면 Chrome에서 정책을 처리하는 방법을 참고하세요.

정책을 선언한 후 storage.managed API에서 정책을 읽을 수 있습니다. 관리자가 구성한 정책을 시행하는 것은 앱에 달려 있습니다.

샘플 manifest.json

storage.managed_schema 속성은 앱 내에 있는 정책 스키마가 포함된 파일을 나타냅니다.

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

그러면 Chrome은 기본 운영체제와 로그인한 사용자의 Google 앱에서 이러한 정책을 로드합니다. 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" }
       
}
     
}
   
}
 
}
}