Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / screenlock_private / screenlock_private_api.h
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.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_
7
8 #include "chrome/browser/extensions/chrome_extension_function.h"
9 #include "chrome/browser/signin/screenlock_bridge.h"
10 #include "extensions/browser/browser_context_keyed_api_factory.h"
11
12 namespace gfx {
13 class Image;
14 }
15
16 namespace extensions {
17
18 class ScreenlockPrivateGetLockedFunction : public ChromeAsyncExtensionFunction {
19  public:
20   DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getLocked",
21                              SCREENLOCKPRIVATE_GETLOCKED)
22   ScreenlockPrivateGetLockedFunction();
23   virtual bool RunAsync() OVERRIDE;
24
25  private:
26   virtual ~ScreenlockPrivateGetLockedFunction();
27   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateGetLockedFunction);
28 };
29
30 class ScreenlockPrivateSetLockedFunction : public ChromeAsyncExtensionFunction {
31  public:
32   DECLARE_EXTENSION_FUNCTION("screenlockPrivate.setLocked",
33                              SCREENLOCKPRIVATE_SETLOCKED)
34   ScreenlockPrivateSetLockedFunction();
35   virtual bool RunAsync() OVERRIDE;
36
37  private:
38   virtual ~ScreenlockPrivateSetLockedFunction();
39   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateSetLockedFunction);
40 };
41
42 class ScreenlockPrivateShowMessageFunction
43     : public ChromeAsyncExtensionFunction {
44  public:
45   DECLARE_EXTENSION_FUNCTION("screenlockPrivate.showMessage",
46                              SCREENLOCKPRIVATE_SHOWMESSAGE)
47   ScreenlockPrivateShowMessageFunction();
48   virtual bool RunAsync() OVERRIDE;
49
50  private:
51   virtual ~ScreenlockPrivateShowMessageFunction();
52   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateShowMessageFunction );
53 };
54
55 class ScreenlockPrivateShowButtonFunction
56     : public ChromeAsyncExtensionFunction {
57  public:
58   DECLARE_EXTENSION_FUNCTION("screenlockPrivate.showButton",
59                              SCREENLOCKPRIVATE_SHOWBUTTON)
60   ScreenlockPrivateShowButtonFunction();
61   virtual bool RunAsync() OVERRIDE;
62
63  private:
64   virtual ~ScreenlockPrivateShowButtonFunction();
65   void OnImageLoaded(const gfx::Image& image);
66   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateShowButtonFunction);
67 };
68
69 class ScreenlockPrivateHideButtonFunction
70     : public ChromeAsyncExtensionFunction {
71  public:
72   DECLARE_EXTENSION_FUNCTION("screenlockPrivate.hideButton",
73                              SCREENLOCKPRIVATE_HIDEBUTTON)
74   ScreenlockPrivateHideButtonFunction();
75   virtual bool RunAsync() OVERRIDE;
76
77  private:
78   virtual ~ScreenlockPrivateHideButtonFunction();
79   void OnImageLoaded(const gfx::Image& image);
80   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateHideButtonFunction);
81 };
82
83 class ScreenlockPrivateSetAuthTypeFunction
84     : public ChromeAsyncExtensionFunction {
85  public:
86   DECLARE_EXTENSION_FUNCTION("screenlockPrivate.setAuthType",
87                              SCREENLOCKPRIVATE_SETAUTHTYPE)
88   ScreenlockPrivateSetAuthTypeFunction();
89   virtual bool RunAsync() OVERRIDE;
90
91  private:
92   virtual ~ScreenlockPrivateSetAuthTypeFunction();
93   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateSetAuthTypeFunction);
94 };
95
96 class ScreenlockPrivateGetAuthTypeFunction
97     : public ChromeAsyncExtensionFunction {
98  public:
99   DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getAuthType",
100                              SCREENLOCKPRIVATE_GETAUTHTYPE)
101   ScreenlockPrivateGetAuthTypeFunction();
102   virtual bool RunAsync() OVERRIDE;
103
104  private:
105   virtual ~ScreenlockPrivateGetAuthTypeFunction();
106   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateGetAuthTypeFunction);
107 };
108
109 class ScreenlockPrivateAcceptAuthAttemptFunction
110     : public ChromeAsyncExtensionFunction {
111  public:
112   DECLARE_EXTENSION_FUNCTION("screenlockPrivate.acceptAuthAttempt",
113                              SCREENLOCKPRIVATE_ACCEPTAUTHATTEMPT)
114   ScreenlockPrivateAcceptAuthAttemptFunction();
115   virtual bool RunAsync() OVERRIDE;
116
117  private:
118   virtual ~ScreenlockPrivateAcceptAuthAttemptFunction();
119   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateAcceptAuthAttemptFunction);
120 };
121
122 class ScreenlockPrivateEventRouter : public extensions::BrowserContextKeyedAPI,
123                                      public ScreenlockBridge::Observer {
124  public:
125   explicit ScreenlockPrivateEventRouter(content::BrowserContext* context);
126   virtual ~ScreenlockPrivateEventRouter();
127
128   void OnButtonClicked();
129
130   void OnAuthAttempted(ScreenlockBridge::LockHandler::AuthType auth_type,
131                        const std::string& value);
132
133   // BrowserContextKeyedAPI
134   static extensions::BrowserContextKeyedAPIFactory<
135       ScreenlockPrivateEventRouter>*
136       GetFactoryInstance();
137   virtual void Shutdown() OVERRIDE;
138
139   // ScreenlockBridge::Observer
140   virtual void OnScreenDidLock() OVERRIDE;
141   virtual void OnScreenDidUnlock() OVERRIDE;
142
143  private:
144   friend class extensions::BrowserContextKeyedAPIFactory<
145       ScreenlockPrivateEventRouter>;
146
147   // BrowserContextKeyedAPI
148   static const char* service_name() {
149     return "ScreenlockPrivateEventRouter";
150   }
151   static const bool kServiceIsNULLWhileTesting = true;
152   static const bool kServiceRedirectedInIncognito = true;
153
154   void DispatchEvent(const std::string& event_name, base::Value* arg);
155
156   content::BrowserContext* browser_context_;
157   DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateEventRouter);
158 };
159
160 }  // namespace extensions
161
162 #endif  // CHROME_BROWSER_EXTENSIONS_API_SCREENLOCK_PRIVATE_SCREENLOCK_PRIVATE_API_H_