#include "components/password_manager/content/browser/content_password_manager_driver.h"
#include <utility>
#include "base/metrics/histogram_macros.h"
#include "components/autofill/content/browser/content_autofill_client.h"
#include "components/autofill/content/browser/content_autofill_driver.h"
#include "components/autofill/core/browser/logging/log_manager.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/unique_ids.h"
#include "components/password_manager/content/browser/bad_message.h"
#include "components/password_manager/content/browser/content_password_manager_driver_factory.h"
#include "components/password_manager/content/browser/form_meta_data.h"
#include "components/password_manager/core/browser/browser_save_password_progress_logger.h"
#include "components/password_manager/core/browser/password_manager.h"
#include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_metrics_recorder.h"
#include "components/password_manager/core/browser/password_suggestion_generator.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/safe_browsing/buildflags.h"
#include "content/public/browser/back_forward_cache.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#include "mojo/public/cpp/bindings/message.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
FocusedFieldType;
namespace password_manager {
namespace {
gfx::RectF TransformToRootCoordinates(
content::RenderFrameHost* render_frame_host,
const gfx::RectF& bounds_in_frame_coordinates) { … }
void LogSiteIsolationMetricsForSubmittedForm(
content::RenderFrameHost* render_frame_host) { … }
bool HasValidURL(content::RenderFrameHost* render_frame_host) { … }
bool IsRenderFrameHostSupported(content::RenderFrameHost* rfh) { … }
}
ContentPasswordManagerDriver::ContentPasswordManagerDriver(
content::RenderFrameHost* render_frame_host,
PasswordManagerClient* client)
: … { … }
ContentPasswordManagerDriver::~ContentPasswordManagerDriver() = default;
ContentPasswordManagerDriver*
ContentPasswordManagerDriver::GetForRenderFrameHost(
content::RenderFrameHost* render_frame_host) { … }
void ContentPasswordManagerDriver::BindPendingReceiver(
mojo::PendingAssociatedReceiver<autofill::mojom::PasswordManagerDriver>
pending_receiver) { … }
void ContentPasswordManagerDriver::DidNavigate() { … }
int ContentPasswordManagerDriver::GetId() const { … }
int ContentPasswordManagerDriver::GetFrameId() const { … }
void ContentPasswordManagerDriver::SetPasswordFillData(
const autofill::PasswordFormFillData& form_data) { … }
void ContentPasswordManagerDriver::InformNoSavedCredentials(
bool should_show_popup_without_passwords) { … }
void ContentPasswordManagerDriver::FormEligibleForGenerationFound(
const autofill::PasswordFormGenerationData& form) { … }
void ContentPasswordManagerDriver::GeneratedPasswordAccepted(
const std::u16string& password) { … }
void ContentPasswordManagerDriver::GeneratedPasswordAccepted(
const autofill::FormData& raw_form,
autofill::FieldRendererId generation_element_id,
const std::u16string& password) { … }
void ContentPasswordManagerDriver::FocusNextFieldAfterPasswords() { … }
void ContentPasswordManagerDriver::FillField(const std::u16string& value) { … }
void ContentPasswordManagerDriver::FillSuggestion(
const std::u16string& username,
const std::u16string& password) { … }
void ContentPasswordManagerDriver::FillIntoFocusedField(
bool is_password,
const std::u16string& credential) { … }
#if BUILDFLAG(IS_ANDROID)
void ContentPasswordManagerDriver::KeyboardReplacingSurfaceClosed(
ToShowVirtualKeyboard show_virtual_keyboard) {
GetPasswordAutofillAgent()->KeyboardReplacingSurfaceClosed(
show_virtual_keyboard.value());
}
void ContentPasswordManagerDriver::TriggerFormSubmission() {
GetPasswordAutofillAgent()->TriggerFormSubmission();
}
#endif
void ContentPasswordManagerDriver::PreviewField(
autofill::FieldRendererId field_id,
const std::u16string& value) { … }
void ContentPasswordManagerDriver::PreviewSuggestion(
const std::u16string& username,
const std::u16string& password) { … }
void ContentPasswordManagerDriver::PreviewGenerationSuggestion(
const std::u16string& password) { … }
void ContentPasswordManagerDriver::ClearPreviewedForm() { … }
void ContentPasswordManagerDriver::SetSuggestionAvailability(
autofill::FieldRendererId element_id,
autofill::mojom::AutofillSuggestionAvailability suggestion_availability) { … }
PasswordGenerationFrameHelper*
ContentPasswordManagerDriver::GetPasswordGenerationHelper() { … }
PasswordManagerInterface* ContentPasswordManagerDriver::GetPasswordManager() { … }
PasswordAutofillManager*
ContentPasswordManagerDriver::GetPasswordAutofillManager() { … }
void ContentPasswordManagerDriver::SendLoggingAvailability() { … }
bool ContentPasswordManagerDriver::IsInPrimaryMainFrame() const { … }
bool ContentPasswordManagerDriver::CanShowAutofillUi() const { … }
const GURL& ContentPasswordManagerDriver::GetLastCommittedURL() const { … }
void ContentPasswordManagerDriver::AnnotateFieldsWithParsingResult(
const autofill::ParsingResult& parsing_result) { … }
base::WeakPtr<password_manager::PasswordManagerDriver>
ContentPasswordManagerDriver::AsWeakPtr() { … }
void ContentPasswordManagerDriver::GeneratePassword(
autofill::mojom::PasswordGenerationAgent::TriggeredGeneratePasswordCallback
callback) { … }
void ContentPasswordManagerDriver::PasswordFormsParsed(
const std::vector<autofill::FormData>& raw_forms) { … }
void ContentPasswordManagerDriver::PasswordFormsRendered(
const std::vector<autofill::FormData>& raw_forms) { … }
void ContentPasswordManagerDriver::PasswordFormSubmitted(
const autofill::FormData& raw_form) { … }
void ContentPasswordManagerDriver::InformAboutUserInput(
const autofill::FormData& raw_form) { … }
void ContentPasswordManagerDriver::DynamicFormSubmission(
autofill::mojom::SubmissionIndicatorEvent submission_indication_event) { … }
void ContentPasswordManagerDriver::PasswordFormCleared(
const autofill::FormData& raw_form) { … }
void ContentPasswordManagerDriver::RecordSavePasswordProgress(
const std::string& log) { … }
void ContentPasswordManagerDriver::UserModifiedPasswordField() { … }
void ContentPasswordManagerDriver::UserModifiedNonPasswordField(
autofill::FieldRendererId renderer_id,
const std::u16string& value,
bool autocomplete_attribute_has_username,
bool is_likely_otp) { … }
void ContentPasswordManagerDriver::ShowPasswordSuggestions(
const autofill::PasswordSuggestionRequest& request) { … }
#if BUILDFLAG(IS_ANDROID)
void ContentPasswordManagerDriver::ShowKeyboardReplacingSurface(
autofill::mojom::SubmissionReadinessState submission_readiness,
bool is_webauthn_form) {
if (!password_manager::bad_message::CheckFrameNotPrerendering(
render_frame_host_)) {
return;
}
autofill::FormData form;
client_->ShowKeyboardReplacingSurface(
this,
PasswordFillingParams(form, 0, 0, autofill::FieldRendererId(),
submission_readiness),
is_webauthn_form, base::DoNothing());
}
#endif
void ContentPasswordManagerDriver::CheckSafeBrowsingReputation(
const GURL& form_action,
const GURL& frame_url) { … }
void ContentPasswordManagerDriver::FocusedInputChanged(
autofill::FieldRendererId focused_field_id,
FocusedFieldType focused_field_type) { … }
void ContentPasswordManagerDriver::LogFirstFillingResult(
autofill::FormRendererId form_renderer_id,
int32_t result) { … }
void ContentPasswordManagerDriver::LogFilledFieldType() { … }
const mojo::AssociatedRemote<autofill::mojom::AutofillAgent>&
ContentPasswordManagerDriver::GetAutofillAgent() { … }
const mojo::AssociatedRemote<autofill::mojom::PasswordAutofillAgent>&
ContentPasswordManagerDriver::GetPasswordAutofillAgent() { … }
const mojo::AssociatedRemote<autofill::mojom::PasswordGenerationAgent>&
ContentPasswordManagerDriver::GetPasswordGenerationAgent() { … }
}