| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // The <code>chrome.clipboard</code> API is provided to allow users to | 5 // The <code>chrome.clipboard</code> API is provided to allow users to |
| 6 // access data of the clipboard. This is a temporary solution for | 6 // access data of the clipboard. This is a temporary solution for |
| 7 // chromeos platform apps until open-web alternative is available. It will be | 7 // chromeos platform apps until open-web alternative is available. It will be |
| 8 // deprecated once open-web solution is available, which could be in 2017 Q2. | 8 // deprecated once open-web solution is available, which could be in 2017 Q4. |
| 9 [platforms=("chromeos"), | 9 [platforms=("chromeos"), |
| 10 implemented_in="extensions/browser/api/clipboard/clipboard_api.h"] | 10 implemented_in="extensions/browser/api/clipboard/clipboard_api.h"] |
| 11 namespace clipboard { | 11 namespace clipboard { |
| 12 // Supported image types. | 12 // Supported image types. |
| 13 enum ImageType {png, jpeg}; | 13 enum ImageType {png, jpeg}; |
| 14 | 14 |
| 15 enum DataItemType {textPlain, textHtml}; |
| 16 |
| 17 // Additional data item to be added along with the |image_data| to describe |
| 18 // the |image_data|. |
| 19 dictionary AdditionalDataItem { |
| 20 // Type of the additional data item. |
| 21 DataItemType type; |
| 22 |
| 23 // Content of the additional data item. Either the plain text string if |
| 24 // |type| is "textPlain" or markup string if |type| is "textHtml". The |
| 25 // data can not exceed 2MB. |
| 26 DOMString data; |
| 27 }; |
| 28 |
| 15 interface Events { | 29 interface Events { |
| 16 // Fired when clipboard data changes. | 30 // Fired when clipboard data changes. |
| 17 // Requires clipboard and clipboardRead permissions for adding listener to | 31 // Requires clipboard and clipboardRead permissions for adding listener to |
| 18 // chrome.clipboard.onClipboardDataChanged event. | 32 // chrome.clipboard.onClipboardDataChanged event. |
| 19 // After this event fires, the clipboard data is available by calling | 33 // After this event fires, the clipboard data is available by calling |
| 20 // document.execCommand('paste'). | 34 // document.execCommand('paste'). |
| 21 static void onClipboardDataChanged(); | 35 static void onClipboardDataChanged(); |
| 22 }; | 36 }; |
| 23 | 37 |
| 24 callback SetImageDataCallback = void(); | 38 callback SetImageDataCallback = void(); |
| 25 | 39 |
| 26 interface Functions { | 40 interface Functions { |
| 27 // Sets image data to clipboard. | 41 // Sets image data to clipboard. |
| 28 // | 42 // |
| 29 // |image_data|: The encoded image data. | 43 // |imageData|: The encoded image data. |
| 30 // |type|: The type of image being passed. | 44 // |type|: The type of image being passed. |
| 45 // |additionalItems|: Additional data items for describing image data. |
| 31 // The callback is called with <code>chrome.runtime.lastError</code> | 46 // The callback is called with <code>chrome.runtime.lastError</code> |
| 32 // set to error code if there is an error. | 47 // set to error code if there is an error. |
| 33 // Requires clipboard and clipboardWrite permissions. | 48 // Requires clipboard and clipboardWrite permissions. |
| 34 static void setImageData(ArrayBuffer image_data, | 49 static void setImageData(ArrayBuffer imageData, |
| 35 ImageType type, | 50 ImageType type, |
| 51 optional AdditionalDataItem[] additionalItems, |
| 36 SetImageDataCallback callback); | 52 SetImageDataCallback callback); |
| 37 }; | 53 }; |
| 38 }; | 54 }; |
| OLD | NEW |