/chrome/browser/extensions/api/autotest_private/autotest_private_api.h

https://gitlab.com/jonnialva90/iridium-browser · C Header · 197 lines · 148 code · 42 blank · 7 comment · 0 complexity · 0794690df1dd5ae723b9bcc6254063ef MD5 · raw file

  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.
  4. #ifndef CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_
  5. #define CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_
  6. #include <string>
  7. #include "base/compiler_specific.h"
  8. #include "chrome/browser/extensions/chrome_extension_function.h"
  9. #include "extensions/browser/browser_context_keyed_api_factory.h"
  10. namespace extensions {
  11. class AutotestPrivateLogoutFunction : public ChromeSyncExtensionFunction {
  12. public:
  13. DECLARE_EXTENSION_FUNCTION("autotestPrivate.logout", AUTOTESTPRIVATE_LOGOUT)
  14. private:
  15. ~AutotestPrivateLogoutFunction() override {}
  16. bool RunSync() override;
  17. };
  18. class AutotestPrivateRestartFunction : public ChromeSyncExtensionFunction {
  19. public:
  20. DECLARE_EXTENSION_FUNCTION("autotestPrivate.restart", AUTOTESTPRIVATE_RESTART)
  21. private:
  22. ~AutotestPrivateRestartFunction() override {}
  23. bool RunSync() override;
  24. };
  25. class AutotestPrivateShutdownFunction : public ChromeSyncExtensionFunction {
  26. public:
  27. DECLARE_EXTENSION_FUNCTION("autotestPrivate.shutdown",
  28. AUTOTESTPRIVATE_SHUTDOWN)
  29. private:
  30. ~AutotestPrivateShutdownFunction() override {}
  31. bool RunSync() override;
  32. };
  33. class AutotestPrivateLoginStatusFunction : public ChromeSyncExtensionFunction {
  34. public:
  35. DECLARE_EXTENSION_FUNCTION("autotestPrivate.loginStatus",
  36. AUTOTESTPRIVATE_LOGINSTATUS)
  37. private:
  38. ~AutotestPrivateLoginStatusFunction() override {}
  39. bool RunSync() override;
  40. };
  41. class AutotestPrivateLockScreenFunction : public ChromeSyncExtensionFunction {
  42. public:
  43. DECLARE_EXTENSION_FUNCTION("autotestPrivate.lockScreen",
  44. AUTOTESTPRIVATE_LOCKSCREEN)
  45. private:
  46. ~AutotestPrivateLockScreenFunction() override {}
  47. bool RunSync() override;
  48. };
  49. class AutotestPrivateGetExtensionsInfoFunction
  50. : public ChromeSyncExtensionFunction {
  51. public:
  52. DECLARE_EXTENSION_FUNCTION("autotestPrivate.getExtensionsInfo",
  53. AUTOTESTPRIVATE_GETEXTENSIONSINFO)
  54. private:
  55. ~AutotestPrivateGetExtensionsInfoFunction() override {}
  56. bool RunSync() override;
  57. };
  58. class AutotestPrivateSimulateAsanMemoryBugFunction
  59. : public ChromeSyncExtensionFunction {
  60. public:
  61. DECLARE_EXTENSION_FUNCTION("autotestPrivate.simulateAsanMemoryBug",
  62. AUTOTESTPRIVATE_SIMULATEASANMEMORYBUG)
  63. private:
  64. ~AutotestPrivateSimulateAsanMemoryBugFunction() override {}
  65. bool RunSync() override;
  66. };
  67. class AutotestPrivateSetTouchpadSensitivityFunction
  68. : public ChromeSyncExtensionFunction {
  69. public:
  70. DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTouchpadSensitivity",
  71. AUTOTESTPRIVATE_SETTOUCHPADSENSITIVITY)
  72. private:
  73. ~AutotestPrivateSetTouchpadSensitivityFunction() override {}
  74. bool RunSync() override;
  75. };
  76. class AutotestPrivateSetTapToClickFunction
  77. : public ChromeSyncExtensionFunction {
  78. public:
  79. DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTapToClick",
  80. AUTOTESTPRIVATE_SETTAPTOCLICK)
  81. private:
  82. ~AutotestPrivateSetTapToClickFunction() override {}
  83. bool RunSync() override;
  84. };
  85. class AutotestPrivateSetThreeFingerClickFunction
  86. : public ChromeSyncExtensionFunction {
  87. public:
  88. DECLARE_EXTENSION_FUNCTION("autotestPrivate.setThreeFingerClick",
  89. AUTOTESTPRIVATE_SETTHREEFINGERCLICK)
  90. private:
  91. ~AutotestPrivateSetThreeFingerClickFunction() override {}
  92. bool RunSync() override;
  93. };
  94. class AutotestPrivateSetTapDraggingFunction
  95. : public ChromeSyncExtensionFunction {
  96. public:
  97. DECLARE_EXTENSION_FUNCTION("autotestPrivate.setTapDragging",
  98. AUTOTESTPRIVATE_SETTAPDRAGGING)
  99. private:
  100. ~AutotestPrivateSetTapDraggingFunction() override {}
  101. bool RunSync() override;
  102. };
  103. class AutotestPrivateSetNaturalScrollFunction
  104. : public ChromeSyncExtensionFunction {
  105. public:
  106. DECLARE_EXTENSION_FUNCTION("autotestPrivate.setNaturalScroll",
  107. AUTOTESTPRIVATE_SETNATURALSCROLL)
  108. private:
  109. ~AutotestPrivateSetNaturalScrollFunction() override {}
  110. bool RunSync() override;
  111. };
  112. class AutotestPrivateSetMouseSensitivityFunction
  113. : public ChromeSyncExtensionFunction {
  114. public:
  115. DECLARE_EXTENSION_FUNCTION("autotestPrivate.setMouseSensitivity",
  116. AUTOTESTPRIVATE_SETMOUSESENSITIVITY)
  117. private:
  118. ~AutotestPrivateSetMouseSensitivityFunction() override {}
  119. bool RunSync() override;
  120. };
  121. class AutotestPrivateSetPrimaryButtonRightFunction
  122. : public ChromeSyncExtensionFunction {
  123. public:
  124. DECLARE_EXTENSION_FUNCTION("autotestPrivate.setPrimaryButtonRight",
  125. AUTOTESTPRIVATE_SETPRIMARYBUTTONRIGHT)
  126. private:
  127. ~AutotestPrivateSetPrimaryButtonRightFunction() override {}
  128. bool RunSync() override;
  129. };
  130. // Don't kill the browser when we're in a browser test.
  131. void SetAutotestPrivateTest();
  132. // The profile-keyed service that manages the autotestPrivate extension API.
  133. class AutotestPrivateAPI : public BrowserContextKeyedAPI {
  134. public:
  135. static BrowserContextKeyedAPIFactory<AutotestPrivateAPI>*
  136. GetFactoryInstance();
  137. // TODO(achuith): Replace these with a mock object for system calls.
  138. bool test_mode() const { return test_mode_; }
  139. void set_test_mode(bool test_mode) { test_mode_ = test_mode; }
  140. private:
  141. friend class BrowserContextKeyedAPIFactory<AutotestPrivateAPI>;
  142. AutotestPrivateAPI();
  143. ~AutotestPrivateAPI() override;
  144. // BrowserContextKeyedAPI implementation.
  145. static const char* service_name() { return "AutotestPrivateAPI"; }
  146. static const bool kServiceIsNULLWhileTesting = true;
  147. static const bool kServiceRedirectedInIncognito = true;
  148. bool test_mode_; // true for ExtensionApiTest.AutotestPrivate browser test.
  149. };
  150. template <>
  151. KeyedService*
  152. BrowserContextKeyedAPIFactory<AutotestPrivateAPI>::BuildServiceInstanceFor(
  153. content::BrowserContext* context) const;
  154. } // namespace extensions
  155. #endif // CHROME_BROWSER_EXTENSIONS_API_AUTOTEST_PRIVATE_AUTOTEST_PRIVATE_API_H_