1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "remoting/protocol/clipboard_echo_filter.h"
7 #include "remoting/proto/event.pb.h"
12 ClipboardEchoFilter::ClipboardEchoFilter()
13 : host_stub_(nullptr),
14 client_stub_(nullptr),
19 ClipboardEchoFilter::~ClipboardEchoFilter() {
22 void ClipboardEchoFilter::set_client_stub(ClipboardStub
* client_stub
) {
23 client_stub_
= client_stub
;
26 void ClipboardEchoFilter::set_host_stub(ClipboardStub
* host_stub
) {
27 host_stub_
= host_stub
;
30 ClipboardStub
* ClipboardEchoFilter::client_filter() {
31 return &client_filter_
;
34 ClipboardStub
* ClipboardEchoFilter::host_filter() {
38 void ClipboardEchoFilter::InjectClipboardEventToClient(
39 const ClipboardEvent
& event
) {
43 if (event
.mime_type() == client_latest_mime_type_
&&
44 event
.data() == client_latest_data_
) {
47 client_stub_
->InjectClipboardEvent(event
);
50 void ClipboardEchoFilter::InjectClipboardEventToHost(
51 const ClipboardEvent
& event
) {
52 client_latest_mime_type_
= event
.mime_type();
53 client_latest_data_
= event
.data();
55 host_stub_
->InjectClipboardEvent(event
);
59 ClipboardEchoFilter::ClientFilter::ClientFilter(
60 ClipboardEchoFilter
* filter
) : filter_(filter
) {
63 void ClipboardEchoFilter::ClientFilter::InjectClipboardEvent(
64 const ClipboardEvent
& event
) {
65 filter_
->InjectClipboardEventToClient(event
);
68 ClipboardEchoFilter::HostFilter::HostFilter(
69 ClipboardEchoFilter
* filter
) : filter_(filter
) {
72 void ClipboardEchoFilter::HostFilter::InjectClipboardEvent(
73 const ClipboardEvent
& event
) {
74 filter_
->InjectClipboardEventToHost(event
);
77 } // namespace protocol
78 } // namespace remoting