Chromium Code Reviews| Index: chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_private_api.h |
| diff --git a/chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_private_api.h b/chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_private_api.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b0afed1f4699ba0bc3c317e7e71849e6c9794dfa |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_private_api.h |
| @@ -0,0 +1,113 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_QUICK_UNLOCK_PRIVATE_QUICK_UNLOCK_PRIVATE_API_H_ |
| +#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_QUICK_UNLOCK_PRIVATE_QUICK_UNLOCK_PRIVATE_API_H_ |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "chrome/browser/extensions/chrome_extension_function_details.h" |
| +#include "chromeos/login/auth/auth_status_consumer.h" |
| +#include "extensions/browser/extension_function.h" |
| + |
| +namespace chromeos { |
| +class ExtendedAuthenticator; |
| +} // namespace chromeos |
|
achuithb
2016/05/20 23:50:21
don't think you need the comment
jdufault
2016/05/23 18:06:09
Done.
|
| + |
| +namespace extensions { |
| + |
| +// Implements the chrome.quickUnlockPrivate.checkPassword method. |
| +class QuickUnlockPrivateCheckPasswordFunction |
| + : public UIThreadExtensionFunction, |
| + public chromeos::AuthStatusConsumer { |
| + public: |
| + // Override how the ExtendedAuthenticator is created. This allows tests to |
| + // bypass the cryptohome calls. |
| + using CreateAuthenticator = |
| + chromeos::ExtendedAuthenticator* (*)(chromeos::AuthStatusConsumer* |
|
achuithb
2016/05/20 23:50:21
why not base::Callback? I think that pattern is mo
jdufault
2016/05/23 18:06:09
base::Callback has a dtor so it cannot be have sta
|
| + auth_status_consumer); |
| + static void SetCreateAuthenticatorForTesting(CreateAuthenticator allocator); |
| + |
| + QuickUnlockPrivateCheckPasswordFunction(); |
| + DECLARE_EXTENSION_FUNCTION("quickUnlockPrivate.checkPassword", |
| + QUICKUNLOCKPRIVATE_CHECKPASSWORD); |
| + |
| + protected: |
| + ~QuickUnlockPrivateCheckPasswordFunction() override; |
| + |
| + // ExtensionFunction overrides. |
| + ResponseAction Run() override; |
| + |
| + // AuthStatusConsumer overrides. |
| + void OnAuthFailure(const chromeos::AuthFailure& error) override; |
| + void OnAuthSuccess(const chromeos::UserContext& user_context) override; |
| + |
| + private: |
| + ChromeExtensionFunctionDetails chrome_details_; |
| + scoped_refptr<chromeos::ExtendedAuthenticator> extended_authenticator_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateCheckPasswordFunction); |
| +}; |
| + |
| +// Implements the chrome.quickUnlockPrivate.setModes method. |
| +class QuickUnlockPrivateSetModesFunction : public UIThreadExtensionFunction { |
| + public: |
| + QuickUnlockPrivateSetModesFunction(); |
| + DECLARE_EXTENSION_FUNCTION("quickUnlockPrivate.setModes", |
| + QUICKUNLOCKPRIVATE_SETMODES); |
| + |
| + protected: |
| + ~QuickUnlockPrivateSetModesFunction() override; |
| + |
| + // ExtensionFunction overrides. |
| + ResponseAction Run() override; |
| + |
| + private: |
| + ChromeExtensionFunctionDetails chrome_details_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateSetModesFunction); |
| +}; |
| + |
| +// Implements the chrome.quickUnlockPrivate.getActiveModes method. |
| +class QuickUnlockPrivateGetActiveModesFunction |
| + : public UIThreadExtensionFunction { |
| + public: |
| + QuickUnlockPrivateGetActiveModesFunction(); |
| + DECLARE_EXTENSION_FUNCTION("quickUnlockPrivate.getActiveModes", |
| + QUICKUNLOCKPRIVATE_GETACTIVEMODES); |
| + |
| + protected: |
| + ~QuickUnlockPrivateGetActiveModesFunction() override; |
| + |
| + // ExtensionFunction overrides. |
| + ResponseAction Run() override; |
| + |
| + private: |
| + ChromeExtensionFunctionDetails chrome_details_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateGetActiveModesFunction); |
| +}; |
| + |
| +// Implements the chrome.quickUnlockPrivate.getAvailableModes method. |
| +class QuickUnlockPrivateGetAvailableModesFunction |
| + : public UIThreadExtensionFunction { |
| + public: |
| + QuickUnlockPrivateGetAvailableModesFunction(); |
| + DECLARE_EXTENSION_FUNCTION("quickUnlockPrivate.getAvailableModes", |
| + QUICKUNLOCKPRIVATE_GETAVAILABLEMODES); |
| + |
| + protected: |
| + ~QuickUnlockPrivateGetAvailableModesFunction() override; |
| + |
| + // ExtensionFunction overrides. |
| + ResponseAction Run() override; |
| + |
| + private: |
| + ChromeExtensionFunctionDetails chrome_details_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateGetAvailableModesFunction); |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_QUICK_UNLOCK_PRIVATE_QUICK_UNLOCK_PRIVATE_API_H_ |