简体   繁体   English

HTML页面内的Chrome应用处理MIME类型

[英]MIME type handling by Chrome app inside a HTML page

Is it possible to create a chrome app to render an embed tag with a specific MIME type inside a HTML page (like what Flash player does for .swf)? 是否可以创建chrome应用程序以在HTML页面内呈现具有特定MIME类型的嵌入标签(例如Flash Player对.swf的作用)? If yes, when does Chrome browser unload the app? 如果是,Chrome浏览器何时卸载该应用程序?

Thanks 谢谢

Yes, it's possible as documented in the distributing page. 是的,有可能如分发页面中所述。 Also see this other SO question . 另请参阅其他SO问题

For posterity: 对于后代:

Registering Native Client modules to handle MIME types If you want Chrome to use a Native Client module to display a particular type of content, you can associate the MIME type of that content with the Native Client module. 注册本机客户端模块以处理MIME类型如果希望Chrome使用本机客户端模块显示特定类型的内容,则可以将该内容的MIME类型与本机客户端模块相关联。 Use the nacl_modules attribute in the Chrome Web Store manifest file to register a Native Client module as the handler for one or more specific MIME types. 使用Chrome Web Store清单文件中的nacl_modules属性将本机客户端模块注册为一种或多种特定MIME类型的处理程序。 For example, the bold code in the snippet below registers a Native Client module as the content handler for the OpenOffice spreadsheet MIME type: 例如,以下代码段中的粗体代码将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"
   }]
}

The value of “path” is the location of a Native Client manifest file (.nmf) within the application directory. “ path”的值是本机客户端清单文件(.nmf)在应用程序目录中的位置。 For more information on Native Client manifest files, see Manifest Files . 有关Native Client清单文件的更多信息,请参见清单文件

The value of “mime_type” is a specific MIME type that you want the Native Client module to handle. “ mime_type”的值是您希望Native Client模块处理的特定MIME类型。 Each MIME type can be associated with only one .nmf file, but a single .nmf file might handle multiple MIME types. 每种MIME类型只能与一个.nmf文件关联,但是单个.nmf文件可以处理多种MIME类型。 The following example shows an extension with two .nmf files that handle three MIME types. 以下示例显示了带有两个处理三种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"
   }]
}

The nacl_modules attribute is optional—specify this attribute only if you want Chrome to use a Native Client module to display a particular type of content. nacl_modules属性是可选的-仅当您希望Chrome使用本机客户端模块显示特定类型的内容时,才指定此属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM