| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/signin/easy_unlock_app_manager.h" | 5 #include "chrome/browser/signin/easy_unlock_app_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "chrome/browser/extensions/component_loader.h" | 9 #include "chrome/browser/extensions/component_loader.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 return false; | 154 return false; |
| 155 | 155 |
| 156 extensions::api::easy_unlock_private::UserInfo info; | 156 extensions::api::easy_unlock_private::UserInfo info; |
| 157 info.user_id = user_id; | 157 info.user_id = user_id; |
| 158 info.logged_in = is_logged_in; | 158 info.logged_in = is_logged_in; |
| 159 info.data_ready = data_ready; | 159 info.data_ready = data_ready; |
| 160 | 160 |
| 161 scoped_ptr<base::ListValue> args(new base::ListValue()); | 161 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 162 args->Append(info.ToValue().release()); | 162 args->Append(info.ToValue().release()); |
| 163 | 163 |
| 164 scoped_ptr<extensions::Event> event( | 164 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 165 new extensions::Event(event_name, args.Pass())); | 165 extensions::events::UNKNOWN, event_name, args.Pass())); |
| 166 | 166 |
| 167 event_router->DispatchEventToExtension(app_id_, event.Pass()); | 167 event_router->DispatchEventToExtension(app_id_, event.Pass()); |
| 168 return true; | 168 return true; |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool EasyUnlockAppManagerImpl::SendAuthAttemptEvent() { | 171 bool EasyUnlockAppManagerImpl::SendAuthAttemptEvent() { |
| 172 ExtensionService* extension_service = extension_system_->extension_service(); | 172 ExtensionService* extension_service = extension_system_->extension_service(); |
| 173 if (!extension_service) | 173 if (!extension_service) |
| 174 return false; | 174 return false; |
| 175 | 175 |
| 176 extensions::EventRouter* event_router = | 176 extensions::EventRouter* event_router = |
| 177 extensions::EventRouter::Get(extension_service->GetBrowserContext()); | 177 extensions::EventRouter::Get(extension_service->GetBrowserContext()); |
| 178 if (!event_router) | 178 if (!event_router) |
| 179 return false; | 179 return false; |
| 180 | 180 |
| 181 std::string event_name = | 181 std::string event_name = |
| 182 extensions::api::screenlock_private::OnAuthAttempted::kEventName; | 182 extensions::api::screenlock_private::OnAuthAttempted::kEventName; |
| 183 | 183 |
| 184 if (!event_router->HasEventListener(event_name)) | 184 if (!event_router->HasEventListener(event_name)) |
| 185 return false; | 185 return false; |
| 186 | 186 |
| 187 scoped_ptr<base::ListValue> args(new base::ListValue()); | 187 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 188 args->AppendString(extensions::api::screenlock_private::ToString( | 188 args->AppendString(extensions::api::screenlock_private::ToString( |
| 189 extensions::api::screenlock_private::AUTH_TYPE_USERCLICK)); | 189 extensions::api::screenlock_private::AUTH_TYPE_USERCLICK)); |
| 190 args->AppendString(std::string()); | 190 args->AppendString(std::string()); |
| 191 | 191 |
| 192 scoped_ptr<extensions::Event> event( | 192 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 193 new extensions::Event(event_name, args.Pass())); | 193 extensions::events::UNKNOWN, event_name, args.Pass())); |
| 194 | 194 |
| 195 // TODO(tbarzic): Restrict this to EasyUnlock app. | 195 // TODO(tbarzic): Restrict this to EasyUnlock app. |
| 196 event_router->BroadcastEvent(event.Pass()); | 196 event_router->BroadcastEvent(event.Pass()); |
| 197 return true; | 197 return true; |
| 198 } | 198 } |
| 199 | 199 |
| 200 } // namespace | 200 } // namespace |
| 201 | 201 |
| 202 EasyUnlockAppManager::~EasyUnlockAppManager() { | 202 EasyUnlockAppManager::~EasyUnlockAppManager() { |
| 203 } | 203 } |
| 204 | 204 |
| 205 // static | 205 // static |
| 206 scoped_ptr<EasyUnlockAppManager> EasyUnlockAppManager::Create( | 206 scoped_ptr<EasyUnlockAppManager> EasyUnlockAppManager::Create( |
| 207 extensions::ExtensionSystem* extension_system, | 207 extensions::ExtensionSystem* extension_system, |
| 208 int manifest_id, | 208 int manifest_id, |
| 209 const base::FilePath& app_path) { | 209 const base::FilePath& app_path) { |
| 210 return scoped_ptr<EasyUnlockAppManager>( | 210 return scoped_ptr<EasyUnlockAppManager>( |
| 211 new EasyUnlockAppManagerImpl(extension_system, manifest_id, app_path)); | 211 new EasyUnlockAppManagerImpl(extension_system, manifest_id, app_path)); |
| 212 } | 212 } |
| OLD | NEW |