Christoph Schwering | 959dd14 | 2024-01-25 22:03:09 | [diff] [blame] | 1 | // 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 | |
| 10 | namespace autofill { |
| 11 | |
| 12 | MockAutofillAgent::MockAutofillAgent() = default; |
| 13 | MockAutofillAgent::~MockAutofillAgent() = default; |
| 14 | |
| 15 | void 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 | |
| 24 | void MockAutofillAgent::BindPendingReceiver( |
| 25 | mojo::ScopedInterfaceEndpointHandle handle) { |
| 26 | receivers_.Add(this, mojo::PendingAssociatedReceiver<mojom::AutofillAgent>( |
| 27 | std::move(handle))); |
| 28 | } |
| 29 | |
| 30 | } // namespace autofill |