18807b8ac2
Over plain http on a tailnet address the page is not a secure context and
navigator.clipboard is undefined, so the web engine refused every copy.
ClipboardReportingMessenger now answers clipboard calls through the
browser's legacy clipboard when the API is missing (web only, conditional
import): copy uses execCommand('copy') with a one-shot copy-event listener
(no focus or selection change); a paste key's Clipboard.getData takes the
browser's own paste event, the key reported not-handled so the browser
still fires it. A Paste button/menu says to use Ctrl+V or the https address.
Secure pages keep the engine path. Capture kit: --insecure and clipboard=.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
1.5 KiB
Dart
47 lines
1.5 KiB
Dart
import 'package:flutter/services.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import '../core/keyboard/key_modifier_sync.dart';
|
|
import 'clipboard_failures.dart';
|
|
import 'insecure_clipboard.dart';
|
|
import 'insecure_clipboard_host.dart';
|
|
|
|
/// The app's binding: Flutter's, with clipboard failures reported
|
|
/// ([ClipboardReportingMessenger]), the browser's legacy clipboard on a page
|
|
/// without the Clipboard API ([InsecureClipboard]) and, on the web, key events carrying the
|
|
/// modifiers their browser events hold ([KeyModifierSync]).
|
|
///
|
|
/// An entry point calls [ensureInitialized] before anything else creates a
|
|
/// binding.
|
|
class PipelinesBinding extends WidgetsFlutterBinding {
|
|
PipelinesBinding._();
|
|
|
|
static bool _created = false;
|
|
|
|
/// The binding, created on the first call.
|
|
static WidgetsBinding ensureInitialized() {
|
|
if (!_created) {
|
|
_created = true;
|
|
PipelinesBinding._();
|
|
}
|
|
return WidgetsBinding.instance;
|
|
}
|
|
|
|
@override
|
|
void initInstances() {
|
|
super.initInstances();
|
|
// The services binding hands key data to the framework only once the
|
|
// keyboard state is synced; the modifier sync goes in front of it then.
|
|
keyboard.syncKeyboardState().then((_) => installKeyModifierSync());
|
|
}
|
|
|
|
@override
|
|
BinaryMessenger createBinaryMessenger() {
|
|
final host = insecureClipboardHost();
|
|
return ClipboardReportingMessenger(
|
|
super.createBinaryMessenger(),
|
|
insecure: host == null ? null : InsecureClipboard(host),
|
|
);
|
|
}
|
|
}
|