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 // Don't kill the browser when we're in a browser test.
87 void SetAutotestPrivateTest();
89 // The profile-keyed service that manages the autotestPrivate extension API.
90 class AutotestPrivateAPI : public BrowserContextKeyedAPI {
92 static BrowserContextKeyedAPIFactory<AutotestPrivateAPI>*
95 // TODO(achuith): Replace these with a mock object for system calls.
96 bool test_mode() const { return test_mode_; }
97 void set_test_mode(bool test_mode) { test_mode_ = test_mode; }
100 friend class BrowserContextKeyedAPIFactory<AutotestPrivateAPI>;
102 AutotestPrivateAPI();
103 ~AutotestPrivateAPI() override;
105 // BrowserContextKeyedAPI implementation.
106 static const char* service_name() { return "AutotestPrivateAPI"; }
107 static const bool kServiceIsNULLWhileTesting = true;
108 static const bool kServiceRedirectedInIncognito = true;
110 bool test_mode_; // true for ExtensionApiTest.AutotestPrivate browser test.
115 BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor(
116 content::BrowserContext* context) const;
118 } // namespace extensions
120 #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_