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 virtual ~AutotestPrivateLogoutFunction() {}
22 virtual bool RunSync() OVERRIDE;
25 class AutotestPrivateRestartFunction : public ChromeSyncExtensionFunction {
27 DECLARE_EXTENSION_FUNCTION("autotestPrivate.restart", AUTOTESTPRIVATE_RESTART)
30 virtual ~AutotestPrivateRestartFunction() {}
31 virtual bool RunSync() OVERRIDE;
34 class AutotestPrivateShutdownFunction : public ChromeSyncExtensionFunction {
36 DECLARE_EXTENSION_FUNCTION("autotestPrivate.shutdown",
37 AUTOTESTPRIVATE_SHUTDOWN)
40 virtual ~AutotestPrivateShutdownFunction() {}
41 virtual bool RunSync() OVERRIDE;
44 class AutotestPrivateLoginStatusFunction : public ChromeSyncExtensionFunction {
46 DECLARE_EXTENSION_FUNCTION("autotestPrivate.loginStatus",
47 AUTOTESTPRIVATE_LOGINSTATUS)
50 virtual ~AutotestPrivateLoginStatusFunction() {}
51 virtual bool RunSync() OVERRIDE;
54 class AutotestPrivateLockScreenFunction : public ChromeSyncExtensionFunction {
56 DECLARE_EXTENSION_FUNCTION("autotestPrivate.lockScreen",
57 AUTOTESTPRIVATE_LOCKSCREEN)
60 virtual ~AutotestPrivateLockScreenFunction() {}
61 virtual bool RunSync() OVERRIDE;
64 class AutotestPrivateGetExtensionsInfoFunction
65 : public ChromeSyncExtensionFunction {
67 DECLARE_EXTENSION_FUNCTION("autotestPrivate.getExtensionsInfo",
68 AUTOTESTPRIVATE_GETEXTENSIONSINFO)
71 virtual ~AutotestPrivateGetExtensionsInfoFunction() {}
72 virtual bool RunSync() OVERRIDE;
75 class AutotestPrivateSimulateAsanMemoryBugFunction
76 : public ChromeSyncExtensionFunction {
78 DECLARE_EXTENSION_FUNCTION("autotestPrivate.simulateAsanMemoryBug",
79 AUTOTESTPRIVATE_SIMULATEASANMEMORYBUG)
82 virtual ~AutotestPrivateSimulateAsanMemoryBugFunction() {}
83 virtual 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 virtual ~AutotestPrivateAPI();
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_