use embedder_traits::EmbedderMsg;
use ipc_channel::ipc::channel;
use script_traits::{ScriptMsg, ScriptToConstellationChan};
pub trait ClipboardProvider {
fn clipboard_contents(&mut self) -> String;
fn set_clipboard_contents(&mut self, _: String);
}
impl ClipboardProvider for ScriptToConstellationChan {
fn clipboard_contents(&mut self) -> String {
let (tx, rx) = channel().unwrap();
self.send(ScriptMsg::ForwardToEmbedder(
EmbedderMsg::GetClipboardContents(tx),
))
.unwrap();
rx.recv().unwrap()
}
fn set_clipboard_contents(&mut self, s: String) {
self.send(ScriptMsg::ForwardToEmbedder(
EmbedderMsg::SetClipboardContents(s),
))
.unwrap();
}
}