| 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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/signin/chrome_proximity_auth_client.h" | 14 #include "chrome/browser/signin/chrome_proximity_auth_client.h" |
| 15 #include "chrome/browser/signin/easy_unlock_service.h" | 15 #include "chrome/browser/signin/easy_unlock_service.h" |
| 16 #include "chrome/common/extensions/api/screenlock_private.h" | 16 #include "chrome/common/extensions/api/screenlock_private.h" |
| 17 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
| 18 #include "components/proximity_auth/screenlock_bridge.h" | 18 #include "components/proximity_auth/screenlock_bridge.h" |
| 19 #include "extensions/browser/app_window/app_window_registry.h" | 19 #include "extensions/browser/app_window/app_window_registry.h" |
| 20 #include "extensions/browser/event_router.h" | 20 #include "extensions/browser/event_router.h" |
| 21 | 21 |
| 22 namespace extensions { | 22 namespace extensions { |
| 23 | 23 |
| 24 namespace screenlock = api::screenlock_private; | 24 namespace screenlock = api::screenlock_private; |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 screenlock::AuthType FromLockHandlerAuthType( | 28 screenlock::AuthType FromLockHandlerAuthType( |
| 29 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type) { | 29 proximity_auth::mojom::AuthType auth_type) { |
| 30 switch (auth_type) { | 30 switch (auth_type) { |
| 31 case proximity_auth::ScreenlockBridge::LockHandler::OFFLINE_PASSWORD: | 31 case proximity_auth::mojom::AuthType::OFFLINE_PASSWORD: |
| 32 return screenlock::AUTH_TYPE_OFFLINEPASSWORD; | 32 return screenlock::AUTH_TYPE_OFFLINEPASSWORD; |
| 33 case proximity_auth::ScreenlockBridge::LockHandler::NUMERIC_PIN: | 33 case proximity_auth::mojom::AuthType::NUMERIC_PIN: |
| 34 return screenlock::AUTH_TYPE_NUMERICPIN; | 34 return screenlock::AUTH_TYPE_NUMERICPIN; |
| 35 case proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK: | 35 case proximity_auth::mojom::AuthType::USER_CLICK: |
| 36 return screenlock::AUTH_TYPE_USERCLICK; | 36 return screenlock::AUTH_TYPE_USERCLICK; |
| 37 case proximity_auth::ScreenlockBridge::LockHandler::ONLINE_SIGN_IN: | 37 case proximity_auth::mojom::AuthType::ONLINE_SIGN_IN: |
| 38 // Apps should treat forced online sign in same as system password. | 38 // Apps should treat forced online sign in same as system password. |
| 39 return screenlock::AUTH_TYPE_OFFLINEPASSWORD; | 39 return screenlock::AUTH_TYPE_OFFLINEPASSWORD; |
| 40 case proximity_auth::ScreenlockBridge::LockHandler::EXPAND_THEN_USER_CLICK: | 40 case proximity_auth::mojom::AuthType::EXPAND_THEN_USER_CLICK: |
| 41 // This type is used for public sessions, which do not support screen | 41 // This type is used for public sessions, which do not support screen |
| 42 // locking. | 42 // locking. |
| 43 NOTREACHED(); | 43 NOTREACHED(); |
| 44 return screenlock::AUTH_TYPE_NONE; | 44 return screenlock::AUTH_TYPE_NONE; |
| 45 case proximity_auth::ScreenlockBridge::LockHandler::FORCE_OFFLINE_PASSWORD: | 45 case proximity_auth::mojom::AuthType::FORCE_OFFLINE_PASSWORD: |
| 46 return screenlock::AUTH_TYPE_OFFLINEPASSWORD; | 46 return screenlock::AUTH_TYPE_OFFLINEPASSWORD; |
| 47 } | 47 } |
| 48 NOTREACHED(); | 48 NOTREACHED(); |
| 49 return screenlock::AUTH_TYPE_OFFLINEPASSWORD; | 49 return screenlock::AUTH_TYPE_OFFLINEPASSWORD; |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 ScreenlockPrivateGetLockedFunction::ScreenlockPrivateGetLockedFunction() {} | 54 ScreenlockPrivateGetLockedFunction::ScreenlockPrivateGetLockedFunction() {} |
| 55 | 55 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>* | 154 BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>* |
| 155 ScreenlockPrivateEventRouter::GetFactoryInstance() { | 155 ScreenlockPrivateEventRouter::GetFactoryInstance() { |
| 156 return g_factory.Pointer(); | 156 return g_factory.Pointer(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void ScreenlockPrivateEventRouter::Shutdown() { | 159 void ScreenlockPrivateEventRouter::Shutdown() { |
| 160 proximity_auth::ScreenlockBridge::Get()->RemoveObserver(this); | 160 proximity_auth::ScreenlockBridge::Get()->RemoveObserver(this); |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool ScreenlockPrivateEventRouter::OnAuthAttempted( | 163 bool ScreenlockPrivateEventRouter::OnAuthAttempted( |
| 164 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type, | 164 proximity_auth::mojom::AuthType auth_type, |
| 165 const std::string& value) { | 165 const std::string& value) { |
| 166 EventRouter* router = EventRouter::Get(browser_context_); | 166 EventRouter* router = EventRouter::Get(browser_context_); |
| 167 if (!router->HasEventListener(screenlock::OnAuthAttempted::kEventName)) | 167 if (!router->HasEventListener(screenlock::OnAuthAttempted::kEventName)) |
| 168 return false; | 168 return false; |
| 169 | 169 |
| 170 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 170 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
| 171 args->AppendString(screenlock::ToString(FromLockHandlerAuthType(auth_type))); | 171 args->AppendString(screenlock::ToString(FromLockHandlerAuthType(auth_type))); |
| 172 args->AppendString(value); | 172 args->AppendString(value); |
| 173 | 173 |
| 174 std::unique_ptr<Event> event( | 174 std::unique_ptr<Event> event( |
| 175 new Event(events::SCREENLOCK_PRIVATE_ON_AUTH_ATTEMPTED, | 175 new Event(events::SCREENLOCK_PRIVATE_ON_AUTH_ATTEMPTED, |
| 176 screenlock::OnAuthAttempted::kEventName, std::move(args))); | 176 screenlock::OnAuthAttempted::kEventName, std::move(args))); |
| 177 router->BroadcastEvent(std::move(event)); | 177 router->BroadcastEvent(std::move(event)); |
| 178 return true; | 178 return true; |
| 179 } | 179 } |
| 180 | 180 |
| 181 } // namespace extensions | 181 } // namespace extensions |
| OLD | NEW |