Commit 7f2c68ac authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS MultiDevice] Create multidevice::CryptAuthClientFactoryImpl.

This class generates CryptAuthClient objects via the IdentityManager
service. This will be used to fetch synced CryptAuth data in the
DeviceSync API.

Bug: 752273
Change-Id: I8378ea9c66eb52b2e6f061de3efea8619fed679a
Reviewed-on: https://chromium-review.googlesource.com/907631
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarTim Song <tengs@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536776}
parent cc4f20d4
......@@ -10,6 +10,8 @@ if (!is_ios && !is_android) {
static_library("service") {
sources = [
"cryptauth_client_factory_impl.cc",
"cryptauth_client_factory_impl.h",
"cryptauth_token_fetcher_impl.cc",
"cryptauth_token_fetcher_impl.h",
"device_sync_impl.cc",
......@@ -22,6 +24,7 @@ if (!is_ios && !is_android) {
deps = [
"//base",
"//net",
"//services/identity/public/cpp",
]
......
......@@ -3,6 +3,7 @@ include_rules = [
"+components/signin/core/browser",
"+google_apis/gaia",
"+mojo/public/cpp",
"+net/url_request",
"+services/identity",
"+services/service_manager/public/cpp",
"+components/cryptauth"
......
// Copyright 2018 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/multidevice/service/cryptauth_client_factory_impl.h"
#include "components/cryptauth/cryptauth_client_impl.h"
#include "components/multidevice/service/cryptauth_token_fetcher_impl.h"
namespace multidevice {
CryptAuthClientFactoryImpl::CryptAuthClientFactoryImpl(
identity::IdentityManager* identity_manager,
scoped_refptr<net::URLRequestContextGetter> url_request_context,
const cryptauth::DeviceClassifier& device_classifier)
: identity_manager_(identity_manager),
url_request_context_(std::move(url_request_context)),
device_classifier_(device_classifier) {}
CryptAuthClientFactoryImpl::~CryptAuthClientFactoryImpl() = default;
std::unique_ptr<cryptauth::CryptAuthClient>
CryptAuthClientFactoryImpl::CreateInstance() {
return std::make_unique<cryptauth::CryptAuthClientImpl>(
std::make_unique<cryptauth::CryptAuthApiCallFlow>(),
std::make_unique<CryptAuthAccessTokenFetcherImpl>(identity_manager_),
url_request_context_, device_classifier_);
}
} // namespace multidevice
// Copyright 2018 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_MULTIDEVICE_CRYPTAUTH_CLIENT_FACTORY_IMPL
#define COMPONENTS_MULTIDEVICE_CRYPTAUTH_CLIENT_FACTORY_IMPL
#include "base/memory/ref_counted.h"
#include "components/cryptauth/cryptauth_client.h"
#include "components/cryptauth/proto/cryptauth_api.pb.h"
namespace identity {
class IdentityManager;
} // namespace identity
namespace net {
class URLRequestContextGetter;
} // namespace net
namespace multidevice {
// CryptAuthClientFactory implementation which utilizes IdentityManager.
class CryptAuthClientFactoryImpl : public cryptauth::CryptAuthClientFactory {
public:
CryptAuthClientFactoryImpl(
identity::IdentityManager* identity_manager,
scoped_refptr<net::URLRequestContextGetter> url_request_context,
const cryptauth::DeviceClassifier& device_classifier);
~CryptAuthClientFactoryImpl() override;
// cryptauth::CryptAuthClientFactory:
std::unique_ptr<cryptauth::CryptAuthClient> CreateInstance() override;
private:
identity::IdentityManager* identity_manager_;
const scoped_refptr<net::URLRequestContextGetter> url_request_context_;
const cryptauth::DeviceClassifier device_classifier_;
};
} // namespace multidevice
#endif // COMPONENTS_MULTIDEVICE_CRYPTAUTH_CLIENT_FACTORY_IMPL
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