بيان مناطق التخزين

على عكس منطقتَي التخزين "local" و"sync"، يجب أن تكون بنية مساحة التخزين "managed" هي تم تعريفه باعتباره مخطط JSON ويتم التحقّق من صحته بدقة من خلال Chrome. يجب تخزين هذا المخطط في يُشار إليه بالسمة "managed_schema" لمفتاح البيان "storage" ويشير إلى سياسات المؤسسة التي تدعمها الإضافة.

تشبه السياسات الخيارات ولكن يتم ضبطها بواسطة مشرف النظام بدلاً من المستخدم، السماح بإعداد الإضافة مسبقًا لجميع مستخدمي المؤسسة. الاطّلاع على كيفية معالجة Chrome السياسات للاطّلاع على أمثلة من Chrome نفسه.

بعد إعلان السياسات، يمكن الاطّلاع عليها من خلال واجهة برمجة التطبيقات storage.managed. الأمر يعود إلى الإضافة لفرض السياسات التي يضبطها المشرف.

نموذج JSON.json

تشير السمة storage.managed_schema إلى ملف ضمن امتداد يتضمّن السياسة. Google.

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

سيقوم Chrome بعد ذلك بتحميل هذه السياسات من نظام التشغيل الأساسي ومن تطبيقات Google المستخدمين المسجّلين الدخول. يتم تنشيط الحدث storage.onChanged عند رصد تغيير في السياسة. بما في ذلك أثناء توقّف المتصفّح عن العمل إذا كانت الإضافة تستخدم صفحات الأحداث. يمكنك إثبات الملكية السياسات التي حمَّلها Chrome في chrome://policy.

تنسيق المخطط

يتضمن تنسيق مخطط JSON بعض المتطلبات الإضافية من Chrome:

  • يجب أن يكون مخطط المستوى الأعلى من النوع object.
  • لا يمكن أن يحتوي object على المستوى الأعلى على additionalProperties. إنّ properties المعلَن عنها هي السياسات المتعلقة بهذه الإضافة.
  • يجب أن يحتوي كل مخطط على قيمة $ref أو قيمة type واحدة بالضبط.

وإذا كان المخطط غير صالح، فلن يقوم Chrome بتحميل الإضافة وسيشير إلى سبب التحقق من صحة المخطط. وإذا كانت قيمة السياسة لا تتوافق مع المخطط، فلن تكون تم نشره من قِبل واجهة برمجة تطبيقات storage.managed

نموذج مخطط

{
  "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" }
        }
      }
    }
  }
}