| 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/chrome_proximity_auth_client.h" |
| 11 #include "chrome/browser/signin/chrome_proximity_auth_client_factory.h" |
| 10 #include "chrome/browser/signin/easy_unlock_service.h" | 12 #include "chrome/browser/signin/easy_unlock_service.h" |
| 11 #include "chrome/browser/signin/proximity_auth_facade.h" | 13 #include "chrome/browser/signin/proximity_auth_facade.h" |
| 12 #include "chrome/common/extensions/api/screenlock_private.h" | 14 #include "chrome/common/extensions/api/screenlock_private.h" |
| 13 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
| 14 #include "extensions/browser/app_window/app_window_registry.h" | 16 #include "extensions/browser/app_window/app_window_registry.h" |
| 15 #include "extensions/browser/event_router.h" | 17 #include "extensions/browser/event_router.h" |
| 16 | 18 |
| 17 namespace screenlock = extensions::api::screenlock_private; | 19 namespace screenlock = extensions::api::screenlock_private; |
| 18 | 20 |
| 19 namespace extensions { | 21 namespace extensions { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 60 } |
| 59 | 61 |
| 60 ScreenlockPrivateSetLockedFunction::ScreenlockPrivateSetLockedFunction() {} | 62 ScreenlockPrivateSetLockedFunction::ScreenlockPrivateSetLockedFunction() {} |
| 61 | 63 |
| 62 ScreenlockPrivateSetLockedFunction::~ScreenlockPrivateSetLockedFunction() {} | 64 ScreenlockPrivateSetLockedFunction::~ScreenlockPrivateSetLockedFunction() {} |
| 63 | 65 |
| 64 bool ScreenlockPrivateSetLockedFunction::RunAsync() { | 66 bool ScreenlockPrivateSetLockedFunction::RunAsync() { |
| 65 scoped_ptr<screenlock::SetLocked::Params> params( | 67 scoped_ptr<screenlock::SetLocked::Params> params( |
| 66 screenlock::SetLocked::Params::Create(*args_)); | 68 screenlock::SetLocked::Params::Create(*args_)); |
| 67 EXTENSION_FUNCTION_VALIDATE(params.get()); | 69 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 70 ChromeProximityAuthClient* proximity_auth_client = |
| 71 ChromeProximityAuthClientFactory::GetForProfile(GetProfile()); |
| 68 if (params->locked) { | 72 if (params->locked) { |
| 69 if (extension()->id() == extension_misc::kEasyUnlockAppId && | 73 if (extension()->id() == extension_misc::kEasyUnlockAppId && |
| 70 AppWindowRegistry::Get(browser_context()) | 74 AppWindowRegistry::Get(browser_context()) |
| 71 ->GetAppWindowForAppAndKey(extension()->id(), | 75 ->GetAppWindowForAppAndKey(extension()->id(), |
| 72 "easy_unlock_pairing")) { | 76 "easy_unlock_pairing")) { |
| 73 // Mark the Easy Unlock behaviour on the lock screen as the one initiated | 77 // Mark the Easy Unlock behaviour on the lock screen as the one initiated |
| 74 // by the Easy Unlock setup app as a trial one. | 78 // by the Easy Unlock setup app as a trial one. |
| 75 // TODO(tbarzic): Move this logic to a new easyUnlockPrivate function. | 79 // TODO(tbarzic): Move this logic to a new easyUnlockPrivate function. |
| 76 EasyUnlockService* service = EasyUnlockService::Get(GetProfile()); | 80 EasyUnlockService* service = EasyUnlockService::Get(GetProfile()); |
| 77 if (service) | 81 if (service) |
| 78 service->SetTrialRun(); | 82 service->SetTrialRun(); |
| 79 } | 83 } |
| 80 GetScreenlockBridgeInstance()->Lock(GetProfile()); | 84 GetScreenlockBridgeInstance()->Lock(proximity_auth_client); |
| 81 } else { | 85 } else { |
| 82 GetScreenlockBridgeInstance()->Unlock(GetProfile()); | 86 GetScreenlockBridgeInstance()->Unlock(proximity_auth_client); |
| 83 } | 87 } |
| 84 SendResponse(error_.empty()); | 88 SendResponse(error_.empty()); |
| 85 return true; | 89 return true; |
| 86 } | 90 } |
| 87 | 91 |
| 88 ScreenlockPrivateAcceptAuthAttemptFunction:: | 92 ScreenlockPrivateAcceptAuthAttemptFunction:: |
| 89 ScreenlockPrivateAcceptAuthAttemptFunction() {} | 93 ScreenlockPrivateAcceptAuthAttemptFunction() {} |
| 90 | 94 |
| 91 ScreenlockPrivateAcceptAuthAttemptFunction:: | 95 ScreenlockPrivateAcceptAuthAttemptFunction:: |
| 92 ~ScreenlockPrivateAcceptAuthAttemptFunction() {} | 96 ~ScreenlockPrivateAcceptAuthAttemptFunction() {} |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 args->AppendString(value); | 168 args->AppendString(value); |
| 165 | 169 |
| 166 scoped_ptr<extensions::Event> event(new extensions::Event( | 170 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 167 extensions::events::UNKNOWN, screenlock::OnAuthAttempted::kEventName, | 171 extensions::events::UNKNOWN, screenlock::OnAuthAttempted::kEventName, |
| 168 args.Pass())); | 172 args.Pass())); |
| 169 router->BroadcastEvent(event.Pass()); | 173 router->BroadcastEvent(event.Pass()); |
| 170 return true; | 174 return true; |
| 171 } | 175 } |
| 172 | 176 |
| 173 } // namespace extensions | 177 } // namespace extensions |
| OLD | NEW |