1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_
10 #include "chrome/browser/extensions/chrome_extension_function.h"
11 #include "components/proximity_auth/screenlock_bridge.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h"
13 #include "extensions/browser/extension_event_histogram_value.h"
15 namespace extensions
{
17 class ScreenlockPrivateGetLockedFunction
: public ChromeAsyncExtensionFunction
{
19 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getLocked",
20 SCREENLOCKPRIVATE_GETLOCKED
)
21 ScreenlockPrivateGetLockedFunction();
22 bool RunAsync() override
;
25 ~ScreenlockPrivateGetLockedFunction() override
;
26 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateGetLockedFunction
);
29 class ScreenlockPrivateSetLockedFunction
: public ChromeAsyncExtensionFunction
{
31 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.setLocked",
32 SCREENLOCKPRIVATE_SETLOCKED
)
33 ScreenlockPrivateSetLockedFunction();
34 bool RunAsync() override
;
37 ~ScreenlockPrivateSetLockedFunction() override
;
38 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateSetLockedFunction
);
41 class ScreenlockPrivateAcceptAuthAttemptFunction
42 : public ChromeSyncExtensionFunction
{
44 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.acceptAuthAttempt",
45 SCREENLOCKPRIVATE_ACCEPTAUTHATTEMPT
)
46 ScreenlockPrivateAcceptAuthAttemptFunction();
47 bool RunSync() override
;
50 ~ScreenlockPrivateAcceptAuthAttemptFunction() override
;
51 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateAcceptAuthAttemptFunction
);
54 class ScreenlockPrivateEventRouter
55 : public BrowserContextKeyedAPI
,
56 public proximity_auth::ScreenlockBridge::Observer
{
58 explicit ScreenlockPrivateEventRouter(content::BrowserContext
* context
);
59 ~ScreenlockPrivateEventRouter() override
;
62 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type
,
63 const std::string
& value
);
65 // BrowserContextKeyedAPI
66 static BrowserContextKeyedAPIFactory
<ScreenlockPrivateEventRouter
>*
68 void Shutdown() override
;
70 // proximity_auth::ScreenlockBridge::Observer
71 void OnScreenDidLock(proximity_auth::ScreenlockBridge::LockHandler::ScreenType
72 screen_type
) override
;
73 void OnScreenDidUnlock(
74 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type
)
76 void OnFocusedUserChanged(const std::string
& user_id
) override
;
79 friend class BrowserContextKeyedAPIFactory
<ScreenlockPrivateEventRouter
>;
81 // BrowserContextKeyedAPI
82 static const char* service_name() {
83 return "ScreenlockPrivateEventRouter";
85 static const bool kServiceIsNULLWhileTesting
= true;
86 static const bool kServiceRedirectedInIncognito
= true;
88 void DispatchEvent(events::HistogramValue histogram_value
,
89 const std::string
& event_name
,
92 content::BrowserContext
* browser_context_
;
93 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateEventRouter
);
96 } // namespace extensions
98 #endif // CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_