Welcome What's new in Chrome extensions Getting started API Reference Samples
Welcome What's new in Chrome extensions Getting started API Reference Samples

chrome.clipboard

This API is part of the deprecated Chrome Apps platform. Learn more about migrating your app.
  • Description

    The chrome.clipboard API is provided to allow users to access data of the clipboard. This is a temporary solution for chromeos platform apps until open-web alternative is available. It will be deprecated once open-web solution is available, which could be in 2017 Q4.

  • Permissions
    clipboard
  • Availability
    Dev channel only.

Summary

Types

AdditionalDataItem

Since Chrome 60.

Properties

  • data
    string

    Content of the additional data item. Either the plain text string if type is "textPlain" or markup string if type is "textHtml". The data can not exceed 2MB.

  • Type of the additional data item.

DataItemType

Since Chrome 60.

Enum

"textPlain", or "textHtml"

ImageType

Supported image types.

Enum

"png", or "jpeg"

Methods

setImageData

clipboard.setImageData(imageData: ArrayBuffer, type: ImageType, additionalItems: AdditionalDataItem[], callback: function)

Sets image data to clipboard.

Parameters

  • imageData
    ArrayBuffer

    Since Chrome 60.

    The encoded image data.

  • The type of image being passed.

  • additionalItems

    Since Chrome 60.

    Additional data items for describing image data. The callback is called with chrome.runtime.lastError set to error code if there is an error. Requires clipboard and clipboardWrite permissions.

  • callback
    function

    The callback parameter should be a function that looks like this:

    () => {...}

Events

onClipboardDataChanged

clipboard.onClipboardDataChanged.addListener(listener: function)

Fired when clipboard data changes. Requires clipboard and clipboardRead permissions for adding listener to chrome.clipboard.onClipboardDataChanged event. After this event fires, the clipboard data is available by calling document.execCommand('paste').

Event

  • listener
    function

    The listener parameter should be a function that looks like this:

    () => {...}
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.