/chrome/browser/extensions/api/screenlock_private/screenlock_private_api.h

https://gitlab.com/jonnialva90/iridium-browser · C Header · 98 lines · 72 code · 20 blank · 6 comment · 0 complexity · e4697cd04d52eac257ba06caf58c6f87 MD5 · raw file

  1. // Copyright 2013 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_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_
  5. #define CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_
  6. #include <string>
  7. #include "chrome/browser/extensions/chrome_extension_function.h"
  8. #include "components/proximity_auth/screenlock_bridge.h"
  9. #include "extensions/browser/browser_context_keyed_api_factory.h"
  10. #include "extensions/browser/extension_event_histogram_value.h"
  11. namespace extensions {
  12. class ScreenlockPrivateGetLockedFunction : public ChromeAsyncExtensionFunction {
  13. public:
  14. DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getLocked",
  15. SCREENLOCKPRIVATE_GETLOCKED)
  16. ScreenlockPrivateGetLockedFunction();
  17. bool RunAsync() override;
  18. private:
  19. ~ScreenlockPrivateGetLockedFunction() override;
  20. DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateGetLockedFunction);
  21. };
  22. class ScreenlockPrivateSetLockedFunction : public ChromeAsyncExtensionFunction {
  23. public:
  24. DECLARE_EXTENSION_FUNCTION("screenlockPrivate.setLocked",
  25. SCREENLOCKPRIVATE_SETLOCKED)
  26. ScreenlockPrivateSetLockedFunction();
  27. bool RunAsync() override;
  28. private:
  29. ~ScreenlockPrivateSetLockedFunction() override;
  30. DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateSetLockedFunction);
  31. };
  32. class ScreenlockPrivateAcceptAuthAttemptFunction
  33. : public ChromeSyncExtensionFunction {
  34. public:
  35. DECLARE_EXTENSION_FUNCTION("screenlockPrivate.acceptAuthAttempt",
  36. SCREENLOCKPRIVATE_ACCEPTAUTHATTEMPT)
  37. ScreenlockPrivateAcceptAuthAttemptFunction();
  38. bool RunSync() override;
  39. private:
  40. ~ScreenlockPrivateAcceptAuthAttemptFunction() override;
  41. DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateAcceptAuthAttemptFunction);
  42. };
  43. class ScreenlockPrivateEventRouter
  44. : public BrowserContextKeyedAPI,
  45. public proximity_auth::ScreenlockBridge::Observer {
  46. public:
  47. explicit ScreenlockPrivateEventRouter(content::BrowserContext* context);
  48. ~ScreenlockPrivateEventRouter() override;
  49. bool OnAuthAttempted(
  50. proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type,
  51. const std::string& value);
  52. // BrowserContextKeyedAPI
  53. static BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>*
  54. GetFactoryInstance();
  55. void Shutdown() override;
  56. // proximity_auth::ScreenlockBridge::Observer
  57. void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType
  58. screen_type) override;
  59. void OnScreenDidUnlock(
  60. proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type)
  61. override;
  62. void OnFocusedUserChanged(const std::string& user_id) override;
  63. private:
  64. friend class BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>;
  65. // BrowserContextKeyedAPI
  66. static const char* service_name() {
  67. return "ScreenlockPrivateEventRouter";
  68. }
  69. static const bool kServiceIsNULLWhileTesting = true;
  70. static const bool kServiceRedirectedInIncognito = true;
  71. void DispatchEvent(events::HistogramValue histogram_value,
  72. const std::string& event_name,
  73. base::Value* arg);
  74. content::BrowserContext* browser_context_;
  75. DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateEventRouter);
  76. };
  77. } // namespace extensions
  78. #endif // CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_