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/chromeos/login/login_display.h" |
9 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | |
10 #include "chrome/browser/extensions/chrome_extension_function.h" | 9 #include "chrome/browser/extensions/chrome_extension_function.h" |
11 #include "chromeos/dbus/session_manager_client.h" | 10 #include "chromeos/dbus/session_manager_client.h" |
| 11 #include "extensions/browser/browser_context_keyed_api_factory.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 class Image; | 14 class Image; |
15 } | 15 } |
16 | 16 |
17 namespace extensions { | 17 namespace extensions { |
18 | 18 |
19 class ScreenlockPrivateGetLockedFunction : public ChromeAsyncExtensionFunction { | 19 class ScreenlockPrivateGetLockedFunction : public ChromeAsyncExtensionFunction { |
20 public: | 20 public: |
21 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getLocked", | 21 DECLARE_EXTENSION_FUNCTION("screenlockPrivate.getLocked", |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 SCREENLOCKPRIVATE_ACCEPTAUTHATTEMPT) | 110 SCREENLOCKPRIVATE_ACCEPTAUTHATTEMPT) |
111 ScreenlockPrivateAcceptAuthAttemptFunction(); | 111 ScreenlockPrivateAcceptAuthAttemptFunction(); |
112 virtual bool RunImpl() OVERRIDE; | 112 virtual bool RunImpl() OVERRIDE; |
113 | 113 |
114 private: | 114 private: |
115 virtual ~ScreenlockPrivateAcceptAuthAttemptFunction(); | 115 virtual ~ScreenlockPrivateAcceptAuthAttemptFunction(); |
116 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateAcceptAuthAttemptFunction); | 116 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateAcceptAuthAttemptFunction); |
117 }; | 117 }; |
118 | 118 |
119 class ScreenlockPrivateEventRouter | 119 class ScreenlockPrivateEventRouter |
120 : public extensions::ProfileKeyedAPI, | 120 : public extensions::BrowserContextKeyedAPI, |
121 public chromeos::SessionManagerClient::Observer { | 121 public chromeos::SessionManagerClient::Observer { |
122 public: | 122 public: |
123 explicit ScreenlockPrivateEventRouter(content::BrowserContext* context); | 123 explicit ScreenlockPrivateEventRouter(content::BrowserContext* context); |
124 virtual ~ScreenlockPrivateEventRouter(); | 124 virtual ~ScreenlockPrivateEventRouter(); |
125 | 125 |
126 void OnButtonClicked(); | 126 void OnButtonClicked(); |
127 | 127 |
128 void OnAuthAttempted(chromeos::LoginDisplay::AuthType auth_type, | 128 void OnAuthAttempted(chromeos::LoginDisplay::AuthType auth_type, |
129 const std::string& value); | 129 const std::string& value); |
130 | 130 |
131 // ProfileKeyedAPI | 131 // BrowserContextKeyedAPI |
132 static extensions::ProfileKeyedAPIFactory<ScreenlockPrivateEventRouter>* | 132 static extensions::BrowserContextKeyedAPIFactory< |
133 GetFactoryInstance(); | 133 ScreenlockPrivateEventRouter>* |
| 134 GetFactoryInstance(); |
134 virtual void Shutdown() OVERRIDE; | 135 virtual void Shutdown() OVERRIDE; |
135 | 136 |
136 // chromeos::SessionManagerClient::Observer | 137 // chromeos::SessionManagerClient::Observer |
137 virtual void ScreenIsLocked() OVERRIDE; | 138 virtual void ScreenIsLocked() OVERRIDE; |
138 virtual void ScreenIsUnlocked() OVERRIDE; | 139 virtual void ScreenIsUnlocked() OVERRIDE; |
139 | 140 |
140 private: | 141 private: |
141 friend class extensions::ProfileKeyedAPIFactory<ScreenlockPrivateEventRouter>; | 142 friend class extensions::BrowserContextKeyedAPIFactory< |
| 143 ScreenlockPrivateEventRouter>; |
142 | 144 |
143 // ProfileKeyedAPI | 145 // BrowserContextKeyedAPI |
144 static const char* service_name() { | 146 static const char* service_name() { |
145 return "ScreenlockPrivateEventRouter"; | 147 return "ScreenlockPrivateEventRouter"; |
146 } | 148 } |
147 static const bool kServiceIsNULLWhileTesting = true; | 149 static const bool kServiceIsNULLWhileTesting = true; |
148 static const bool kServiceRedirectedInIncognito = true; | 150 static const bool kServiceRedirectedInIncognito = true; |
149 | 151 |
150 void DispatchEvent(const std::string& event_name, base::Value* arg); | 152 void DispatchEvent(const std::string& event_name, base::Value* arg); |
151 | 153 |
152 content::BrowserContext* browser_context_; | 154 content::BrowserContext* browser_context_; |
153 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateEventRouter); | 155 DISALLOW_COPY_AND_ASSIGN(ScreenlockPrivateEventRouter); |
154 }; | 156 }; |
155 | 157 |
156 } // namespace extensions | 158 } // namespace extensions |
157 | 159 |
158 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_ | 160 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_SCREENLOCK_PRIVATE_API_H_ |
OLD | NEW |