chromium/components/autofill/content/renderer/form_autofill_issues.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/autofill/content/renderer/form_autofill_issues.h"

#include <string_view>
#include <vector>

#include "base/no_destructor.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_split.h"
#include "components/autofill/content/renderer/form_autofill_util.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/form_field_data.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/platform/web_string.h"
#include "third_party/blink/public/platform/web_vector.h"
#include "third_party/blink/public/web/web_autofill_client.h"
#include "third_party/blink/public/web/web_document.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_input_element.h"
#include "third_party/blink/public/web/web_label_element.h"
#include "third_party/blink/public/web/web_local_frame.h"

WebDocument;
WebElement;
WebElementCollection;
WebFormControlElement;
WebFormElement;
WebInputElement;
WebLabelElement;
WebLocalFrame;
WebString;
WebVector;
GenericIssueErrorType;

namespace autofill::form_issues {

IsAutofillableElement;

namespace {

constexpr size_t kMaxNumberOfDevtoolsIssuesEmitted =;

constexpr std::string_view kFor =;
constexpr std::string_view kAriaLabelledBy =;
constexpr std::string_view kName =;
constexpr std::string_view kId =;
constexpr std::string_view kLabel =;
constexpr std::string_view kAutocomplete =;

// Wrapper for frequently used WebString constants.
template <const std::string_view& string>
const WebString& GetWebString() {}

void MaybeAppendLabelWithoutControlDevtoolsIssue(
    WebLabelElement label,
    std::vector<FormIssue>& form_issues) {}

void MaybeAppendAriaLabelledByDevtoolsIssue(
    const WebElement& element,
    std::vector<FormIssue>& form_issues) {}

void MaybeAppendInputWithEmptyIdAndNameDevtoolsIssue(
    const WebFormControlElement& element,
    std::vector<FormIssue>& form_issues) {}

int GetShadowHostDOMNodeId(const WebFormControlElement& element) {}

void MaybeAppendDuplicateIdForInputDevtoolsIssue(
    const WebVector<WebFormControlElement>& elements,
    std::vector<FormIssue>& form_issues) {}

void MaybeAppendAutocompleteAttributeDevtoolsIssue(
    const WebElement& element,
    std::vector<FormIssue>& form_issues) {}

void MaybeAppendInputAssignedAutocompleteValueToIdOrNameAttributesDevtoolsIssue(
    const WebFormControlElement& element,
    std::vector<FormIssue>& form_issues) {}

void AppendFormIssuesInternal(const WebVector<WebFormControlElement>& elements,
                              std::vector<FormIssue>& form_issues) {}

// Looks for form issues in `control_elements`, e.g., inputs with duplicate ids
// and returns a vector that is the union of `form_issues` and the new issues
// found.
std::vector<FormIssue> GetFormIssues(
    const blink::WebVector<blink::WebFormControlElement>& control_elements,
    std::vector<FormIssue> form_issues) {}

// Method specific to find issues regarding label `for` attribute. This needs to
// be called after label extraction. Similar to `GetFormIssues` it returns
// a vector that is the union of `form_issues` and the new issues found.
std::vector<FormIssue> CheckForLabelsWithIncorrectForAttribute(
    const blink::WebDocument& document,
    const std::vector<FormFieldData>& fields,
    std::vector<FormIssue> form_issues) {}

}  // namespace

void MaybeEmitFormIssuesToDevtools(blink::WebLocalFrame& web_local_frame,
                                   base::span<const FormData> forms) {}

std::vector<FormIssue> GetFormIssuesForTesting(  // IN-TEST
    const blink::WebVector<blink::WebFormControlElement>& control_elements,
    std::vector<FormIssue> form_issues) {}

std::vector<FormIssue>
CheckForLabelsWithIncorrectForAttributeForTesting(  // IN-TEST
    const blink::WebDocument& document,
    const std::vector<FormFieldData>& fields,
    std::vector<FormIssue> form_issues) {}

}  // namespace autofill::form_issues