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

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 Apps에서 이러한 정책을 로드합니다. storage.onChanged 이벤트는 앱에서 이벤트 페이지를 사용하는 경우 브라우저가 실행되지 않는 동안을 포함하여 정책 변경이 감지될 때마다 실행됩니다. Chrome이 로드한 정책은 chrome://policy에서 확인할 수 있습니다.

스키마 형식

JSON 스키마 형식에는 Chrome의 추가 요구사항이 있습니다.

  • 최상위 스키마는 object 유형이어야 합니다.
  • 최상위 objectadditionalProperties을 가질 수 없습니다. 선언된 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" }
        }
      }
    }
  }
}