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, ""); test::SetCreditCardInfo(&card, kNameFull, kNumber, kExpMonth, kExpYear, "");
auto* manager = TestAutofillManager::GetForRenderFrameHost(rfh); auto* manager = TestAutofillManager::GetForRenderFrameHost(rfh);
manager->FillCreditCardFormImpl(form, triggered_field, card, manager->FillCreditCardFormImpl(form, triggered_field, card,
base::ASCIIToUTF16(base::StringPiece(kCvc)), base::ASCIIToUTF16(base::StringPiece(kCvc)));
kCrossFrameFill);
} }
// Clicks the first input, textarea, or select in `rfh`. // 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(), test::CreateTestFormField(/*label=*/"", input_name.c_str(), prefix.c_str(),
"input", &field); "input", &field);
EXPECT_TRUE(autocomplete_history_manager()->OnGetSingleFieldSuggestions( EXPECT_TRUE(autocomplete_history_manager()->OnGetSingleFieldSuggestions(
1, AutoselectFirstSuggestion(false), field, *autofill_client, AutoselectFirstSuggestion(false), field, *autofill_client,
handler.GetWeakPtr(), SuggestionsContext())); handler.GetWeakPtr(), SuggestionsContext()));
// Make sure the DB task gets executed. // Make sure the DB task gets executed.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -15,10 +15,8 @@ interface AutofillAgent {
TriggerReparse(); TriggerReparse();
// Instructs the renderer to fill or preview the active form with the given // Instructs the renderer to fill or preview the active form with the given
// form data. Refer to AutofillDriver.AskForValuesToFill for comments // form data.
// about the |query_id|. FillOrPreviewForm(FormData form,
FillOrPreviewForm(int32 query_id,
FormData form,
RendererFormDataAction action); RendererFormDataAction action);
// Sends the heuristic and server field type predictions to the renderer. // 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. // Queries the browser for Autofill suggestions for a form input field.
// For autofill this means asking the user which values to fill. // 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 // |autoselect_first_suggestion| indicates whether a first suggestion gets
// auto selected. |form_element_was_clicked| indicates the user tapped an // auto selected. |form_element_was_clicked| indicates the user tapped an
// input element. When this happens, surfaces like Touch To Fill and Fast // input element. When this happens, surfaces like Touch To Fill and Fast
@ -60,7 +59,6 @@ interface AutofillDriver {
AskForValuesToFill(FormData form, AskForValuesToFill(FormData form,
FormFieldData field, FormFieldData field,
gfx.mojom.RectF bounding_box, gfx.mojom.RectF bounding_box,
int32 query_id,
AutoselectFirstSuggestion autoselect_first_suggestion, AutoselectFirstSuggestion autoselect_first_suggestion,
FormElementWasClicked form_element_was_clicked); FormElementWasClicked form_element_was_clicked);

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

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

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

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

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

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

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

@ -71,13 +71,14 @@ class AutofillExternalDelegate : public AutofillPopupDelegate {
void RegisterDeletionCallback(base::OnceClosure deletion_callback) override; void RegisterDeletionCallback(base::OnceClosure deletion_callback) override;
// Records and associates a query_id with web form data. Called // Called when the renderer posts an Autofill query to the browser. |bounds|
// 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 // 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 // has disabled Autocomplete because they have their own popup, and showing
// our popup on to of theirs would be a poor user experience. // 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 FormFieldData& field,
const gfx::RectF& element_bounds); const gfx::RectF& element_bounds);
@ -157,10 +158,6 @@ class AutofillExternalDelegate : public AutofillPopupDelegate {
// outlive this object. // outlive this object.
const raw_ptr<AutofillDriver> driver_; // weak 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. // The current form and field selected by Autofill.
FormData query_form_; FormData query_form_;
FormFieldData query_field_; FormFieldData query_field_;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -126,7 +126,7 @@ TEST_F(SingleFieldFormFillRouterTest,
EXPECT_EQ(test_field_.should_autocomplete, EXPECT_EQ(test_field_.should_autocomplete,
single_field_form_fill_router_->OnGetSingleFieldSuggestions( single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_, AutoselectFirstSuggestion(false), test_field_,
autofill_client_, suggestions_handler->GetWeakPtr(), autofill_client_, suggestions_handler->GetWeakPtr(),
/*context=*/SuggestionsContext())); /*context=*/SuggestionsContext()));
} }
@ -258,9 +258,8 @@ TEST_F(SingleFieldFormFillRouterTest,
.WillOnce(testing::Return(true)); .WillOnce(testing::Return(true));
EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions( EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_, AutoselectFirstSuggestion(false), test_field_, autofill_client_,
autofill_client_, suggestions_handler->GetWeakPtr(), suggestions_handler->GetWeakPtr(), SuggestionsContext()));
SuggestionsContext()));
} }
} }
@ -286,9 +285,8 @@ TEST_F(SingleFieldFormFillRouterTest, MerchantPromoCodeManagerNotPresent) {
// autocomplete. SingleFieldFormFillRouter::OnGetSingleFieldSuggestions() // autocomplete. SingleFieldFormFillRouter::OnGetSingleFieldSuggestions()
// should return true. // should return true.
EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions( EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_, AutoselectFirstSuggestion(false), test_field_, autofill_client_,
autofill_client_, suggestions_handler->GetWeakPtr(), suggestions_handler->GetWeakPtr(), SuggestionsContext()));
SuggestionsContext()));
} }
// Ensure that the router routes to AutocompleteHistoryManager for this // Ensure that the router routes to AutocompleteHistoryManager for this
@ -317,9 +315,8 @@ TEST_F(SingleFieldFormFillRouterTest, MerchantPromoCodeManagerReturnedFalse) {
// autocomplete. SingleFieldFormFillRouter::OnGetSingleFieldSuggestions() // autocomplete. SingleFieldFormFillRouter::OnGetSingleFieldSuggestions()
// should return true. // should return true.
EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions( EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_, AutoselectFirstSuggestion(false), test_field_, autofill_client_,
autofill_client_, suggestions_handler->GetWeakPtr(), suggestions_handler->GetWeakPtr(), SuggestionsContext()));
SuggestionsContext()));
} }
// Ensure that the router routes to MerchantPromoCodeManager for this // 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 // All SingleFieldFormFillers returned false, so we should return false as we
// did not attempt to display any single field form fill suggestions. // did not attempt to display any single field form fill suggestions.
EXPECT_FALSE(single_field_form_fill_router_->OnGetSingleFieldSuggestions( EXPECT_FALSE(single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_, AutoselectFirstSuggestion(false), test_field_, autofill_client_,
autofill_client_, suggestions_handler->GetWeakPtr(), suggestions_handler->GetWeakPtr(), SuggestionsContext()));
SuggestionsContext()));
} }
// Ensure that the router routes to AutocompleteHistoryManager for this // Ensure that the router routes to AutocompleteHistoryManager for this
@ -391,9 +387,8 @@ TEST_F(SingleFieldFormFillRouterTest, IBANManagerNotPresent) {
// autocomplete. SingleFieldFormFillRouter::OnGetSingleFieldSuggestions() // autocomplete. SingleFieldFormFillRouter::OnGetSingleFieldSuggestions()
// should return true. // should return true.
EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions( EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_, AutoselectFirstSuggestion(false), test_field_, autofill_client_,
autofill_client_, suggestions_handler->GetWeakPtr(), suggestions_handler->GetWeakPtr(), SuggestionsContext()));
SuggestionsContext()));
} }
// Ensure that the router routes to AutocompleteHistoryManager for this // Ensure that the router routes to AutocompleteHistoryManager for this
@ -421,9 +416,8 @@ TEST_F(SingleFieldFormFillRouterTest, IBANManagerReturnedFalse) {
// autocomplete. SingleFieldFormFillRouter::OnGetSingleFieldSuggestions() // autocomplete. SingleFieldFormFillRouter::OnGetSingleFieldSuggestions()
// should return true. // should return true.
EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions( EXPECT_TRUE(single_field_form_fill_router_->OnGetSingleFieldSuggestions(
/*query_id=*/2, AutoselectFirstSuggestion(false), test_field_, AutoselectFirstSuggestion(false), test_field_, autofill_client_,
autofill_client_, suggestions_handler->GetWeakPtr(), suggestions_handler->GetWeakPtr(), SuggestionsContext()));
SuggestionsContext()));
} }
// Ensure that the router routes to IBANManager for this // 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 // 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. // 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 // `client` is used for functionality such as checking if autocomplete is
// enabled, or checking if the URL we navigated to is blocklisted for the // enabled, or checking if the URL we navigated to is blocklisted for the
// specific single field form filler that we are trying to retrieve // 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 // SingleFieldFormFillers to offer filling the field. The callback can happen
// synchronously even before OnGetSingleFieldSuggestions returns true. // synchronously even before OnGetSingleFieldSuggestions returns true.
[[nodiscard]] virtual bool OnGetSingleFieldSuggestions( [[nodiscard]] virtual bool OnGetSingleFieldSuggestions(
int query_id,
AutoselectFirstSuggestion autoselect_first_suggestion, AutoselectFirstSuggestion autoselect_first_suggestion,
const FormFieldData& field, const FormFieldData& field,
const AutofillClient& client, const AutofillClient& client,
@ -101,10 +99,6 @@ class SingleFieldFormFiller {
QueryHandler(const QueryHandler& original); QueryHandler(const QueryHandler& original);
~QueryHandler(); ~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. // The queried field ID.
FieldGlobalId field_id_; FieldGlobalId field_id_;

@ -62,7 +62,6 @@ bool TestAutofillDriver::RendererIsAvailable() {
} }
std::vector<FieldGlobalId> TestAutofillDriver::FillOrPreviewForm( std::vector<FieldGlobalId> TestAutofillDriver::FillOrPreviewForm(
int query_id,
mojom::RendererFormDataAction action, mojom::RendererFormDataAction action,
const FormData& form_data, const FormData& form_data,
const url::Origin& triggered_origin, 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 // The return value contains the members (field, type) of `field_type_map` for
// which `field_type_filter_.Run(triggered_origin, field, type)` is true. // which `field_type_filter_.Run(triggered_origin, field, type)` is true.
std::vector<FieldGlobalId> FillOrPreviewForm( std::vector<FieldGlobalId> FillOrPreviewForm(
int query_id,
mojom::RendererFormDataAction action, mojom::RendererFormDataAction action,
const FormData& data, const FormData& data,
const url::Origin& triggered_origin, const url::Origin& triggered_origin,

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

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

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

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

@ -25,13 +25,11 @@ TouchToFillDelegateImpl::~TouchToFillDelegateImpl() {
HideTouchToFill(); HideTouchToFill();
} }
bool TouchToFillDelegateImpl::TryToShowTouchToFill(int query_id, bool TouchToFillDelegateImpl::TryToShowTouchToFill(const FormData& form,
const FormData& form,
const FormFieldData& field) { const FormFieldData& field) {
// TODO(crbug.com/1386143): store only FormGlobalId and FieldGlobalId instead // TODO(crbug.com/1386143): store only FormGlobalId and FieldGlobalId instead
// to avoid that FormData and FormFieldData may become obsolete during the // to avoid that FormData and FormFieldData may become obsolete during the
// bottomsheet being open. // bottomsheet being open.
query_id_ = query_id;
query_form_ = form; query_form_ = form;
query_field_ = field; query_field_ = field;
// Trigger only for a credit card field/form. // Trigger only for a credit card field/form.
@ -113,7 +111,7 @@ void TouchToFillDelegateImpl::ScanCreditCard() {
void TouchToFillDelegateImpl::OnCreditCardScanned(const CreditCard& card) { void TouchToFillDelegateImpl::OnCreditCardScanned(const CreditCard& card) {
HideTouchToFill(); HideTouchToFill();
manager_->FillCreditCardFormImpl(query_form_, query_field_, card, manager_->FillCreditCardFormImpl(query_form_, query_field_, card,
std::u16string(), query_id_); std::u16string());
} }
void TouchToFillDelegateImpl::ShowCreditCardSettings() { void TouchToFillDelegateImpl::ShowCreditCardSettings() {
@ -127,8 +125,7 @@ void TouchToFillDelegateImpl::SuggestionSelected(std::string unique_id) {
DCHECK(pdm); DCHECK(pdm);
CreditCard* card = pdm->GetCreditCardByGUID(unique_id); CreditCard* card = pdm->GetCreditCardByGUID(unique_id);
manager_->FillOrPreviewCreditCardForm(mojom::RendererFormDataAction::kFill, manager_->FillOrPreviewCreditCardForm(mojom::RendererFormDataAction::kFill,
query_id_, query_form_, query_field_, query_form_, query_field_, card);
card);
} }
base::WeakPtr<TouchToFillDelegateImpl> TouchToFillDelegateImpl::GetWeakPtr() { 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 // Checks whether TTF is eligible for the given web form data. On success
// triggers the corresponding surface and returns |true|. // triggers the corresponding surface and returns |true|.
virtual bool TryToShowTouchToFill(int query_id, virtual bool TryToShowTouchToFill(const FormData& form,
const FormData& form,
const FormFieldData& field); const FormFieldData& field);
// Returns whether the TTF surface is currently being shown. // Returns whether the TTF surface is currently being shown.
@ -70,7 +69,6 @@ class TouchToFillDelegateImpl : public TouchToFillDelegate {
TouchToFillState ttf_credit_card_state_ = TouchToFillState::kShouldShow; TouchToFillState ttf_credit_card_state_ = TouchToFillState::kShouldShow;
const raw_ptr<BrowserAutofillManager> manager_; const raw_ptr<BrowserAutofillManager> manager_;
int query_id_;
FormData query_form_; FormData query_form_;
FormFieldData query_field_; FormFieldData query_field_;

@ -24,9 +24,6 @@ namespace autofill {
namespace { namespace {
// A constant value to use as a suggestions query ID.
const int kQueryId = 1;
class MockAutofillDriver : public TestAutofillDriver { class MockAutofillDriver : public TestAutofillDriver {
public: public:
MockAutofillDriver() = default; MockAutofillDriver() = default;
@ -97,13 +94,11 @@ class MockBrowserAutofillManager : public TestBrowserAutofillManager {
(const FormData& form, (const FormData& form,
const FormFieldData& field, const FormFieldData& field,
const CreditCard& credit_card, const CreditCard& credit_card,
const std::u16string& cvc, const std::u16string& cvc),
int query_id),
(override)); (override));
MOCK_METHOD(void, MOCK_METHOD(void,
FillOrPreviewCreditCardForm, FillOrPreviewCreditCardForm,
(mojom::RendererFormDataAction action, (mojom::RendererFormDataAction action,
int query_id,
const FormData& form, const FormData& form,
const FormFieldData& field, const FormFieldData& field,
const CreditCard* credit_card)); const CreditCard* credit_card));
@ -149,8 +144,8 @@ class TouchToFillDelegateImplUnitTest : public testing::Test {
HideAutofillPopup( HideAutofillPopup(
PopupHidingReason::kOverlappingWithTouchToFillSurface)) PopupHidingReason::kOverlappingWithTouchToFillSurface))
.Times(expected_success ? 1 : 0); .Times(expected_success ? 1 : 0);
EXPECT_EQ(expected_success, touch_to_fill_delegate_->TryToShowTouchToFill( EXPECT_EQ(expected_success,
kQueryId, form_, field_)); touch_to_fill_delegate_->TryToShowTouchToFill(form_, field_));
EXPECT_EQ(expected_success, EXPECT_EQ(expected_success,
touch_to_fill_delegate_->IsShowingTouchToFill()); touch_to_fill_delegate_->IsShowingTouchToFill());
} }
@ -219,8 +214,7 @@ TEST_F(TouchToFillDelegateImplUnitTest,
autofill_client_, autofill_client_,
HideAutofillPopup(PopupHidingReason::kOverlappingWithTouchToFillSurface)) HideAutofillPopup(PopupHidingReason::kOverlappingWithTouchToFillSurface))
.Times(0); .Times(0);
EXPECT_FALSE( EXPECT_FALSE(touch_to_fill_delegate_->TryToShowTouchToFill(form_, field_));
touch_to_fill_delegate_->TryToShowTouchToFill(kQueryId, form_, field_));
EXPECT_TRUE(touch_to_fill_delegate_->IsShowingTouchToFill()); 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. // upload the form to and request predictions from the Autofill servers.
constexpr size_t kRequiredFieldsForFormsWithOnlyPasswordFields = 2; 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 // Options bitmask values for AutofillHostMsg_ShowPasswordSuggestions IPC
enum ShowPasswordSuggestionsOptions { enum ShowPasswordSuggestionsOptions {
SHOW_ALL = 1 << 0 /* show all credentials, not just ones matching username */, 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. // ID of the last Autofill query made. Used to discard outdated suggestions.
autofill::FieldGlobalId _lastQueriedFieldID; autofill::FieldGlobalId _lastQueriedFieldID;
// ID of the last Autofill query made. Used to discard outdated suggestions.
int _lastQueryID;
} }
@end @end
@ -212,7 +209,6 @@ void GetFormField(autofill::FormFieldData* field,
UniqueIDDataTabHelper* uniqueIDDataTabHelper = UniqueIDDataTabHelper* uniqueIDDataTabHelper =
UniqueIDDataTabHelper::FromWebState(_webState); UniqueIDDataTabHelper::FromWebState(_webState);
_fieldDataManager = uniqueIDDataTabHelper->GetFieldDataManager(); _fieldDataManager = uniqueIDDataTabHelper->GetFieldDataManager();
_lastQueryID = 0;
} }
return self; return self;
} }
@ -338,8 +334,7 @@ void GetFormField(autofill::FormFieldData* field,
// -showAutofillPopup:popupDelegate:. // -showAutofillPopup:popupDelegate:.
_lastQueriedFieldID = field.global_id(); _lastQueriedFieldID = field.global_id();
autofillManager->OnAskForValuesToFill( autofillManager->OnAskForValuesToFill(
form, field, gfx::RectF(), ++_lastQueryID, form, field, gfx::RectF(), autofill::AutoselectFirstSuggestion(false),
autofill::AutoselectFirstSuggestion(false),
autofill::FormElementWasClicked(false)); autofill::FormElementWasClicked(false));
} }

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

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

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

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