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 "chromeos/login/auth/auth_status_consumer.h" | |
11 #include "extensions/browser/extension_function.h" | |
12 | |
13 namespace chromeos { | |
14 class ExtendedAuthenticator; | |
15 } | |
16 | |
17 namespace extensions { | |
18 | |
19 // Implements the chrome.quickUnlockPrivate.getAvailableModes method. | |
Devlin
2016/05/31 22:58:38
nit: I think these are self-explained by the name
jdufault
2016/06/01 00:07:35
Done.
| |
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 // Implements the chrome.quickUnlockPrivate.getActiveModes method. | |
40 class QuickUnlockPrivateGetActiveModesFunction | |
41 : public UIThreadExtensionFunction { | |
42 public: | |
43 QuickUnlockPrivateGetActiveModesFunction(); | |
44 DECLARE_EXTENSION_FUNCTION("quickUnlockPrivate.getActiveModes", | |
45 QUICKUNLOCKPRIVATE_GETACTIVEMODES); | |
46 | |
47 protected: | |
48 ~QuickUnlockPrivateGetActiveModesFunction() override; | |
49 | |
50 // ExtensionFunction overrides. | |
51 ResponseAction Run() override; | |
52 | |
53 private: | |
54 ChromeExtensionFunctionDetails chrome_details_; | |
55 | |
56 DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateGetActiveModesFunction); | |
57 }; | |
58 | |
59 // Implements the chrome.quickUnlockPrivate.setModes method. | |
60 class QuickUnlockPrivateSetModesFunction : public UIThreadExtensionFunction, | |
61 public chromeos::AuthStatusConsumer { | |
62 public: | |
63 // Override how the ExtendedAuthenticator is created. This allows tests to | |
Devlin
2016/05/31 22:58:38
Can we combine this comment with the one on line 7
jdufault
2016/06/01 00:07:35
Done.
| |
64 // bypass the cryptohome calls. | |
65 using CreateAuthenticator = | |
66 chromeos::ExtendedAuthenticator* (*)(chromeos::AuthStatusConsumer* | |
67 auth_status_consumer); | |
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 DECLARE_EXTENSION_FUNCTION("quickUnlockPrivate.setModes", | |
76 QUICKUNLOCKPRIVATE_SETMODES); | |
77 | |
78 protected: | |
79 ~QuickUnlockPrivateSetModesFunction() override; | |
80 | |
81 // ExtensionFunction overrides. | |
82 ResponseAction Run() override; | |
83 | |
84 // AuthStatusConsumer overrides. | |
85 void OnAuthFailure(const chromeos::AuthFailure& error) override; | |
86 void OnAuthSuccess(const chromeos::UserContext& user_context) override; | |
87 | |
88 void ApplyModeChange(); | |
89 | |
90 private: | |
91 ChromeExtensionFunctionDetails chrome_details_; | |
92 scoped_refptr<chromeos::ExtendedAuthenticator> extended_authenticator_; | |
93 | |
94 DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateSetModesFunction); | |
95 }; | |
96 | |
97 } // namespace extensions | |
98 | |
99 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_QUICK_UNLOCK_PRIVATE_QUICK_UNLOCK_ PRIVATE_API_H_ | |
OLD | NEW |