aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/clipboard_provider.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/clipboard_provider.rs')
-rw-r--r--components/script/clipboard_provider.rs26
1 files changed, 17 insertions, 9 deletions
diff --git a/components/script/clipboard_provider.rs b/components/script/clipboard_provider.rs
index 666bf74c825..32d80bb3f32 100644
--- a/components/script/clipboard_provider.rs
+++ b/components/script/clipboard_provider.rs
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+use base::id::WebViewId;
use embedder_traits::EmbedderMsg;
use ipc_channel::ipc::channel;
use script_traits::{ScriptMsg, ScriptToConstellationChan};
@@ -13,19 +14,26 @@ pub trait ClipboardProvider {
fn set_clipboard_contents(&mut self, _: String);
}
-impl ClipboardProvider for ScriptToConstellationChan {
+pub(crate) struct EmbedderClipboardProvider {
+ pub constellation_sender: ScriptToConstellationChan,
+ pub webview_id: WebViewId,
+}
+
+impl ClipboardProvider for EmbedderClipboardProvider {
fn clipboard_contents(&mut self) -> String {
let (tx, rx) = channel().unwrap();
- self.send(ScriptMsg::ForwardToEmbedder(
- EmbedderMsg::GetClipboardContents(tx),
- ))
- .unwrap();
+ self.constellation_sender
+ .send(ScriptMsg::ForwardToEmbedder(
+ EmbedderMsg::GetClipboardContents(self.webview_id, tx),
+ ))
+ .unwrap();
rx.recv().unwrap()
}
fn set_clipboard_contents(&mut self, s: String) {
- self.send(ScriptMsg::ForwardToEmbedder(
- EmbedderMsg::SetClipboardContents(s),
- ))
- .unwrap();
+ self.constellation_sender
+ .send(ScriptMsg::ForwardToEmbedder(
+ EmbedderMsg::SetClipboardContents(self.webview_id, s),
+ ))
+ .unwrap();
}
}