从 MIME 类型到处理每种类型的 Native Client 模块的一个或多个映射。例如,以下代码段中的粗体代码会将 Native Client 模块注册为 OpenOffice 电子表格 MIME 类型的内容处理程序。
{
"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"
}]
}
“path”的值是 Native Client 清单(.nmf
文件)在扩展程序目录中的位置。如需详细了解 Native Client 和 .nmf
文件,请参阅 Native Client 技术概览。
每个 MIME 类型只能与一个 .nmf
文件关联,但单个 .nmf
文件可以处理多个 MIME 类型。以下示例展示了一个扩展程序,其中包含两个 .nmf
文件,可处理三种 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"
}]
}
注意:您可以在扩展程序中使用 Native Client 模块,而无需指定“nacl_modules”。仅当您希望浏览器使用 Native Client 模块显示特定类型的内容时,才使用“nacl_modules”。