blob: 6dadbbf58e46c14a253f7defe7c6acb9f2af2ef8 [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_PROTOCOL_CLIPBOARD_FILTER_H_
#define REMOTING_PROTOCOL_CLIPBOARD_FILTER_H_
#include "base/compiler_specific.h"
#include "base/memory/raw_ptr.h"
#include "remoting/protocol/clipboard_stub.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace remoting {
namespace protocol {
// Forwards clipboard events to |clipboard_stub|, if configured. Event
// forwarding may also be disabled independently of the configured
// |clipboard_stub|. ClipboardFilters initially have event forwarding enabled
// and no maximum size set. If |max_size| is configured, it will be used to
// limit the amount of data transferred when InjectClipboardEvent() is called.
class ClipboardFilter : public ClipboardStub {
public:
ClipboardFilter();
explicit ClipboardFilter(ClipboardStub* clipboard_stub);
ClipboardFilter(const ClipboardFilter&) = delete;
ClipboardFilter& operator=(const ClipboardFilter&) = delete;
~ClipboardFilter() override;
// Set the ClipboardStub that events will be forwarded to.
void set_clipboard_stub(ClipboardStub* clipboard_stub);
// Enable/disable forwarding of clipboard events to the ClipboardStub.
void set_enabled(bool enabled) { enabled_ = enabled; }
bool enabled() const { return enabled_; }
void set_max_size(size_t max_size) { max_size_ = max_size; }
// ClipboardStub interface.
void InjectClipboardEvent(const ClipboardEvent& event) override;
private:
raw_ptr<ClipboardStub> clipboard_stub_ = nullptr;
bool enabled_ = true;
absl::optional<size_t> max_size_;
};
} // namespace protocol
} // namespace remoting
#endif // REMOTING_PROTOCOL_CLIPBOARD_FILTER_H_