【发布时间】:2023-03-27 07:01:01
【问题描述】:
是否可以创建一个 chrome 应用程序以在 HTML 页面中呈现具有特定 MIME 类型的嵌入标签(就像 Flash 播放器对 .swf 所做的那样)?如果是,Chrome 浏览器何时卸载应用?
谢谢
【问题讨论】:
标签: google-chrome google-chrome-extension google-nativeclient cordova-chrome-app
是否可以创建一个 chrome 应用程序以在 HTML 页面中呈现具有特定 MIME 类型的嵌入标签(就像 Flash 播放器对 .swf 所做的那样)?如果是,Chrome 浏览器何时卸载应用?
谢谢
【问题讨论】:
标签: google-chrome google-chrome-extension google-nativeclient cordova-chrome-app
是的,正如distributing 页面中所述,这是可能的。另见other SO question。
为了后代:
注册 Native Client 模块以处理 MIME 类型 如果您希望 Chrome 使用 Native Client 模块来显示特定类型的内容,您可以将该内容的 MIME 类型与 Native Client 模块相关联。使用 Chrome Web Store 清单文件中的
nacl_modules属性将 Native Client 模块注册为一种或多种特定 MIME 类型的处理程序。例如,下面 sn-p 中的粗体代码将 Native Client 模块注册为 OpenOffice 电子表格 MIME 类型的内容处理程序:
{
"name": "My Native Client Spreadsheet Viewer",
"version": "0.1",
"description": "Open spreadsheets right in your browser.",
"nacl_modules": [{
"path": "SpreadsheetViewer.nmf",
"mime_type": "application/vnd.oasis.opendocument.spreadsheet"
}]
}
“路径”的值是本机客户端清单文件 (.nmf) 在应用程序目录中的位置。有关 Native Client 清单文件的更多信息,请参阅Manifest Files。
“mime_type”的值是您希望 Native Client 模块处理的特定 MIME 类型。每种 MIME 类型只能与一个 .nmf 文件相关联,但一个 .nmf 文件可能会处理多种 MIME 类型。以下示例显示了一个包含两个处理三种 MIME 类型的 .nmf 文件的扩展。
{
"name": "My Native Client Spreadsheet and Document Viewer",
"version": "0.1",
"description": "Open spreadsheets and documents right in your browser.",
"nacl_modules": [{
"path": "SpreadsheetViewer.nmf",
"mime_type": "application/vnd.oasis.opendocument.spreadsheet"
},
{
"path": "SpreadsheetViewer.nmf",
"mime_type": "application/vnd.oasis.opendocument.spreadsheet-template"
},
{
"path": "DocumentViewer.nmf",
"mime_type": "application/vnd.oasis.opendocument.text"
}]
}
nacl_modules属性是可选的 - 仅当您希望 Chrome 使用 Native Client 模块显示特定类型的内容时才指定此属性。
【讨论】: