MIME type handling by Chrome app inside a HTML page

1.7k views Asked by At

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)? If yes, when does Chrome browser unload the app?

Thanks

1

There are 1 answers

0
JF Bastien On

Yes, it's possible as documented in the distributing page. Also see this other SO question.

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. 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. For example, the bold code in the snippet below registers a Native Client module as the content handler for the OpenOffice spreadsheet MIME type:

{
   "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. For more information on Native Client manifest files, see Manifest Files.

The value of “mime_type” is a specific MIME type that you want the Native Client module to handle. Each MIME type can be associated with only one .nmf file, but a single .nmf file might handle multiple MIME types. The following example shows an extension with two .nmf files that handle three MIME types.

{
   "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.