Revert 285173 "Removed InProcessBrowserTest::CleanUpOnMainThread()"
[chromium-blink-merge.git] / chrome / browser / extensions / api / screenlock_private / screenlock_private_api.h
blob1abbf64787ca2fe69e2d82e829a91501462a114f
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_
8 #include <string>
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 gfx {
15 class Image;
18 namespace extensions {
20 class ScreenlockPrivateGetLockedFunction : public ChromeAsyncExtensionFunction {
21 public:
22 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getLocked",
23 SCREENLOCKPRIVATE_GETLOCKED)
24 ScreenlockPrivateGetLockedFunction();
25 virtual bool RunAsync() OVERRIDE;
27 private:
28 virtual ~ScreenlockPrivateGetLockedFunction();
29 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateGetLockedFunction);
32 class ScreenlockPrivateSetLockedFunction : public ChromeAsyncExtensionFunction {
33 public:
34 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.setLocked",
35 SCREENLOCKPRIVATE_SETLOCKED)
36 ScreenlockPrivateSetLockedFunction();
37 virtual bool RunAsync() OVERRIDE;
39 private:
40 virtual ~ScreenlockPrivateSetLockedFunction();
41 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateSetLockedFunction);
44 class ScreenlockPrivateShowMessageFunction
45 : public ChromeAsyncExtensionFunction {
46 public:
47 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.showMessage",
48 SCREENLOCKPRIVATE_SHOWMESSAGE)
49 ScreenlockPrivateShowMessageFunction();
50 virtual bool RunAsync() OVERRIDE;
52 private:
53 virtual ~ScreenlockPrivateShowMessageFunction();
54 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateShowMessageFunction);
57 class ScreenlockPrivateShowCustomIconFunction
58 : public ChromeAsyncExtensionFunction {
59 public:
60 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.showCustomIcon",
61 SCREENLOCKPRIVATE_SHOWCUSTOMICON)
62 ScreenlockPrivateShowCustomIconFunction();
63 virtual bool RunAsync() OVERRIDE;
65 private:
66 virtual ~ScreenlockPrivateShowCustomIconFunction();
67 void OnImageLoaded(const gfx::Image& image);
68 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateShowCustomIconFunction);
71 class ScreenlockPrivateHideCustomIconFunction
72 : public ChromeAsyncExtensionFunction {
73 public:
74 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.hideCustomIcon",
75 SCREENLOCKPRIVATE_HIDECUSTOMICON)
76 ScreenlockPrivateHideCustomIconFunction();
77 virtual bool RunAsync() OVERRIDE;
79 private:
80 virtual ~ScreenlockPrivateHideCustomIconFunction();
81 void OnImageLoaded(const gfx::Image& image);
82 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateHideCustomIconFunction);
85 class ScreenlockPrivateSetAuthTypeFunction
86 : public ChromeAsyncExtensionFunction {
87 public:
88 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.setAuthType",
89 SCREENLOCKPRIVATE_SETAUTHTYPE)
90 ScreenlockPrivateSetAuthTypeFunction();
91 virtual bool RunAsync() OVERRIDE;
93 private:
94 virtual ~ScreenlockPrivateSetAuthTypeFunction();
95 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateSetAuthTypeFunction);
98 class ScreenlockPrivateGetAuthTypeFunction
99 : public ChromeAsyncExtensionFunction {
100 public:
101 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getAuthType",
102 SCREENLOCKPRIVATE_GETAUTHTYPE)
103 ScreenlockPrivateGetAuthTypeFunction();
104 virtual bool RunAsync() OVERRIDE;
106 private:
107 virtual ~ScreenlockPrivateGetAuthTypeFunction();
108 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateGetAuthTypeFunction);
111 class ScreenlockPrivateAcceptAuthAttemptFunction
112 : public ChromeAsyncExtensionFunction {
113 public:
114 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.acceptAuthAttempt",
115 SCREENLOCKPRIVATE_ACCEPTAUTHATTEMPT)
116 ScreenlockPrivateAcceptAuthAttemptFunction();
117 virtual bool RunAsync() OVERRIDE;
119 private:
120 virtual ~ScreenlockPrivateAcceptAuthAttemptFunction();
121 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateAcceptAuthAttemptFunction);
124 class ScreenlockPrivateEventRouter : public extensions::BrowserContextKeyedAPI,
125 public ScreenlockBridge::Observer {
126 public:
127 explicit ScreenlockPrivateEventRouter(content::BrowserContext* context);
128 virtual ~ScreenlockPrivateEventRouter();
130 void OnAuthAttempted(ScreenlockBridge::LockHandler::AuthType auth_type,
131 const std::string& value);
133 // BrowserContextKeyedAPI
134 static extensions::BrowserContextKeyedAPIFactory<
135 ScreenlockPrivateEventRouter>*
136 GetFactoryInstance();
137 virtual void Shutdown() OVERRIDE;
139 // ScreenlockBridge::Observer
140 virtual void OnScreenDidLock() OVERRIDE;
141 virtual void OnScreenDidUnlock() OVERRIDE;
143 private:
144 friend class extensions::BrowserContextKeyedAPIFactory<
145 ScreenlockPrivateEventRouter>;
147 // BrowserContextKeyedAPI
148 static const char* service_name() {
149 return "ScreenlockPrivateEventRouter";
151 static const bool kServiceIsNULLWhileTesting = true;
152 static const bool kServiceRedirectedInIncognito = true;
154 void DispatchEvent(const std::string& event_name, base::Value* arg);
156 content::BrowserContext* browser_context_;
157 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateEventRouter);
160 } // namespace extensions
162 #endif // CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_