|
@@ -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 d21e492cac6b6750dfab320e35c94841df54e2e4..3c05ae9bf223e9b3b6ca6d4c05be31c517e2a996 100644
|
|
|
+--- a/components/permissions/permission_util.cc
|
|
|
++++ b/components/permissions/permission_util.cc
|
|
|
+@@ -364,6 +364,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 4e6b9b4073892051a72e40808365fe59c1e77903..e4403c1e95510b7846cc57f3c5a95a41480149f5 100644
|
|
|
+--- a/content/browser/permissions/permission_controller_impl.cc
|
|
|
++++ b/content/browser/permissions/permission_controller_impl.cc
|
|
|
+@@ -94,6 +94,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 baa74bd6c7bf6350f4ef06f00d94d1d517b43943..2d4f846f08383e22e42c55f783eb1041de4cd258 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 20ebd3f2f5fa7b16ad1b2081ca41b007bc78a354..b248e3135182d36a6524c2e626157a0e4c759d14 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,
|
|
|
+@@ -300,7 +300,7 @@ bool ClipboardCommands::PasteSupported(LocalFrame* frame) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return frame->GetContentSettingsClient() &&
|
|
|
+- frame->GetContentSettingsClient()->AllowReadFromClipboard();
|
|
|
++ frame->GetContentSettingsClient()->AllowReadFromClipboardSync();
|
|
|
+ }
|
|
|
+
|
|
|
+ bool ClipboardCommands::ExecuteCopy(LocalFrame& frame,
|