1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_
10 #include "base/compiler_specific.h"
11 #include "chrome/browser/extensions/chrome_extension_function.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h"
14 namespace extensions
{
16 class AutotestPrivateLogoutFunction
: public ChromeSyncExtensionFunction
{
18 DECLARE_EXTENSION_FUNCTION("autotestPrivate.logout", AUTOTESTPRIVATE_LOGOUT
)
21 ~AutotestPrivateLogoutFunction() override
{}
22 bool RunSync() override
;
25 class AutotestPrivateRestartFunction
: public ChromeSyncExtensionFunction
{
27 DECLARE_EXTENSION_FUNCTION("autotestPrivate.restart", AUTOTESTPRIVATE_RESTART
)
30 ~AutotestPrivateRestartFunction() override
{}
31 bool RunSync() override
;
34 class AutotestPrivateShutdownFunction
: public ChromeSyncExtensionFunction
{
36 DECLARE_EXTENSION_FUNCTION("autotestPrivate.shutdown",
37 AUTOTESTPRIVATE_SHUTDOWN
)
40 ~AutotestPrivateShutdownFunction() override
{}
41 bool RunSync() override
;
44 class AutotestPrivateLoginStatusFunction
: public ChromeSyncExtensionFunction
{
46 DECLARE_EXTENSION_FUNCTION("autotestPrivate.loginStatus",
47 AUTOTESTPRIVATE_LOGINSTATUS
)
50 ~AutotestPrivateLoginStatusFunction() override
{}
51 bool RunSync() override
;
54 class AutotestPrivateLockScreenFunction
: public ChromeSyncExtensionFunction
{
56 DECLARE_EXTENSION_FUNCTION("autotestPrivate.lockScreen",
57 AUTOTESTPRIVATE_LOCKSCREEN
)
60 ~AutotestPrivateLockScreenFunction() override
{}
61 bool RunSync() override
;
64 class AutotestPrivateGetExtensionsInfoFunction
65 : public ChromeSyncExtensionFunction
{
67 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getExtensionsInfo",
68 AUTOTESTPRIVATE_GETEXTENSIONSINFO
)
71 ~AutotestPrivateGetExtensionsInfoFunction() override
{}
72 bool RunSync() override
;
75 class AutotestPrivateSimulateAsanMemoryBugFunction
76 : public ChromeSyncExtensionFunction
{
78 DECLARE_EXTENSION_FUNCTION("autotestPrivate.simulateAsanMemoryBug",
79 AUTOTESTPRIVATE_SIMULATEASANMEMORYBUG
)
82 ~AutotestPrivateSimulateAsanMemoryBugFunction() override
{}
83 bool RunSync() override
;
86 class AutotestPrivateSetTouchpadSensitivityFunction
87 : public ChromeSyncExtensionFunction
{
89 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTouchpadSensitivity",
90 AUTOTESTPRIVATE_SETTOUCHPADSENSITIVITY
)
93 ~AutotestPrivateSetTouchpadSensitivityFunction() override
{}
94 bool RunSync() override
;
97 class AutotestPrivateSetTapToClickFunction
98 : public ChromeSyncExtensionFunction
{
100 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTapToClick",
101 AUTOTESTPRIVATE_SETTAPTOCLICK
)
104 ~AutotestPrivateSetTapToClickFunction() override
{}
105 bool RunSync() override
;
108 class AutotestPrivateSetThreeFingerClickFunction
109 : public ChromeSyncExtensionFunction
{
111 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setThreeFingerClick",
112 AUTOTESTPRIVATE_SETTHREEFINGERCLICK
)
115 ~AutotestPrivateSetThreeFingerClickFunction() override
{}
116 bool RunSync() override
;
119 class AutotestPrivateSetTapDraggingFunction
120 : public ChromeSyncExtensionFunction
{
122 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTapDragging",
123 AUTOTESTPRIVATE_SETTAPDRAGGING
)
126 ~AutotestPrivateSetTapDraggingFunction() override
{}
127 bool RunSync() override
;
130 class AutotestPrivateSetNaturalScrollFunction
131 : public ChromeSyncExtensionFunction
{
133 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setNaturalScroll",
134 AUTOTESTPRIVATE_SETNATURALSCROLL
)
137 ~AutotestPrivateSetNaturalScrollFunction() override
{}
138 bool RunSync() override
;
141 class AutotestPrivateSetMouseSensitivityFunction
142 : public ChromeSyncExtensionFunction
{
144 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setMouseSensitivity",
145 AUTOTESTPRIVATE_SETMOUSESENSITIVITY
)
148 ~AutotestPrivateSetMouseSensitivityFunction() override
{}
149 bool RunSync() override
;
152 class AutotestPrivateSetPrimaryButtonRightFunction
153 : public ChromeSyncExtensionFunction
{
155 DECLARE_EXTENSION_FUNCTION("autotestPrivate.setPrimaryButtonRight",
156 AUTOTESTPRIVATE_SETPRIMARYBUTTONRIGHT
)
159 ~AutotestPrivateSetPrimaryButtonRightFunction() override
{}
160 bool RunSync() override
;
163 // Don't kill the browser when we're in a browser test.
164 void SetAutotestPrivateTest();
166 // The profile-keyed service that manages the autotestPrivate extension API.
167 class AutotestPrivateAPI
: public BrowserContextKeyedAPI
{
169 static BrowserContextKeyedAPIFactory
<AutotestPrivateAPI
>*
170 GetFactoryInstance();
172 // TODO(achuith): Replace these with a mock object for system calls.
173 bool test_mode() const { return test_mode_
; }
174 void set_test_mode(bool test_mode
) { test_mode_
= test_mode
; }
177 friend class BrowserContextKeyedAPIFactory
<AutotestPrivateAPI
>;
179 AutotestPrivateAPI();
180 ~AutotestPrivateAPI() override
;
182 // BrowserContextKeyedAPI implementation.
183 static const char* service_name() { return "AutotestPrivateAPI"; }
184 static const bool kServiceIsNULLWhileTesting
= true;
185 static const bool kServiceRedirectedInIncognito
= true;
187 bool test_mode_
; // true for ExtensionApiTest.AutotestPrivate browser test.
192 BrowserContextKeyedAPIFactory
<AutotestPrivateAPI
>::BuildServiceInstanceFor(
193 content::BrowserContext
* context
) const;
195 } // namespace extensions
197 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_