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

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: Migrate browser tests to unit tests 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/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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698