feat: route deprecated sync clipboard read through permission checks (#45471)

* feat: route deprecated clipboard commands through permission checks

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* docs: address review feedback

Co-authored-by: deepak1556 <hop2deep@gmail.com>

* fix: enable checks for child windows

Co-authored-by: deepak1556 <hop2deep@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: deepak1556 <hop2deep@gmail.com>
This commit is contained in:
trop[bot] 2025-02-05 14:10:43 -05:00 committed by GitHub
parent 51170c3652
commit 46c9ed61da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 441 additions and 35 deletions

View file

@ -26,3 +26,16 @@ mojom("plugin") {
"//mojo/public/mojom/base",
]
}
mojom("web_contents_utility") {
# We don't want Blink variants of these bindings to be generated.
disable_variants = true
sources = [ "web_contents_utility.mojom" ]
public_deps = [
"//content/public/common:interfaces",
"//third_party/blink/public/mojom/tokens",
"//url/mojom:url_mojom_origin",
]
}

View file

@ -25,17 +25,6 @@ interface ElectronAutofillDriver {
HideAutofillPopup();
};
interface ElectronWebContentsUtility {
// Informs underlying WebContents that first non-empty layout was performed
// by compositor.
OnFirstNonEmptyLayout();
SetTemporaryZoomLevel(double zoom_level);
[Sync]
DoGetZoomLevel() => (double result);
};
interface ElectronApiIPC {
// Emits an event on |channel| from the ipcMain JavaScript object in the main
// process.

View file

@ -226,6 +226,8 @@ v8::Local<v8::Value> Converter<blink::PermissionType>::ToV8(
return StringToV8(isolate, "speaker-selection");
case blink::PermissionType::WEB_APP_INSTALLATION:
return StringToV8(isolate, "web-app-installation");
case blink::PermissionType::DEPRECATED_SYNC_CLIPBOARD_READ:
return StringToV8(isolate, "deprecated-sync-clipboard-read");
case blink::PermissionType::NUM:
break;
}

View file

@ -205,6 +205,11 @@ inline constexpr std::string_view kEnablePreferredSizeMode =
inline constexpr std::string_view kHiddenPage = "hiddenPage";
inline constexpr std::string_view kSpellcheck = "spellcheck";
// Enables the permission managed support for
// document.execCommand("paste").
inline constexpr std::string_view kEnableDeprecatedPaste =
"enableDeprecatedPaste";
} // namespace options
// Following are actually command line switches, should be moved to other files.

View file

@ -0,0 +1,25 @@
module electron.mojom;
import "third_party/blink/public/mojom/permissions/permission_status.mojom";
import "third_party/blink/public/mojom/tokens/tokens.mojom";
import "url/mojom/origin.mojom";
enum PermissionName {
DEPRECATED_SYNC_CLIPBOARD_READ,
};
interface ElectronWebContentsUtility {
// Informs underlying WebContents that first non-empty layout was performed
// by compositor.
OnFirstNonEmptyLayout();
SetTemporaryZoomLevel(double zoom_level);
[Sync]
DoGetZoomLevel() => (double result);
[Sync]
CanAccessClipboardDeprecated(
PermissionName name,
blink.mojom.LocalFrameToken frame_token) => (blink.mojom.PermissionStatus status);
};