Add Download.ShowDangerousDownloadConfirmationPrompt for Windows/CrOS
[chromium-blink-merge.git] / remoting / client / key_event_mapper.h
blob69e096944e387a34bf769e6da2a0d4102232811e
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_CLIENT_KEY_EVENT_MAPPER_H_
6 #define REMOTING_CLIENT_KEY_EVENT_MAPPER_H_
8 #include <map>
9 #include <set>
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/compiler_specific.h"
14 #include "remoting/protocol/input_filter.h"
16 namespace remoting {
18 // Filtering InputStub which can be used to re-map the USB keycodes of events
19 // before they are passed on to the next InputStub in the chain, or to trap
20 // events with specific USB keycodes for special handling.
21 class KeyEventMapper : public protocol::InputFilter {
22 public:
23 KeyEventMapper();
24 explicit KeyEventMapper(InputStub* input_stub);
25 virtual ~KeyEventMapper();
27 // Callback type for use with SetTrapCallback(), below.
28 typedef base::Callback<void(const protocol::KeyEvent&)> KeyTrapCallback;
30 // Sets the callback to which trapped keys will be delivered.
31 void SetTrapCallback(KeyTrapCallback callback);
33 // Causes events matching |usb_keycode| to be delivered to the trap callback.
34 // Trapped events are not dispatched to the next InputStub in the chain.
35 void TrapKey(uint32 usb_keycode, bool trap_key);
37 // Causes events matching |in_usb_keycode| to be mapped to |out_usb_keycode|.
38 // Keys are remapped at most once. Traps are processed before remapping.
39 void RemapKey(uint32 in_usb_keycode, uint32 out_usb_keycode);
41 // InputFilter overrides.
42 virtual void InjectKeyEvent(const protocol::KeyEvent& event) OVERRIDE;
44 private:
45 std::map<uint32,uint32> mapped_keys;
46 std::set<uint32> trapped_keys;
47 KeyTrapCallback trap_callback;
49 DISALLOW_COPY_AND_ASSIGN(KeyEventMapper);
52 } // namespace remoting
54 #endif // REMOTING_CLIENT_KEY_EVENT_MAPPER_H_