Blink Clipboard: Implement Raw Clipboard API write.

- Adds ClipboardItem property raw, and plumbing/support for this property in
  `navigator.clipboard.write` (ClipboardPromise and ClipboardWriter).
- Adds a `RawClipboard` flag, to ensure this feature isn't accidentally
  activated via experimental flags or otherwise.
- Adds tests, including VirtualTestSuite and tentative tests, to verify that
  this works with the flag enabled, but is correctly disabled without the
  flag enabled.


Bug: 897289
Change-Id: I453bb0ad18d9e52a4f2054d0f124fc3e8d5b430d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1927003
Commit-Queue: Darwin Huang <[email protected]>
Reviewed-by: Matthew Denton <[email protected]>
Reviewed-by: Kentaro Hara <[email protected]>
Reviewed-by: Victor Costan <[email protected]>
Cr-Commit-Position: refs/heads/master@{#724804}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index ce3cd59..1c1bbc6 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -4839,6 +4839,11 @@
      FEATURE_VALUE_TYPE(switches::kAccountIdMigration)},
 #endif  // defined(OS_CHROMEOS)
 
+    // TODO(https://crbug.com/1032161): Implement and enable for ChromeOS.
+    {"raw-clipboard", flag_descriptions::kRawClipboardName,
+     flag_descriptions::kRawClipboardDescription, kOsMac | kOsWin | kOsLinux,
+     FEATURE_VALUE_TYPE(blink::features::kRawClipboard)},
+
     // NOTE: Adding a new flag requires adding a corresponding entry to enum
     // "LoginCustomFlags" in tools/metrics/histograms/enums.xml. See "Flag
     // Histograms" in tools/metrics/histograms/README.md (run the
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json
index 399a1ff1..64d6d9e 100644
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -3109,6 +3109,11 @@
     "expiry_milestone": 83
   },
   {
+    "name": "raw-clipboard",
+    "owners": ["huangdarwin", "pwnall"],
+    "expiry_milestone": 84
+  },
+  {
     "name": "reader-mode-heuristics",
     "owners": [ "mdjones", "wychen" ],
     // This flag is a utility for testing Reader Mode heuristics or force
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index cc0e88aea5..a485ba3 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -1727,6 +1727,11 @@
     "When a site wishes to show notifications, the usual modal dialog is "
     "replaced with a quieter version.";
 
+const char kRawClipboardName[] = "Raw Clipboard";
+const char kRawClipboardDescription[] =
+    "Allows raw / unsanitized clipboard content to be read and written. "
+    "See https://github.com/WICG/raw-clipboard-access.";
+
 const char kReducedReferrerGranularityName[] =
     "Reduce default 'referer' header granularity.";
 const char kReducedReferrerGranularityDescription[] =
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index 7e2f5195..4a2deb2e 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -1027,6 +1027,9 @@
 extern const char kQuietNotificationPromptsName[];
 extern const char kQuietNotificationPromptsDescription[];
 
+extern const char kRawClipboardName[];
+extern const char kRawClipboardDescription[];
+
 extern const char kReducedReferrerGranularityName[];
 extern const char kReducedReferrerGranularityDescription[];