1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_DEVICE_REAUTH_CHROME_DEVICE_AUTHENTICATOR_FACTORY_H_
#define CHROME_BROWSER_DEVICE_REAUTH_CHROME_DEVICE_AUTHENTICATOR_FACTORY_H_
#include "base/no_destructor.h"
#include "base/time/time.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_keyed_service_factory.h"
#include "components/device_reauth/device_authenticator.h"
#include "ui/gfx/native_widget_types.h"
namespace content {
class BrowserContext;
}
// Implementation for every OS will be in the same file, as the only thing
// different will be the way of creating a DeviceAuthenticator object, and
// that part will be hidden behind a BUILDFLAG.
class ChromeDeviceAuthenticatorFactory : public ProfileKeyedServiceFactory {
public:
ChromeDeviceAuthenticatorFactory(
const ChromeDeviceAuthenticatorFactory& other) = delete;
ChromeDeviceAuthenticatorFactory& operator=(
const ChromeDeviceAuthenticatorFactory&) = delete;
static ChromeDeviceAuthenticatorFactory* GetInstance();
// Create an instance of the DeviceAuthenticator. Trying to use this
// API on platforms that do not provide an implementation will result in a
// link error.
static std::unique_ptr<device_reauth::DeviceAuthenticator> GetForProfile(
Profile* profile,
const gfx::NativeWindow window,
const device_reauth::DeviceAuthParams& params);
#if BUILDFLAG(IS_ANDROID)
// Create an instance of the DeviceAuthenticator. Trying to use this
// API on platforms that do not provide an implementation will result in a
// link error.
static std::unique_ptr<device_reauth::DeviceAuthenticator> GetForProfile(
Profile* profile,
const base::android::JavaParamRef<jobject>& activity,
const device_reauth::DeviceAuthParams& params);
#endif
private:
std::unique_ptr<KeyedService> BuildServiceInstanceForBrowserContext(
content::BrowserContext* context) const override;
friend class base::NoDestructor<ChromeDeviceAuthenticatorFactory>;
ChromeDeviceAuthenticatorFactory();
~ChromeDeviceAuthenticatorFactory() override;
};
#endif // CHROME_BROWSER_DEVICE_REAUTH_CHROME_DEVICE_AUTHENTICATOR_FACTORY_H_
|