Commit a7554261 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS MultDevice] Add SoftwareFeatureManager.

This CL renames and refactors DeviceCapabilityManager. Now, this class
makes use of the SoftwareFeature proto message instead of relying on its
own Capability enum. Likewise, now the class utilizes new fields in
ToggleEasyUnlockRequest (e.g., is_exclusive). Finally, this class no
longer has any promo-related functionality, since that is being removed
in favor of the unified setup flow.

Bug: 824568, 752273
Change-Id: I23f5c642a3974c2723f29591d67fe79d0426effb
Reviewed-on: https://chromium-review.googlesource.com/1011543Reviewed-by: default avatarJeremy Klein <jlklein@chromium.org>
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551536}
parent 07624090
...@@ -45,9 +45,6 @@ static_library("cryptauth") { ...@@ -45,9 +45,6 @@ static_library("cryptauth") {
"cryptauth_service.h", "cryptauth_service.h",
"data_with_timestamp.cc", "data_with_timestamp.cc",
"data_with_timestamp.h", "data_with_timestamp.h",
"device_capability_manager.h",
"device_capability_manager_impl.cc",
"device_capability_manager_impl.h",
"device_classifier_util.cc", "device_classifier_util.cc",
"device_classifier_util.h", "device_classifier_util.h",
"device_to_device_authenticator.cc", "device_to_device_authenticator.cc",
...@@ -85,6 +82,9 @@ static_library("cryptauth") { ...@@ -85,6 +82,9 @@ static_library("cryptauth") {
"secure_message_delegate_impl.h", "secure_message_delegate_impl.h",
"session_keys.cc", "session_keys.cc",
"session_keys.h", "session_keys.h",
"software_feature_manager.h",
"software_feature_manager_impl.cc",
"software_feature_manager_impl.h",
"switches.cc", "switches.cc",
"switches.h", "switches.h",
"sync_scheduler.cc", "sync_scheduler.cc",
...@@ -141,8 +141,6 @@ static_library("test_support") { ...@@ -141,8 +141,6 @@ static_library("test_support") {
"fake_cryptauth_gcm_manager.h", "fake_cryptauth_gcm_manager.h",
"fake_cryptauth_service.cc", "fake_cryptauth_service.cc",
"fake_cryptauth_service.h", "fake_cryptauth_service.h",
"fake_device_capability_manager.cc",
"fake_device_capability_manager.h",
"fake_gcm_device_info_provider.cc", "fake_gcm_device_info_provider.cc",
"fake_gcm_device_info_provider.h", "fake_gcm_device_info_provider.h",
"fake_remote_device_provider.cc", "fake_remote_device_provider.cc",
...@@ -153,6 +151,8 @@ static_library("test_support") { ...@@ -153,6 +151,8 @@ static_library("test_support") {
"fake_secure_context.h", "fake_secure_context.h",
"fake_secure_message_delegate.cc", "fake_secure_message_delegate.cc",
"fake_secure_message_delegate.h", "fake_secure_message_delegate.h",
"fake_software_feature_manager.cc",
"fake_software_feature_manager.h",
"mock_cryptauth_client.cc", "mock_cryptauth_client.cc",
"mock_cryptauth_client.h", "mock_cryptauth_client.h",
"mock_foreground_eid_generator.cc", "mock_foreground_eid_generator.cc",
...@@ -191,7 +191,6 @@ source_set("unit_tests") { ...@@ -191,7 +191,6 @@ source_set("unit_tests") {
"cryptauth_enroller_impl_unittest.cc", "cryptauth_enroller_impl_unittest.cc",
"cryptauth_enrollment_manager_impl_unittest.cc", "cryptauth_enrollment_manager_impl_unittest.cc",
"cryptauth_gcm_manager_impl_unittest.cc", "cryptauth_gcm_manager_impl_unittest.cc",
"device_capability_manager_impl_unittest.cc",
"device_to_device_authenticator_unittest.cc", "device_to_device_authenticator_unittest.cc",
"device_to_device_operations_unittest.cc", "device_to_device_operations_unittest.cc",
"device_to_device_secure_context_unittest.cc", "device_to_device_secure_context_unittest.cc",
...@@ -204,6 +203,7 @@ source_set("unit_tests") { ...@@ -204,6 +203,7 @@ source_set("unit_tests") {
"remote_device_provider_impl_unittest.cc", "remote_device_provider_impl_unittest.cc",
"secure_channel_unittest.cc", "secure_channel_unittest.cc",
"session_keys_unittest.cc", "session_keys_unittest.cc",
"software_feature_manager_impl_unittest.cc",
"sync_scheduler_impl_unittest.cc", "sync_scheduler_impl_unittest.cc",
"wire_message_unittest.cc", "wire_message_unittest.cc",
] ]
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/cryptauth/fake_device_capability_manager.h"
namespace cryptauth {
FakeDeviceCapabilityManager::FakeDeviceCapabilityManager() {}
FakeDeviceCapabilityManager::~FakeDeviceCapabilityManager() {}
void FakeDeviceCapabilityManager::SetCapabilityEnabled(
const std::string& public_key,
Capability capability,
bool enabled,
const base::Closure& success_callback,
const base::Callback<void(const std::string&)>& error_callback) {
if (set_capability_enabled_error_code_.empty()) {
success_callback.Run();
return;
}
error_callback.Run(std::move(set_capability_enabled_error_code_));
}
void FakeDeviceCapabilityManager::FindEligibleDevicesForCapability(
Capability capability,
const base::Callback<void(const std::vector<ExternalDeviceInfo>&,
const std::vector<IneligibleDevice>&)>&
success_callback,
const base::Callback<void(const std::string&)>& error_callback) {
if (find_eligible_devices_for_capability_error_code_.empty()) {
success_callback.Run(external_device_infos_, ineligible_devices_);
return;
}
error_callback.Run(find_eligible_devices_for_capability_error_code_);
}
void FakeDeviceCapabilityManager::IsCapabilityPromotable(
const std::string& public_key,
Capability capability,
const base::Callback<void(bool)>& success_callback,
const base::Callback<void(const std::string&)>& error_callback) {
if (is_capability_promotable_error_code_.empty()) {
success_callback.Run(true /* capability is promotable */);
return;
}
error_callback.Run(is_capability_promotable_error_code_);
}
} // namespace cryptauth
\ No newline at end of file
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_CRYPTAUTH_FAKE_DEVICE_CAPABILITY_MANAGER_H_
#define COMPONENTS_CRYPTAUTH_FAKE_DEVICE_CAPABILITY_MANAGER_H_
#include "base/callback.h"
#include "components/cryptauth/device_capability_manager.h"
#include "components/cryptauth/proto/cryptauth_api.pb.h"
namespace cryptauth {
using Capability = DeviceCapabilityManager::Capability;
// Test double for Device Capability Manager.
class FakeDeviceCapabilityManager : public cryptauth::DeviceCapabilityManager {
public:
FakeDeviceCapabilityManager();
~FakeDeviceCapabilityManager() override;
void set_find_eligible_devices_for_capability_error_code(
std::string error_code) {
find_eligible_devices_for_capability_error_code_ = error_code;
}
void set_capability_enabled_error_code(std::string error_code) {
set_capability_enabled_error_code_ = error_code;
LOG(ERROR) << set_capability_enabled_error_code_;
}
void set_is_capability_promotable_error_code(std::string error_code) {
is_capability_promotable_error_code_ = error_code;
}
void set_external_device_info(
std::vector<ExternalDeviceInfo> external_device_infos) {
external_device_infos_ = external_device_infos;
}
void set_ineligible_devices(
std::vector<IneligibleDevice> ineligible_devices) {
ineligible_devices_ = ineligible_devices;
}
// cryptauth::DeviceCapabilityManager:
void SetCapabilityEnabled(
const std::string& public_key,
Capability capability,
bool enabled,
const base::Closure& success_callback,
const base::Callback<void(const std::string&)>& error_callback) override;
void FindEligibleDevicesForCapability(
Capability capability,
const base::Callback<void(const std::vector<ExternalDeviceInfo>&,
const std::vector<IneligibleDevice>&)>&
success_callback,
const base::Callback<void(const std::string&)>& error_callback) override;
void IsCapabilityPromotable(
const std::string& public_key,
Capability capability,
const base::Callback<void(bool)>& success_callback,
const base::Callback<void(const std::string&)>& error_callback) override;
std::string set_capability_enabled_error_code_;
std::string find_eligible_devices_for_capability_error_code_;
std::string is_capability_promotable_error_code_;
std::vector<ExternalDeviceInfo> external_device_infos_;
std::vector<IneligibleDevice> ineligible_devices_;
};
} // namespace cryptauth
#endif // COMPONENTS_CRYPTAUTH_FAKE_DEVICE_CAPABILITY_MANAGER_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/cryptauth/fake_software_feature_manager.h"
namespace cryptauth {
FakeSoftwareFeatureManager::SetSoftwareFeatureStateArgs::
SetSoftwareFeatureStateArgs(
const std::string& public_key,
SoftwareFeature software_feature,
bool enabled,
const base::Closure& success_callback,
const base::Callback<void(const std::string&)>& error_callback,
bool is_exclusive)
: public_key(public_key),
software_feature(software_feature),
enabled(enabled),
success_callback(success_callback),
error_callback(error_callback),
is_exclusive(is_exclusive) {}
FakeSoftwareFeatureManager::SetSoftwareFeatureStateArgs::
~SetSoftwareFeatureStateArgs() = default;
FakeSoftwareFeatureManager::FindEligibleDevicesArgs::FindEligibleDevicesArgs(
SoftwareFeature software_feature,
const base::Callback<void(const std::vector<ExternalDeviceInfo>&,
const std::vector<IneligibleDevice>&)>&
success_callback,
const base::Callback<void(const std::string&)>& error_callback)
: software_feature(software_feature),
success_callback(success_callback),
error_callback(error_callback) {}
FakeSoftwareFeatureManager::FindEligibleDevicesArgs::
~FindEligibleDevicesArgs() = default;
FakeSoftwareFeatureManager::FakeSoftwareFeatureManager() = default;
FakeSoftwareFeatureManager::~FakeSoftwareFeatureManager() = default;
void FakeSoftwareFeatureManager::SetSoftwareFeatureState(
const std::string& public_key,
SoftwareFeature software_feature,
bool enabled,
const base::Closure& success_callback,
const base::Callback<void(const std::string&)>& error_callback,
bool is_exclusive) {
set_software_feature_state_calls_.emplace_back(
std::make_unique<SetSoftwareFeatureStateArgs>(
public_key, software_feature, enabled, success_callback,
error_callback, is_exclusive));
}
void FakeSoftwareFeatureManager::FindEligibleDevices(
SoftwareFeature software_feature,
const base::Callback<void(const std::vector<ExternalDeviceInfo>&,
const std::vector<IneligibleDevice>&)>&
success_callback,
const base::Callback<void(const std::string&)>& error_callback) {
find_eligible_multidevice_host_calls_.emplace_back(
std::make_unique<FindEligibleDevicesArgs>(
software_feature, success_callback, error_callback));
}
} // namespace cryptauth
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_CRYPTAUTH_FAKE_SOFTWARE_FEATURE_MANAGER_H_
#define COMPONENTS_CRYPTAUTH_FAKE_SOFTWARE_FEATURE_MANAGER_H_
#include <string>
#include <vector>
#include "base/callback.h"
#include "components/cryptauth/proto/cryptauth_api.pb.h"
#include "components/cryptauth/software_feature_manager.h"
namespace cryptauth {
// Test implementation of SoftwareFeatureManager.
class FakeSoftwareFeatureManager : public SoftwareFeatureManager {
public:
struct SetSoftwareFeatureStateArgs {
SetSoftwareFeatureStateArgs(
const std::string& public_key,
SoftwareFeature software_feature,
bool enabled,
const base::Closure& success_callback,
const base::Callback<void(const std::string&)>& error_callback,
bool is_exclusive);
~SetSoftwareFeatureStateArgs();
std::string public_key;
SoftwareFeature software_feature;
bool enabled;
base::Closure success_callback;
base::Callback<void(const std::string&)> error_callback;
bool is_exclusive;
private:
DISALLOW_COPY_AND_ASSIGN(SetSoftwareFeatureStateArgs);
};
struct FindEligibleDevicesArgs {
FindEligibleDevicesArgs(
SoftwareFeature software_feature,
const base::Callback<void(const std::vector<ExternalDeviceInfo>&,
const std::vector<IneligibleDevice>&)>&
success_callback,
const base::Callback<void(const std::string&)>& error_callback);
~FindEligibleDevicesArgs();
SoftwareFeature software_feature;
base::Callback<void(const std::vector<ExternalDeviceInfo>&,
const std::vector<IneligibleDevice>&)>
success_callback;
base::Callback<void(const std::string&)> error_callback;
private:
DISALLOW_COPY_AND_ASSIGN(FindEligibleDevicesArgs);
};
FakeSoftwareFeatureManager();
~FakeSoftwareFeatureManager() override;
const std::vector<std::unique_ptr<SetSoftwareFeatureStateArgs>>&
set_software_feature_state_calls() {
return set_software_feature_state_calls_;
}
const std::vector<std::unique_ptr<FindEligibleDevicesArgs>>&
find_eligible_multidevice_host_calls() {
return find_eligible_multidevice_host_calls_;
}
// SoftwareFeatureManager:
void SetSoftwareFeatureState(
const std::string& public_key,
SoftwareFeature software_feature,
bool enabled,
const base::Closure& success_callback,
const base::Callback<void(const std::string&)>& error_callback,
bool is_exclusive = false) override;
void FindEligibleDevices(
SoftwareFeature software_feature,
const base::Callback<void(const std::vector<ExternalDeviceInfo>&,
const std::vector<IneligibleDevice>&)>&
success_callback,
const base::Callback<void(const std::string&)>& error_callback) override;
private:
std::vector<std::unique_ptr<SetSoftwareFeatureStateArgs>>
set_software_feature_state_calls_;
std::vector<std::unique_ptr<FindEligibleDevicesArgs>>
find_eligible_multidevice_host_calls_;
DISALLOW_COPY_AND_ASSIGN(FakeSoftwareFeatureManager);
};
} // namespace cryptauth
#endif // COMPONENTS_CRYPTAUTH_FAKE_SOFTWARE_FEATURE_MANAGER_H_
...@@ -2,45 +2,42 @@ ...@@ -2,45 +2,42 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_CRYPTAUTH_DEVICE_CAPABILITY_MANAGER_H_ #ifndef COMPONENTS_CRYPTAUTH_SOFTWARE_FEATURE_MANAGER_H_
#define COMPONENTS_CRYPTAUTH_DEVICE_CAPABILITY_MANAGER_H_ #define COMPONENTS_CRYPTAUTH_SOFTWARE_FEATURE_MANAGER_H_
#include "base/callback.h" #include "base/callback.h"
#include "components/cryptauth/proto/cryptauth_api.pb.h" #include "components/cryptauth/proto/cryptauth_api.pb.h"
namespace cryptauth { namespace cryptauth {
// DeviceCapabilityManager sends requests to the back-end which enable/disable // Queries for eligible MultiDevice hosts and sets/changes/unsets the current
// device capabilities and finds devices which contain those capabilities. Here, // MultiDevice host for the logged-in account.
// the term "capability" refers to the ability of a device to use a given class SoftwareFeatureManager {
// feature (e.g. EasyUnlock or Instant Tethering).
class DeviceCapabilityManager {
public: public:
// CAPABILITY_UNLOCK_KEY refers to EasyUnlock. virtual ~SoftwareFeatureManager() {}
enum class Capability { CAPABILITY_UNLOCK_KEY };
virtual ~DeviceCapabilityManager(){}; // Enables or disables |software_feature| for the device with public key
// |public_key|. If |enabled| and |is_exclusive| are both true, then all other
virtual void SetCapabilityEnabled( // devices associated with this account will have |sofware_feature| disabled.
// |is_exclusive| is ignored if |enabled| is false.
virtual void SetSoftwareFeatureState(
const std::string& public_key, const std::string& public_key,
Capability capability, SoftwareFeature software_feature,
bool enabled, bool enabled,
const base::Closure& success_callback, const base::Closure& success_callback,
const base::Callback<void(const std::string&)>& error_callback) = 0; const base::Callback<void(const std::string&)>& error_callback,
bool is_exclusive = false) = 0;
virtual void FindEligibleDevicesForCapability( // Finds eligible devices associated with the logged-in account which support
Capability capability, // |software_feature|.
virtual void FindEligibleDevices(
SoftwareFeature software_feature,
const base::Callback<void(const std::vector<ExternalDeviceInfo>&, const base::Callback<void(const std::vector<ExternalDeviceInfo>&,
const std::vector<IneligibleDevice>&)>& const std::vector<IneligibleDevice>&)>&
success_callback, success_callback,
const base::Callback<void(const std::string&)>& error_callback) = 0; const base::Callback<void(const std::string&)>& error_callback) = 0;
virtual void IsCapabilityPromotable(
const std::string& public_key,
Capability capability,
const base::Callback<void(bool)>& success_callback,
const base::Callback<void(const std::string&)>& error_callback) = 0;
}; };
} // namespace cryptauth } // namespace cryptauth
#endif // COMPONENTS_CRYPTAUTH_DEVICE_CAPABILITY_MANAGER_H_ #endif // COMPONENTS_CRYPTAUTH_SOFTWARE_FEATURE_MANAGER_H_
...@@ -2,152 +2,109 @@ ...@@ -2,152 +2,109 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef COMPONENTS_CRYPTAUTH_DEVICE_CAPABILITY_MANAGER_IMPL_H_ #ifndef COMPONENTS_CRYPTAUTH_SOFTWARE_FEATURE_MANAGER_IMPL_H_
#define COMPONENTS_CRYPTAUTH_DEVICE_CAPABILITY_MANAGER_IMPL_H_ #define COMPONENTS_CRYPTAUTH_SOFTWARE_FEATURE_MANAGER_IMPL_H_
#include "base/bind.h" #include "base/bind.h"
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/containers/queue.h" #include "base/containers/queue.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "components/cryptauth/cryptauth_client.h" #include "components/cryptauth/cryptauth_client.h"
#include "components/cryptauth/device_capability_manager.h"
#include "components/cryptauth/proto/cryptauth_api.pb.h" #include "components/cryptauth/proto/cryptauth_api.pb.h"
#include "components/cryptauth/software_feature_manager.h"
namespace cryptauth { namespace cryptauth {
using Capability = DeviceCapabilityManager::Capability; // Concrete SoftwareFeatureManager implementation. To query and/or set
// MultiDevice hosts, this class makes network requests to the CryptAuth
// Concrete DeviceCapabilityManager implementation. // back-end.
class DeviceCapabilityManagerImpl : public DeviceCapabilityManager { class SoftwareFeatureManagerImpl : public SoftwareFeatureManager {
public: public:
class Factory { class Factory {
public: public:
static std::unique_ptr<DeviceCapabilityManager> NewInstance( static std::unique_ptr<SoftwareFeatureManager> NewInstance(
CryptAuthClientFactory* cryptauth_client_factory); CryptAuthClientFactory* cryptauth_client_factory);
static void SetInstanceForTesting(Factory* factory); static void SetInstanceForTesting(Factory* test_factory);
protected: protected:
virtual std::unique_ptr<DeviceCapabilityManager> BuildInstance( virtual std::unique_ptr<SoftwareFeatureManager> BuildInstance(
CryptAuthClientFactory* cryptauth_client_factory); CryptAuthClientFactory* cryptauth_client_factory);
private: private:
static Factory* factory_instance_; static Factory* test_factory_instance_;
}; };
DeviceCapabilityManagerImpl(CryptAuthClientFactory* cryptauth_client_factory); ~SoftwareFeatureManagerImpl() override;
~DeviceCapabilityManagerImpl() override;
// Enables or disables |capability| for the device corresponding to // SoftwareFeatureManager:
// |public_key|. In error cases, |error_callback| is invoked with an error void SetSoftwareFeatureState(
// string.
void SetCapabilityEnabled(
const std::string& public_key, const std::string& public_key,
Capability capability, SoftwareFeature software_feature,
bool enabled, bool enabled,
const base::Closure& success_callback, const base::Closure& success_callback,
const base::Callback<void(const std::string&)>& error_callback) override; const base::Callback<void(const std::string&)>& error_callback,
bool is_exclusive = false) override;
// Fetches metadata about the device which are eligible for |capability|. In void FindEligibleDevices(
// error cases, |error_callback| is invoked with an error string. SoftwareFeature software_feature,
void FindEligibleDevicesForCapability(
Capability capability,
const base::Callback<void(const std::vector<ExternalDeviceInfo>&, const base::Callback<void(const std::vector<ExternalDeviceInfo>&,
const std::vector<IneligibleDevice>&)>& const std::vector<IneligibleDevice>&)>&
success_callback, success_callback,
const base::Callback<void(const std::string&)>& error_callback) override; const base::Callback<void(const std::string&)>& error_callback) override;
// Determines whether a device with |public_key| is promotable for
// |capability|. In error cases, |error_callback| is invoked with an error
// string.
void IsCapabilityPromotable(
const std::string& public_key,
Capability capability,
const base::Callback<void(bool)>& success_callback,
const base::Callback<void(const std::string&)>& error_callback) override;
private: private:
enum class RequestType { enum class RequestType {
SET_CAPABILITY_ENABLED, SET_SOFTWARE_FEATURE,
FIND_ELIGIBLE_DEVICES_FOR_CAPABILITY, FIND_ELIGIBLE_MULTIDEVICE_HOSTS,
IS_CAPABILITY_PROMOTABLE
}; };
struct Request { struct Request {
// Used for SET_CAPABILITY_ENABLED Requests. // Used for SET_SOFTWARE_FEATURE Requests.
Request(RequestType request_type, Request(std::unique_ptr<ToggleEasyUnlockRequest> toggle_request,
Capability capability, const base::Closure& set_software_success_callback,
std::string public_key, const base::Callback<void(const std::string&)> error_callback);
bool enabled,
const base::Closure& set_capability_callback,
const base::Callback<void(const std::string&)>& error_callback);
// Used for FIND_ELIGIBLE_DEVICES_FOR_CAPABILITY Requests.
Request(RequestType request_type,
Capability capability,
const base::Callback<void(const std::vector<ExternalDeviceInfo>&,
const std::vector<IneligibleDevice>&)>&
find_eligible_devices_callback,
const base::Callback<void(const std::string&)>& error_callback);
// Used for IS_CAPABILITY_PROMOTABLE Requests. // Used for FIND_ELIGIBLE_MULTIDEVICE_HOSTS Requests.
Request(RequestType request_type, Request(std::unique_ptr<FindEligibleUnlockDevicesRequest> find_request,
Capability capability, const base::Callback<void(const std::vector<ExternalDeviceInfo>&,
std::string public_key, const std::vector<IneligibleDevice>&)>
const base::Callback<void(bool)> is_device_promotable_callback, find_hosts_success_callback,
const base::Callback<void(const std::string&)>& error_callback); const base::Callback<void(const std::string&)> error_callback);
~Request(); ~Request();
// Defined for every request. const base::Callback<void(const std::string&)> error_callback;
RequestType request_type;
base::Callback<void(const std::string&)> error_callback;
Capability capability;
// Defined for SET_CAPABILITY_ENABLED and IS_CAPABILITY_PROMOTABLE; // Set for SET_SOFTWARE_FEATURE; unset otherwise.
// otherwise, unused. std::unique_ptr<ToggleEasyUnlockRequest> toggle_request;
std::string public_key; const base::Closure set_software_success_callback;
// Defined if |request_type_| is SET_CAPABILITY_ENABLED; otherwise, unused. // Set for FIND_ELIGIBLE_MULTIDEVICE_HOSTS; unset otherwise.
base::Closure set_capability_callback; std::unique_ptr<FindEligibleUnlockDevicesRequest> find_request;
bool enabled; const base::Callback<void(const std::vector<ExternalDeviceInfo>&,
const std::vector<IneligibleDevice>&)>
// Defined if |request_type_| is FIND_ELIGIBLE_DEVICES_FOR_CAPABILITY; find_hosts_success_callback;
// otherwise, unused.
base::Callback<void(const std::vector<ExternalDeviceInfo>&,
const std::vector<IneligibleDevice>&)>
find_eligible_devices_callback;
// Defined if |request_type_| is IS_CAPABILITY_PROMOTABLE; otherwise,
// unused.
base::Callback<void(bool)> is_device_promotable_callback;
}; };
void CreateNewCryptAuthClient(); SoftwareFeatureManagerImpl(CryptAuthClientFactory* cryptauth_client_factory);
void ProcessSetCapabilityEnabledRequest();
void ProcessFindEligibleDevicesForCapability();
void ProcessIsCapabilityPromotableRequest();
void SetUnlockKeyCapability(); void ProcessRequestQueue();
void FindEligibleUnlockDevices(); void ProcessSetSoftwareFeatureStateRequest();
void IsDeviceUnlockPromotable(); void ProcessFindEligibleDevicesRequest();
void OnToggleEasyUnlockResponse(const ToggleEasyUnlockResponse& response); void OnToggleEasyUnlockResponse(const ToggleEasyUnlockResponse& response);
void OnFindEligibleUnlockDevicesResponse( void OnFindEligibleUnlockDevicesResponse(
const FindEligibleUnlockDevicesResponse& response); const FindEligibleUnlockDevicesResponse& response);
void OnIsDeviceUnlockPromotableResponse(
const FindEligibleForPromotionResponse& response);
void OnErrorResponse(const std::string& response); void OnErrorResponse(const std::string& response);
void ProcessRequestQueue();
CryptAuthClientFactory* crypt_auth_client_factory_;
std::unique_ptr<CryptAuthClient> current_cryptauth_client_; std::unique_ptr<CryptAuthClient> current_cryptauth_client_;
std::unique_ptr<Request> current_request_; std::unique_ptr<Request> current_request_;
base::queue<std::unique_ptr<Request>> pending_requests_; base::queue<std::unique_ptr<Request>> pending_requests_;
CryptAuthClientFactory* crypt_auth_client_factory_;
base::WeakPtrFactory<DeviceCapabilityManagerImpl> weak_ptr_factory_; base::WeakPtrFactory<SoftwareFeatureManagerImpl> weak_ptr_factory_;
}; };
} // namespace cryptauth } // namespace cryptauth
#endif // COMPONENTS_CRYPTAUTH_DEVICE_CAPABILITY_MANAGER_IMPL_H_ #endif // COMPONENTS_CRYPTAUTH_SOFTWARE_FEATURE_MANAGER_IMPL_H_
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