Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / remoting / host / remote_input_filter.h
blob8645db1930ede600c24256b0a22969b223747b2f
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 #ifndef REMOTING_HOST_REMOTE_INPUT_FILTER_H_
6 #define REMOTING_HOST_REMOTE_INPUT_FILTER_H_
8 #include <list>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/time/time.h"
13 #include "remoting/protocol/input_event_tracker.h"
14 #include "remoting/protocol/input_stub.h"
16 namespace remoting {
18 // Filtering InputStub that filters remotely-injected input if it has been
19 // notified of local input recently.
20 class RemoteInputFilter : public protocol::InputStub {
21 public:
22 // Creates a filter forwarding events to the specified InputEventTracker.
23 // The filter needs a tracker to release buttons & keys when blocking input.
24 explicit RemoteInputFilter(protocol::InputEventTracker* event_tracker);
25 ~RemoteInputFilter() override;
27 // Informs the filter that local mouse activity has been detected. If the
28 // activity does not match events we injected then we assume that it is local,
29 // and block remote input for a short while.
30 void LocalMouseMoved(const webrtc::DesktopVector& mouse_pos);
32 // Informs the filter that injecting input causes an echo.
33 void SetExpectLocalEcho(bool expect_local_echo);
35 // InputStub overrides.
36 void InjectKeyEvent(const protocol::KeyEvent& event) override;
37 void InjectTextEvent(const protocol::TextEvent& event) override;
38 void InjectMouseEvent(const protocol::MouseEvent& event) override;
39 void InjectTouchEvent(const protocol::TouchEvent& event) override;
41 private:
42 bool ShouldIgnoreInput() const;
44 protocol::InputEventTracker* event_tracker_;
46 // Queue of recently-injected mouse positions used to distinguish echoes of
47 // injected events from movements from a local input device.
48 std::list<webrtc::DesktopVector> injected_mouse_positions_;
50 // Time at which local input events were most recently observed.
51 base::TimeTicks latest_local_input_time_;
53 // If |true| than the filter assumes that injecting input causes an echo.
54 bool expect_local_echo_;
56 DISALLOW_COPY_AND_ASSIGN(RemoteInputFilter);
59 } // namespace remoting
61 #endif // REMOTING_HOST_REMOTE_INPUT_FILTER_H_