#ifndef COMPONENTS_AUTOFILL_IOS_BROWSER_PASSWORD_AUTOFILL_AGENT_H_
#define COMPONENTS_AUTOFILL_IOS_BROWSER_PASSWORD_AUTOFILL_AGENT_H_
#import <string>
#import "base/memory/raw_ptr.h"
#import "components/autofill/core/common/unique_ids.h"
#import "ios/web/public/web_state_observer.h"
#import "ios/web/public/web_state_user_data.h"
namespace web {
class WebFrame;
class WebState;
}
namespace autofill {
class PasswordAutofillAgentDelegate {
public:
PasswordAutofillAgentDelegate() = default;
virtual ~PasswordAutofillAgentDelegate() = default;
PasswordAutofillAgentDelegate(const PasswordAutofillAgentDelegate&) = delete;
PasswordAutofillAgentDelegate& operator=(
const PasswordAutofillAgentDelegate&) = delete;
virtual void DidFillField(web::WebFrame* frame,
std::optional<autofill::FormRendererId> form_id,
autofill::FieldRendererId field_id,
const std::u16string& field_value) = 0;
};
class PasswordAutofillAgent
: public web::WebStateObserver,
public web::WebStateUserData<PasswordAutofillAgent> {
public:
PasswordAutofillAgent();
~PasswordAutofillAgent() override;
PasswordAutofillAgent(const PasswordAutofillAgent&) = delete;
PasswordAutofillAgent& operator=(const PasswordAutofillAgent&) = delete;
void DidFillField(web::WebFrame* frame,
std::optional<autofill::FormRendererId> form_id,
autofill::FieldRendererId field_id,
const std::u16string& field_value);
void WebStateDestroyed(web::WebState* web_state) override;
private:
friend class web::WebStateUserData<PasswordAutofillAgent>;
PasswordAutofillAgent(web::WebState* web_state,
PasswordAutofillAgentDelegate* delegate);
raw_ptr<PasswordAutofillAgentDelegate> delegate_;
};
}
#endif