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 VirtualKeyboardPrivateSendKeyEventFunction
31 : public SyncExtensionFunction
{
33 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.sendKeyEvent",
34 VIRTUALKEYBOARDPRIVATE_SENDKEYEVENT
);
37 ~VirtualKeyboardPrivateSendKeyEventFunction() override
{}
40 bool RunSync() override
;
43 class VirtualKeyboardPrivateHideKeyboardFunction
44 : public SyncExtensionFunction
{
46 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.hideKeyboard",
47 VIRTUALKEYBOARDPRIVATE_HIDEKEYBOARD
);
50 ~VirtualKeyboardPrivateHideKeyboardFunction() override
{}
53 bool RunSync() override
;
56 class VirtualKeyboardPrivateSetHotrodKeyboardFunction
57 : public SyncExtensionFunction
{
59 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.setHotrodKeyboard",
60 VIRTUALKEYBOARDPRIVATE_SETHOTRODKEYBOARD
);
63 ~VirtualKeyboardPrivateSetHotrodKeyboardFunction() override
{}
66 bool RunSync() override
;
69 class VirtualKeyboardPrivateLockKeyboardFunction
70 : public SyncExtensionFunction
{
72 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.lockKeyboard",
73 VIRTUALKEYBOARDPRIVATE_LOCKKEYBOARD
);
76 ~VirtualKeyboardPrivateLockKeyboardFunction() override
{}
79 bool RunSync() override
;
82 class VirtualKeyboardPrivateKeyboardLoadedFunction
83 : public SyncExtensionFunction
{
85 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.keyboardLoaded",
86 VIRTUALKEYBOARDPRIVATE_KEYBOARDLOADED
);
89 ~VirtualKeyboardPrivateKeyboardLoadedFunction() override
{}
92 bool RunSync() override
;
95 class VirtualKeyboardPrivateGetKeyboardConfigFunction
96 : public SyncExtensionFunction
{
98 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.getKeyboardConfig",
99 VIRTUALKEYBOARDPRIVATE_GETKEYBOARDCONFIG
);
102 ~VirtualKeyboardPrivateGetKeyboardConfigFunction() override
{}
104 // ExtensionFunction:
105 bool RunSync() override
;
108 class VirtualKeyboardPrivateOpenSettingsFunction
109 : public SyncExtensionFunction
{
111 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.openSettings",
112 VIRTUALKEYBOARDPRIVATE_OPENSETTINGS
);
115 ~VirtualKeyboardPrivateOpenSettingsFunction() override
{}
117 // ExtensionFunction:
118 bool RunSync() override
;
121 class VirtualKeyboardPrivateSetModeFunction
: public SyncExtensionFunction
{
123 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.setMode",
124 VIRTUALKEYBOARDPRIVATE_SETMODE
);
127 ~VirtualKeyboardPrivateSetModeFunction() override
{}
129 // ExtensionFunction:
130 bool RunSync() override
;
133 class VirtualKeyboardPrivateSetKeyboardStateFunction
134 : public SyncExtensionFunction
{
136 DECLARE_EXTENSION_FUNCTION("virtualKeyboardPrivate.setKeyboardState",
137 VIRTUALKEYBOARDPRIVATE_SETKEYBOARDSTATE
);
140 ~VirtualKeyboardPrivateSetKeyboardStateFunction() override
{}
142 // ExtensionFunction:
143 bool RunSync() override
;
146 class VirtualKeyboardDelegate
;
148 class VirtualKeyboardAPI
: public BrowserContextKeyedAPI
{
150 explicit VirtualKeyboardAPI(content::BrowserContext
* context
);
151 ~VirtualKeyboardAPI() override
;
153 // BrowserContextKeyedAPI implementation.
154 static BrowserContextKeyedAPIFactory
<VirtualKeyboardAPI
>*
155 GetFactoryInstance();
157 VirtualKeyboardDelegate
* delegate() { return delegate_
.get(); }
160 friend class BrowserContextKeyedAPIFactory
<VirtualKeyboardAPI
>;
162 // BrowserContextKeyedAPI implementation.
163 static const char* service_name() { return "VirtualKeyboardAPI"; }
165 // Require accces to delegate while incognito or during login.
166 static const bool kServiceHasOwnInstanceInIncognito
= true;
168 scoped_ptr
<VirtualKeyboardDelegate
> delegate_
;
171 } // namespace extensions
173 #endif // EXTENSIONS_BROWSER_API_VIRTUAL_KEYBOARD_PRIVATE_VIRTUAL_KEYBOARD_PRIVATE_API_H_