OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_QUICK_UNLOCK_PRIVATE_QUICK_UNLOCK_PRI
VATE_API_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_QUICK_UNLOCK_PRIVATE_QUICK_UNLOCK_PRI
VATE_API_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "chrome/browser/extensions/chrome_extension_function_details.h" |
| 10 #include "chrome/common/extensions/api/quick_unlock_private.h" |
| 11 #include "chromeos/login/auth/auth_status_consumer.h" |
| 12 #include "extensions/browser/extension_function.h" |
| 13 |
| 14 namespace chromeos { |
| 15 class ExtendedAuthenticator; |
| 16 } |
| 17 |
| 18 namespace extensions { |
| 19 |
| 20 class QuickUnlockPrivateGetAvailableModesFunction |
| 21 : public UIThreadExtensionFunction { |
| 22 public: |
| 23 QuickUnlockPrivateGetAvailableModesFunction(); |
| 24 DECLARE_EXTENSION_FUNCTION("quickUnlockPrivate.getAvailableModes", |
| 25 QUICKUNLOCKPRIVATE_GETAVAILABLEMODES); |
| 26 |
| 27 protected: |
| 28 ~QuickUnlockPrivateGetAvailableModesFunction() override; |
| 29 |
| 30 // ExtensionFunction overrides. |
| 31 ResponseAction Run() override; |
| 32 |
| 33 private: |
| 34 ChromeExtensionFunctionDetails chrome_details_; |
| 35 |
| 36 DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateGetAvailableModesFunction); |
| 37 }; |
| 38 |
| 39 class QuickUnlockPrivateGetActiveModesFunction |
| 40 : public UIThreadExtensionFunction { |
| 41 public: |
| 42 QuickUnlockPrivateGetActiveModesFunction(); |
| 43 DECLARE_EXTENSION_FUNCTION("quickUnlockPrivate.getActiveModes", |
| 44 QUICKUNLOCKPRIVATE_GETACTIVEMODES); |
| 45 |
| 46 protected: |
| 47 ~QuickUnlockPrivateGetActiveModesFunction() override; |
| 48 |
| 49 // ExtensionFunction overrides. |
| 50 ResponseAction Run() override; |
| 51 |
| 52 private: |
| 53 ChromeExtensionFunctionDetails chrome_details_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateGetActiveModesFunction); |
| 56 }; |
| 57 |
| 58 class QuickUnlockPrivateSetModesFunction : public UIThreadExtensionFunction, |
| 59 public chromeos::AuthStatusConsumer { |
| 60 public: |
| 61 using CreateAuthenticator = |
| 62 chromeos::ExtendedAuthenticator* (*)(chromeos::AuthStatusConsumer* |
| 63 auth_status_consumer); |
| 64 using QuickUnlockMode = |
| 65 extensions::api::quick_unlock_private::QuickUnlockMode; |
| 66 using ModesChangedEventHandler = |
| 67 void (*)(const std::vector<QuickUnlockMode>& modes); |
| 68 |
| 69 QuickUnlockPrivateSetModesFunction(); |
| 70 |
| 71 // Use the given |allocator| to create an ExtendedAuthenticator instance. This |
| 72 // lets tests intercept authentication calls. |
| 73 static void SetCreateAuthenticatorForTesting(CreateAuthenticator allocator); |
| 74 |
| 75 // The given event handler will be called whenever a |
| 76 // quickUnlockPrivate.onActiveModesChanged event is raised instead of the |
| 77 // default event handling mechanism. |
| 78 static void SetModesChangedEventHandlerForTesting( |
| 79 ModesChangedEventHandler handler); |
| 80 |
| 81 DECLARE_EXTENSION_FUNCTION("quickUnlockPrivate.setModes", |
| 82 QUICKUNLOCKPRIVATE_SETMODES); |
| 83 |
| 84 protected: |
| 85 ~QuickUnlockPrivateSetModesFunction() override; |
| 86 |
| 87 // ExtensionFunction overrides. |
| 88 ResponseAction Run() override; |
| 89 |
| 90 // AuthStatusConsumer overrides. |
| 91 void OnAuthFailure(const chromeos::AuthFailure& error) override; |
| 92 void OnAuthSuccess(const chromeos::UserContext& user_context) override; |
| 93 |
| 94 void ApplyModeChange(); |
| 95 |
| 96 private: |
| 97 ChromeExtensionFunctionDetails chrome_details_; |
| 98 scoped_refptr<chromeos::ExtendedAuthenticator> extended_authenticator_; |
| 99 |
| 100 DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateSetModesFunction); |
| 101 }; |
| 102 |
| 103 } // namespace extensions |
| 104 |
| 105 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_QUICK_UNLOCK_PRIVATE_QUICK_UNLOCK_
PRIVATE_API_H_ |
OLD | NEW |