Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_private_api.h

Issue 1968083004: Implement the private API for quick unlock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Move to base::Callback, adjust api_test_utils api, address comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "chrome/browser/extensions/chrome_extension_function_details.h"
11 #include "chrome/common/extensions/api/quick_unlock_private.h"
12 #include "chromeos/login/auth/auth_status_consumer.h"
13 #include "extensions/browser/extension_function.h"
14
15 namespace chromeos {
16 class ExtendedAuthenticator;
17 }
18
19 namespace extensions {
20
21 class QuickUnlockPrivateGetAvailableModesFunction
22 : public UIThreadExtensionFunction {
23 public:
24 QuickUnlockPrivateGetAvailableModesFunction();
25 DECLARE_EXTENSION_FUNCTION("quickUnlockPrivate.getAvailableModes",
26 QUICKUNLOCKPRIVATE_GETAVAILABLEMODES);
27
28 protected:
29 ~QuickUnlockPrivateGetAvailableModesFunction() override;
30
31 // ExtensionFunction overrides.
32 ResponseAction Run() override;
33
34 private:
35 ChromeExtensionFunctionDetails chrome_details_;
36
37 DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateGetAvailableModesFunction);
38 };
39
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 class QuickUnlockPrivateSetModesFunction : public UIThreadExtensionFunction,
60 public chromeos::AuthStatusConsumer {
61 public:
62 using AuthenticatorAllocator =
63 base::Callback<chromeos::ExtendedAuthenticator*(
64 chromeos::AuthStatusConsumer* auth_status_consumer)>;
65 using QuickUnlockMode =
66 extensions::api::quick_unlock_private::QuickUnlockMode;
67 using ModesChangedEventHandler =
68 base::Callback<void(const std::vector<QuickUnlockMode>&)>;
69
70 QuickUnlockPrivateSetModesFunction();
71
72 // Use the given |allocator| to create an ExtendedAuthenticator instance. This
73 // lets tests intercept authentication calls.
74 void SetAuthenticatorAllocatorForTesting(AuthenticatorAllocator allocator);
Devlin 2016/06/21 00:16:45 const& on these callbacks now.
jdufault 2016/06/21 18:46:39 Done.
75
76 // The given event handler will be called whenever a
77 // quickUnlockPrivate.onActiveModesChanged event is raised instead of the
78 // default event handling mechanism.
79 void SetModesChangedEventHandlerForTesting(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 void FireEvent(const std::vector<QuickUnlockMode>& modes);
98
99 ChromeExtensionFunctionDetails chrome_details_;
100 scoped_refptr<chromeos::ExtendedAuthenticator> extended_authenticator_;
101 std::unique_ptr<api::quick_unlock_private::SetModes::Params> params_;
102
103 AuthenticatorAllocator authenticator_allocator_;
104 ModesChangedEventHandler modes_changed_handler_;
105
106 DISALLOW_COPY_AND_ASSIGN(QuickUnlockPrivateSetModesFunction);
107 };
108
109 } // namespace extensions
110
111 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_QUICK_UNLOCK_PRIVATE_QUICK_UNLOCK_ PRIVATE_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698