chromium/chrome/browser/extensions/api/web_authentication_proxy/web_authentication_proxy_service.h

// 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_EXTENSIONS_API_WEB_AUTHENTICATION_PROXY_WEB_AUTHENTICATION_PROXY_SERVICE_H_
#define CHROME_BROWSER_EXTENSIONS_API_WEB_AUTHENTICATION_PROXY_WEB_AUTHENTICATION_PROXY_SERVICE_H_

#include <optional>

#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/no_destructor.h"
#include "base/scoped_observation.h"
#include "base/sequence_checker.h"
#include "base/types/pass_key.h"
#include "chrome/browser/profiles/profile_keyed_service_factory.h"
#include "chrome/browser/profiles/profile_observer.h"
#include "chrome/common/extensions/api/web_authentication_proxy.h"
#include "components/keyed_service/core/keyed_service.h"
#include "content/public/browser/web_authentication_request_proxy.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/common/extension.h"
#include "services/data_decoder/public/cpp/data_decoder.h"

namespace content {
class BrowserContext;
}  // namespace content

namespace extensions {

class EventRouter;
class ExtensionRegistry;

// WebAuthenticationProxyRegistrar keeps track of extensions attaching
// themselves via the webAuthenticationRequestProxy API to intercept WebAuthn
// request processing.
//
// You can obtain the instance for a given profile from
// WebAuthenticationProxyRegistrarFactory. Off-the-record profiles like
// incognito are redirected to their "regular" main profile.
class WebAuthenticationProxyRegistrar : public KeyedService,
                                        public ExtensionRegistryObserver,
                                        public ProfileObserver {};

// WebAuthenticationProxyRegistrarFactory  creates instances of
// WebAuthenticationProxyRegistrar for a given BrowserContext.
class WebAuthenticationProxyRegistrarFactory
    : public ProfileKeyedServiceFactory {};

// WebAuthenticationProxyService is an implementation of the
// content::WebAuthenticationRequestProxy interface that integrates Chrome's Web
// Authentication API with the webAuthenticationProxy extension API.
//
// Use GetIfProxyAttached() to obtain an instance of this class.
class WebAuthenticationProxyService
    : public content::WebAuthenticationRequestProxy,
      public KeyedService {};

// WebAuthenticationProxyServiceFactory creates instances of
// WebAuthenticationProxyService for a given BrowserContext.
class WebAuthenticationProxyServiceFactory : public ProfileKeyedServiceFactory {};

}  // namespace extensions

#endif  // CHROME_BROWSER_EXTENSIONS_API_WEB_AUTHENTICATION_PROXY_WEB_AUTHENTICATION_PROXY_SERVICE_H_