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 "chrome/browser/signin/screenlock_bridge.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h"
14 namespace extensions {
16 class ScreenlockPrivateGetLockedFunction : public ChromeAsyncExtensionFunction {
18 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getLocked",
19 SCREENLOCKPRIVATE_GETLOCKED)
20 ScreenlockPrivateGetLockedFunction();
21 virtual bool RunAsync() OVERRIDE;
24 virtual ~ScreenlockPrivateGetLockedFunction();
25 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateGetLockedFunction);
28 class ScreenlockPrivateSetLockedFunction : public ChromeAsyncExtensionFunction {
30 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.setLocked",
31 SCREENLOCKPRIVATE_SETLOCKED)
32 ScreenlockPrivateSetLockedFunction();
33 virtual bool RunAsync() OVERRIDE;
36 virtual ~ScreenlockPrivateSetLockedFunction();
37 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateSetLockedFunction);
40 class ScreenlockPrivateAcceptAuthAttemptFunction
41 : public ChromeSyncExtensionFunction {
43 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.acceptAuthAttempt",
44 SCREENLOCKPRIVATE_ACCEPTAUTHATTEMPT)
45 ScreenlockPrivateAcceptAuthAttemptFunction();
46 virtual bool RunSync() OVERRIDE;
49 virtual ~ScreenlockPrivateAcceptAuthAttemptFunction();
50 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateAcceptAuthAttemptFunction);
53 class ScreenlockPrivateEventRouter : public extensions::BrowserContextKeyedAPI,
54 public ScreenlockBridge::Observer {
56 explicit ScreenlockPrivateEventRouter(content::BrowserContext* context);
57 virtual ~ScreenlockPrivateEventRouter();
59 bool OnAuthAttempted(ScreenlockBridge::LockHandler::AuthType auth_type,
60 const std::string& value);
62 // BrowserContextKeyedAPI
63 static extensions::BrowserContextKeyedAPIFactory<
64 ScreenlockPrivateEventRouter>*
66 virtual void Shutdown() OVERRIDE;
68 // ScreenlockBridge::Observer
69 virtual void OnScreenDidLock() OVERRIDE;
70 virtual void OnScreenDidUnlock() OVERRIDE;
71 virtual void OnFocusedUserChanged(const std::string& user_id) OVERRIDE;
74 friend class extensions::BrowserContextKeyedAPIFactory<
75 ScreenlockPrivateEventRouter>;
77 // BrowserContextKeyedAPI
78 static const char* service_name() {
79 return "ScreenlockPrivateEventRouter";
81 static const bool kServiceIsNULLWhileTesting = true;
82 static const bool kServiceRedirectedInIncognito = true;
84 void DispatchEvent(const std::string& event_name, base::Value* arg);
86 content::BrowserContext* browser_context_;
87 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateEventRouter);
90 } // namespace extensions
92 #endif // CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_