stub_autofill_provider.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef WEBLAYER_TEST_STUB_AUTOFILL_PROVIDER_H_
  5. #define WEBLAYER_TEST_STUB_AUTOFILL_PROVIDER_H_
  6. #include "base/callback_forward.h"
  7. #include "components/android_autofill/browser/test_autofill_provider.h"
  8. #include "content/public/browser/web_contents.h"
  9. namespace weblayer {
  10. // A stub AutofillProvider implementation that is used in cross-platform
  11. // integration tests of renderer-side autofill detection and communication to
  12. // the browser.
  13. class StubAutofillProvider : public autofill::TestAutofillProvider {
  14. public:
  15. // WebContents takes the ownership of StubAutofillProvider.
  16. explicit StubAutofillProvider(
  17. content::WebContents* web_contents,
  18. const base::RepeatingCallback<void(const autofill::FormData&)>&
  19. on_received_form_data);
  20. StubAutofillProvider(const StubAutofillProvider&) = delete;
  21. StubAutofillProvider& operator=(const StubAutofillProvider&) = delete;
  22. ~StubAutofillProvider() override;
  23. // AutofillProvider:
  24. void OnAskForValuesToFill(
  25. autofill::AndroidAutofillManager* manager,
  26. const autofill::FormData& form,
  27. const autofill::FormFieldData& field,
  28. const gfx::RectF& bounding_box,
  29. int32_t query_id,
  30. bool /*unused_autoselect_first_suggestion*/,
  31. autofill::TouchToFillEligible /*unused_touch_to_fill_eligible*/) override;
  32. private:
  33. base::RepeatingCallback<void(const autofill::FormData&)>
  34. on_received_form_data_;
  35. };
  36. } // namespace weblayer
  37. #endif // WEBLAYER_TEST_STUB_AUTOFILL_PROVIDER_H_