feat: add clipboard privacy options #49567
Open
+56
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
This is my attempt to resolve #49466. I don't think it's quite ready, so
I'm opening it as a draft PR.I welcome comments and critiques to help refine this.I've added the ability to define the privacy of a write to the clipboard. While the original issue was requesting for the Apple platform, this PR should be cross-platform (to the extend that Chromium upstream actually uses the API's I'm depending on).
Upstream API's Used
(links pinned to Chromium 144.0.7559.60, the version used on the current major: Electron 40.0.0)
Our clipboard API uses the
ScopedClipboardWriterclass from upstream to manage writing to the clipboard. This class has a private member variable calledprivacy_types_that holds an enumeration of privacy settings for a write to the clipboard.Unfortunately, that member variable isn't writable directory, and the only mechanisms for manipulating it are the functions
MarkAsConfidential()andMarkAsOffTheRecord(). To avoid patching Chromium, I simply take these and expose them as mutually-exclusive values for aprivacyoption in theclipboardwriting API's in JS-land. I took the "privacy type" name for the name in of the enum in C++-land (even though it's now not really a one-to-one mapping) because I wasn't sure what else to call it.Local Testing
Final note: while this does compile and build, I haven't fully tested if the behavior actually works as I expect it to. I plan to do so soon, though.I have tested this briefly between my MacBook and my iPad and it seems to work well enough.
npm testpassesRelease Notes
Notes: Added clipboard privacy options to
clipboardwriting API's.