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_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_
8 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
9 #include "chrome/browser/extensions/chrome_extension_function.h"
10 #include "chromeos/dbus/session_manager_client.h"
12 namespace extensions
{
14 class ScreenlockPrivateGetLockedFunction
: public ChromeAsyncExtensionFunction
{
16 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getLocked",
17 SCREENLOCKPRIVATE_GETLOCKED
)
18 ScreenlockPrivateGetLockedFunction();
19 virtual bool RunImpl() OVERRIDE
;
21 virtual ~ScreenlockPrivateGetLockedFunction();
22 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateGetLockedFunction
);
25 class ScreenlockPrivateSetLockedFunction
: public ChromeAsyncExtensionFunction
{
27 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.setLocked",
28 SCREENLOCKPRIVATE_SETLOCKED
)
29 ScreenlockPrivateSetLockedFunction();
30 virtual bool RunImpl() OVERRIDE
;
32 virtual ~ScreenlockPrivateSetLockedFunction();
33 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateSetLockedFunction
);
36 class ScreenlockPrivateShowMessageFunction
37 : public ChromeAsyncExtensionFunction
{
39 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.showMessage",
40 SCREENLOCKPRIVATE_SHOWMESSAGE
)
41 ScreenlockPrivateShowMessageFunction();
42 virtual bool RunImpl() OVERRIDE
;
44 virtual ~ScreenlockPrivateShowMessageFunction();
45 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateShowMessageFunction
);
48 class ScreenlockPrivateShowButtonFunction
49 : public ChromeAsyncExtensionFunction
{
51 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.showButton",
52 SCREENLOCKPRIVATE_SHOWBUTTON
)
53 ScreenlockPrivateShowButtonFunction();
54 virtual bool RunImpl() OVERRIDE
;
56 virtual ~ScreenlockPrivateShowButtonFunction();
57 void OnImageLoaded(const gfx::Image
& image
);
58 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateShowButtonFunction
);
61 class ScreenlockPrivateEventRouter
62 : public extensions::ProfileKeyedAPI
,
63 public chromeos::SessionManagerClient::Observer
{
65 explicit ScreenlockPrivateEventRouter(Profile
* profile
);
66 virtual ~ScreenlockPrivateEventRouter();
68 void OnButtonClicked();
71 static extensions::ProfileKeyedAPIFactory
<ScreenlockPrivateEventRouter
>*
73 virtual void Shutdown() OVERRIDE
;
75 // chromeos::SessionManagerClient::Observer
76 virtual void ScreenIsLocked() OVERRIDE
;
77 virtual void ScreenIsUnlocked() OVERRIDE
;
80 friend class extensions::ProfileKeyedAPIFactory
<ScreenlockPrivateEventRouter
>;
83 static const char* service_name() {
84 return "ScreenlockPrivateEventRouter";
86 static const bool kServiceIsNULLWhileTesting
= true;
87 static const bool kServiceRedirectedInIncognito
= true;
89 void DispatchEvent(const std::string
& event_name
, base::Value
* arg
);
92 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateEventRouter
);
95 } // namespace extensions
97 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_