Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / extensions / browser / api / virtual_keyboard_private / virtual_keyboard_delegate.h
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.
4
5 #ifndef EXTENSIONS_BROWSER_API_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_DELEGATE_H_
6 #define EXTENSIONS_BROWSER_API_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_DELEGATE_H_
7
8 #include "base/macros.h"
9 #include "base/strings/string16.h"
10 #include "base/values.h"
11 #include "content/public/browser/browser_thread.h"
12
13 namespace extensions {
14
15 class VirtualKeyboardDelegate {
16  public:
17   virtual ~VirtualKeyboardDelegate() {}
18
19   // Fetch information about the preferred configuration of the keyboard. On
20   // exit, |settings| is populated with the keyboard configuration. Returns true
21   // if successful.
22   virtual bool GetKeyboardConfig(base::DictionaryValue* settings) = 0;
23
24   // Dismiss the virtual keyboard without changing input focus. Returns true if
25   // successful.
26   virtual bool HideKeyboard() = 0;
27
28   // Insert |text| verbatim into a text area. Returns true if successful.
29   virtual bool InsertText(const base::string16& text) = 0;
30
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;
34
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;
38
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;
43
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;
49
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
55   // successful.
56   virtual bool SendKeyEvent(const std::string& type,
57                             int char_value,
58                             int key_code,
59                             const std::string& key_name,
60                             int modifiers) = 0;
61
62   // Launches the settings app. Returns true if successful.
63   virtual bool ShowLanguageSettings() = 0;
64 };
65
66 }  // namespace extensions
67
68 #endif  // EXTENSIONS_BROWSER_API_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_DELEGATE_H_