Commit 7f112aaa authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Commit Bot

[CrOS Multidevice] Integrate SecureChannel API into EasyUnlockServices.

Grab the global SecureChannelClient instance in EasyUnlockServiceFactory,
and inject it into EasyUnlockServiceRegular and EasyUnlockServiceSignin.

This change has allowed me to manually verify that Smart Lock works with
the new SecureChannel API, in the regular, lock-screen case. Additional
work still needs to be done to fully integrate the sign-in case, which
will come in subsequent CLs.

R=jhawkins@chromium.org, khorimoto@chromium.org

Bug: 824568, 752273
Change-Id: I77952966eace55dabb6895569c8b18ac03cd1189
Reviewed-on: https://chromium-review.googlesource.com/1108880
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarJames Hawkins <jhawkins@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570110}
parent c5a0d954
...@@ -64,7 +64,9 @@ constexpr char kInvalidPassword[] = "invalid"; ...@@ -64,7 +64,9 @@ constexpr char kInvalidPassword[] = "invalid";
class FakeEasyUnlockService : public EasyUnlockServiceRegular { class FakeEasyUnlockService : public EasyUnlockServiceRegular {
public: public:
explicit FakeEasyUnlockService(Profile* profile) explicit FakeEasyUnlockService(Profile* profile)
: EasyUnlockServiceRegular(profile, nullptr /* device_sync_client */), : EasyUnlockServiceRegular(profile,
nullptr /* secure_channel_client */,
nullptr /* device_sync_client */),
reauth_count_(0) {} reauth_count_(0) {}
~FakeEasyUnlockService() override {} ~FakeEasyUnlockService() override {}
......
...@@ -219,8 +219,11 @@ class EasyUnlockService::PowerMonitor : public PowerManagerClient::Observer { ...@@ -219,8 +219,11 @@ class EasyUnlockService::PowerMonitor : public PowerManagerClient::Observer {
DISALLOW_COPY_AND_ASSIGN(PowerMonitor); DISALLOW_COPY_AND_ASSIGN(PowerMonitor);
}; };
EasyUnlockService::EasyUnlockService(Profile* profile) EasyUnlockService::EasyUnlockService(
Profile* profile,
secure_channel::SecureChannelClient* secure_channel_client)
: profile_(profile), : profile_(profile),
secure_channel_client_(secure_channel_client),
proximity_auth_client_(profile), proximity_auth_client_(profile),
bluetooth_detector_(new BluetoothDetector(this)), bluetooth_detector_(new BluetoothDetector(this)),
shut_down_(false), shut_down_(false),
...@@ -682,12 +685,11 @@ void EasyUnlockService::SetProximityAuthDevices( ...@@ -682,12 +685,11 @@ void EasyUnlockService::SetProximityAuthDevices(
if (!proximity_auth_system_) { if (!proximity_auth_system_) {
PA_LOG(INFO) << "Creating ProximityAuthSystem."; PA_LOG(INFO) << "Creating ProximityAuthSystem.";
// TODO(crbug.com/752273): Inject a real secure_channel_client.
proximity_auth_system_.reset(new proximity_auth::ProximityAuthSystem( proximity_auth_system_.reset(new proximity_auth::ProximityAuthSystem(
GetType() == TYPE_SIGNIN GetType() == TYPE_SIGNIN
? proximity_auth::ProximityAuthSystem::SIGN_IN ? proximity_auth::ProximityAuthSystem::SIGN_IN
: proximity_auth::ProximityAuthSystem::SESSION_LOCK, : proximity_auth::ProximityAuthSystem::SESSION_LOCK,
proximity_auth_client(), nullptr /* secure_channel_client */)); proximity_auth_client(), secure_channel_client_));
} }
proximity_auth_system_->SetRemoteDevicesForUser(account_id, remote_devices, proximity_auth_system_->SetRemoteDevicesForUser(account_id, remote_devices,
......
...@@ -47,6 +47,10 @@ class PrefRegistrySimple; ...@@ -47,6 +47,10 @@ class PrefRegistrySimple;
namespace chromeos { namespace chromeos {
namespace secure_channel {
class SecureChannelClient;
} // namespace secure_channel
class EasyUnlockAppManager; class EasyUnlockAppManager;
class EasyUnlockServiceObserver; class EasyUnlockServiceObserver;
class UserContext; class UserContext;
...@@ -196,7 +200,8 @@ class EasyUnlockService : public KeyedService { ...@@ -196,7 +200,8 @@ class EasyUnlockService : public KeyedService {
} }
protected: protected:
explicit EasyUnlockService(Profile* profile); EasyUnlockService(Profile* profile,
secure_channel::SecureChannelClient* secure_channel_client);
~EasyUnlockService() override; ~EasyUnlockService() override;
// Does a service type specific initialization. // Does a service type specific initialization.
...@@ -300,6 +305,7 @@ class EasyUnlockService : public KeyedService { ...@@ -300,6 +305,7 @@ class EasyUnlockService : public KeyedService {
void EnsureTpmKeyPresentIfNeeded(); void EnsureTpmKeyPresentIfNeeded();
Profile* const profile_; Profile* const profile_;
secure_channel::SecureChannelClient* secure_channel_client_;
ChromeProximityAuthClient proximity_auth_client_; ChromeProximityAuthClient proximity_auth_client_;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_signin_chromeos.h" #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_service_signin_chromeos.h"
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.h" #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h" #include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/secure_channel/secure_channel_client_provider.h"
#include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
...@@ -87,13 +88,17 @@ KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor( ...@@ -87,13 +88,17 @@ KeyedService* EasyUnlockServiceFactory::BuildServiceInstanceFor(
if (!context->IsOffTheRecord()) if (!context->IsOffTheRecord())
return NULL; return NULL;
service = new EasyUnlockServiceSignin(Profile::FromBrowserContext(context)); service = new EasyUnlockServiceSignin(
Profile::FromBrowserContext(context),
secure_channel::SecureChannelClientProvider::GetInstance()
->GetClient());
manifest_id = IDR_EASY_UNLOCK_MANIFEST_SIGNIN; manifest_id = IDR_EASY_UNLOCK_MANIFEST_SIGNIN;
} }
if (!service) { if (!service) {
service = new EasyUnlockServiceRegular( service = new EasyUnlockServiceRegular(
Profile::FromBrowserContext(context), Profile::FromBrowserContext(context),
secure_channel::SecureChannelClientProvider::GetInstance()->GetClient(),
device_sync::DeviceSyncClientFactory::GetForProfile( device_sync::DeviceSyncClientFactory::GetForProfile(
Profile::FromBrowserContext(context))); Profile::FromBrowserContext(context)));
manifest_id = IDR_EASY_UNLOCK_MANIFEST; manifest_id = IDR_EASY_UNLOCK_MANIFEST;
......
...@@ -107,17 +107,20 @@ void LogSmartLockEnabledState(SmartLockEnabledState state) { ...@@ -107,17 +107,20 @@ void LogSmartLockEnabledState(SmartLockEnabledState state) {
EasyUnlockServiceRegular::EasyUnlockServiceRegular( EasyUnlockServiceRegular::EasyUnlockServiceRegular(
Profile* profile, Profile* profile,
secure_channel::SecureChannelClient* secure_channel_client,
device_sync::DeviceSyncClient* device_sync_client) device_sync::DeviceSyncClient* device_sync_client)
: EasyUnlockServiceRegular( : EasyUnlockServiceRegular(
profile, profile,
secure_channel_client,
std::make_unique<EasyUnlockNotificationController>(profile), std::make_unique<EasyUnlockNotificationController>(profile),
device_sync_client) {} device_sync_client) {}
EasyUnlockServiceRegular::EasyUnlockServiceRegular( EasyUnlockServiceRegular::EasyUnlockServiceRegular(
Profile* profile, Profile* profile,
secure_channel::SecureChannelClient* secure_channel_client,
std::unique_ptr<EasyUnlockNotificationController> notification_controller, std::unique_ptr<EasyUnlockNotificationController> notification_controller,
device_sync::DeviceSyncClient* device_sync_client) device_sync::DeviceSyncClient* device_sync_client)
: EasyUnlockService(profile), : EasyUnlockService(profile, secure_channel_client),
turn_off_flow_status_(EasyUnlockService::IDLE), turn_off_flow_status_(EasyUnlockService::IDLE),
scoped_crypt_auth_device_manager_observer_(this), scoped_crypt_auth_device_manager_observer_(this),
will_unlock_using_easy_unlock_(false), will_unlock_using_easy_unlock_(false),
......
...@@ -43,6 +43,10 @@ class Profile; ...@@ -43,6 +43,10 @@ class Profile;
namespace chromeos { namespace chromeos {
namespace secure_channel {
class SecureChannelClient;
} // namespace secure_channel
class EasyUnlockNotificationController; class EasyUnlockNotificationController;
// EasyUnlockService instance that should be used for regular, non-signin // EasyUnlockService instance that should be used for regular, non-signin
...@@ -53,13 +57,15 @@ class EasyUnlockServiceRegular ...@@ -53,13 +57,15 @@ class EasyUnlockServiceRegular
public cryptauth::CryptAuthDeviceManager::Observer, public cryptauth::CryptAuthDeviceManager::Observer,
public device_sync::DeviceSyncClient::Observer { public device_sync::DeviceSyncClient::Observer {
public: public:
explicit EasyUnlockServiceRegular( EasyUnlockServiceRegular(
Profile* profile, Profile* profile,
secure_channel::SecureChannelClient* secure_channel_client,
device_sync::DeviceSyncClient* device_sync_client); device_sync::DeviceSyncClient* device_sync_client);
// Constructor for tests. // Constructor for tests.
EasyUnlockServiceRegular( EasyUnlockServiceRegular(
Profile* profile, Profile* profile,
secure_channel::SecureChannelClient* secure_channel_client,
std::unique_ptr<EasyUnlockNotificationController> notification_controller, std::unique_ptr<EasyUnlockNotificationController> notification_controller,
device_sync::DeviceSyncClient* device_sync_client); device_sync::DeviceSyncClient* device_sync_client);
......
...@@ -167,8 +167,10 @@ EasyUnlockServiceSignin::UserData::UserData() ...@@ -167,8 +167,10 @@ EasyUnlockServiceSignin::UserData::UserData()
EasyUnlockServiceSignin::UserData::~UserData() {} EasyUnlockServiceSignin::UserData::~UserData() {}
EasyUnlockServiceSignin::EasyUnlockServiceSignin(Profile* profile) EasyUnlockServiceSignin::EasyUnlockServiceSignin(
: EasyUnlockService(profile), Profile* profile,
secure_channel::SecureChannelClient* secure_channel_client)
: EasyUnlockService(profile, secure_channel_client),
account_id_(EmptyAccountId()), account_id_(EmptyAccountId()),
user_pod_last_focused_timestamp_(base::TimeTicks::Now()), user_pod_last_focused_timestamp_(base::TimeTicks::Now()),
remote_device_cache_( remote_device_cache_(
......
...@@ -28,6 +28,10 @@ class ProximityAuthLocalStatePrefManager; ...@@ -28,6 +28,10 @@ class ProximityAuthLocalStatePrefManager;
namespace chromeos { namespace chromeos {
namespace secure_channel {
class SecureChannelClient;
} // namespace secure_channel
class EasyUnlockChallengeWrapper; class EasyUnlockChallengeWrapper;
// EasyUnlockService instance that should be used for signin profile. // EasyUnlockService instance that should be used for signin profile.
...@@ -36,7 +40,9 @@ class EasyUnlockServiceSignin ...@@ -36,7 +40,9 @@ class EasyUnlockServiceSignin
public proximity_auth::ScreenlockBridge::Observer, public proximity_auth::ScreenlockBridge::Observer,
public LoginState::Observer { public LoginState::Observer {
public: public:
explicit EasyUnlockServiceSignin(Profile* profile); EasyUnlockServiceSignin(
Profile* profile,
secure_channel::SecureChannelClient* secure_channel_client);
~EasyUnlockServiceSignin() override; ~EasyUnlockServiceSignin() override;
// Wraps the challenge for the remote device identified by |account_id| and // Wraps the challenge for the remote device identified by |account_id| and
......
...@@ -210,6 +210,7 @@ std::unique_ptr<KeyedService> CreateEasyUnlockServiceForTest( ...@@ -210,6 +210,7 @@ std::unique_ptr<KeyedService> CreateEasyUnlockServiceForTest(
std::unique_ptr<EasyUnlockServiceRegular> service( std::unique_ptr<EasyUnlockServiceRegular> service(
new EasyUnlockServiceRegular( new EasyUnlockServiceRegular(
Profile::FromBrowserContext(context), Profile::FromBrowserContext(context),
nullptr /* secure_channel_client */,
std::make_unique<MockEasyUnlockNotificationController>(), std::make_unique<MockEasyUnlockNotificationController>(),
fake_device_sync_client)); fake_device_sync_client));
service->Initialize(std::move(app_manager)); service->Initialize(std::move(app_manager));
......
...@@ -22,7 +22,7 @@ namespace { ...@@ -22,7 +22,7 @@ namespace {
class FakeEasyUnlockService : public EasyUnlockService { class FakeEasyUnlockService : public EasyUnlockService {
public: public:
explicit FakeEasyUnlockService(Profile* profile) explicit FakeEasyUnlockService(Profile* profile)
: EasyUnlockService(profile), : EasyUnlockService(profile, nullptr /* secure_channel_client */),
turn_off_status_(IDLE), turn_off_status_(IDLE),
is_allowed_(true), is_allowed_(true),
is_enabled_(false) {} is_enabled_(false) {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment