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 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap
i.h" | 5 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap
i.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/signin/easy_unlock_service.h" | 10 #include "chrome/browser/signin/easy_unlock_service.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 const std::string& user_id) { | 127 const std::string& user_id) { |
128 } | 128 } |
129 | 129 |
130 void ScreenlockPrivateEventRouter::DispatchEvent( | 130 void ScreenlockPrivateEventRouter::DispatchEvent( |
131 const std::string& event_name, | 131 const std::string& event_name, |
132 base::Value* arg) { | 132 base::Value* arg) { |
133 scoped_ptr<base::ListValue> args(new base::ListValue()); | 133 scoped_ptr<base::ListValue> args(new base::ListValue()); |
134 if (arg) | 134 if (arg) |
135 args->Append(arg); | 135 args->Append(arg); |
136 scoped_ptr<extensions::Event> event(new extensions::Event( | 136 scoped_ptr<extensions::Event> event(new extensions::Event( |
137 event_name, args.Pass())); | 137 extensions::events::UNKNOWN, event_name, args.Pass())); |
138 extensions::EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); | 138 extensions::EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
139 } | 139 } |
140 | 140 |
141 static base::LazyInstance<extensions::BrowserContextKeyedAPIFactory< | 141 static base::LazyInstance<extensions::BrowserContextKeyedAPIFactory< |
142 ScreenlockPrivateEventRouter> > g_factory = LAZY_INSTANCE_INITIALIZER; | 142 ScreenlockPrivateEventRouter> > g_factory = LAZY_INSTANCE_INITIALIZER; |
143 | 143 |
144 // static | 144 // static |
145 extensions::BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>* | 145 extensions::BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>* |
146 ScreenlockPrivateEventRouter::GetFactoryInstance() { | 146 ScreenlockPrivateEventRouter::GetFactoryInstance() { |
147 return g_factory.Pointer(); | 147 return g_factory.Pointer(); |
148 } | 148 } |
149 | 149 |
150 void ScreenlockPrivateEventRouter::Shutdown() { | 150 void ScreenlockPrivateEventRouter::Shutdown() { |
151 GetScreenlockBridgeInstance()->RemoveObserver(this); | 151 GetScreenlockBridgeInstance()->RemoveObserver(this); |
152 } | 152 } |
153 | 153 |
154 bool ScreenlockPrivateEventRouter::OnAuthAttempted( | 154 bool ScreenlockPrivateEventRouter::OnAuthAttempted( |
155 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type, | 155 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type, |
156 const std::string& value) { | 156 const std::string& value) { |
157 extensions::EventRouter* router = | 157 extensions::EventRouter* router = |
158 extensions::EventRouter::Get(browser_context_); | 158 extensions::EventRouter::Get(browser_context_); |
159 if (!router->HasEventListener(screenlock::OnAuthAttempted::kEventName)) | 159 if (!router->HasEventListener(screenlock::OnAuthAttempted::kEventName)) |
160 return false; | 160 return false; |
161 | 161 |
162 scoped_ptr<base::ListValue> args(new base::ListValue()); | 162 scoped_ptr<base::ListValue> args(new base::ListValue()); |
163 args->AppendString(screenlock::ToString(FromLockHandlerAuthType(auth_type))); | 163 args->AppendString(screenlock::ToString(FromLockHandlerAuthType(auth_type))); |
164 args->AppendString(value); | 164 args->AppendString(value); |
165 | 165 |
166 scoped_ptr<extensions::Event> event(new extensions::Event( | 166 scoped_ptr<extensions::Event> event(new extensions::Event( |
167 screenlock::OnAuthAttempted::kEventName, args.Pass())); | 167 extensions::events::UNKNOWN, screenlock::OnAuthAttempted::kEventName, |
| 168 args.Pass())); |
168 router->BroadcastEvent(event.Pass()); | 169 router->BroadcastEvent(event.Pass()); |
169 return true; | 170 return true; |
170 } | 171 } |
171 | 172 |
172 } // namespace extensions | 173 } // namespace extensions |
OLD | NEW |