|
@@ -0,0 +1,114 @@
|
|
|
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
+From: deepak1556 <[email protected]>
|
|
|
+Date: Thu, 30 Jan 2025 20:28:38 +0900
|
|
|
+Subject: feat: separate content settings callback for sync and async clipboard
|
|
|
+
|
|
|
+`AllowReadFromClipboard` is called from both the types without a way to differentiate.
|
|
|
+
|
|
|
+[sync path] - third_party/blink/renderer/core/editing/commands/clipboard_commands.cc
|
|
|
+[async path] - third_party/blink/renderer/modules/clipboard/clipboard_promise.cc
|
|
|
+
|
|
|
+This patch adds a new callback to separate these two paths so that we
|
|
|
+can have sync permission checks for the sync path.
|
|
|
+
|
|
|
+Additionally, `blink::PermissionType::DEPRECATED_SYNC_CLIPBOARD_READ`
|
|
|
+has been added to support type conversion in permission policy checks. We have extended
|
|
|
+`blink::PermissionType` in `electron::WebContentsPermissionHelper::PermissionType`
|
|
|
+but it is hard to import the latter into the content permission layer checks.
|
|
|
+
|
|
|
+This patch will be removed when the deprecated sync api support is
|
|
|
+removed.
|
|
|
+
|
|
|
+diff --git a/components/permissions/permission_util.cc b/components/permissions/permission_util.cc
|
|
|
+index 0265815ae3b300c1c0637686e212d3a1c55fdd1b..eb7ea287de24a2563604e639de3bb783d80d98eb 100644
|
|
|
+--- a/components/permissions/permission_util.cc
|
|
|
++++ b/components/permissions/permission_util.cc
|
|
|
+@@ -384,6 +384,7 @@ ContentSettingsType PermissionUtil::PermissionTypeToContentSettingsTypeSafe(
|
|
|
+ return ContentSettingsType::AUTOMATIC_FULLSCREEN;
|
|
|
+ case PermissionType::WEB_APP_INSTALLATION:
|
|
|
+ return ContentSettingsType::WEB_APP_INSTALLATION;
|
|
|
++ case PermissionType::DEPRECATED_SYNC_CLIPBOARD_READ:
|
|
|
+ case PermissionType::NUM:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+diff --git a/content/browser/permissions/permission_controller_impl.cc b/content/browser/permissions/permission_controller_impl.cc
|
|
|
+index e991887c103618b35688cf72307ca05fdb202e6e..54894f3412d42264eae80d767be5215e52f08184 100644
|
|
|
+--- a/content/browser/permissions/permission_controller_impl.cc
|
|
|
++++ b/content/browser/permissions/permission_controller_impl.cc
|
|
|
+@@ -86,6 +86,7 @@ PermissionToSchedulingFeature(PermissionType permission_name) {
|
|
|
+ case PermissionType::POINTER_LOCK:
|
|
|
+ case PermissionType::AUTOMATIC_FULLSCREEN:
|
|
|
+ case PermissionType::WEB_APP_INSTALLATION:
|
|
|
++ case PermissionType::DEPRECATED_SYNC_CLIPBOARD_READ:
|
|
|
+ return std::nullopt;
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/third_party/blink/common/permissions/permission_utils.cc b/third_party/blink/common/permissions/permission_utils.cc
|
|
|
+index dfcd99a4336db5c5b8b722c6612b8abbf419a08f..9f074285203e6ee408abf8275f3070221b0d25c0 100644
|
|
|
+--- a/third_party/blink/common/permissions/permission_utils.cc
|
|
|
++++ b/third_party/blink/common/permissions/permission_utils.cc
|
|
|
+@@ -99,6 +99,8 @@ std::string GetPermissionString(PermissionType permission) {
|
|
|
+ return "AutomaticFullscreen";
|
|
|
+ case PermissionType::WEB_APP_INSTALLATION:
|
|
|
+ return "WebAppInstallation";
|
|
|
++ case PermissionType::DEPRECATED_SYNC_CLIPBOARD_READ:
|
|
|
++ return "DeprecatedSyncClipboardRead";
|
|
|
+ case PermissionType::NUM:
|
|
|
+ NOTREACHED();
|
|
|
+ }
|
|
|
+@@ -171,6 +173,7 @@ PermissionTypeToPermissionsPolicyFeature(PermissionType permission) {
|
|
|
+ case PermissionType::NOTIFICATIONS:
|
|
|
+ case PermissionType::KEYBOARD_LOCK:
|
|
|
+ case PermissionType::POINTER_LOCK:
|
|
|
++ case PermissionType::DEPRECATED_SYNC_CLIPBOARD_READ:
|
|
|
+ return std::nullopt;
|
|
|
+
|
|
|
+ case PermissionType::NUM:
|
|
|
+diff --git a/third_party/blink/public/common/permissions/permission_utils.h b/third_party/blink/public/common/permissions/permission_utils.h
|
|
|
+index ae03b7f099d30c157cfda7d1beb7c535d3615471..ca287e7a5271ee83c393de6c1fe347973f4292ba 100644
|
|
|
+--- a/third_party/blink/public/common/permissions/permission_utils.h
|
|
|
++++ b/third_party/blink/public/common/permissions/permission_utils.h
|
|
|
+@@ -64,6 +64,7 @@ enum class PermissionType {
|
|
|
+ AUTOMATIC_FULLSCREEN = 40,
|
|
|
+ HAND_TRACKING = 41,
|
|
|
+ WEB_APP_INSTALLATION = 42,
|
|
|
++ DEPRECATED_SYNC_CLIPBOARD_READ = 43,
|
|
|
+
|
|
|
+ // Always keep this at the end.
|
|
|
+ NUM,
|
|
|
+diff --git a/third_party/blink/public/platform/web_content_settings_client.h b/third_party/blink/public/platform/web_content_settings_client.h
|
|
|
+index 28f616f21f998c7cd1c794e58efaccf9e6c11e6e..c64896642209124e500db2ed6fe2357e426cd10b 100644
|
|
|
+--- a/third_party/blink/public/platform/web_content_settings_client.h
|
|
|
++++ b/third_party/blink/public/platform/web_content_settings_client.h
|
|
|
+@@ -55,6 +55,9 @@ class WebContentSettingsClient {
|
|
|
+ // Controls whether access to write the clipboard is allowed for this frame.
|
|
|
+ virtual bool AllowWriteToClipboard() { return false; }
|
|
|
+
|
|
|
++ // Controls whether synchronous access to read the clipboard is allowed for this frame.
|
|
|
++ virtual bool AllowReadFromClipboardSync() { return false; }
|
|
|
++
|
|
|
+ // Controls whether to enable MutationEvents for this frame.
|
|
|
+ // The common use case of this method is actually to selectively disable
|
|
|
+ // MutationEvents, but it's been named for consistency with the rest of the
|
|
|
+diff --git a/third_party/blink/renderer/core/editing/commands/clipboard_commands.cc b/third_party/blink/renderer/core/editing/commands/clipboard_commands.cc
|
|
|
+index 271ca7ba88fc92b8f6bad5ee4cffedf7f1b05aee..d8d01062de4af45a59eb10a1c0fa046a4adf1894 100644
|
|
|
+--- a/third_party/blink/renderer/core/editing/commands/clipboard_commands.cc
|
|
|
++++ b/third_party/blink/renderer/core/editing/commands/clipboard_commands.cc
|
|
|
+@@ -121,7 +121,7 @@ bool ClipboardCommands::CanReadClipboard(LocalFrame& frame,
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return frame.GetContentSettingsClient() &&
|
|
|
+- frame.GetContentSettingsClient()->AllowReadFromClipboard();
|
|
|
++ frame.GetContentSettingsClient()->AllowReadFromClipboardSync();
|
|
|
+ }
|
|
|
+
|
|
|
+ bool ClipboardCommands::CanWriteClipboard(LocalFrame& frame,
|
|
|
+@@ -310,7 +310,7 @@ bool ClipboardCommands::PasteSupported(LocalFrame* frame) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return frame->GetContentSettingsClient() &&
|
|
|
+- frame->GetContentSettingsClient()->AllowReadFromClipboard();
|
|
|
++ frame->GetContentSettingsClient()->AllowReadFromClipboardSync();
|
|
|
+ }
|
|
|
+
|
|
|
+ bool ClipboardCommands::ExecuteCopy(LocalFrame& frame,
|