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_PRIVATE_VIRTUAL_KEYBOARD_PRIVATE_API_H_
6 #define EXTENSIONS_BROWSER_API_VIRTUAL_KEYBOARD_PRIVATE_VIRTUAL_KEYBOARD_PRIVATE_API_H_
8 #include "base/compiler_specific.h"
9 #include "extensions/browser/browser_context_keyed_api_factory.h"
10 #include "extensions/browser/extension_function.h"
16 namespace extensions
{
18 class VirtualKeyboardPrivateInsertTextFunction
: public SyncExtensionFunction
{
20 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.insertText",
21 VIRTUALKEYBOARDPRIVATE_INSERTTEXT
);
24 ~VirtualKeyboardPrivateInsertTextFunction() override
{}
27 bool RunSync() override
;
30 class VirtualKeyboardPrivateMoveCursorFunction
: public SyncExtensionFunction
{
32 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.moveCursor",
33 VIRTUALKEYBOARDPRIVATE_MOVECURSOR
);
36 ~VirtualKeyboardPrivateMoveCursorFunction() override
{}
39 bool RunSync() override
;
42 class VirtualKeyboardPrivateSendKeyEventFunction
43 : public SyncExtensionFunction
{
45 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.sendKeyEvent",
46 VIRTUALKEYBOARDPRIVATE_SENDKEYEVENT
);
49 ~VirtualKeyboardPrivateSendKeyEventFunction() override
{}
52 bool RunSync() override
;
55 class VirtualKeyboardPrivateHideKeyboardFunction
56 : public SyncExtensionFunction
{
58 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.hideKeyboard",
59 VIRTUALKEYBOARDPRIVATE_HIDEKEYBOARD
);
62 ~VirtualKeyboardPrivateHideKeyboardFunction() override
{}
65 bool RunSync() override
;
68 class VirtualKeyboardPrivateLockKeyboardFunction
69 : public SyncExtensionFunction
{
71 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.lockKeyboard",
72 VIRTUALKEYBOARDPRIVATE_LOCKKEYBOARD
);
75 ~VirtualKeyboardPrivateLockKeyboardFunction() override
{}
78 bool RunSync() override
;
81 class VirtualKeyboardPrivateKeyboardLoadedFunction
82 : public SyncExtensionFunction
{
84 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.keyboardLoaded",
85 VIRTUALKEYBOARDPRIVATE_KEYBOARDLOADED
);
88 ~VirtualKeyboardPrivateKeyboardLoadedFunction() override
{}
91 bool RunSync() override
;
94 class VirtualKeyboardPrivateGetKeyboardConfigFunction
95 : public SyncExtensionFunction
{
97 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.getKeyboardConfig",
98 VIRTUALKEYBOARDPRIVATE_GETKEYBOARDCONFIG
);
101 ~VirtualKeyboardPrivateGetKeyboardConfigFunction() override
{}
103 // ExtensionFunction:
104 bool RunSync() override
;
107 class VirtualKeyboardPrivateOpenSettingsFunction
108 : public SyncExtensionFunction
{
110 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.openSettings",
111 VIRTUALKEYBOARDPRIVATE_OPENSETTINGS
);
114 ~VirtualKeyboardPrivateOpenSettingsFunction() override
{}
116 // ExtensionFunction:
117 bool RunSync() override
;
120 class VirtualKeyboardDelegate
;
122 class VirtualKeyboardAPI
: public BrowserContextKeyedAPI
{
124 explicit VirtualKeyboardAPI(content::BrowserContext
* context
);
125 ~VirtualKeyboardAPI() override
;
127 // BrowserContextKeyedAPI implementation.
128 static BrowserContextKeyedAPIFactory
<VirtualKeyboardAPI
>*
129 GetFactoryInstance();
131 VirtualKeyboardDelegate
* delegate() { return delegate_
.get(); }
134 friend class BrowserContextKeyedAPIFactory
<VirtualKeyboardAPI
>;
136 // BrowserContextKeyedAPI implementation.
137 static const char* service_name() { return "VirtualKeyboardAPI"; }
139 // Require accces to delegate while incognito or during login.
140 static const bool kServiceHasOwnInstanceInIncognito
= true;
142 scoped_ptr
<VirtualKeyboardDelegate
> delegate_
;
145 } // namespace extensions
147 #endif // EXTENSIONS_BROWSER_API_VIRTUAL_KEYBOARD_PRIVATE_VIRTUAL_KEYBOARD_PRIVATE_API_H_