0

[Autofill] Remove query IDs.

This CL eliminates the obsolete concept of query IDs. It's obsolete
due to renderer IDs.

This CL has no side-effects.

Before this CL
- crrev.com/c/4065339 replaced query IDs for an iOS-specific bug
  fix with FieldGlobalIds;
- crrev.com/c/4079161 made query IDs ineffective in AutofillAgent.

Bug: 1361395
Change-Id: I9bfb61efdb065b5ffd8afc345e06fc43edda8267
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3924074
Reviewed-by: Dominic Battré <battre@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Auto-Submit: Christoph Schwering <schwering@google.com>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1080218}
This commit is contained in:
Christoph Schwering
2022-12-07 08:17:38 +00:00
committed by Chromium LUCI CQ
parent a25cf855da
commit 60928da296
69 changed files with 546 additions and 965 deletions
chrome
components
android_autofill
autofill
content
core
ios
weblayer/test

@ -127,8 +127,7 @@ void FillCard(content::RenderFrameHost* rfh,
test::SetCreditCardInfo(&card, kNameFull, kNumber, kExpMonth, kExpYear, "");
auto* manager = TestAutofillManager::GetForRenderFrameHost(rfh);
manager->FillCreditCardFormImpl(form, triggered_field, card,
base::ASCIIToUTF16(base::StringPiece(kCvc)),
kCrossFrameFill);
base::ASCIIToUTF16(base::StringPiece(kCvc)));
}
// Clicks the first input, textarea, or select in `rfh`.

@ -215,7 +215,7 @@ class AutofillAutocompleteTest : public InProcessBrowserTest {
test::CreateTestFormField(/*label=*/"", input_name.c_str(), prefix.c_str(),
"input", &field);
EXPECT_TRUE(autocomplete_history_manager()->OnGetSingleFieldSuggestions(
1, AutoselectFirstSuggestion(false), field, *autofill_client,
AutoselectFirstSuggestion(false), field, *autofill_client,
handler.GetWeakPtr(), SuggestionsContext()));
// Make sure the DB task gets executed.

@ -129,7 +129,6 @@ void WaitForPersonalDataManagerToBeLoaded(Profile* base_profile) {
void GenerateTestAutofillPopup(
AutofillExternalDelegate* autofill_external_delegate) {
int query_id = 1;
FormData form;
form.url = GURL("https://foo.com/bar");
form.fields.emplace_back();
@ -143,7 +142,7 @@ void GenerateTestAutofillPopup(
mojom::AutofillDriver* mojo_driver = driver;
TestAutofillManagerWaiter waiter(
*manager, {&AutofillManager::Observer::OnAfterAskForValuesToFill});
mojo_driver->AskForValuesToFill(form, form.fields.front(), bounds, query_id,
mojo_driver->AskForValuesToFill(form, form.fields.front(), bounds,
AutoselectFirstSuggestion(false),
FormElementWasClicked(false));
ASSERT_TRUE(waiter.Wait());

@ -106,7 +106,6 @@ class FakeContentAutofillDriver : public mojom::AutofillDriver {
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) override {}
@ -142,12 +141,10 @@ using AutofillQueryParam =
class AutofillRendererTest : public ChromeRenderViewTest {
public:
AutofillRendererTest() {}
AutofillRendererTest() = default;
AutofillRendererTest(const AutofillRendererTest&) = delete;
AutofillRendererTest& operator=(const AutofillRendererTest&) = delete;
~AutofillRendererTest() override {}
~AutofillRendererTest() override = default;
protected:
void SetUp() override {

@ -104,7 +104,6 @@ class FakeContentAutofillDriver : public mojom::AutofillDriver {
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_field,
FormElementWasClicked form_element_was_clicked) override {}
@ -243,7 +242,7 @@ void SimulateFillForm(const FormData& form_data,
autofill_agent->FormControlElementClicked(
fname_element.To<WebInputElement>());
autofill_agent->FillOrPreviewForm(0, form_data,
autofill_agent->FillOrPreviewForm(form_data,
mojom::RendererFormDataAction::kFill);
}
@ -307,20 +306,17 @@ void SimulateFillFormWithNonFillableFields(
autofill_agent->FormControlElementClicked(
fname_element.To<WebInputElement>());
autofill_agent->FillOrPreviewForm(0, data,
mojom::RendererFormDataAction::kFill);
autofill_agent->FillOrPreviewForm(data, mojom::RendererFormDataAction::kFill);
}
} // end namespace
class FormAutocompleteTest : public ChromeRenderViewTest {
public:
FormAutocompleteTest() {}
FormAutocompleteTest() = default;
FormAutocompleteTest(const FormAutocompleteTest&) = delete;
FormAutocompleteTest& operator=(const FormAutocompleteTest&) = delete;
~FormAutocompleteTest() override {}
~FormAutocompleteTest() override = default;
protected:
void SetUp() override {

@ -57,8 +57,7 @@ void AndroidAutofillManager::FillCreditCardFormImpl(
const FormData& form,
const FormFieldData& field,
const CreditCard& credit_card,
const std::u16string& cvc,
int query_id) {
const std::u16string& cvc) {
NOTREACHED();
}
@ -98,11 +97,10 @@ void AndroidAutofillManager::OnAskForValuesToFillImpl(
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) {
if (auto* provider = GetAutofillProvider()) {
provider->OnAskForValuesToFill(this, form, field, bounding_box, query_id,
provider->OnAskForValuesToFill(this, form, field, bounding_box,
autoselect_first_suggestion,
form_element_was_clicked);
}
@ -195,11 +193,10 @@ AutofillProvider* AndroidAutofillManager::GetAutofillProvider() {
}
void AndroidAutofillManager::FillOrPreviewForm(
int query_id,
mojom::RendererFormDataAction action,
const FormData& form,
const url::Origin& triggered_origin) {
driver()->FillOrPreviewForm(query_id, action, form, triggered_origin, {});
driver()->FillOrPreviewForm(action, form, triggered_origin, {});
}
} // namespace autofill

@ -49,8 +49,7 @@ class AndroidAutofillManager : public AutofillManager {
void FillCreditCardFormImpl(const FormData& form,
const FormFieldData& field,
const CreditCard& credit_card,
const std::u16string& cvc,
int query_id) override;
const std::u16string& cvc) override;
void FillProfileFormImpl(const FormData& form,
const FormFieldData& field,
const autofill::AutofillProfile& profile) override;
@ -78,8 +77,7 @@ class AndroidAutofillManager : public AutofillManager {
// |triggered_origin| is the origin of the field from which the autofill is
// triggered; this affects the security policy for cross-frame fills. See
// AutofillDriver::FillOrPreviewForm() for further details.
void FillOrPreviewForm(int query_id,
mojom::RendererFormDataAction action,
void FillOrPreviewForm(mojom::RendererFormDataAction action,
const FormData& form,
const url::Origin& triggered_origin);
@ -111,7 +109,6 @@ class AndroidAutofillManager : public AutofillManager {
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) override;

@ -32,11 +32,10 @@ AutofillProvider::AutofillProvider(content::WebContents* web_contents)
AutofillProvider::~AutofillProvider() = default;
void AutofillProvider::FillOrPreviewForm(AndroidAutofillManager* manager,
int requestId,
const FormData& formData,
const url::Origin& triggered_origin) {
manager->FillOrPreviewForm(requestId, mojom::RendererFormDataAction::kFill,
formData, triggered_origin);
manager->FillOrPreviewForm(mojom::RendererFormDataAction::kFill, formData,
triggered_origin);
}
void AutofillProvider::RendererShouldAcceptDataListSuggestion(

@ -39,7 +39,6 @@ class AutofillProvider : public content::WebContentsUserData<AutofillProvider> {
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) = 0;
@ -90,7 +89,6 @@ class AutofillProvider : public content::WebContentsUserData<AutofillProvider> {
virtual void Reset(AndroidAutofillManager* manager) = 0;
void FillOrPreviewForm(AndroidAutofillManager* manager,
int requestId,
const FormData& formData,
const url::Origin& triggered_origin);

@ -74,7 +74,6 @@ AutofillProviderAndroid::AutofillProviderAndroid(
const JavaRef<jobject>& jcaller,
content::WebContents* web_contents)
: AutofillProvider(web_contents),
id_(kNoQueryId),
java_ref_(JavaObjectWeakGlobalRef(env, jcaller)),
check_submission_(false) {}
@ -105,14 +104,12 @@ void AutofillProviderAndroid::OnAskForValuesToFill(
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion /*unused_autoselect_first_suggestion*/,
FormElementWasClicked /*unused_form_element_was_clicked*/) {
// The id isn't passed to Java side because Android API guarantees the
// response is always for current session, so we just use the current id
// in response, see OnAutofillAvailable.
DCHECK_CURRENTLY_ON(BrowserThread::UI);
id_ = query_id;
// Focus or field value change will also trigger the query, so it should be
// ignored if the form is same.
@ -186,7 +183,7 @@ void AutofillProviderAndroid::OnAutofillAvailable(JNIEnv* env,
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (manager_ && form_) {
const FormData& form = form_->GetAutofillValues();
FillOrPreviewForm(manager_.get(), id_, form, triggered_origin_);
FillOrPreviewForm(manager_.get(), form, triggered_origin_);
}
}
@ -307,10 +304,6 @@ void AutofillProviderAndroid::OnFocusOnFormField(
!form_->GetSimilarFieldIndex(field, &index))
return;
// Because this will trigger a suggestion query, set request id to browser
// initiated request.
id_ = kNoQueryId;
OnFocusChanged(true, index, ToClientAreaBound(bounding_box));
}
@ -460,7 +453,6 @@ void AutofillProviderAndroid::Reset() {
form_.reset(nullptr);
field_id_ = {};
triggered_origin_ = {};
id_ = kNoQueryId;
check_submission_ = false;
}

@ -52,7 +52,6 @@ class AutofillProviderAndroid : public AutofillProvider {
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion /*unused_autoselect_first_suggestion*/,
FormElementWasClicked /*unused_form_element_was_clicked*/) override;
void OnTextFieldDidChange(AndroidAutofillManager* manager,
@ -132,7 +131,6 @@ class AutofillProviderAndroid : public AutofillProvider {
void Reset();
int32_t id_;
// The form of the current session (queried input or changed select box).
std::unique_ptr<FormDataAndroid> form_;
// The field of the current session (queried input or changed select box).

@ -25,7 +25,7 @@ class AndroidAutofillManagerTestHelper : public AndroidAutofillManager {
void SimulateOnAskForValuesToFillImpl() {
OnAskForValuesToFillImpl(FormData(), FormFieldData(), gfx::RectF(),
/*query_id=*/0, AutoselectFirstSuggestion(false),
AutoselectFirstSuggestion(false),
FormElementWasClicked(false));
}
};
@ -44,7 +44,6 @@ class AutofillProviderTestHelper : public TestAutofillProvider {
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) override {
manager_ = manager;

@ -25,7 +25,6 @@ class TestAutofillProvider : public AutofillProvider {
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) override {}
void OnTextFieldDidChange(AndroidAutofillManager* manager,

@ -156,18 +156,17 @@ net::IsolationInfo ContentAutofillDriver::IsolationInfo() {
}
std::vector<FieldGlobalId> ContentAutofillDriver::FillOrPreviewForm(
int query_id,
mojom::RendererFormDataAction action,
const FormData& data,
const url::Origin& triggered_origin,
const base::flat_map<FieldGlobalId, ServerFieldType>& field_type_map) {
return autofill_router().FillOrPreviewForm(
this, query_id, action, data, triggered_origin, field_type_map,
[](ContentAutofillDriver* target, int query_id,
mojom::RendererFormDataAction action, const FormData& data) {
this, action, data, triggered_origin, field_type_map,
[](ContentAutofillDriver* target, mojom::RendererFormDataAction action,
const FormData& data) {
if (!target->RendererIsAvailable())
return;
target->GetAutofillAgent()->FillOrPreviewForm(query_id, data, action);
target->GetAutofillAgent()->FillOrPreviewForm(data, action);
});
}
@ -407,7 +406,6 @@ void ContentAutofillDriver::AskForValuesToFill(
const FormData& raw_form,
const FormFieldData& raw_field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) {
if (!bad_message::CheckFrameNotPrerendering(render_frame_host_))
@ -417,15 +415,14 @@ void ContentAutofillDriver::AskForValuesToFill(
SetFrameAndFormMetaData(form, &field);
autofill_router().AskForValuesToFill(
this, form, field,
TransformBoundingBoxToViewportCoordinates(bounding_box), query_id,
TransformBoundingBoxToViewportCoordinates(bounding_box),
autoselect_first_suggestion, form_element_was_clicked,
[](ContentAutofillDriver* target, const FormData& form,
const FormFieldData& field, const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) {
target->autofill_manager_->OnAskForValuesToFill(
form, field, bounding_box, query_id, autoselect_first_suggestion,
form, field, bounding_box, autoselect_first_suggestion,
form_element_was_clicked);
});
}
@ -549,8 +546,7 @@ void ContentAutofillDriver::FillFormForAssistant(
field);
} else if (fill_data.is_credit_card()) {
target->autofill_manager_->FillCreditCardForm(
/*query_id=*/kNoQueryId, form, field, fill_data.credit_card(),
fill_data.cvc());
form, field, fill_data.credit_card(), fill_data.cvc());
} else {
NOTREACHED();
}

@ -253,7 +253,6 @@ class ContentAutofillDriver : public AutofillDriver,
// These events are private to to avoid accidental in the browser.
// They can be accessed explicitly through browser_events().
std::vector<FieldGlobalId> FillOrPreviewForm(
int query_id,
mojom::RendererFormDataAction action,
const FormData& data,
const url::Origin& triggered_origin,
@ -309,7 +308,6 @@ class ContentAutofillDriver : public AutofillDriver,
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) override;
void HidePopup() override;

@ -50,9 +50,7 @@ class MockAutofillAgent : public mojom::AutofillAgent {
MOCK_METHOD(void, TriggerReparse, (), (override));
MOCK_METHOD(void,
FillOrPreviewForm,
(int32_t query_id,
const FormData& form,
mojom::RendererFormDataAction action),
(const FormData& form, mojom::RendererFormDataAction action),
(override));
MOCK_METHOD(void,
FieldTypePredictionsAvailable,

@ -60,10 +60,7 @@ const char kAppLocale[] = "en-US";
class FakeAutofillAgent : public mojom::AutofillAgent {
public:
FakeAutofillAgent()
: fill_form_id_(-1),
preview_form_id_(-1),
called_clear_section_(false),
called_clear_previewed_form_(false) {}
: called_clear_section_(false), called_clear_previewed_form_(false) {}
~FakeAutofillAgent() override {}
@ -78,14 +75,9 @@ class FakeAutofillAgent : public mojom::AutofillAgent {
// Returns the id and formdata received via
// mojo interface method mojom::AutofillAgent::FillOrPreviewForm().
bool GetAutofillFillFormMessage(int* page_id, FormData* results) {
if (fill_form_id_ == -1)
return false;
bool GetAutofillFillFormMessage(FormData* results) {
if (!fill_form_form_)
return false;
if (page_id)
*page_id = fill_form_id_;
if (results)
*results = *fill_form_form_;
return true;
@ -93,14 +85,9 @@ class FakeAutofillAgent : public mojom::AutofillAgent {
// Returns the id and formdata received via
// mojo interface method mojom::AutofillAgent::PreviewForm().
bool GetAutofillPreviewFormMessage(int* page_id, FormData* results) {
if (preview_form_id_ == -1)
return false;
bool GetAutofillPreviewFormMessage(FormData* results) {
if (!preview_form_form_)
return false;
if (page_id)
*page_id = preview_form_id_;
if (results)
*results = *preview_form_form_;
return true;
@ -167,14 +154,11 @@ class FakeAutofillAgent : public mojom::AutofillAgent {
// mojom::AutofillAgent:
void TriggerReparse() override {}
void FillOrPreviewForm(int32_t query_id,
const FormData& form,
void FillOrPreviewForm(const FormData& form,
mojom::RendererFormDataAction action) override {
if (action == mojom::RendererFormDataAction::kPreview) {
preview_form_id_ = query_id;
preview_form_form_ = form;
} else {
fill_form_id_ = query_id;
fill_form_form_ = form;
}
CallDone();
@ -257,9 +241,7 @@ class FakeAutofillAgent : public mojom::AutofillAgent {
base::OnceClosure quit_closure_;
// Records data received from FillOrPreviewForm() call.
int32_t fill_form_id_;
absl::optional<FormData> fill_form_form_;
int32_t preview_form_id_;
absl::optional<FormData> preview_form_form_;
// Records data received from FieldTypePredictionsAvailable() call.
absl::optional<std::vector<FormDataPredictions>> predictions_;
@ -531,7 +513,6 @@ TEST_P(ContentAutofillDriverTest, SetFrameAndFormMetaDataOfField) {
}
TEST_P(ContentAutofillDriverTest, FormDataSentToRenderer_FillForm) {
int input_page_id = autofill_across_iframes_ ? kCrossFrameFill : 42;
url::Origin triggered_origin;
FormData input_form_data = SeeAddressFormData();
for (FormFieldData& field : input_form_data.fields) {
@ -541,24 +522,19 @@ TEST_P(ContentAutofillDriverTest, FormDataSentToRenderer_FillForm) {
base::RunLoop run_loop;
fake_agent_.SetQuitLoopClosure(run_loop.QuitClosure());
driver_->browser_events().FillOrPreviewForm(
input_page_id, mojom::RendererFormDataAction::kFill, input_form_data,
triggered_origin, {});
mojom::RendererFormDataAction::kFill, input_form_data, triggered_origin,
{});
run_loop.RunUntilIdle();
int output_page_id = 0;
FormData output_form_data;
EXPECT_FALSE(fake_agent_.GetAutofillPreviewFormMessage(&output_page_id,
&output_form_data));
EXPECT_TRUE(fake_agent_.GetAutofillFillFormMessage(&output_page_id,
&output_form_data));
EXPECT_EQ(input_page_id, output_page_id);
EXPECT_FALSE(fake_agent_.GetAutofillPreviewFormMessage(&output_form_data));
EXPECT_TRUE(fake_agent_.GetAutofillFillFormMessage(&output_form_data));
EXPECT_TRUE(test::WithoutUnserializedData(input_form_data)
.SameFormAs(output_form_data));
}
TEST_P(ContentAutofillDriverTest, FormDataSentToRenderer_PreviewForm) {
int input_page_id = autofill_across_iframes_ ? kCrossFrameFill : 42;
url::Origin triggered_origin;
FormData input_form_data = SeeAddressFormData();
for (FormFieldData& field : input_form_data.fields) {
@ -571,18 +547,14 @@ TEST_P(ContentAutofillDriverTest, FormDataSentToRenderer_PreviewForm) {
base::RunLoop run_loop;
fake_agent_.SetQuitLoopClosure(run_loop.QuitClosure());
driver_->browser_events().FillOrPreviewForm(
input_page_id, mojom::RendererFormDataAction::kPreview, input_form_data,
mojom::RendererFormDataAction::kPreview, input_form_data,
triggered_origin, {});
run_loop.RunUntilIdle();
int output_page_id = 0;
FormData output_form_data;
EXPECT_FALSE(fake_agent_.GetAutofillFillFormMessage(&output_page_id,
&output_form_data));
EXPECT_TRUE(fake_agent_.GetAutofillPreviewFormMessage(&output_page_id,
&output_form_data));
EXPECT_EQ(input_page_id, output_page_id);
EXPECT_FALSE(fake_agent_.GetAutofillFillFormMessage(&output_form_data));
EXPECT_TRUE(fake_agent_.GetAutofillPreviewFormMessage(&output_form_data));
EXPECT_TRUE(test::WithoutUnserializedData(input_form_data)
.SameFormAs(output_form_data));
}

@ -400,19 +400,17 @@ void ContentAutofillRouter::AskForValuesToFill(
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked,
void (*callback)(ContentAutofillDriver* target,
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked)) {
if (!base::FeatureList::IsEnabled(features::kAutofillAcrossIframes)) {
callback(source, form, field, bounding_box, query_id,
autoselect_first_suggestion, form_element_was_clicked);
callback(source, form, field, bounding_box, autoselect_first_suggestion,
form_element_was_clicked);
return;
}
@ -428,7 +426,7 @@ void ContentAutofillRouter::AskForValuesToFill(
AFCHECK(target, return );
SetLastQueriedSource(source);
SetLastQueriedTarget(target);
callback(target, browser_form, field, bounding_box, query_id,
callback(target, browser_form, field, bounding_box,
autoselect_first_suggestion, form_element_was_clicked);
}
@ -686,17 +684,15 @@ void ContentAutofillRouter::OnContextMenuShownInField(
std::vector<FieldGlobalId> ContentAutofillRouter::FillOrPreviewForm(
ContentAutofillDriver* source,
int query_id,
mojom::RendererFormDataAction action,
const FormData& data,
const url::Origin& triggered_origin,
const base::flat_map<FieldGlobalId, ServerFieldType>& field_type_map,
void (*callback)(ContentAutofillDriver*,
int,
mojom::RendererFormDataAction,
const FormData&)) {
void (*callback)(ContentAutofillDriver* target,
mojom::RendererFormDataAction action,
const FormData& form)) {
if (!base::FeatureList::IsEnabled(features::kAutofillAcrossIframes)) {
callback(source, query_id, action, data);
callback(source, action, data);
std::vector<FieldGlobalId> safe_fields;
safe_fields.reserve(data.fields.size());
for (const auto& field : data.fields)
@ -716,9 +712,8 @@ std::vector<FieldGlobalId> ContentAutofillRouter::FillOrPreviewForm(
&FormFieldData::value)) {
continue;
}
if (auto* target = DriverOfFrame(renderer_form.host_frame)) {
callback(target, kCrossFrameFill, action, renderer_form);
}
if (auto* target = DriverOfFrame(renderer_form.host_frame))
callback(target, action, renderer_form);
}
return renderer_forms.safe_fields;
}
@ -726,8 +721,8 @@ std::vector<FieldGlobalId> ContentAutofillRouter::FillOrPreviewForm(
void ContentAutofillRouter::SendAutofillTypePredictionsToRenderer(
ContentAutofillDriver* source,
const std::vector<FormDataPredictions>& browser_fdps,
void (*callback)(ContentAutofillDriver*,
const std::vector<FormDataPredictions>&)) {
void (*callback)(ContentAutofillDriver* target,
const std::vector<FormDataPredictions>& predictions)) {
if (!base::FeatureList::IsEnabled(features::kAutofillAcrossIframes)) {
callback(source, browser_fdps);
return;

@ -229,14 +229,12 @@ class ContentAutofillRouter {
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked,
void (*callback)(ContentAutofillDriver* target,
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked));
void HidePopup(ContentAutofillDriver* source,
@ -300,20 +298,18 @@ class ContentAutofillRouter {
// Routing of events called by the browser:
std::vector<FieldGlobalId> FillOrPreviewForm(
ContentAutofillDriver* source,
int query_id,
mojom::RendererFormDataAction action,
const FormData& data,
const url::Origin& triggered_origin,
const base::flat_map<FieldGlobalId, ServerFieldType>& field_type_map,
void (*callback)(ContentAutofillDriver*,
int,
mojom::RendererFormDataAction,
const FormData&));
void (*callback)(ContentAutofillDriver* target,
mojom::RendererFormDataAction action,
const FormData& form));
void SendAutofillTypePredictionsToRenderer(
ContentAutofillDriver* source,
const std::vector<FormDataPredictions>& type_predictions,
void (*callback)(ContentAutofillDriver*,
const std::vector<FormDataPredictions>&));
void (*callback)(ContentAutofillDriver* target,
const std::vector<FormDataPredictions>& predictions));
void SendFieldsEligibleForManualFillingToRenderer(
ContentAutofillDriver* source,
const std::vector<FieldGlobalId>& fields,

@ -15,10 +15,8 @@ interface AutofillAgent {
TriggerReparse();
// Instructs the renderer to fill or preview the active form with the given
// form data. Refer to AutofillDriver.AskForValuesToFill for comments
// about the |query_id|.
FillOrPreviewForm(int32 query_id,
FormData form,
// form data.
FillOrPreviewForm(FormData form,
RendererFormDataAction action);
// Sends the heuristic and server field type predictions to the renderer.

@ -52,7 +52,6 @@ interface AutofillDriver {
// Queries the browser for Autofill suggestions for a form input field.
// For autofill this means asking the user which values to fill.
// |query_id| is the request ID which is used to map responses correctly.
// |autoselect_first_suggestion| indicates whether a first suggestion gets
// auto selected. |form_element_was_clicked| indicates the user tapped an
// input element. When this happens, surfaces like Touch To Fill and Fast
@ -60,7 +59,6 @@ interface AutofillDriver {
AskForValuesToFill(FormData form,
FormFieldData field,
gfx.mojom.RectF bounding_box,
int32 query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked);

@ -177,11 +177,10 @@ class AutofillAgent::DeferringAutofillDriver : public mojom::AutofillDriver {
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) override {
DeferMsg(&mojom::AutofillDriver::AskForValuesToFill, form, field,
bounding_box, query_id, autoselect_first_suggestion,
bounding_box, autoselect_first_suggestion,
form_element_was_clicked);
}
void HidePopup() override { DeferMsg(&mojom::AutofillDriver::HidePopup); }
@ -226,7 +225,6 @@ AutofillAgent::AutofillAgent(content::RenderFrame* render_frame,
password_autofill_agent_(password_autofill_agent),
password_generation_agent_(password_generation_agent),
autofill_assistant_agent_(autofill_assistant_agent),
autofill_query_id_(0),
query_node_autofill_state_(WebAutofillState::kNotFilled),
is_popup_possibly_visible_(false),
is_generation_popup_possibly_visible_(false),
@ -531,8 +529,7 @@ void AutofillAgent::TriggerRefillIfNeeded(const FormData& form) {
}
// mojom::AutofillAgent:
void AutofillAgent::FillOrPreviewForm(int32_t query_id,
const FormData& form,
void AutofillAgent::FillOrPreviewForm(const FormData& form,
mojom::RendererFormDataAction action) {
// If `element_` is null or not focused, Autofill was either triggered from
// another frame or the `element_` has been detached from the DOM or the focus
@ -896,9 +893,6 @@ void AutofillAgent::QueryAutofillSuggestions(
DCHECK(!element.DynamicTo<WebInputElement>().IsNull() ||
form_util::IsTextAreaElement(element));
static int query_counter = 0;
autofill_query_id_ = query_counter++;
FormData form;
FormFieldData field;
if (!FindFormAndFieldForFormControlElement(
@ -933,9 +927,9 @@ void AutofillAgent::QueryAutofillSuggestions(
}
is_popup_possibly_visible_ = true;
GetAutofillDriver().AskForValuesToFill(
form, field, field.bounds, autofill_query_id_,
autoselect_first_suggestion, form_element_was_clicked);
GetAutofillDriver().AskForValuesToFill(form, field, field.bounds,
autoselect_first_suggestion,
form_element_was_clicked);
}
void AutofillAgent::DoFillFieldWithValue(const std::u16string& value,

@ -90,8 +90,7 @@ class AutofillAgent : public content::RenderFrameObserver,
// mojom::AutofillAgent:
void TriggerReparse() override;
void FillOrPreviewForm(int32_t query_id,
const FormData& form,
void FillOrPreviewForm(const FormData& form,
mojom::RendererFormDataAction action) override;
void FieldTypePredictionsAvailable(
const std::vector<FormDataPredictions>& forms) override;
@ -308,10 +307,6 @@ class AutofillAgent : public content::RenderFrameObserver,
PasswordGenerationAgent* password_generation_agent_; // Weak reference.
AutofillAssistantAgent* autofill_assistant_agent_; // Weak reference.
// The ID of the last request sent for form field Autofill. Used to ignore
// out of date responses.
int autofill_query_id_;
// The element corresponding to the last request sent for form field Autofill.
blink::WebFormControlElement element_;

@ -95,7 +95,6 @@ class MockAutofillDriver : public mojom::AutofillDriver {
(const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked),
(override));

@ -81,7 +81,6 @@ AutocompleteHistoryManager::~AutocompleteHistoryManager() {
}
bool AutocompleteHistoryManager::OnGetSingleFieldSuggestions(
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,

@ -46,7 +46,6 @@ class AutocompleteHistoryManager : public SingleFieldFormFiller,
// SingleFieldFormFiller overrides:
[[nodiscard]] bool OnGetSingleFieldSuggestions(
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,

@ -470,7 +470,6 @@ TEST_F(AutocompleteHistoryManagerTest,
test_field_.should_autocomplete = false;
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
// Setting up mock to verify that call to the handler's OnSuggestionsReturned
// is not triggered.
@ -480,9 +479,8 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for suggestions.
EXPECT_FALSE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
}
// Make sure our handler is called at the right time.
@ -491,7 +489,6 @@ TEST_F(AutocompleteHistoryManagerTest,
int mocked_db_query_id = 100;
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
std::vector<AutofillEntry> expected_values;
@ -505,9 +502,8 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
// Setting up mock to verify that DB response triggers a call to the handler's
// OnSuggestionsReturned
@ -526,7 +522,6 @@ TEST_F(AutocompleteHistoryManagerTest,
TEST_F(AutocompleteHistoryManagerTest,
DoQuerySuggestionsForMeaninglessFieldNames_FilterSubStringName) {
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
test::CreateTestFormField(/*label=*/"", "payment_cvv_info", /*value=*/"",
"Some Type", &test_field_);
@ -538,9 +533,8 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
// Setting up mock to verify that DB response does not trigger a call to the
// handler's OnSuggestionsReturned.
@ -555,7 +549,6 @@ TEST_F(AutocompleteHistoryManagerTest,
TEST_F(AutocompleteHistoryManagerTest,
DoQuerySuggestionsForMeaninglessFieldNames_FilterName) {
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
test::CreateTestFormField(/*label=*/"", "input_123", /*value=*/"",
"Some Type", &test_field_);
@ -567,9 +560,8 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
// Setting up mock to verify that DB response does not trigger a call to the
// handler's OnSuggestionsReturned.
@ -584,7 +576,6 @@ TEST_F(AutocompleteHistoryManagerTest,
TEST_F(AutocompleteHistoryManagerTest,
DoQuerySuggestionsForMeaninglessFieldNames_PassNameWithSubstring) {
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
int mocked_db_query_id = 100;
test::CreateTestFormField(/*label=*/"", "foOTPace", /*value=*/"", "Some Type",
&test_field_);
@ -602,9 +593,8 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
// Setting up mock to verify that DB response triggers a call to the handler's
EXPECT_CALL(*suggestions_handler.get(),
@ -619,7 +609,6 @@ TEST_F(AutocompleteHistoryManagerTest,
TEST_F(AutocompleteHistoryManagerTest,
DoQuerySuggestionsForMeaninglessFieldNames_PassName) {
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
int mocked_db_query_id = 100;
test::CreateTestFormField(/*label=*/"", "addressline_1", /*value=*/"",
"Some Type", &test_field_);
@ -637,9 +626,8 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
// Setting up mock to verify that DB response triggers a call to the handler's
EXPECT_CALL(*suggestions_handler.get(),
@ -655,7 +643,6 @@ TEST_F(AutocompleteHistoryManagerTest,
int mocked_db_query_id = 100;
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
std::vector<AutofillEntry> expected_values = {
GetAutofillEntry(test_field_.name, u"SomePrefixOne")};
@ -670,9 +657,8 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
// Setting up mock to verify that DB response triggers a call to the handler's
EXPECT_CALL(*suggestions_handler.get(),
@ -695,7 +681,6 @@ TEST_F(AutocompleteHistoryManagerTest,
int mocked_db_query_id = 100;
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
std::vector<AutofillEntry> expected_values = {
GetAutofillEntry(test_field_.name, u"SomePrefixOne")};
@ -710,9 +695,8 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(true), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(true), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
// Setting up mock to verify that DB response triggers a call to the handler's
EXPECT_CALL(*suggestions_handler.get(),
@ -735,7 +719,6 @@ TEST_F(AutocompleteHistoryManagerTest,
int mocked_db_query_id = 100;
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
std::vector<AutofillEntry> expected_values = {
GetAutofillEntry(test_field_.name, test_field_.value)};
@ -750,9 +733,8 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
// Setting up mock to verify that DB response triggers a call to the handler's
EXPECT_CALL(*suggestions_handler.get(),
@ -772,7 +754,6 @@ TEST_F(AutocompleteHistoryManagerTest,
int mocked_db_query_id = 100;
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
std::vector<AutofillEntry> expected_values = {
GetAutofillEntry(test_field_.name, u"someprefix")};
@ -787,9 +768,8 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
// Setting up mock to verify that DB response triggers a call to the handler's
EXPECT_CALL(*suggestions_handler.get(),
@ -812,7 +792,6 @@ TEST_F(AutocompleteHistoryManagerTest,
int mocked_db_query_id = 100;
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
std::u16string test_value = u"SomePrefixOne";
std::u16string other_test_value = u"SomePrefixOne";
int days_since_last_use = 10;
@ -837,9 +816,8 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
// Simulate response from DB.
autocomplete_manager_->OnWebDataServiceRequestDone(mocked_db_query_id,
@ -862,8 +840,6 @@ TEST_F(AutocompleteHistoryManagerTest,
int mocked_db_query_id_second = 101;
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id_first = 2;
int test_query_id_second = 3;
std::vector<AutofillEntry> expected_values_first = {
GetAutofillEntry(test_field_.name, u"SomePrefixOne")};
@ -885,18 +861,16 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for the first suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id_first, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
// Simulate request for the second suggestions (this will cancel the first
// one).
EXPECT_CALL(*web_data_service_, CancelRequest(mocked_db_query_id_first))
.Times(1);
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id_second, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
// Setting up mock to verify that we can get the second response first.
EXPECT_CALL(*suggestions_handler.get(),
@ -930,8 +904,6 @@ TEST_F(AutocompleteHistoryManagerTest,
auto suggestions_handler_first = std::make_unique<MockSuggestionsHandler>();
auto suggestions_handler_second = std::make_unique<MockSuggestionsHandler>();
int test_query_id_first = 2;
int test_query_id_second = 3;
std::vector<AutofillEntry> expected_values_first = {
GetAutofillEntry(test_field_.name, u"SomePrefixOne")};
@ -953,15 +925,13 @@ TEST_F(AutocompleteHistoryManagerTest,
// Simulate request for the first suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id_first, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler_first->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler_first->GetWeakPtr(), SuggestionsContext()));
// Simulate request for the second suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id_second, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler_second->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler_second->GetWeakPtr(), SuggestionsContext()));
// Setting up mock to verify that we get the second response first.
EXPECT_CALL(*suggestions_handler_second.get(),
@ -996,7 +966,6 @@ TEST_F(AutocompleteHistoryManagerTest,
// cancelled.
auto suggestions_handler_one = std::make_unique<MockSuggestionsHandler>();
int mocked_db_query_id_one = 100;
int test_query_id_one = 1;
std::vector<AutofillEntry> expected_values_one = {
GetAutofillEntry(test_field_.name, u"SomePrefixOne")};
std::unique_ptr<WDTypedResult> mocked_results_one =
@ -1004,7 +973,6 @@ TEST_F(AutocompleteHistoryManagerTest,
// Initialize variables for the second handler, which will be fulfilled.
auto suggestions_handler_two = std::make_unique<MockSuggestionsHandler>();
int test_query_id_two = 2;
int mocked_db_query_id_two = 101;
std::vector<AutofillEntry> expected_values_two = {
GetAutofillEntry(test_field_.name, u"SomePrefixTwo")};
@ -1019,15 +987,13 @@ TEST_F(AutocompleteHistoryManagerTest,
.WillOnce(Return(mocked_db_query_id_two));
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id_one, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler_one->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler_one->GetWeakPtr(), SuggestionsContext()));
// Simlate second handler request for autocomplete suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id_two, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler_two->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler_two->GetWeakPtr(), SuggestionsContext()));
// Simlate first handler cancelling its request.
EXPECT_CALL(*web_data_service_, CancelRequest(mocked_db_query_id_one))
@ -1071,7 +1037,7 @@ TEST_F(AutocompleteHistoryManagerTest, NoAutocompleteSuggestionsForTextarea) {
testing::Truly(IsEmptySuggestionVector)));
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
0, AutoselectFirstSuggestion(false), field, autofill_client_,
AutoselectFirstSuggestion(false), field, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
}
@ -1081,8 +1047,6 @@ TEST_F(AutocompleteHistoryManagerTest, DestructorCancelsRequests) {
auto suggestions_handler_first = std::make_unique<MockSuggestionsHandler>();
auto suggestions_handler_second = std::make_unique<MockSuggestionsHandler>();
int test_query_id_first = 2;
int test_query_id_second = 3;
EXPECT_CALL(*web_data_service_,
GetFormValuesForElementName(test_field_.name, test_field_.value,
@ -1092,15 +1056,13 @@ TEST_F(AutocompleteHistoryManagerTest, DestructorCancelsRequests) {
// Simulate request for the first suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id_first, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler_first->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler_first->GetWeakPtr(), SuggestionsContext()));
// Simulate request for the second suggestions.
EXPECT_TRUE(autocomplete_manager_->OnGetSingleFieldSuggestions(
test_query_id_second, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler_second->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler_second->GetWeakPtr(), SuggestionsContext()));
// Expect cancel calls for both requests.
EXPECT_CALL(*web_data_service_, CancelRequest(mocked_db_query_id_first))

@ -89,8 +89,6 @@ class AutofillDriver {
// Forwards |data| to the renderer which shall preview or fill the values of
// |data|'s fields into the relevant DOM elements.
//
// |query_id| is the id of the renderer's original request for the data.
//
// |action| is the action the renderer should perform with the |data|.
//
// |triggered_origin| is the origin of the field on which Autofill was
@ -107,7 +105,6 @@ class AutofillDriver {
//
// This method is a no-op if the renderer is not currently available.
virtual std::vector<FieldGlobalId> FillOrPreviewForm(
int query_id,
mojom::RendererFormDataAction action,
const FormData& data,
const url::Origin& triggered_origin,

@ -63,13 +63,11 @@ AutofillExternalDelegate::~AutofillExternalDelegate() {
std::move(deletion_callback_).Run();
}
void AutofillExternalDelegate::OnQuery(int query_id,
const FormData& form,
void AutofillExternalDelegate::OnQuery(const FormData& form,
const FormFieldData& field,
const gfx::RectF& element_bounds) {
query_form_ = form;
query_field_ = field;
query_id_ = query_id;
element_bounds_ = element_bounds;
should_show_scan_credit_card_ =
manager_->ShouldShowScanCreditCard(query_form_, query_field_);
@ -223,7 +221,7 @@ void AutofillExternalDelegate::DidSelectSuggestion(
value);
} else if (frontend_id == POPUP_ITEM_ID_VIRTUAL_CREDIT_CARD_ENTRY) {
manager_->FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction::kPreview, backend_id.value(), query_id_,
mojom::RendererFormDataAction::kPreview, backend_id.value(),
query_form_, query_field_);
}
}
@ -282,8 +280,8 @@ void AutofillExternalDelegate::DidAcceptSuggestion(const Suggestion& suggestion,
// actually chosen credit card.
manager_->FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction::kFill,
suggestion.GetPayload<Suggestion::BackendId>().value(), query_id_,
query_form_, query_field_);
suggestion.GetPayload<Suggestion::BackendId>().value(), query_form_,
query_field_);
} else if (suggestion.frontend_id == POPUP_ITEM_ID_SEE_PROMO_CODE_DETAILS) {
manager_->OnSeePromoCodeOfferDetailsSelected(suggestion.GetPayload<GURL>(),
suggestion.main_text.value,
@ -305,7 +303,7 @@ void AutofillExternalDelegate::DidAcceptSuggestion(const Suggestion& suggestion,
if (suggestion.frontend_id == POPUP_ITEM_ID_SHOW_ACCOUNT_CARDS) {
should_show_cards_from_account_option_ = false;
manager_->RefetchCardsAndUpdatePopup(query_id_, query_form_, query_field_);
manager_->RefetchCardsAndUpdatePopup(query_form_, query_field_);
} else {
manager_->client()->HideAutofillPopup(PopupHidingReason::kAcceptSuggestion);
}
@ -371,7 +369,7 @@ base::WeakPtr<AutofillExternalDelegate> AutofillExternalDelegate::GetWeakPtr() {
void AutofillExternalDelegate::OnCreditCardScanned(const CreditCard& card) {
manager_->FillCreditCardFormImpl(query_form_, query_field_, card,
std::u16string(), query_id_);
std::u16string());
}
void AutofillExternalDelegate::FillAutofillFormData(int unique_id,
@ -386,8 +384,8 @@ void AutofillExternalDelegate::FillAutofillFormData(int unique_id,
DCHECK(driver_->RendererIsAvailable());
// Fill the values for the whole form.
manager_->FillOrPreviewForm(renderer_action, query_id_, query_form_,
query_field_, unique_id);
manager_->FillOrPreviewForm(renderer_action, query_form_, query_field_,
unique_id);
}
void AutofillExternalDelegate::PossiblyRemoveAutofillWarnings(

@ -71,13 +71,14 @@ class AutofillExternalDelegate : public AutofillPopupDelegate {
void RegisterDeletionCallback(base::OnceClosure deletion_callback) override;
// Records and associates a query_id with web form data. Called
// when the renderer posts an Autofill query to the browser. |bounds|
// Called when the renderer posts an Autofill query to the browser. |bounds|
// is window relative. We might not want to display the warning if a website
// has disabled Autocomplete because they have their own popup, and showing
// our popup on to of theirs would be a poor user experience.
virtual void OnQuery(int query_id,
const FormData& form,
//
// TODO(crbug.com/1117028): Storing `form` and `field` in member variables
// breaks the cache.
virtual void OnQuery(const FormData& form,
const FormFieldData& field,
const gfx::RectF& element_bounds);
@ -157,10 +158,6 @@ class AutofillExternalDelegate : public AutofillPopupDelegate {
// outlive this object.
const raw_ptr<AutofillDriver> driver_; // weak
// The ID of the last request sent for form field Autofill. Used to ignore
// out of date responses.
int query_id_ = 0;
// The current form and field selected by Autofill.
FormData query_form_;
FormFieldData query_field_;

@ -44,9 +44,6 @@ namespace autofill {
namespace {
// A constant value to use as the Autofill query ID.
const int kRecentQueryId = 1;
// A constant value to use as an Autofill profile ID.
const int kAutofillProfileId = 1;
@ -145,7 +142,6 @@ class MockBrowserAutofillManager : public BrowserAutofillManager {
FillOrPreviewVirtualCardInformation,
(mojom::RendererFormDataAction action,
const std::string& guid,
int query_id,
const FormData& form,
const FormFieldData& field),
(override));
@ -162,7 +158,6 @@ class MockBrowserAutofillManager : public BrowserAutofillManager {
MOCK_METHOD(void,
FillOrPreviewForm,
(mojom::RendererFormDataAction action,
int query_id,
const FormData& form,
const FormFieldData& field,
int unique_id),
@ -172,8 +167,7 @@ class MockBrowserAutofillManager : public BrowserAutofillManager {
(const FormData& form,
const FormFieldData& field,
const CreditCard& credit_card,
const std::u16string& cvc,
int query_id),
const std::u16string& cvc),
(override));
private:
@ -201,8 +195,8 @@ class AutofillExternalDelegateUnitTest : public testing::Test {
autofill_driver_.reset();
}
// Issue an OnQuery call with the given |query_id|.
void IssueOnQuery(int query_id) {
// Issue an OnQuery call.
void IssueOnQuery() {
FormData form;
form.host_frame = form_id_.frame_token;
form.unique_renderer_id = form_id_.renderer_id;
@ -212,8 +206,7 @@ class AutofillExternalDelegateUnitTest : public testing::Test {
field.host_form_id = form.unique_renderer_id;
field.is_focusable = true;
field.should_autocomplete = true;
external_delegate_->OnQuery(query_id, form, field, gfx::RectF());
external_delegate_->OnQuery(form, field, gfx::RectF());
}
void IssueOnSuggestionsReturned(FieldGlobalId field_id) {
@ -249,7 +242,7 @@ class AutofillExternalDelegateCardsFromAccountTest
// Test that our external delegate called the virtual methods at the right time.
TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
// The enums must be cast to ints to prevent compile errors on linux_rel.
auto element_ids =
@ -272,9 +265,8 @@ TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
EXPECT_FALSE(open_args.autoselect_first_suggestion);
EXPECT_EQ(open_args.popup_type, PopupType::kPersonalInformation);
EXPECT_CALL(
*browser_autofill_manager_,
FillOrPreviewForm(mojom::RendererFormDataAction::kFill, _, _, _, _));
EXPECT_CALL(*browser_autofill_manager_,
FillOrPreviewForm(mojom::RendererFormDataAction::kFill, _, _, _));
EXPECT_CALL(autofill_client_,
HideAutofillPopup(PopupHidingReason::kAcceptSuggestion));
@ -290,7 +282,7 @@ TEST_F(AutofillExternalDelegateUnitTest,
EXPECT_CALL(*browser_autofill_manager_, ShouldShowCreditCardSigninPromo(_, _))
.WillOnce(testing::Return(true));
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
// The enums must be cast to ints to prevent compile errors on linux_rel.
auto element_ids =
@ -317,9 +309,8 @@ TEST_F(AutofillExternalDelegateUnitTest,
EXPECT_FALSE(open_args.autoselect_first_suggestion);
EXPECT_EQ(open_args.popup_type, PopupType::kPersonalInformation);
EXPECT_CALL(
*browser_autofill_manager_,
FillOrPreviewForm(mojom::RendererFormDataAction::kFill, _, _, _, _));
EXPECT_CALL(*browser_autofill_manager_,
FillOrPreviewForm(mojom::RendererFormDataAction::kFill, _, _, _));
EXPECT_CALL(autofill_client_,
HideAutofillPopup(PopupHidingReason::kAcceptSuggestion));
@ -335,7 +326,7 @@ TEST_F(AutofillExternalDelegateUnitTest,
EXPECT_CALL(*browser_autofill_manager_, ShouldShowCreditCardSigninPromo(_, _))
.WillOnce(testing::Return(true));
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
// The enums must be cast to ints to prevent compile errors on linux_rel.
auto element_ids = testing::ElementsAre(
@ -370,7 +361,7 @@ TEST_F(AutofillExternalDelegateUnitTest,
// Test that data list elements for a node will appear in the Autofill popup.
TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateDataList) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
std::vector<std::u16string> data_list_items;
data_list_items.emplace_back();
@ -425,7 +416,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateDataList) {
// Test that datalist values can get updated while a popup is showing.
TEST_F(AutofillExternalDelegateUnitTest, UpdateDataListWhileShowingPopup) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
EXPECT_CALL(autofill_client_, ShowAutofillPopup).Times(0);
@ -483,7 +474,7 @@ TEST_F(AutofillExternalDelegateUnitTest, UpdateDataListWhileShowingPopup) {
// Test that we _don't_ de-dupe autofill values against datalist values. We
// keep both with a separator.
TEST_F(AutofillExternalDelegateUnitTest, DuplicateAutofillDatalistValues) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
std::vector<std::u16string> data_list_values{u"Rick", u"Beyonce"};
std::vector<std::u16string> data_list_labels{u"Deckard", u"Knowles"};
@ -527,7 +518,7 @@ TEST_F(AutofillExternalDelegateUnitTest, DuplicateAutofillDatalistValues) {
// Test that we de-dupe autocomplete values against datalist values, keeping the
// latter in case of a match.
TEST_F(AutofillExternalDelegateUnitTest, DuplicateAutocompleteDatalistValues) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
std::vector<std::u16string> data_list_values{u"Rick", u"Beyonce"};
std::vector<std::u16string> data_list_labels{u"Deckard", u"Knowles"};
@ -573,7 +564,7 @@ TEST_F(AutofillExternalDelegateUnitTest, DuplicateAutocompleteDatalistValues) {
// Autofill is disabled for a website.
// Regression test for http://crbug.com/247880
TEST_F(AutofillExternalDelegateUnitTest, AutofillWarnings) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
AutofillClient::PopupOpenArgs open_args;
EXPECT_CALL(autofill_client_, ShowAutofillPopup)
@ -601,7 +592,7 @@ TEST_F(AutofillExternalDelegateUnitTest, AutofillWarnings) {
// entries in the vector.
TEST_F(AutofillExternalDelegateUnitTest,
AutofillWarningsNotShown_WithSuggestions) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
AutofillClient::PopupOpenArgs open_args;
EXPECT_CALL(autofill_client_, ShowAutofillPopup)
@ -631,7 +622,7 @@ TEST_F(AutofillExternalDelegateUnitTest,
// negative unique id.
TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) {
// Ensure it doesn't try to preview the negative id.
EXPECT_CALL(*browser_autofill_manager_, FillOrPreviewForm(_, _, _, _, _))
EXPECT_CALL(*browser_autofill_manager_, FillOrPreviewForm(_, _, _, _))
.Times(0);
EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1);
external_delegate_->DidSelectSuggestion(std::u16string(), -1,
@ -640,7 +631,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) {
// Ensure it doesn't try to fill the form in with the negative id.
EXPECT_CALL(autofill_client_,
HideAutofillPopup(PopupHidingReason::kAcceptSuggestion));
EXPECT_CALL(*browser_autofill_manager_, FillOrPreviewForm(_, _, _, _, _))
EXPECT_CALL(*browser_autofill_manager_, FillOrPreviewForm(_, _, _, _))
.Times(0);
external_delegate_->DidAcceptSuggestion(Suggestion(-1), 0);
@ -649,7 +640,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateInvalidUniqueId) {
// Test that the Autofill delegate still allows previewing and filling
// specifically of the negative ID for POPUP_ITEM_ID_IBAN_ENTRY.
TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillsIbanEntry) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
AutofillClient::PopupOpenArgs open_args;
EXPECT_CALL(autofill_client_, ShowAutofillPopup)
@ -686,7 +677,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillsIbanEntry) {
// specifically of the negative ID for POPUP_ITEM_ID_MERCHANT_PROMO_CODE_ENTRY.
TEST_F(AutofillExternalDelegateUnitTest,
ExternalDelegateFillsMerchantPromoCodeEntry) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
AutofillClient::PopupOpenArgs open_args;
EXPECT_CALL(autofill_client_, ShowAutofillPopup)
@ -742,14 +733,14 @@ TEST_F(AutofillExternalDelegateUnitTest,
TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearPreviewedForm) {
// Ensure selecting a new password entries or Autofill entries will
// cause any previews to get cleared.
IssueOnQuery(123);
IssueOnQuery();
EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1);
external_delegate_->DidSelectSuggestion(
u"baz foo", POPUP_ITEM_ID_PASSWORD_ENTRY, Suggestion::BackendId());
EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1);
EXPECT_CALL(
*browser_autofill_manager_,
FillOrPreviewForm(mojom::RendererFormDataAction::kPreview, _, _, _, _));
FillOrPreviewForm(mojom::RendererFormDataAction::kPreview, _, _, _));
external_delegate_->DidSelectSuggestion(u"baz foo", 1,
Suggestion::BackendId());
@ -766,7 +757,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearPreviewedForm) {
EXPECT_CALL(*autofill_driver_, RendererShouldClearPreviewedForm()).Times(1);
EXPECT_CALL(*browser_autofill_manager_,
FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction::kPreview, _, _, _, _));
mojom::RendererFormDataAction::kPreview, _, _, _));
external_delegate_->DidSelectSuggestion(
std::u16string(), POPUP_ITEM_ID_VIRTUAL_CREDIT_CARD_ENTRY,
Suggestion::BackendId());
@ -787,7 +778,7 @@ TEST_F(AutofillExternalDelegateUnitTest,
// that the user accepted the data list suggestion.
TEST_F(AutofillExternalDelegateUnitTest,
ExternalDelegateAcceptDatalistSuggestion) {
IssueOnQuery(0);
IssueOnQuery();
EXPECT_CALL(autofill_client_,
HideAutofillPopup(PopupHidingReason::kAcceptSuggestion));
std::u16string dummy_string(u"baz qux");
@ -807,7 +798,7 @@ TEST_F(AutofillExternalDelegateUnitTest,
HideAutofillPopup(PopupHidingReason::kAcceptSuggestion));
std::u16string dummy_string(u"John Legend");
EXPECT_CALL(*browser_autofill_manager_,
FillOrPreviewForm(mojom::RendererFormDataAction::kFill, _, _, _,
FillOrPreviewForm(mojom::RendererFormDataAction::kFill, _, _,
kAutofillProfileId));
external_delegate_->DidAcceptSuggestion(
@ -843,7 +834,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ScanCreditCardPromptMetricsTest) {
EXPECT_CALL(*browser_autofill_manager_, ShouldShowScanCreditCard(_, _))
.WillOnce(testing::Return(true));
base::HistogramTester histogram;
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
IssueOnSuggestionsReturned(field_id_);
external_delegate_->OnPopupShown();
histogram.ExpectUniqueSample("Autofill.ScanCreditCardPrompt",
@ -854,7 +845,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ScanCreditCardPromptMetricsTest) {
EXPECT_CALL(*browser_autofill_manager_, ShouldShowScanCreditCard(_, _))
.WillOnce(testing::Return(true));
base::HistogramTester histogram;
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
IssueOnSuggestionsReturned(field_id_);
external_delegate_->OnPopupShown();
@ -874,7 +865,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ScanCreditCardPromptMetricsTest) {
EXPECT_CALL(*browser_autofill_manager_, ShouldShowScanCreditCard(_, _))
.WillOnce(testing::Return(true));
base::HistogramTester histogram;
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
IssueOnSuggestionsReturned(field_id_);
external_delegate_->OnPopupShown();
@ -894,7 +885,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ScanCreditCardPromptMetricsTest) {
EXPECT_CALL(*browser_autofill_manager_, ShouldShowScanCreditCard(_, _))
.WillOnce(testing::Return(false));
base::HistogramTester histogram;
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
IssueOnSuggestionsReturned(field_id_);
external_delegate_->OnPopupShown();
histogram.ExpectTotalCount("Autofill.ScanCreditCardPrompt", 0);
@ -922,9 +913,9 @@ MATCHER_P(CreditCardMatches, card, "") {
TEST_F(AutofillExternalDelegateUnitTest, FillCreditCardFormImpl) {
CreditCard card;
test::SetCreditCardInfo(&card, "Alice", "4111", "1", "3000", "1");
EXPECT_CALL(*browser_autofill_manager_,
FillCreditCardFormImpl(_, _, CreditCardMatches(card),
std::u16string(), _));
EXPECT_CALL(
*browser_autofill_manager_,
FillCreditCardFormImpl(_, _, CreditCardMatches(card), std::u16string()));
external_delegate_->OnCreditCardScanned(card);
}
@ -934,7 +925,7 @@ TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) {
field.is_focusable = true;
field.should_autocomplete = false;
external_delegate_->OnQuery(kRecentQueryId, form, field, gfx::RectF());
external_delegate_->OnQuery(form, field, gfx::RectF());
std::vector<Suggestion> autofill_items;
autofill_items.emplace_back();
@ -952,7 +943,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) {
EXPECT_CALL(autofill_client_,
HideAutofillPopup(PopupHidingReason::kAcceptSuggestion))
.Times(3);
IssueOnQuery(456);
IssueOnQuery();
std::u16string dummy_string(u"baz foo");
EXPECT_CALL(*autofill_driver_,
RendererShouldFillFieldWithValue(field_id_, dummy_string));
@ -995,7 +986,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) {
}
TEST_F(AutofillExternalDelegateUnitTest, ShouldShowGooglePayIcon) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
auto element_icons = testing::ElementsAre(std::string(),
#if !BUILDFLAG(IS_ANDROID)
@ -1027,7 +1018,7 @@ TEST_F(AutofillExternalDelegateUnitTest, ShouldShowGooglePayIcon) {
TEST_F(AutofillExternalDelegateUnitTest,
ShouldNotShowGooglePayIconIfSuggestionsContainLocalCards) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
auto element_icons = testing::ElementsAre(std::string(),
#if !BUILDFLAG(IS_ANDROID)
@ -1051,7 +1042,7 @@ TEST_F(AutofillExternalDelegateUnitTest,
}
TEST_F(AutofillExternalDelegateUnitTest, ShouldUseNewSettingName) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
auto element_main_texts = testing::ElementsAre(
Suggestion::Text(std::u16string(), Suggestion::Text::IsPrimary(true)),
@ -1084,8 +1075,7 @@ TEST_F(AutofillExternalDelegateUnitTest, AcceptVirtualCardOptionItem) {
FormData form;
EXPECT_CALL(*browser_autofill_manager_,
FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction::kFill, _, _, _, _));
mojom::RendererFormDataAction::kFill, _, _, _));
external_delegate_->DidAcceptSuggestion(
Suggestion(POPUP_ITEM_ID_VIRTUAL_CREDIT_CARD_ENTRY), 0);
}
@ -1093,7 +1083,7 @@ TEST_F(AutofillExternalDelegateUnitTest, AcceptVirtualCardOptionItem) {
TEST_F(AutofillExternalDelegateUnitTest, SelectVirtualCardOptionItem) {
EXPECT_CALL(*browser_autofill_manager_,
FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction::kPreview, _, _, _, _));
mojom::RendererFormDataAction::kPreview, _, _, _));
external_delegate_->DidSelectSuggestion(
std::u16string(), POPUP_ITEM_ID_VIRTUAL_CREDIT_CARD_ENTRY,
Suggestion::BackendId());
@ -1104,7 +1094,7 @@ TEST_F(AutofillExternalDelegateUnitTest, SelectVirtualCardOptionItem) {
// row in the footer.
TEST_F(AutofillExternalDelegateCardsFromAccountTest,
ShouldShowCardsFromAccountOptionWithCards) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
auto element_main_texts = testing::ElementsAre(
Suggestion::Text(std::u16string(), Suggestion::Text::IsPrimary(true)),
@ -1138,7 +1128,7 @@ TEST_F(AutofillExternalDelegateCardsFromAccountTest,
// *not* show up in this case.
TEST_F(AutofillExternalDelegateCardsFromAccountTest,
ShouldShowCardsFromAccountOptionWithoutCards) {
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
auto element_main_texts = testing::ElementsAre(Suggestion::Text(
l10n_util::GetStringUTF16(IDS_AUTOFILL_SHOW_ACCOUNT_CARDS),
@ -1162,7 +1152,7 @@ TEST_F(AutofillExternalDelegateCardsFromAccountTest,
FieldGlobalId old_field_id = test::MakeFieldGlobalId();
FieldGlobalId new_field_id = test::MakeFieldGlobalId();
autofill_client_.set_last_queried_field(new_field_id);
IssueOnQuery(kRecentQueryId);
IssueOnQuery();
EXPECT_CALL(autofill_client_, ShowAutofillPopup).Times(0);
external_delegate_->OnSuggestionsReturned(old_field_id,
std::vector<Suggestion>(),

@ -251,18 +251,17 @@ LanguageCode AutofillManager::GetCurrentPageLanguage() {
return LanguageCode(language_state->current_language());
}
void AutofillManager::FillCreditCardForm(int query_id,
const FormData& form,
void AutofillManager::FillCreditCardForm(const FormData& form,
const FormFieldData& field,
const CreditCard& credit_card,
const std::u16string& cvc) {
if (!base::FeatureList::IsEnabled(features::kAutofillParseAsync)) {
FillCreditCardFormImpl(form, field, credit_card, cvc, query_id);
FillCreditCardFormImpl(form, field, credit_card, cvc);
return;
}
ParseFormAsync(form, ParsingCallback(&AutofillManager::FillCreditCardFormImpl,
/*after_event=*/nullptr, field,
credit_card, cvc, query_id));
ParseFormAsync(
form, ParsingCallback(&AutofillManager::FillCreditCardFormImpl,
/*after_event=*/nullptr, field, credit_card, cvc));
}
void AutofillManager::FillProfileForm(const AutofillProfile& profile,
@ -480,7 +479,6 @@ void AutofillManager::OnAskForValuesToFill(
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) {
if (!IsValidFormData(form) || !IsValidFormFieldData(field))
@ -496,17 +494,17 @@ void AutofillManager::OnAskForValuesToFill(
client_->IsFastCheckoutSupported()
#endif
) {
OnAskForValuesToFillImpl(form, field, bounding_box, query_id,
OnAskForValuesToFillImpl(form, field, bounding_box,
autoselect_first_suggestion,
form_element_was_clicked);
NotifyObservers(&Observer::OnAfterAskForValuesToFill);
return;
}
ParseFormAsync(
form, ParsingCallback(&AutofillManager::OnAskForValuesToFillImpl,
&Observer::OnAfterAskForValuesToFill, field,
bounding_box, query_id, autoselect_first_suggestion,
form_element_was_clicked));
form,
ParsingCallback(&AutofillManager::OnAskForValuesToFillImpl,
&Observer::OnAfterAskForValuesToFill, field, bounding_box,
autoselect_first_suggestion, form_element_was_clicked));
}
void AutofillManager::OnFocusOnFormField(const FormData& form,

@ -177,7 +177,6 @@ class AutofillManager
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked);
@ -195,8 +194,7 @@ class AutofillManager
bool known_success,
mojom::SubmissionSource source);
void FillCreditCardForm(int query_id,
const FormData& form,
void FillCreditCardForm(const FormData& form,
const FormFieldData& field,
const CreditCard& credit_card,
const std::u16string& cvc);
@ -383,7 +381,6 @@ class AutofillManager
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) = 0;
@ -402,8 +399,7 @@ class AutofillManager
virtual void FillCreditCardFormImpl(const FormData& form,
const FormFieldData& field,
const CreditCard& credit_card,
const std::u16string& cvc,
int query_id) = 0;
const std::u16string& cvc) = 0;
virtual void FillProfileFormImpl(const FormData& form,
const FormFieldData& field,
const AutofillProfile& profile) = 0;

@ -72,8 +72,7 @@ class MockAutofillManager : public AutofillManager {
(const FormData& form,
const FormFieldData& field,
const CreditCard& credit_card,
const std::u16string& cvc,
int query_id),
const std::u16string& cvc),
(override));
MOCK_METHOD(void,
FillProfileFormImpl,
@ -130,7 +129,6 @@ class MockAutofillManager : public AutofillManager {
(const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked),
(override));

@ -1034,7 +1034,6 @@ void FillUploadField(AutofillUploadContents::Field* field,
void GenerateTestAutofillPopup(
AutofillExternalDelegate* autofill_external_delegate) {
int query_id = 1;
FormData form;
FormFieldData field;
form.host_frame = MakeLocalFrameToken();
@ -1044,7 +1043,7 @@ void GenerateTestAutofillPopup(
field.is_focusable = true;
field.should_autocomplete = true;
gfx::RectF bounds(100.f, 100.f);
autofill_external_delegate->OnQuery(query_id, form, field, bounds);
autofill_external_delegate->OnQuery(form, field, bounds);
std::vector<Suggestion> suggestions;
suggestions.push_back(Suggestion(u"Test suggestion"));

@ -661,7 +661,6 @@ void BrowserAutofillManager::OnUserAcceptedCardsFromAccountOption() {
}
void BrowserAutofillManager::RefetchCardsAndUpdatePopup(
int query_id,
const FormData& form,
const FormFieldData& field_data) {
AutofillField* autofill_field = GetAutofillField(form, field_data);
@ -1061,7 +1060,6 @@ void BrowserAutofillManager::OnAskForValuesToFillImpl(
const FormData& form,
const FormFieldData& field,
const gfx::RectF& transformed_box,
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) {
if (base::FeatureList::IsEnabled(features::kAutofillDisableFilling)) {
@ -1069,7 +1067,7 @@ void BrowserAutofillManager::OnAskForValuesToFillImpl(
}
SetDataList(field.datalist_values, field.datalist_labels);
external_delegate_->OnQuery(query_id, form, field, transformed_box);
external_delegate_->OnQuery(form, field, transformed_box);
std::vector<Suggestion> suggestions;
SuggestionsContext context;
@ -1181,7 +1179,7 @@ void BrowserAutofillManager::OnAskForValuesToFillImpl(
// will handle sending the results back to the renderer.
bool handled_by_single_field_form_filler =
single_field_form_fill_router_->OnGetSingleFieldSuggestions(
query_id, autoselect_first_suggestion, field, *client(),
autoselect_first_suggestion, field, *client(),
weak_ptr_factory_.GetWeakPtr(), context);
if (handled_by_single_field_form_filler)
return;
@ -1190,7 +1188,7 @@ void BrowserAutofillManager::OnAskForValuesToFillImpl(
single_field_form_fill_router_->CancelPendingQueries(this);
if (touch_to_fill_delegate_->IsShowingTouchToFill() ||
(form_element_was_clicked &&
touch_to_fill_delegate_->TryToShowTouchToFill(query_id, form, field))) {
touch_to_fill_delegate_->TryToShowTouchToFill(form, field))) {
// Touch To Fill surface is shown, so abort showing regular Autofill UI.
// Now the flow is controlled by the |touch_to_fill_delegate_| instead
// of |external_delegate_|.
@ -1239,7 +1237,6 @@ bool BrowserAutofillManager::WillFillCreditCardNumber(
void BrowserAutofillManager::FillOrPreviewCreditCardForm(
mojom::RendererFormDataAction action,
int query_id,
const FormData& form,
const FormFieldData& field,
const CreditCard* credit_card) {
@ -1257,7 +1254,6 @@ void BrowserAutofillManager::FillOrPreviewCreditCardForm(
credit_card_, *form_structure, sync_state_);
credit_card_action_ = action;
credit_card_query_id_ = query_id;
credit_card_form_ = form;
credit_card_field_ = field;
@ -1268,14 +1264,13 @@ void BrowserAutofillManager::FillOrPreviewCreditCardForm(
return;
}
FillOrPreviewDataModelForm(action, query_id, form, field, &credit_card_,
FillOrPreviewDataModelForm(action, form, field, &credit_card_,
/*optional_cvc=*/nullptr, form_structure,
autofill_field);
}
void BrowserAutofillManager::FillOrPreviewProfileForm(
mojom::RendererFormDataAction action,
int query_id,
const FormData& form,
const FormFieldData& field,
const AutofillProfile& profile) {
@ -1283,14 +1278,13 @@ void BrowserAutofillManager::FillOrPreviewProfileForm(
AutofillField* autofill_field = nullptr;
if (!GetCachedFormAndField(form, field, &form_structure, &autofill_field))
return;
FillOrPreviewDataModelForm(action, query_id, form, field, &profile,
FillOrPreviewDataModelForm(action, form, field, &profile,
/*optional_cvc=*/nullptr, form_structure,
autofill_field);
}
void BrowserAutofillManager::FillOrPreviewForm(
mojom::RendererFormDataAction action,
int query_id,
const FormData& form,
const FormFieldData& field,
int unique_id) {
@ -1305,18 +1299,18 @@ void BrowserAutofillManager::FillOrPreviewForm(
const AutofillProfile* profile = GetProfile(unique_id);
const CreditCard* credit_card = GetCreditCard(unique_id);
if (credit_card)
FillOrPreviewCreditCardForm(action, query_id, form, field, credit_card);
else if (profile)
FillOrPreviewProfileForm(action, query_id, form, field, *profile);
if (credit_card) {
FillOrPreviewCreditCardForm(action, form, field, credit_card);
} else if (profile) {
FillOrPreviewProfileForm(action, form, field, *profile);
}
}
void BrowserAutofillManager::FillCreditCardFormImpl(
const FormData& form,
const FormFieldData& field,
const CreditCard& credit_card,
const std::u16string& cvc,
int query_id) {
const std::u16string& cvc) {
if (!IsValidFormData(form) || !IsValidFormFieldData(field) ||
!driver()->RendererIsAvailable()) {
return;
@ -1327,8 +1321,8 @@ void BrowserAutofillManager::FillCreditCardFormImpl(
if (!GetCachedFormAndField(form, field, &form_structure, &autofill_field))
return;
FillOrPreviewDataModelForm(mojom::RendererFormDataAction::kFill, query_id,
form, field, &credit_card, &cvc, form_structure,
FillOrPreviewDataModelForm(mojom::RendererFormDataAction::kFill, form, field,
&credit_card, &cvc, form_structure,
autofill_field);
}
@ -1336,14 +1330,13 @@ void BrowserAutofillManager::FillProfileFormImpl(
const FormData& form,
const FormFieldData& field,
const AutofillProfile& profile) {
FillOrPreviewProfileForm(mojom::RendererFormDataAction::kFill,
/*query_id=*/kNoQueryId, form, field, profile);
FillOrPreviewProfileForm(mojom::RendererFormDataAction::kFill, form, field,
profile);
}
void BrowserAutofillManager::FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction action,
const std::string& guid,
int query_id,
const FormData& form,
const FormFieldData& field) {
if (!IsValidFormData(form) || !IsValidFormFieldData(field) ||
@ -1355,7 +1348,7 @@ void BrowserAutofillManager::FillOrPreviewVirtualCardInformation(
if (credit_card) {
CreditCard copy = *credit_card;
copy.set_record_type(CreditCard::VIRTUAL_CARD);
FillOrPreviewCreditCardForm(action, query_id, form, field, &copy);
FillOrPreviewCreditCardForm(action, form, field, &copy);
}
}
@ -1809,7 +1802,7 @@ void BrowserAutofillManager::OnCreditCardFetched(CreditCardFetchResult result,
credit_card->instrument_id());
FillCreditCardFormImpl(credit_card_form_, credit_card_field_, *credit_card,
cvc, credit_card_query_id_);
cvc);
if (credit_card->record_type() == CreditCard::FULL_SERVER_CARD ||
credit_card->record_type() == CreditCard::VIRTUAL_CARD) {
credit_card_access_manager_->CacheUnmaskedCardInfo(*credit_card, cvc);
@ -1990,7 +1983,6 @@ void BrowserAutofillManager::Reset() {
user_did_autofill_ = false;
user_did_edit_autofilled_field_ = false;
credit_card_ = CreditCard();
credit_card_query_id_ = -1;
credit_card_form_ = FormData();
credit_card_field_ = FormFieldData();
last_unlocked_credit_card_cvc_.clear();
@ -2068,7 +2060,6 @@ AutofillProfile* BrowserAutofillManager::GetProfile(int unique_id) {
void BrowserAutofillManager::FillOrPreviewDataModelForm(
mojom::RendererFormDataAction action,
int query_id,
const FormData& form,
const FormFieldData& field,
absl::variant<const AutofillProfile*, const CreditCard*>
@ -2299,8 +2290,8 @@ void BrowserAutofillManager::FillOrPreviewDataModelForm(
return std::make_pair(field->global_id(),
field->Type().GetStorableType());
});
std::vector<FieldGlobalId> safe_fields = driver()->FillOrPreviewForm(
query_id, action, result, field.origin, field_types);
std::vector<FieldGlobalId> safe_fields =
driver()->FillOrPreviewForm(action, result, field.origin, field_types);
// Report the fields that were not filled due to the iframe security policy.
for (FieldGlobalId field_global_id : newly_filled_fields) {
@ -2900,15 +2891,14 @@ void BrowserAutofillManager::TriggerRefill(const FormData& form) {
const auto& [credit_card, cvc] =
absl::get<std::pair<CreditCard, std::u16string>>(
filling_context->profile_or_credit_card_with_cvc);
FillOrPreviewDataModelForm(mojom::RendererFormDataAction::kFill,
/*query_id=*/-1, form, field, &credit_card, &cvc,
form_structure, autofill_field,
FillOrPreviewDataModelForm(mojom::RendererFormDataAction::kFill, form,
field, &credit_card, &cvc, form_structure,
autofill_field,
/*is_refill=*/true);
} else if (absl::holds_alternative<AutofillProfile>(
filling_context->profile_or_credit_card_with_cvc)) {
FillOrPreviewDataModelForm(
mojom::RendererFormDataAction::kFill,
/*query_id=*/-1, form, field,
mojom::RendererFormDataAction::kFill, form, field,
&absl::get<AutofillProfile>(
filling_context->profile_or_credit_card_with_cvc),
/*optional_cvc=*/nullptr, form_structure, autofill_field,

@ -133,8 +133,7 @@ class BrowserAutofillManager : public AutofillManager,
virtual bool ShouldShowCardsFromAccountOption(const FormData& form,
const FormFieldData& field);
virtual void OnUserAcceptedCardsFromAccountOption();
virtual void RefetchCardsAndUpdatePopup(int query_id,
const FormData& form,
virtual void RefetchCardsAndUpdatePopup(const FormData& form,
const FormFieldData& field_data);
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
@ -156,15 +155,13 @@ class BrowserAutofillManager : public AutofillManager,
// ContentAutofillDriver::FillFormForAssistant().
// TODO(crbug.com/1330108): Clean up the API.
virtual void FillOrPreviewForm(mojom::RendererFormDataAction action,
int query_id,
const FormData& form,
const FormFieldData& field,
int unique_id);
void FillCreditCardFormImpl(const FormData& form,
const FormFieldData& field,
const CreditCard& credit_card,
const std::u16string& cvc,
int query_id) override;
const std::u16string& cvc) override;
void DidShowSuggestions(bool has_autofill_suggestions,
const FormData& form,
const FormFieldData& field);
@ -174,7 +171,6 @@ class BrowserAutofillManager : public AutofillManager,
// Asks for authentication via CVC before filling with server card data.
// TODO(crbug.com/1330108): Clean up the API.
virtual void FillOrPreviewCreditCardForm(mojom::RendererFormDataAction action,
int query_id,
const FormData& form,
const FormFieldData& field,
const CreditCard* credit_card);
@ -192,7 +188,6 @@ class BrowserAutofillManager : public AutofillManager,
virtual void FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction action,
const std::string& guid,
int query_id,
const FormData& form,
const FormFieldData& field);
@ -394,7 +389,6 @@ class BrowserAutofillManager : public AutofillManager,
void FillOrPreviewDataModelFormForTest(
mojom::RendererFormDataAction action,
int query_id,
const FormData& form,
const FormFieldData& field,
absl::variant<const AutofillProfile*, const CreditCard*>
@ -402,7 +396,7 @@ class BrowserAutofillManager : public AutofillManager,
const std::u16string* optional_cvc,
FormStructure* form_structure,
AutofillField* autofill_field) {
return FillOrPreviewDataModelForm(action, query_id, form, field,
return FillOrPreviewDataModelForm(action, form, field,
profile_or_credit_card, optional_cvc,
form_structure, autofill_field);
}
@ -452,7 +446,6 @@ class BrowserAutofillManager : public AutofillManager,
const FormData& form,
const FormFieldData& field,
const gfx::RectF& transformed_box,
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) override;
void OnSelectControlDidChangeImpl(const FormData& form,
@ -529,7 +522,6 @@ class BrowserAutofillManager : public AutofillManager,
// Assumes the form and field are valid.
// TODO(crbug.com/1330108): Clean up the API.
void FillOrPreviewProfileForm(mojom::RendererFormDataAction action,
int query_id,
const FormData& form,
const FormFieldData& field,
const AutofillProfile& profile);
@ -538,7 +530,6 @@ class BrowserAutofillManager : public AutofillManager,
// TODO(crbug.com/1330108): Clean up the API.
void FillOrPreviewDataModelForm(
mojom::RendererFormDataAction action,
int query_id,
const FormData& form,
const FormFieldData& field,
absl::variant<const AutofillProfile*, const CreditCard*>
@ -785,7 +776,6 @@ class BrowserAutofillManager : public AutofillManager,
// Collected information about the autofill form where a credit card will be
// filled.
mojom::RendererFormDataAction credit_card_action_;
int credit_card_query_id_ = -1;
FormData credit_card_form_;
FormFieldData credit_card_field_;
CreditCard credit_card_;

File diff suppressed because it is too large Load Diff

@ -21,7 +21,6 @@ IBANManager::IBANManager(PersonalDataManager* personal_data_manager,
IBANManager::~IBANManager() = default;
bool IBANManager::OnGetSingleFieldSuggestions(
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,

@ -41,7 +41,6 @@ class IBANManager : public SingleFieldFormFiller,
// SingleFieldFormFiller overrides:
[[nodiscard]] bool OnGetSingleFieldSuggestions(
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,

@ -78,7 +78,6 @@ class IBANManagerTest : public testing::Test {
};
TEST_F(IBANManagerTest, ShowsIBANSuggestions) {
int test_query_id = 2;
Suggestion iban_suggestion_0 =
SetUpIBANAndSuggestion(u"IE12 BOFI 9000 0112 3456 78", u"Nickname 0");
Suggestion iban_suggestion_1 =
@ -102,13 +101,12 @@ TEST_F(IBANManagerTest, ShowsIBANSuggestions) {
// Because all criteria are met to trigger returning to the handler,
// the handler should be triggered and this should return true.
EXPECT_TRUE(iban_manager_.OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(false), test_field,
autofill_client_, suggestions_handler_.GetWeakPtr(),
AutoselectFirstSuggestion(false), test_field, autofill_client_,
suggestions_handler_.GetWeakPtr(),
/*context=*/context));
}
TEST_F(IBANManagerTest, ShowsIBANSuggestions_OnlyPrefixMatch) {
int test_query_id = 2;
base::StringPiece16 value_0 = u"IE12 BOFI 9000 0112 3456 78";
Suggestion iban_suggestion_0 = SetUpIBANAndSuggestion(value_0, u"Nickname 0");
Suggestion iban_suggestion_1 =
@ -132,8 +130,8 @@ TEST_F(IBANManagerTest, ShowsIBANSuggestions_OnlyPrefixMatch) {
// Because all criteria are met to trigger returning to the handler,
// the handler should be triggered and this should return true.
EXPECT_TRUE(iban_manager_.OnGetSingleFieldSuggestions(
test_query_id, AutoselectFirstSuggestion(false), test_field,
autofill_client_, suggestions_handler_.GetWeakPtr(),
AutoselectFirstSuggestion(false), test_field, autofill_client_,
suggestions_handler_.GetWeakPtr(),
/*context=*/context));
}
@ -149,8 +147,8 @@ TEST_F(IBANManagerTest, DoesNotShowIBANsForOffTheRecord) {
// Simulate request for suggestions.
EXPECT_FALSE(iban_manager_.OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field,
autofill_client_, suggestions_handler_.GetWeakPtr(),
AutoselectFirstSuggestion(false), test_field, autofill_client_,
suggestions_handler_.GetWeakPtr(),
/*context=*/context));
}

@ -19,7 +19,6 @@ MerchantPromoCodeManager::MerchantPromoCodeManager() = default;
MerchantPromoCodeManager::~MerchantPromoCodeManager() = default;
bool MerchantPromoCodeManager::OnGetSingleFieldSuggestions(
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,

@ -36,7 +36,6 @@ class MerchantPromoCodeManager : public SingleFieldFormFiller,
// SingleFieldFormFiller overrides:
[[nodiscard]] bool OnGetSingleFieldSuggestions(
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,

@ -102,7 +102,6 @@ class MerchantPromoCodeManagerTest : public testing::Test {
TEST_F(MerchantPromoCodeManagerTest, ShowsPromoCodeSuggestions) {
base::HistogramTester histogram_tester;
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
AutoselectFirstSuggestion autoselect_first_suggestion(false);
std::string last_committed_origin_url = "https://www.example.com";
FormData form_data;
@ -135,14 +134,14 @@ TEST_F(MerchantPromoCodeManagerTest, ShowsPromoCodeSuggestions) {
// merchant site will be displayed instead of requesting Autocomplete
// suggestions.
EXPECT_TRUE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
test_query_id, autoselect_first_suggestion, test_field_, autofill_client_,
autoselect_first_suggestion, test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));
// Trigger offers suggestions popup again to be able to test that we do not
// log metrics twice for the same field.
EXPECT_TRUE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
test_query_id, autoselect_first_suggestion, test_field_, autofill_client_,
autoselect_first_suggestion, test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));
@ -152,7 +151,7 @@ TEST_F(MerchantPromoCodeManagerTest, ShowsPromoCodeSuggestions) {
test::CreateTestFormField(/*label=*/"", "Some Other Name", "SomePrefix",
"Some Type", &other_field);
EXPECT_TRUE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
test_query_id, autoselect_first_suggestion, other_field, autofill_client_,
autoselect_first_suggestion, other_field, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));
@ -185,8 +184,8 @@ TEST_F(MerchantPromoCodeManagerTest,
// Simulate request for suggestions.
EXPECT_FALSE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/SuggestionsContext()));
// Ensure that no metrics were logged.
@ -230,8 +229,8 @@ TEST_F(MerchantPromoCodeManagerTest,
// Simulate request for suggestions.
EXPECT_FALSE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));
// Ensure that no metrics were logged.
@ -273,8 +272,8 @@ TEST_F(MerchantPromoCodeManagerTest,
// Simulate request for suggestions.
EXPECT_FALSE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));
// Ensure that no metrics were logged.
@ -316,8 +315,8 @@ TEST_F(MerchantPromoCodeManagerTest, NoPromoCodeOffers) {
// Simulate request for suggestions.
EXPECT_FALSE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));
// Ensure that no metrics were logged.
@ -363,8 +362,8 @@ TEST_F(MerchantPromoCodeManagerTest, AutofillWalletImportDisabled) {
// Simulate request for suggestions.
EXPECT_FALSE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));
// Ensure that no metrics were logged.
@ -410,8 +409,8 @@ TEST_F(MerchantPromoCodeManagerTest, AutofillCreditCardDisabled) {
// Simulate request for suggestions.
EXPECT_FALSE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));
// Ensure that no metrics were logged.
@ -450,8 +449,7 @@ TEST_F(MerchantPromoCodeManagerTest, NoQueryHandler) {
// Simulate request for suggestions, but with an empty handler.
EXPECT_TRUE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_,
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
/*handler=*/nullptr,
/*context=*/context));
@ -502,8 +500,8 @@ TEST_F(MerchantPromoCodeManagerTest, PrefixMatched) {
// Simulate request for suggestions.
EXPECT_TRUE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));
// No metrics should be logged because no suggestions were shown.
@ -530,7 +528,6 @@ TEST_F(MerchantPromoCodeManagerTest,
// Set up the test.
base::HistogramTester histogram_tester;
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
std::u16string test_promo_code = u"test_promo_code";
AutoselectFirstSuggestion autoselect_first_suggestion(false);
std::string last_committed_origin_url = "https://www.example.com";
@ -554,7 +551,7 @@ TEST_F(MerchantPromoCodeManagerTest,
// Simulate showing the promo code offers suggestions popup.
EXPECT_TRUE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
test_query_id, autoselect_first_suggestion, test_field_, autofill_client_,
autoselect_first_suggestion, test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));
@ -573,7 +570,7 @@ TEST_F(MerchantPromoCodeManagerTest,
// Simulate showing the promo code offers suggestions popup.
EXPECT_TRUE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
test_query_id, autoselect_first_suggestion, test_field_, autofill_client_,
autoselect_first_suggestion, test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));
@ -596,7 +593,6 @@ TEST_F(MerchantPromoCodeManagerTest,
// Set up the test.
base::HistogramTester histogram_tester;
auto suggestions_handler = std::make_unique<MockSuggestionsHandler>();
int test_query_id = 2;
std::u16string test_promo_code = u"test_promo_code";
AutoselectFirstSuggestion autoselect_first_suggestion(false);
std::string last_committed_origin_url = "https://www.example.com";
@ -622,7 +618,7 @@ TEST_F(MerchantPromoCodeManagerTest,
// Simulate showing the promo code offers suggestions popup.
EXPECT_TRUE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
test_query_id, autoselect_first_suggestion, test_field_, autofill_client_,
autoselect_first_suggestion, test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));
@ -644,7 +640,7 @@ TEST_F(MerchantPromoCodeManagerTest,
// Simulate showing the promo code offers suggestions popup.
EXPECT_TRUE(merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
test_query_id, autoselect_first_suggestion, test_field_, autofill_client_,
autoselect_first_suggestion, test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(),
/*context=*/context));

@ -160,7 +160,7 @@ class AutofillMetricsBaseTest : public testing::Test {
void FillTestProfile(const FormData& form) {
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.profile_id = kTestProfileId}));
}

@ -144,8 +144,6 @@ using ExpectedUkmMetrics = std::vector<ExpectedUkmMetricsRecord>;
using AddressImportRequirements =
AutofillMetrics::AddressProfileImportRequirementMetric;
const int kDefaultPageID = 137;
FormSignature Collapse(FormSignature sig) {
return FormSignature(sig.value() % 1021);
}
@ -3356,7 +3354,7 @@ TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) {
// Simulate selecting a credit card suggestions.
{
base::UserActionTester user_action_tester;
external_delegate_->OnQuery(0, form, form.fields.front(), gfx::RectF());
external_delegate_->OnQuery(form, form.fields.front(), gfx::RectF());
external_delegate_->DidAcceptSuggestion(
test::CreateAutofillSuggestion(
@ -3381,7 +3379,7 @@ TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) {
// Simulate selecting a "Clear form" suggestion.
{
base::UserActionTester user_action_tester;
external_delegate_->OnQuery(0, form, form.fields.front(), gfx::RectF());
external_delegate_->OnQuery(form, form.fields.front(), gfx::RectF());
external_delegate_->DidAcceptSuggestion(
Suggestion(POPUP_ITEM_ID_CLEAR_FORM), 0);
@ -3402,7 +3400,7 @@ TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) {
// Simulate selecting a credit card suggestions.
{
base::UserActionTester user_action_tester;
external_delegate_->OnQuery(0, form, form.fields.front(), gfx::RectF());
external_delegate_->OnQuery(form, form.fields.front(), gfx::RectF());
external_delegate_->DidAcceptSuggestion(
test::CreateAutofillSuggestion(
@ -3418,7 +3416,7 @@ TEST_F(AutofillMetricsTest, CreditCardCheckoutFlowUserActions) {
{
base::UserActionTester user_action_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = kTestLocalCardId}));
EXPECT_EQ(1, user_action_tester.GetActionCount(
"Autofill_FilledCreditCardSuggestion"));
@ -3553,7 +3551,7 @@ TEST_F(AutofillMetricsTest, ProfileCheckoutFlowUserActions) {
// Simulate selecting a profile suggestions.
{
base::UserActionTester user_action_tester;
external_delegate_->OnQuery(0, form, form.fields.front(), gfx::RectF());
external_delegate_->OnQuery(form, form.fields.front(), gfx::RectF());
external_delegate_->DidAcceptSuggestion(
test::CreateAutofillSuggestion(
@ -3826,10 +3824,8 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardInteractedFormEvents) {
{
// Simulate activating the autofill popup for the credit card field twice.
base::HistogramTester histogram_tester;
autofill_manager().OnAskForValuesToFillTest(form, form.fields[0],
/*query_id=*/0);
autofill_manager().OnAskForValuesToFillTest(form, form.fields[0],
/*query_id=*/1);
autofill_manager().OnAskForValuesToFillTest(form, form.fields[0]);
autofill_manager().OnAskForValuesToFillTest(form, form.fields[0]);
histogram_tester.ExpectUniqueSample("Autofill.FormEvents.CreditCard",
FORM_EVENT_INTERACTED_ONCE, 1);
histogram_tester.ExpectUniqueSample(
@ -4109,7 +4105,7 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardSelectedFormEvents) {
// Simulating selecting a masked server card suggestion.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields[2],
mojom::RendererFormDataAction::kFill, form, form.fields[2],
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
EXPECT_THAT(
histogram_tester.GetAllSamples("Autofill.FormEvents.CreditCard"),
@ -4132,10 +4128,10 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardSelectedFormEvents) {
// Simulating selecting a masked server card multiple times.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields[2],
mojom::RendererFormDataAction::kFill, form, form.fields[2],
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields[2],
mojom::RendererFormDataAction::kFill, form, form.fields[2],
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
EXPECT_THAT(
histogram_tester.GetAllSamples("Autofill.FormEvents.CreditCard"),
@ -4159,8 +4155,8 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardSelectedFormEvents) {
// option based on the enrolled masked card.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction::kFill, kTestMaskedCardId, kDefaultPageID,
form, form.fields[2]);
mojom::RendererFormDataAction::kFill, kTestMaskedCardId, form,
form.fields[2]);
OnCreditCardFetchingSuccessful(u"6011000990139424",
/*is_virtual_card=*/true);
EXPECT_THAT(
@ -4184,13 +4180,13 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardSelectedFormEvents) {
// Simulating selecting a virtual card multiple times.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction::kFill, kTestMaskedCardId, kDefaultPageID,
form, form.fields[2]);
mojom::RendererFormDataAction::kFill, kTestMaskedCardId, form,
form.fields[2]);
OnCreditCardFetchingSuccessful(u"6011000990139424",
/*is_virtual_card=*/true);
autofill_manager().FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction::kFill, kTestMaskedCardId, kDefaultPageID,
form, form.fields[2]);
mojom::RendererFormDataAction::kFill, kTestMaskedCardId, form,
form.fields[2]);
OnCreditCardFetchingSuccessful(u"6011000990139424",
/*is_virtual_card=*/true);
EXPECT_THAT(
@ -4228,7 +4224,7 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardFilledFormEvents) {
// Simulating filling a local card suggestion.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = kTestLocalCardId}));
EXPECT_THAT(
histogram_tester.GetAllSamples("Autofill.FormEvents.CreditCard"),
@ -4250,8 +4246,8 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardFilledFormEvents) {
// based on the enrolled masked card.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction::kFill, kTestMaskedCardId, kDefaultPageID,
form, form.fields.front());
mojom::RendererFormDataAction::kFill, kTestMaskedCardId, form,
form.fields.front());
OnCreditCardFetchingSuccessful(u"6011000990139424",
/*is_virtual_card=*/true);
EXPECT_THAT(
@ -4274,7 +4270,7 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardFilledFormEvents) {
// Simulating filling a masked card server suggestion.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
OnCreditCardFetchingSuccessful(u"6011000990139424");
SubmitForm(form);
@ -4306,7 +4302,7 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardFilledFormEvents) {
// Simulating filling a full card server suggestion.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = kTestFullServerCardId}));
EXPECT_THAT(
histogram_tester.GetAllSamples("Autofill.FormEvents.CreditCard"),
@ -4327,10 +4323,10 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardFilledFormEvents) {
// Simulating filling multiple times.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = kTestLocalCardId}));
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = kTestLocalCardId}));
EXPECT_THAT(
histogram_tester.GetAllSamples("Autofill.FormEvents.CreditCard"),
@ -4366,7 +4362,7 @@ TEST_P(
// Simulate filling a unique local card suggestion.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = local_guid}));
EXPECT_THAT(
@ -4407,7 +4403,7 @@ TEST_P(AutofillMetricsIFrameTest,
base::HistogramTester histogram_tester;
// Local card with a duplicate server card present at index 0.
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = local_guid}));
EXPECT_THAT(
@ -4504,7 +4500,7 @@ TEST_F(AutofillMetricsTest, CreditCardUnmaskingPreflightCall) {
autofill_manager().DidShowSuggestions(/*is_new_popup=*/true, form,
form.fields[0]);
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
// Preflight call is made only if a masked server card is available and the
// user is eligible for FIDO authentication (except iOS).
@ -4529,7 +4525,7 @@ TEST_F(AutofillMetricsTest, CreditCardUnmaskingPreflightCall) {
autofill_manager().DidShowSuggestions(/*is_new_popup=*/true, form,
form.fields[0]);
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
// Preflight call is made only if a masked server card is available and the
// user is eligible for FIDO authentication (except iOS).
@ -4564,7 +4560,7 @@ TEST_F(AutofillMetricsTest, CreditCardGetRealPanDuration_ServerCard) {
// Simulating filling a masked card server suggestion.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
OnDidGetRealPan(AutofillClient::PaymentsRpcResult::kSuccess,
"6011000990139424");
@ -4587,7 +4583,7 @@ TEST_F(AutofillMetricsTest, CreditCardGetRealPanDuration_ServerCard) {
// Simulating filling a masked card server suggestion.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
OnDidGetRealPan(AutofillClient::PaymentsRpcResult::kPermanentFailure,
std::string());
@ -4623,7 +4619,7 @@ TEST_F(AutofillMetricsTest, CreditCardGetRealPanDuration_BadServerResponse) {
// Simulating filling a masked card server suggestion.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
OnDidGetRealPanWithNonHttpOkResponse();
histogram_tester.ExpectTotalCount(
@ -4900,7 +4896,7 @@ TEST_P(AutofillMetricsIFrameTest,
form.fields[0]);
autofill_manager().OnAskForValuesToFillTest(form, form.fields[0]);
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kTestLocalCardId}));
SubmitForm(form);
@ -5079,7 +5075,7 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardSubmittedFormEvents) {
base::HistogramTester histogram_tester;
autofill_manager().OnAskForValuesToFillTest(form, form.fields.back());
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = kTestLocalCardId}));
SubmitForm(form);
EXPECT_THAT(
@ -5120,8 +5116,8 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardSubmittedFormEvents) {
base::HistogramTester histogram_tester;
autofill_manager().OnAskForValuesToFillTest(form, form.fields.back());
autofill_manager().FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction::kFill, kTestMaskedCardId, kDefaultPageID,
form, form.fields.front());
mojom::RendererFormDataAction::kFill, kTestMaskedCardId, form,
form.fields.front());
OnCreditCardFetchingSuccessful(u"6011000990139424",
/*is_virtual_card=*/true);
SubmitForm(form);
@ -5164,7 +5160,7 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardSubmittedFormEvents) {
base::HistogramTester histogram_tester;
autofill_manager().OnAskForValuesToFillTest(form, form.fields.back());
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = kTestFullServerCardId}));
SubmitForm(form);
@ -5204,7 +5200,7 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardSubmittedFormEvents) {
// Simulating submission with a masked card server suggestion.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
OnCreditCardFetchingSuccessful(u"6011000990139424");
SubmitForm(form);
@ -5449,7 +5445,7 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardWillSubmitFormEvents) {
base::HistogramTester histogram_tester;
autofill_manager().OnAskForValuesToFillTest(form, form.fields[0]);
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = kTestLocalCardId}));
SubmitForm(form);
EXPECT_THAT(
@ -5473,8 +5469,8 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardWillSubmitFormEvents) {
base::HistogramTester histogram_tester;
autofill_manager().OnAskForValuesToFillTest(form, form.fields[0]);
autofill_manager().FillOrPreviewVirtualCardInformation(
mojom::RendererFormDataAction::kFill, kTestMaskedCardId, kDefaultPageID,
form, form.fields.front());
mojom::RendererFormDataAction::kFill, kTestMaskedCardId, form,
form.fields.front());
OnCreditCardFetchingSuccessful(u"6011000990139424",
/*is_virtual_card=*/true);
SubmitForm(form);
@ -5501,7 +5497,7 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardWillSubmitFormEvents) {
autofill_manager().OnAskForValuesToFillTest(form, form.fields[0]);
// Full server card.
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = kTestFullServerCardId}));
SubmitForm(form);
EXPECT_THAT(
@ -5523,7 +5519,7 @@ TEST_P(AutofillMetricsIFrameTest, CreditCardWillSubmitFormEvents) {
// Simulating submission with a masked card server suggestion.
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
OnCreditCardFetchingSuccessful(u"6011000990139424");
EXPECT_THAT(
@ -5663,7 +5659,7 @@ TEST_F(AutofillMetricsTest, LogServerOfferFormEvents) {
autofill_manager().DidShowSuggestions(/*is_new_popup=*/true, form,
form.fields.back());
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = kTestLocalCardId}));
EXPECT_THAT(
histogram_tester.GetAllSamples("Autofill.FormEvents.CreditCard"),
@ -5710,7 +5706,7 @@ TEST_F(AutofillMetricsTest, LogServerOfferFormEvents) {
form.fields.back());
// Select the masked server card with the linked offer.
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kMaskedServerCardIds[0]}));
OnDidGetRealPan(AutofillClient::PaymentsRpcResult::kSuccess,
"6011000990139424");
@ -5757,7 +5753,7 @@ TEST_F(AutofillMetricsTest, LogServerOfferFormEvents) {
// Select another card, and still log to offer
// sub-histogram because user has another masked server card with offer.
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
OnDidGetRealPan(AutofillClient::PaymentsRpcResult::kSuccess,
"6011000990139424");
@ -5810,7 +5806,7 @@ TEST_F(AutofillMetricsTest, LogServerOfferFormEvents) {
// Select the card with linked offer, though metrics should not record it
// since the offer is expired.
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kMaskedServerCardIds[1]}));
OnDidGetRealPan(AutofillClient::PaymentsRpcResult::kSuccess,
"6011000990139424");
@ -5875,7 +5871,7 @@ TEST_F(AutofillMetricsTest, LogServerOfferFormEvents) {
form.fields.back());
// Select the masked server card with the linked offer.
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kMaskedServerCardIds[2]}));
OnDidGetRealPan(AutofillClient::PaymentsRpcResult::kSuccess,
"6011000990139424");
@ -5928,7 +5924,7 @@ TEST_F(AutofillMetricsTest, LogServerOfferFormEvents) {
// Select the masked server card with the linked offer, but fail the CVC
// check.
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kMaskedServerCardIds[2]}));
OnDidGetRealPan(AutofillClient::PaymentsRpcResult::kPermanentFailure,
std::string());
@ -5977,7 +5973,7 @@ TEST_F(AutofillMetricsTest, LogServerOfferFormEvents) {
autofill_manager().DidShowSuggestions(/*is_new_popup=*/true, form,
form.fields.back());
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kMaskedServerCardIds[2]}));
OnDidGetRealPan(AutofillClient::PaymentsRpcResult::kSuccess,
"6011000990139424");
@ -5987,7 +5983,7 @@ TEST_F(AutofillMetricsTest, LogServerOfferFormEvents) {
autofill_manager().DidShowSuggestions(/*is_new_popup=*/true, form,
form.fields.back());
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.back(),
mojom::RendererFormDataAction::kFill, form, form.fields.back(),
MakeFrontendId({.credit_card_id = kTestLocalCardId}));
SubmitForm(form);
EXPECT_THAT(
@ -6093,7 +6089,7 @@ TEST_P(AutofillMetricsTestForCardMetadata, LogCardMetadataMetrics) {
form.fields.back());
test_clock.SetNowTicks(now + base::Seconds(2));
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = kTestMaskedCardId}));
std::string histogram_prefix =
@ -6212,10 +6208,8 @@ TEST_F(AutofillMetricsTest, AddressInteractedFormEvents) {
{
// Simulate activating the autofill popup for the street field twice.
base::HistogramTester histogram_tester;
autofill_manager().OnAskForValuesToFillTest(form, form.fields[2],
/*query_id=*/0);
autofill_manager().OnAskForValuesToFillTest(form, form.fields[2],
/*query_id=*/1);
autofill_manager().OnAskForValuesToFillTest(form, form.fields[2]);
autofill_manager().OnAskForValuesToFillTest(form, form.fields[2]);
histogram_tester.ExpectUniqueSample("Autofill.FormEvents.Address",
FORM_EVENT_INTERACTED_ONCE, 1);
// Check if FormEvent UKM is logged properly
@ -7545,7 +7539,7 @@ TEST_F(AutofillMetricsTest, UserHappinessFormInteraction_CreditCardForm) {
SCOPED_TRACE("Edit autofilled field");
base::HistogramTester histogram_tester;
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, 0, form, form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
MakeFrontendId({.credit_card_id = kTestLocalCardId}));
SimulateUserChangedTextField(form, form.fields.front());
// Simulate a second keystroke; make sure we don't log the metric twice.
@ -9546,13 +9540,11 @@ TEST_P(AutofillMetricsFunnelTest, LogFunnelMetrics) {
}
// Simulate filling the form.
if (user_accepted_suggestion) {
if (user_accepted_suggestion)
FillTestProfile(form);
}
if (user_submitted_form) {
if (user_submitted_form)
SubmitForm(form);
}
FormInteractionsFlowId flow_id =
autofill_manager().address_form_interactions_flow_id_for_test();
@ -10220,7 +10212,7 @@ class AutofillMetricsCrossFrameFormTest : public AutofillMetricsTest {
// mimic its effect on |form_|.
void FillForm(const FormFieldData& triggering_field) {
autofill_manager().FillCreditCardForm(
0, form_, triggering_field, fill_data().credit_card, fill_data().cvc);
form_, triggering_field, fill_data().credit_card, fill_data().cvc);
}
// Sets the field values of |form_| according to the parameters.
@ -10548,8 +10540,7 @@ TEST_P(AutofillMetricsTestForLaxLocalHeuristics, TestHistogramReporting) {
/*has_autofill_suggestions=*/true, form, form.fields[0]);
// Simulate filling the form.
autofill_manager().FillOrPreviewForm(
mojom::RendererFormDataAction::kFill, /*query_id=*/0, form,
form.fields.front(),
mojom::RendererFormDataAction::kFill, form, form.fields.front(),
is_cc_form ? MakeFrontendId({.credit_card_id = kTestLocalCardId})
: MakeFrontendId({.profile_id = kTestProfileId}));

@ -19,8 +19,7 @@ class MockAutocompleteHistoryManager : public AutocompleteHistoryManager {
MOCK_METHOD(
bool,
OnGetSingleFieldSuggestions,
(int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
(AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,
base::WeakPtr<AutocompleteHistoryManager::SuggestionsHandler> handler,

@ -20,8 +20,7 @@ class MockIBANManager : public IBANManager {
MOCK_METHOD(bool,
OnGetSingleFieldSuggestions,
(int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
(AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,
base::WeakPtr<IBANManager::SuggestionsHandler> handler,

@ -19,8 +19,7 @@ class MockMerchantPromoCodeManager : public MerchantPromoCodeManager {
MOCK_METHOD(
bool,
OnGetSingleFieldSuggestions,
(int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
(AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,
base::WeakPtr<MerchantPromoCodeManager::SuggestionsHandler> handler,

@ -29,8 +29,7 @@ class MockSingleFieldFormFillRouter : public SingleFieldFormFillRouter {
(override));
MOCK_METHOD(bool,
OnGetSingleFieldSuggestions,
(int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
(AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,
base::WeakPtr<SingleFieldFormFiller::SuggestionsHandler> handler,

@ -62,7 +62,6 @@ void SingleFieldFormFillRouter::OnWillSubmitForm(
}
bool SingleFieldFormFillRouter::OnGetSingleFieldSuggestions(
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,
@ -71,18 +70,16 @@ bool SingleFieldFormFillRouter::OnGetSingleFieldSuggestions(
// Retrieving suggestions for a new field; select the appropriate filler.
if (merchant_promo_code_manager_ &&
merchant_promo_code_manager_->OnGetSingleFieldSuggestions(
query_id, autoselect_first_suggestion, field, client, handler,
context)) {
autoselect_first_suggestion, field, client, handler, context)) {
return true;
}
if (iban_manager_ && iban_manager_->OnGetSingleFieldSuggestions(
query_id, autoselect_first_suggestion, field, client,
handler, context)) {
if (iban_manager_ &&
iban_manager_->OnGetSingleFieldSuggestions(
autoselect_first_suggestion, field, client, handler, context)) {
return true;
}
if (autocomplete_history_manager_->OnGetSingleFieldSuggestions(
query_id, autoselect_first_suggestion, field, client, handler,
context)) {
autoselect_first_suggestion, field, client, handler, context)) {
return true;
}
return false;

@ -46,7 +46,6 @@ class SingleFieldFormFillRouter : public SingleFieldFormFiller {
// SingleFieldFormFiller overrides:
[[nodiscard]] bool OnGetSingleFieldSuggestions(
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,

@ -126,7 +126,7 @@ TEST_F(SingleFieldFormFillRouterTest,
EXPECT_EQ(test_field_.should_autocomplete,
single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
/*context=*/SuggestionsContext()));
}
@ -258,9 +258,8 @@ TEST_F(SingleFieldFormFillRouterTest,
.WillOnce(testing::Return(true));
EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
}
}
@ -286,9 +285,8 @@ TEST_F(SingleFieldFormFillRouterTest, MerchantPromoCodeManagerNotPresent) {
// autocomplete. SingleFieldFormFillRouter::OnGetSingleFieldSuggestions()
// should return true.
EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
}
// Ensure that the router routes to AutocompleteHistoryManager for this
@ -317,9 +315,8 @@ TEST_F(SingleFieldFormFillRouterTest, MerchantPromoCodeManagerReturnedFalse) {
// autocomplete. SingleFieldFormFillRouter::OnGetSingleFieldSuggestions()
// should return true.
EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
}
// Ensure that the router routes to MerchantPromoCodeManager for this
@ -365,9 +362,8 @@ TEST_F(
// All SingleFieldFormFillers returned false, so we should return false as we
// did not attempt to display any single field form fill suggestions.
EXPECT_FALSE(single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
}
// Ensure that the router routes to AutocompleteHistoryManager for this
@ -391,9 +387,8 @@ TEST_F(SingleFieldFormFillRouterTest, IBANManagerNotPresent) {
// autocomplete. SingleFieldFormFillRouter::OnGetSingleFieldSuggestions()
// should return true.
EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
}
// Ensure that the router routes to AutocompleteHistoryManager for this
@ -421,9 +416,8 @@ TEST_F(SingleFieldFormFillRouterTest, IBANManagerReturnedFalse) {
// autocomplete. SingleFieldFormFillRouter::OnGetSingleFieldSuggestions()
// should return true.
EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(),
SuggestionsContext()));
AutoselectFirstSuggestion(false), test_field_, autofill_client_,
suggestions_handler->GetWeakPtr(), SuggestionsContext()));
}
// Ensure that the router routes to IBANManager for this

@ -40,7 +40,6 @@ class SingleFieldFormFiller {
// Gets suggestions for a given field. In the case of Autocomplete, this is
// through a DB query, though it could be different for other fill types.
// `query_id` is given by the client as context.
// `client` is used for functionality such as checking if autocomplete is
// enabled, or checking if the URL we navigated to is blocklisted for the
// specific single field form filler that we are trying to retrieve
@ -56,7 +55,6 @@ class SingleFieldFormFiller {
// SingleFieldFormFillers to offer filling the field. The callback can happen
// synchronously even before OnGetSingleFieldSuggestions returns true.
[[nodiscard]] virtual bool OnGetSingleFieldSuggestions(
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field,
const AutofillClient& client,
@ -101,10 +99,6 @@ class SingleFieldFormFiller {
QueryHandler(const QueryHandler& original);
~QueryHandler();
// Query ID living in the handler's scope, which is NOT the same as the
// database query ID. This ID is unique per frame, but not per profile.
int client_query_id_;
// The queried field ID.
FieldGlobalId field_id_;

@ -62,7 +62,6 @@ bool TestAutofillDriver::RendererIsAvailable() {
}
std::vector<FieldGlobalId> TestAutofillDriver::FillOrPreviewForm(
int query_id,
mojom::RendererFormDataAction action,
const FormData& form_data,
const url::Origin& triggered_origin,

@ -54,7 +54,6 @@ class TestAutofillDriver : public ContentAutofillDriver {
// The return value contains the members (field, type) of `field_type_map` for
// which `field_type_filter_.Run(triggered_origin, field, type)` is true.
std::vector<FieldGlobalId> FillOrPreviewForm(
int query_id,
mojom::RendererFormDataAction action,
const FormData& data,
const url::Origin& triggered_origin,

@ -32,8 +32,7 @@ void TestAutofillExternalDelegate::OnPopupHidden() {
run_loop_.Quit();
}
void TestAutofillExternalDelegate::OnQuery(int field_id,
const FormData& form,
void TestAutofillExternalDelegate::OnQuery(const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounds) {
on_query_seen_ = true;
@ -42,7 +41,7 @@ void TestAutofillExternalDelegate::OnQuery(int field_id,
// If necessary, call the superclass's OnQuery to set up its other fields
// properly.
if (call_parent_methods_)
AutofillExternalDelegate::OnQuery(field_id, form, field, bounds);
AutofillExternalDelegate::OnQuery(form, field, bounds);
}
void TestAutofillExternalDelegate::OnSuggestionsReturned(

@ -28,8 +28,7 @@ class TestAutofillExternalDelegate : public AutofillExternalDelegate {
// AutofillExternalDelegate overrides.
void OnPopupShown() override;
void OnPopupHidden() override;
void OnQuery(int query_id,
const FormData& form,
void OnQuery(const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounds) override;
void OnSuggestionsReturned(

@ -83,12 +83,11 @@ void TestBrowserAutofillManager::OnAskForValuesToFill(
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) {
TestAutofillManagerWaiter waiter(*this,
{&Observer::OnAfterAskForValuesToFill});
AutofillManager::OnAskForValuesToFill(form, field, bounding_box, query_id,
AutofillManager::OnAskForValuesToFill(form, field, bounding_box,
autoselect_first_suggestion,
form_element_was_clicked);
ASSERT_TRUE(waiter.Wait());
@ -257,15 +256,14 @@ const std::string TestBrowserAutofillManager::GetSubmittedFormSignature() {
void TestBrowserAutofillManager::OnAskForValuesToFillTest(
const FormData& form,
const FormFieldData& field,
int query_id,
const gfx::RectF& bounding_box,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) {
TestAutofillManagerWaiter waiter(
*this, {&AutofillManager::Observer::OnAfterAskForValuesToFill});
BrowserAutofillManager::OnAskForValuesToFill(
form, field, bounding_box, query_id, autoselect_first_suggestion,
form_element_was_clicked);
BrowserAutofillManager::OnAskForValuesToFill(form, field, bounding_box,
autoselect_first_suggestion,
form_element_was_clicked);
ASSERT_TRUE(waiter.Wait());
}

@ -55,7 +55,6 @@ class TestBrowserAutofillManager : public BrowserAutofillManager {
const FormData& form,
const FormFieldData& field,
const gfx::RectF& bounding_box,
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked) override;
void OnJavaScriptChangedAutofilledValue(
@ -117,7 +116,6 @@ class TestBrowserAutofillManager : public BrowserAutofillManager {
void OnAskForValuesToFillTest(
const FormData& form,
const FormFieldData& field,
int query_id = 0,
const gfx::RectF& bounding_box = {},
AutoselectFirstSuggestion autoselect_first_suggestion =
AutoselectFirstSuggestion(false),

@ -25,13 +25,11 @@ TouchToFillDelegateImpl::~TouchToFillDelegateImpl() {
HideTouchToFill();
}
bool TouchToFillDelegateImpl::TryToShowTouchToFill(int query_id,
const FormData& form,
bool TouchToFillDelegateImpl::TryToShowTouchToFill(const FormData& form,
const FormFieldData& field) {
// TODO(crbug.com/1386143): store only FormGlobalId and FieldGlobalId instead
// to avoid that FormData and FormFieldData may become obsolete during the
// bottomsheet being open.
query_id_ = query_id;
query_form_ = form;
query_field_ = field;
// Trigger only for a credit card field/form.
@ -113,7 +111,7 @@ void TouchToFillDelegateImpl::ScanCreditCard() {
void TouchToFillDelegateImpl::OnCreditCardScanned(const CreditCard& card) {
HideTouchToFill();
manager_->FillCreditCardFormImpl(query_form_, query_field_, card,
std::u16string(), query_id_);
std::u16string());
}
void TouchToFillDelegateImpl::ShowCreditCardSettings() {
@ -127,8 +125,7 @@ void TouchToFillDelegateImpl::SuggestionSelected(std::string unique_id) {
DCHECK(pdm);
CreditCard* card = pdm->GetCreditCardByGUID(unique_id);
manager_->FillOrPreviewCreditCardForm(mojom::RendererFormDataAction::kFill,
query_id_, query_form_, query_field_,
card);
query_form_, query_field_, card);
}
base::WeakPtr<TouchToFillDelegateImpl> TouchToFillDelegateImpl::GetWeakPtr() {

@ -37,8 +37,7 @@ class TouchToFillDelegateImpl : public TouchToFillDelegate {
// Checks whether TTF is eligible for the given web form data. On success
// triggers the corresponding surface and returns |true|.
virtual bool TryToShowTouchToFill(int query_id,
const FormData& form,
virtual bool TryToShowTouchToFill(const FormData& form,
const FormFieldData& field);
// Returns whether the TTF surface is currently being shown.
@ -70,7 +69,6 @@ class TouchToFillDelegateImpl : public TouchToFillDelegate {
TouchToFillState ttf_credit_card_state_ = TouchToFillState::kShouldShow;
const raw_ptr<BrowserAutofillManager> manager_;
int query_id_;
FormData query_form_;
FormFieldData query_field_;

@ -24,9 +24,6 @@ namespace autofill {
namespace {
// A constant value to use as a suggestions query ID.
const int kQueryId = 1;
class MockAutofillDriver : public TestAutofillDriver {
public:
MockAutofillDriver() = default;
@ -97,13 +94,11 @@ class MockBrowserAutofillManager : public TestBrowserAutofillManager {
(const FormData& form,
const FormFieldData& field,
const CreditCard& credit_card,
const std::u16string& cvc,
int query_id),
const std::u16string& cvc),
(override));
MOCK_METHOD(void,
FillOrPreviewCreditCardForm,
(mojom::RendererFormDataAction action,
int query_id,
const FormData& form,
const FormFieldData& field,
const CreditCard* credit_card));
@ -149,8 +144,8 @@ class TouchToFillDelegateImplUnitTest : public testing::Test {
HideAutofillPopup(
PopupHidingReason::kOverlappingWithTouchToFillSurface))
.Times(expected_success ? 1 : 0);
EXPECT_EQ(expected_success, touch_to_fill_delegate_->TryToShowTouchToFill(
kQueryId, form_, field_));
EXPECT_EQ(expected_success,
touch_to_fill_delegate_->TryToShowTouchToFill(form_, field_));
EXPECT_EQ(expected_success,
touch_to_fill_delegate_->IsShowingTouchToFill());
}
@ -219,8 +214,7 @@ TEST_F(TouchToFillDelegateImplUnitTest,
autofill_client_,
HideAutofillPopup(PopupHidingReason::kOverlappingWithTouchToFillSurface))
.Times(0);
EXPECT_FALSE(
touch_to_fill_delegate_->TryToShowTouchToFill(kQueryId, form_, field_));
EXPECT_FALSE(touch_to_fill_delegate_->TryToShowTouchToFill(form_, field_));
EXPECT_TRUE(touch_to_fill_delegate_->IsShowingTouchToFill());
}

@ -63,14 +63,6 @@ constexpr size_t kMaxTypeMatchingCalls = 5000;
// upload the form to and request predictions from the Autofill servers.
constexpr size_t kRequiredFieldsForFormsWithOnlyPasswordFields = 2;
// Special query id used between the browser and the renderer when the action
// is initiated from the browser.
constexpr int kNoQueryId = -1;
// Special query id used between the browser and the renderer when the action
// is initiated from the browser.
constexpr int kCrossFrameFill = -2;
// Options bitmask values for AutofillHostMsg_ShowPasswordSuggestions IPC
enum ShowPasswordSuggestionsOptions {
SHOW_ALL = 1 << 0 /* show all credentials, not just ones matching username */,

@ -180,9 +180,6 @@ void GetFormField(autofill::FormFieldData* field,
// ID of the last Autofill query made. Used to discard outdated suggestions.
autofill::FieldGlobalId _lastQueriedFieldID;
// ID of the last Autofill query made. Used to discard outdated suggestions.
int _lastQueryID;
}
@end
@ -212,7 +209,6 @@ void GetFormField(autofill::FormFieldData* field,
UniqueIDDataTabHelper* uniqueIDDataTabHelper =
UniqueIDDataTabHelper::FromWebState(_webState);
_fieldDataManager = uniqueIDDataTabHelper->GetFieldDataManager();
_lastQueryID = 0;
}
return self;
}
@ -338,8 +334,7 @@ void GetFormField(autofill::FormFieldData* field,
// -showAutofillPopup:popupDelegate:.
_lastQueriedFieldID = field.global_id();
autofillManager->OnAskForValuesToFill(
form, field, gfx::RectF(), ++_lastQueryID,
autofill::AutoselectFirstSuggestion(false),
form, field, gfx::RectF(), autofill::AutoselectFirstSuggestion(false),
autofill::FormElementWasClicked(false));
}

@ -49,7 +49,6 @@ class AutofillDriverIOS : public AutofillDriver {
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
bool RendererIsAvailable() override;
std::vector<FieldGlobalId> FillOrPreviewForm(
int query_id,
mojom::RendererFormDataAction action,
const FormData& data,
const url::Origin& triggered_origin,

@ -103,7 +103,6 @@ bool AutofillDriverIOS::RendererIsAvailable() {
}
std::vector<FieldGlobalId> AutofillDriverIOS::FillOrPreviewForm(
int query_id,
mojom::RendererFormDataAction action,
const FormData& data,
const url::Origin& triggered_origin,

@ -20,7 +20,6 @@ void StubAutofillProvider::OnAskForValuesToFill(
const autofill::FormData& form,
const autofill::FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
autofill::AutoselectFirstSuggestion /*unused_autoselect_first_suggestion*/,
autofill::FormElementWasClicked /*unused_form_element_was_clicked*/) {
on_received_form_data_.Run(form);

@ -33,7 +33,6 @@ class StubAutofillProvider : public autofill::TestAutofillProvider {
const autofill::FormData& form,
const autofill::FormFieldData& field,
const gfx::RectF& bounding_box,
int32_t query_id,
autofill::
AutoselectFirstSuggestion /*unused_autoselect_first_suggestion*/,
autofill::FormElementWasClicked /*unused_form_element_was_clicked*/)