diff --git a/ClipboardAPI/clipboard-change-event-explainer.md b/ClipboardAPI/clipboard-change-event-explainer.md index 4a9762823..8266295b4 100644 --- a/ClipboardAPI/clipboard-change-event-explainer.md +++ b/ClipboardAPI/clipboard-change-event-explainer.md @@ -172,13 +172,14 @@ One clear issue with this approach is that we are providing all the methods of D ### 6.1 APIs provided by all OS to listen to clipboardchange event: -| OS | API | +| OS | Native API available | |---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Windows | We can use the [AddClipboardFormatListener](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-addclipboardformatlistener) function (winuser.h) which posts a [WM_CLIPBOARDUPDATE](https://learn.microsoft.com/en-us/windows/win32/dataxchg/wm-clipboardupdate) message whenever the clipboard changes. | -| MacOS | No API provided, need to poll OS clipboard for changes | -| Linux | TBD | -| ChromeOS | TBD | -| Android / iOS | TBD | +| Windows | ✔ We can use the [AddClipboardFormatListener function (winuser.h)](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-addclipboardformatlistener) which posts a [WM_CLIPBOARDUPDATE](https://learn.microsoft.com/en-us/windows/win32/dataxchg/wm-clipboardupdate) message whenever the clipboard changes. | +| MacOS | ✘ No API provided, need to poll OS clipboard for changes. To detect clipboard changes, we will poll for value changes to “[changecount](https://developer.apple.com/documentation/uikit/uipasteboard/changecount?language=objc)” provided by the OS which should be more efficient than polling entire contents. | +| Linux X11/Wayland | ✔ In Chromium, the Wayland/X11 implementation of clipboard already calls ui::ClipboardMonitor on clipboard change, so no further changes should be required. - X11 mechanism [code](https://source.chromium.org/chromium/chromium/src/+/main:ui/base/x/x11_clipboard_helper.cc;drc=d815f515138991af2aa5b1d07c64906fd8a7366b;l=68), Wayland mechanism [code](https://source.chromium.org/chromium/chromium/src/+/main:ui/ozone/platform/wayland/host/wayland_data_device.cc;drc=d815f515138991af2aa5b1d07c64906fd8a7366b;l=182) | +| Android | ✔ API to monitor clipboard change available - [here](https://developer.android.com/reference/android/content/ClipboardManager.OnPrimaryClipChangedListener). | +| iOS | ✔ [changedNotification](https://developer.apple.com/documentation/uikit/uipasteboard/changednotification) API available. Note that this API and the types API both don't require any user attention to be used unlike other APIs which read clipboard contents on iOS. | +| ChromeOS | ✔ By default Chrome uses the custom in-memory implementation of the clipboard - [ui::ClipboardNonBacked](https://source.chromium.org/chromium/chromium/src/+/main:ui/base/clipboard/clipboard_non_backed.h), which already invokes [ui::ClipboardMonitor::NotifyClipboardDataChanged()](https://source.chromium.org/chromium/chromium/src/+/main:ui/base/clipboard/clipboard_monitor.h;drc=e7eae5389783001142ba2134e853e987a2d3fe50;l=34) upon clipboard change. It can also use Ozone clipboard implementation from Linux when `--use-system-clipboard` is supplied to the chrome binary; then it will just use the same implementation as on Linux. | ### 6.2 Permission prompt mechanism in various browsers