chrome.mimeHandler

Description

Use the chrome.mimeHandler API to handle MIME type streams in third-party extensions.

Availability

Pending

Types

MimeHandlerOptions

Properties

  • enabled

    boolean

    Whether this handler is active for the given MIME type.

StreamInfo

Properties

  • embedded

    boolean

    True if loaded in an embedded context (iframe/embed/object).

  • mimeType

    string

    The MIME type of the intercepted content.

  • originalUrl

    string

    The original URL the user navigated to.

  • responseHeaders

    object

    HTTP response headers as key-value pairs.

  • streamUrl

    string

    The URL to fetch the stream data from.

  • tabId

    number

    The tab ID containing the document.

Methods

abortAndFallbackToNativeHandler()

Promise
chrome.mimeHandler.abortAndFallbackToNativeHandler(
  callback?: function,
)
: Promise<void>

Aborts current stream handling and hands the content off to the user agent's native handler. After this call the extension frame will be torn down; callers should not expect further execution.

Parameters

  • callback

    function optional

    The callback parameter looks like:

    () => void

Returns

  • Promise<void>

    Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.

getMimeHandlerOptions()

Promise
chrome.mimeHandler.getMimeHandlerOptions(
  mimeType: string,
  callback?: function,
)
: Promise<MimeHandlerOptions>

Reads the persisted options for a MIME type. Returns defaults (enabled=true) if none have been stored.

Parameters

  • mimeType

    string

    The MIME type whose options to read.

  • callback

    function optional

    The callback parameter looks like:

    (options: MimeHandlerOptions) => void

Returns

  • Promise resolved with the persisted options for the MIME type.

    Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.

getStreamInfo()

Promise
chrome.mimeHandler.getStreamInfo(
  callback?: function,
)
: Promise<StreamInfo>

Retrieves stream information for the current MIME handler context. Must be called from within a MIME handler extension page.

Parameters

  • callback

    function optional

    The callback parameter looks like:

    (info: StreamInfo) => void

Returns

  • Promise<StreamInfo>

    Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.

setMimeHandlerOptions()

Promise
chrome.mimeHandler.setMimeHandlerOptions(
  mimeType: string,
  options: MimeHandlerOptions,
  callback?: function,
)
: Promise<void>

Sets the configuration options for a specified MIME type.

Parameters

  • mimeType

    string

    The MIME type to configure.

  • The new options to use.

  • callback

    function optional

    The callback parameter looks like:

    () => void

Returns

  • Promise<void>

    Promise resolved when the configuration has been set.

    Promises are only supported for Manifest V3 and later, other platforms need to use callbacks.