blob: afe087888618156fcc4a40b52f1f1034737a506b [file] [log] [blame]
Christoph Schwering959dd142024-01-25 22:03:091// Copyright 2024 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/autofill/mock_autofill_agent.h"
6
7#include "content/public/browser/render_frame_host.h"
8#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
9
10namespace autofill {
11
12MockAutofillAgent::MockAutofillAgent() = default;
13MockAutofillAgent::~MockAutofillAgent() = default;
14
15void MockAutofillAgent::BindForTesting(content::RenderFrameHost* rfh) {
16 blink::AssociatedInterfaceProvider* remote_interfaces =
17 rfh->GetRemoteAssociatedInterfaces();
18 remote_interfaces->OverrideBinderForTesting(
19 mojom::AutofillAgent::Name_,
20 base::BindRepeating(&MockAutofillAgent::BindPendingReceiver,
21 weak_ptr_factory_.GetWeakPtr()));
22}
23
24void MockAutofillAgent::BindPendingReceiver(
25 mojo::ScopedInterfaceEndpointHandle handle) {
26 receivers_.Add(this, mojo::PendingAssociatedReceiver<mojom::AutofillAgent>(
27 std::move(handle)));
28}
29
30} // namespace autofill