#include "components/autofill/content/renderer/page_passwords_analyser.h"
#include <map>
#include <stack>
#include <string>
#include <vector>
#include "base/containers/contains.h"
#include "base/lazy_instance.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/content/renderer/form_autofill_util.h"
#include "components/autofill/content/renderer/page_form_analyser_logger.h"
#include "components/autofill/content/renderer/password_form_conversion_utils.h"
#include "third_party/blink/public/web/web_document.h"
#include "third_party/blink/public/web/web_element.h"
#include "third_party/blink/public/web/web_element_collection.h"
#include "third_party/blink/public/web/web_form_control_element.h"
#include "third_party/blink/public/web/web_label_element.h"
#include "third_party/blink/public/web/web_node.h"
#include "third_party/re2/src/re2/re2.h"
WebDocument;
WebElement;
WebElementCollection;
WebFormControlElement;
WebFormElement;
WebInputElement;
WebLabelElement;
WebLocalFrame;
WebNode;
WebString;
WebVector;
namespace autofill {
namespace {
const char kDocumentationUrl[] = …;
const char* kTypeAttributes[] = …;
const char* kTypeTextAttributes[] = …;
char kTextFieldSignature = …;
char kPasswordFieldSignature = …;
std::string LinkDocumentation(const std::string& message,
const char* reference = nullptr) { … }
struct TraversalInfo { … };
struct FormInputCollection { … };
#define DECLARE_LAZY_MATCHER …
DECLARE_LAZY_MATCHER(ignored_characters_matcher, R"(\W)");
DECLARE_LAZY_MATCHER(username_matcher, R"(user(name)?|login)");
DECLARE_LAZY_MATCHER(email_matcher, R"(email(address)?)");
DECLARE_LAZY_MATCHER(telephone_matcher, R"((mobile)?(telephone)?(number|no))");
#undef DECLARE_LAZY_MATCHER
struct InputHint { … };
bool FormIsTooComplex(const std::string& signature) { … }
void TrackElementId(const WebElement& element,
std::map<std::string, std::vector<WebNode>>* nodes_for_id) { … }
template <typename RendererId>
bool TrackElementByRendererIdIfUntracked(
const WebElement& element,
const RendererId renderer_id,
std::set<RendererId>* skip_renderer_ids,
std::map<std::string, std::vector<WebNode>>* nodes_for_id) { … }
std::vector<FormInputCollection> ExtractFormsForAnalysis(
const WebDocument& document,
std::set<FormRendererId>* skip_form_ids,
std::set<FieldRendererId>* skip_control_ids,
PageFormAnalyserLogger* logger) { … }
void InferUsernameField(
const WebFormElement& form,
const std::vector<WebFormControlElement>& inputs,
size_t username_field_guess,
std::map<size_t, std::string>* autocomplete_suggestions) { … }
void GuessAutocompleteAttributesForPasswordFields(
const std::vector<size_t>& password_inputs,
bool has_text_field,
std::map<size_t, std::string>* autocomplete_suggestions) { … }
void AnalyseForm(const FormInputCollection& form_input_collection,
PageFormAnalyserLogger* logger) { … }
}
PagePasswordsAnalyser::PagePasswordsAnalyser() = default;
PagePasswordsAnalyser::~PagePasswordsAnalyser() = default;
void PagePasswordsAnalyser::Reset() { … }
void PagePasswordsAnalyser::AnalyseDocumentDOM(WebLocalFrame* frame,
PageFormAnalyserLogger* logger) { … }
void PagePasswordsAnalyser::AnalyseDocumentDOM(WebLocalFrame* frame) { … }
}