Tệp kê khai – Mô-đun Nacl

Một hoặc nhiều ánh xạ từ loại MIME đến mô-đun Native Client xử lý từng loại. Ví dụ: mã in đậm trong đoạn mã sau đây đăng ký mô-đun Native Client làm trình xử lý nội dung cho loại MIME bảng tính OpenOffice.

{
  "name": "Native Client OpenOffice Spreadsheet Viewer",
  "version": "0.1",
  "description": "Open OpenOffice spreadsheets, right in your browser.",
  "nacl_modules": [{
    "path": "OpenOfficeViewer.nmf",
    "mime_type": "application/vnd.oasis.opendocument.spreadsheet"
  }]
}

Giá trị của "path" là vị trí của tệp kê khai Native Client (tệp .nmf) trong thư mục tiện ích. Để biết thêm thông tin về tệp Native Client và tệp .nmf, hãy xem Tổng quan về kỹ thuật của Native Client.

Mỗi loại MIME chỉ có thể liên kết với một tệp .nmf, nhưng một tệp .nmf có thể xử lý nhiều loại MIME. Ví dụ sau đây cho thấy một tiện ích có 2 tệp .nmf xử lý 3 loại MIME.

{
  "name": "Spreadsheet Viewer",
  "version": "0.1",
  "description": "Open OpenOffice and Excel spreadsheets, right in your browser.",
  "nacl_modules": [{
    "path": "OpenOfficeViewer.nmf",
    "mime_type": "application/vnd.oasis.opendocument.spreadsheet"
  },
  {
    "path": "OpenOfficeViewer.nmf",
    "mime_type": "application/vnd.oasis.opendocument.spreadsheet-template"
  },
  {
    "path": "ExcelViewer.nmf",
    "mime_type": "application/excel"
  }]
}
Lưu ý: Bạn có thể sử dụng các mô-đun Native Client trong các tiện ích mà không cần chỉ định "nacl_modules". Chỉ sử dụng "nacl_modules" nếu bạn muốn trình duyệt sử dụng mô-đun Native Client để hiển thị một loại nội dung cụ thể.