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 61
|
// Copyright 2022 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_PASSWORD_MANAGER_CHROME_WEBAUTHN_CREDENTIALS_DELEGATE_FACTORY_H_
#define CHROME_BROWSER_PASSWORD_MANAGER_CHROME_WEBAUTHN_CREDENTIALS_DELEGATE_FACTORY_H_
#include <memory>
#include "base/containers/flat_map.h"
#include "chrome/browser/password_manager/chrome_webauthn_credentials_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
namespace content {
class NavigationHandle;
class RenderFrameHost;
} // namespace content
class ChromeWebAuthnCredentialsDelegateFactory
: public content::WebContentsObserver,
public content::WebContentsUserData<
ChromeWebAuthnCredentialsDelegateFactory> {
public:
ChromeWebAuthnCredentialsDelegateFactory(
const ChromeWebAuthnCredentialsDelegateFactory&) = delete;
ChromeWebAuthnCredentialsDelegateFactory& operator=(
const ChromeWebAuthnCredentialsDelegateFactory&) = delete;
~ChromeWebAuthnCredentialsDelegateFactory() override;
// Returns the instance of ChromeWebAuthnCredentialsDelegateFactory for the
// given |web_contents|, creating one if it doesn't already exist.
static ChromeWebAuthnCredentialsDelegateFactory* GetFactory(
content::WebContents* web_contents);
// Returns the delegate for the given frame, creating one if possible.
// Can return nullptr.
ChromeWebAuthnCredentialsDelegate* GetDelegateForFrame(
content::RenderFrameHost* frame_host);
private:
friend class content::WebContentsUserData<
ChromeWebAuthnCredentialsDelegateFactory>;
explicit ChromeWebAuthnCredentialsDelegateFactory(
content::WebContents* web_contents);
// content::WebContentsObserver:
void RenderFrameDeleted(content::RenderFrameHost* frame_host) override;
void DidFinishNavigation(
content::NavigationHandle* navigation_handle) override;
base::flat_map<content::RenderFrameHost*,
std::unique_ptr<ChromeWebAuthnCredentialsDelegate>>
delegate_map_;
WEB_CONTENTS_USER_DATA_KEY_DECL();
};
#endif // CHROME_BROWSER_PASSWORD_MANAGER_CHROME_WEBAUTHN_CREDENTIALS_DELEGATE_FACTORY_H_
|