स्टोरेज की जगहों के लिए मेनिफ़ेस्ट

local और sync स्टोरेज एरिया के लिए, 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 का टाइप होना चाहिए.
  • टॉप लेवल 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" }
        }
      }
    }
  }
}