reveman | 5cacf70c | 2015-12-09 22:50:02 | [diff] [blame^] | 1 | // Copyright 2015 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. |
| 4 | |
| 5 | #ifndef COMPONENTS_EXO_KEYBOARD_DELEGATE_H_ |
| 6 | #define COMPONENTS_EXO_KEYBOARD_DELEGATE_H_ |
| 7 | |
| 8 | #include <vector> |
| 9 | |
| 10 | #include "base/time/time.h" |
| 11 | |
| 12 | namespace ui { |
| 13 | enum class DomCode; |
| 14 | } |
| 15 | |
| 16 | namespace exo { |
| 17 | class Keyboard; |
| 18 | class Surface; |
| 19 | |
| 20 | // Handles events on keyboards in context-specific ways. |
| 21 | class KeyboardDelegate { |
| 22 | public: |
| 23 | // Called at the top of the keyboard's destructor, to give observers a |
| 24 | // chance to remove themselves. |
| 25 | virtual void OnKeyboardDestroying(Keyboard* keyboard) = 0; |
| 26 | |
| 27 | // This should return true if |surface| is a valid target for this keyboard. |
| 28 | // E.g. the surface is owned by the same client as the keyboard. |
| 29 | virtual bool CanAcceptKeyboardEventsForSurface(Surface* surface) const = 0; |
| 30 | |
| 31 | // Called when keyboard focus enters a new valid target surface. |
| 32 | virtual void OnKeyboardEnter( |
| 33 | Surface* surface, |
| 34 | const std::vector<ui::DomCode>& pressed_keys) = 0; |
| 35 | |
| 36 | // Called when keyboard focus leaves a valid target surface. |
| 37 | virtual void OnKeyboardLeave(Surface* surface) = 0; |
| 38 | |
| 39 | // Called when pkeyboard key state changed. |pressed| is true when |key| |
| 40 | // was pressed and false if it was released. |
| 41 | virtual void OnKeyboardKey(base::TimeDelta time_stamp, |
| 42 | ui::DomCode key, |
| 43 | bool pressed) = 0; |
| 44 | |
| 45 | // Called when keyboard modifier state changed. |
| 46 | virtual void OnKeyboardModifiers(int modifier_flags) = 0; |
| 47 | |
| 48 | protected: |
| 49 | virtual ~KeyboardDelegate() {} |
| 50 | }; |
| 51 | |
| 52 | } // namespace exo |
| 53 | |
| 54 | #endif // COMPONENTS_EXO_KEYBOARD_DELEGATE_H_ |