Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / ui / events / ozone / layout / keyboard_layout_engine.h
blob766da2196b4d21303cfaab632312d1d1d458fa4b
1 // Copyright 2014 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 UI_OZONE_PUBLIC_KEYBOARD_LAYOUT_ENGINE_H_
6 #define UI_OZONE_PUBLIC_KEYBOARD_LAYOUT_ENGINE_H_
8 #include <string>
10 #include "base/strings/string16.h"
11 #include "ui/events/keycodes/keyboard_codes.h"
12 #include "ui/events/ozone/layout/events_ozone_layout_export.h"
14 namespace ui {
16 enum class DomCode;
17 enum class DomKey;
19 // A KeyboardLayoutEngine provides a platform-independent interface to
20 // key mapping. Key mapping provides a meaning (DomKey and character,
21 // and optionally Windows key code) for a physical key press (DomCode
22 // and modifier flags).
24 // This interface does not expose individual layouts because it must support
25 // platforms that only provide for one active system layout, and/or platforms
26 // where layouts have no accessible representation.
27 class EVENTS_OZONE_LAYOUT_EXPORT KeyboardLayoutEngine {
28 public:
29 KeyboardLayoutEngine() {}
30 virtual ~KeyboardLayoutEngine() {}
32 // Returns true if it is possible to change the current layout.
33 virtual bool CanSetCurrentLayout() const = 0;
35 // Sets the current layout; returns true on success.
36 // Drop-in replacement for ImeKeyboard::SetCurrentKeyboardLayoutByName();
37 // the argument string is defined by that interface (crbug.com/362698).
38 virtual bool SetCurrentLayoutByName(const std::string& layout_name) = 0;
40 // Returns true if the current layout makes use of the ISO Level 5 Shift key.
41 // Drop-in replacement for ImeKeyboard::IsISOLevel5ShiftAvailable().
42 virtual bool UsesISOLevel5Shift() const = 0;
44 // Returns true if the current layout makes use of the AltGr
45 // (ISO Level 3 Shift) key.
46 // Drop-in replacement for ImeKeyboard::IsAltGrAvailable().
47 virtual bool UsesAltGr() const = 0;
49 // Provides the meaning of a physical key.
51 // The caller must supply valid addresses for all the output parameters;
52 // the function must not use their initial values.
54 // Returns true if it can determine the DOM meaning (i.e. ui::DomKey and
55 // character) and the corresponding legacy KeyboardCode from the given
56 // physical state (ui::DomCode and ui::EventFlags), OR if it can determine
57 // that there is no meaning in the current layout (e.g. the key is unbound).
58 // In the latter case, the function sets *dom_key to UNIDENTIFIED, *character
59 // to 0, and *key_code to VKEY_UNKNOWN.
61 // Returns false if it cannot determine the meaning (and cannot determine
62 // that there is none); in this case it does not set any of the output
63 // parameters.
65 // TODO(kpschoedel): remove the platform_keycode output. crbug.com/442757
66 virtual bool Lookup(DomCode dom_code,
67 int event_flags,
68 DomKey* dom_key,
69 base::char16* character,
70 KeyboardCode* key_code,
71 uint32* platform_keycode) const = 0;
74 } // namespace ui
76 #endif // UI_OZONE_PUBLIC_KEYBOARD_LAYOUT_ENGINE_H_