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 EXTENSIONS_BROWSER_API_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_DELEGATE_H_
6 #define EXTENSIONS_BROWSER_API_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_DELEGATE_H_
8 #include "base/macros.h"
9 #include "base/strings/string16.h"
10 #include "base/values.h"
11 #include "content/public/browser/browser_thread.h"
13 namespace extensions
{
15 class VirtualKeyboardDelegate
{
17 virtual ~VirtualKeyboardDelegate() {}
19 // Fetch information about the preferred configuration of the keyboard. On
20 // exit, |settings| is populated with the keyboard configuration. Returns true
22 virtual bool GetKeyboardConfig(base::DictionaryValue
* settings
) = 0;
24 // Dismiss the virtual keyboard without changing input focus. Returns true if
26 virtual bool HideKeyboard() = 0;
28 // Insert |text| verbatim into a text area. Returns true if successful.
29 virtual bool InsertText(const base::string16
& text
) = 0;
31 // Notifiy system that keyboard loading is complete. Used in UMA stats to
32 // track loading performance. Returns true if the notification was handled.
33 virtual bool OnKeyboardLoaded() = 0;
35 // Indicate if settings are accessible and enabled based on current state.
36 // For example, settings should be blocked when the session is locked.
37 virtual bool IsLanguageSettingsEnabled() = 0;
39 // Activate and lock the virtual keyboad on screen or dismiss the keyboard
40 // regardless of the state of text focus. Used in a11y mode to allow typing
41 // hotkeys without the need for text focus. Returns true if successful.
42 virtual bool LockKeyboard(bool state
) = 0;
44 // Moves the text caret. |swipe_direction| indicates the direction to move the
45 // caret. Swipes can be in one or 4 directions denoted by an enumerated value.
46 // |modifier_flags| indicates which keyboard modifier keys (e.g. shift or alt)
47 // are being held during the swipe. Returns true if successful.
48 virtual bool MoveCursor(int swipe_direction
, int modifier_flags
) = 0;
50 // Dispatches a virtual key event. |type| indicates if the event is a keydown
51 // or keyup event. |char_value| is the unicode value for the key. |key_code|
52 // is the code assigned to the key, which is independent of the state of
53 // modifier keys. |key_name| is the standardized w3c name for the key.
54 // |modifiers| indicates which modifier keys are active. Returns true if
56 virtual bool SendKeyEvent(const std::string
& type
,
59 const std::string
& key_name
,
62 // Launches the settings app. Returns true if successful.
63 virtual bool ShowLanguageSettings() = 0;
66 } // namespace extensions
68 #endif // EXTENSIONS_BROWSER_API_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_DELEGATE_H_