OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_ |
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_ |
7 | 7 |
| 8 #include "chrome/browser/chromeos/login/login_display.h" |
8 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | 9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
9 #include "chrome/browser/extensions/chrome_extension_function.h" | 10 #include "chrome/browser/extensions/chrome_extension_function.h" |
10 #include "chromeos/dbus/session_manager_client.h" | 11 #include "chromeos/dbus/session_manager_client.h" |
11 | 12 |
12 namespace extensions { | 13 namespace extensions { |
13 | 14 |
14 class ScreenlockPrivateGetLockedFunction : public ChromeAsyncExtensionFunction { | 15 class ScreenlockPrivateGetLockedFunction : public ChromeAsyncExtensionFunction { |
15 public: | 16 public: |
16 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getLocked", | 17 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getLocked", |
17 SCREENLOCKPRIVATE_GETLOCKED) | 18 SCREENLOCKPRIVATE_GETLOCKED) |
(...skipping 30 matching lines...) Expand all Loading... |
48 class ScreenlockPrivateShowButtonFunction | 49 class ScreenlockPrivateShowButtonFunction |
49 : public ChromeAsyncExtensionFunction { | 50 : public ChromeAsyncExtensionFunction { |
50 public: | 51 public: |
51 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.showButton", | 52 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.showButton", |
52 SCREENLOCKPRIVATE_SHOWBUTTON) | 53 SCREENLOCKPRIVATE_SHOWBUTTON) |
53 ScreenlockPrivateShowButtonFunction(); | 54 ScreenlockPrivateShowButtonFunction(); |
54 virtual bool RunImpl() OVERRIDE; | 55 virtual bool RunImpl() OVERRIDE; |
55 private: | 56 private: |
56 virtual ~ScreenlockPrivateShowButtonFunction(); | 57 virtual ~ScreenlockPrivateShowButtonFunction(); |
57 void OnImageLoaded(const gfx::Image& image); | 58 void OnImageLoaded(const gfx::Image& image); |
58 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateShowButtonFunction ); | 59 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateShowButtonFunction); |
| 60 }; |
| 61 |
| 62 class ScreenlockPrivateHideButtonFunction |
| 63 : public ChromeAsyncExtensionFunction { |
| 64 public: |
| 65 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.hideButton", |
| 66 SCREENLOCKPRIVATE_HIDEBUTTON) |
| 67 ScreenlockPrivateHideButtonFunction(); |
| 68 virtual bool RunImpl() OVERRIDE; |
| 69 |
| 70 private: |
| 71 virtual ~ScreenlockPrivateHideButtonFunction(); |
| 72 void OnImageLoaded(const gfx::Image& image); |
| 73 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateHideButtonFunction); |
| 74 }; |
| 75 |
| 76 class ScreenlockPrivateSetAuthTypeFunction |
| 77 : public ChromeAsyncExtensionFunction { |
| 78 public: |
| 79 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.setAuthType", |
| 80 SCREENLOCKPRIVATE_SETAUTHTYPE) |
| 81 ScreenlockPrivateSetAuthTypeFunction(); |
| 82 virtual bool RunImpl() OVERRIDE; |
| 83 |
| 84 private: |
| 85 virtual ~ScreenlockPrivateSetAuthTypeFunction(); |
| 86 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateSetAuthTypeFunction); |
| 87 }; |
| 88 |
| 89 class ScreenlockPrivateGetAuthTypeFunction |
| 90 : public ChromeAsyncExtensionFunction { |
| 91 public: |
| 92 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getAuthType", |
| 93 SCREENLOCKPRIVATE_GETAUTHTYPE) |
| 94 ScreenlockPrivateGetAuthTypeFunction(); |
| 95 virtual bool RunImpl() OVERRIDE; |
| 96 |
| 97 private: |
| 98 virtual ~ScreenlockPrivateGetAuthTypeFunction(); |
| 99 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateGetAuthTypeFunction); |
| 100 }; |
| 101 |
| 102 class ScreenlockPrivateAcceptAuthAttemptFunction |
| 103 : public ChromeAsyncExtensionFunction { |
| 104 public: |
| 105 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.acceptAuthAttempt", |
| 106 SCREENLOCKPRIVATE_ACCEPTAUTHATTEMPT) |
| 107 ScreenlockPrivateAcceptAuthAttemptFunction(); |
| 108 virtual bool RunImpl() OVERRIDE; |
| 109 |
| 110 private: |
| 111 virtual ~ScreenlockPrivateAcceptAuthAttemptFunction(); |
| 112 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateAcceptAuthAttemptFunction); |
59 }; | 113 }; |
60 | 114 |
61 class ScreenlockPrivateEventRouter | 115 class ScreenlockPrivateEventRouter |
62 : public extensions::ProfileKeyedAPI, | 116 : public extensions::ProfileKeyedAPI, |
63 public chromeos::SessionManagerClient::Observer { | 117 public chromeos::SessionManagerClient::Observer { |
64 public: | 118 public: |
65 explicit ScreenlockPrivateEventRouter(Profile* profile); | 119 explicit ScreenlockPrivateEventRouter(Profile* profile); |
66 virtual ~ScreenlockPrivateEventRouter(); | 120 virtual ~ScreenlockPrivateEventRouter(); |
67 | 121 |
68 void OnButtonClicked(); | 122 void OnButtonClicked(); |
69 | 123 |
| 124 void OnAuthAttempted(chromeos::LoginDisplay::AuthType auth_type, |
| 125 const std::string& value); |
| 126 |
70 // ProfileKeyedAPI | 127 // ProfileKeyedAPI |
71 static extensions::ProfileKeyedAPIFactory<ScreenlockPrivateEventRouter>* | 128 static extensions::ProfileKeyedAPIFactory<ScreenlockPrivateEventRouter>* |
72 GetFactoryInstance(); | 129 GetFactoryInstance(); |
73 virtual void Shutdown() OVERRIDE; | 130 virtual void Shutdown() OVERRIDE; |
74 | 131 |
75 // chromeos::SessionManagerClient::Observer | 132 // chromeos::SessionManagerClient::Observer |
76 virtual void ScreenIsLocked() OVERRIDE; | 133 virtual void ScreenIsLocked() OVERRIDE; |
77 virtual void ScreenIsUnlocked() OVERRIDE; | 134 virtual void ScreenIsUnlocked() OVERRIDE; |
78 | 135 |
79 private: | 136 private: |
80 friend class extensions::ProfileKeyedAPIFactory<ScreenlockPrivateEventRouter>; | 137 friend class extensions::ProfileKeyedAPIFactory<ScreenlockPrivateEventRouter>; |
81 | 138 |
82 // ProfileKeyedAPI | 139 // ProfileKeyedAPI |
83 static const char* service_name() { | 140 static const char* service_name() { |
84 return "ScreenlockPrivateEventRouter"; | 141 return "ScreenlockPrivateEventRouter"; |
85 } | 142 } |
86 static const bool kServiceIsNULLWhileTesting = true; | 143 static const bool kServiceIsNULLWhileTesting = true; |
87 static const bool kServiceRedirectedInIncognito = true; | 144 static const bool kServiceRedirectedInIncognito = true; |
88 | 145 |
89 void DispatchEvent(const std::string& event_name, base::Value* arg); | 146 void DispatchEvent(const std::string& event_name, base::Value* arg); |
90 | 147 |
91 Profile* profile_; | 148 Profile* profile_; |
92 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateEventRouter); | 149 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateEventRouter); |
93 }; | 150 }; |
94 | 151 |
95 } // namespace extensions | 152 } // namespace extensions |
96 | 153 |
97 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_ | 154 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_ |
OLD | NEW |