從 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"
}]
}
「路徑」的值是擴充功能目錄中 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」。