1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34

content / public / test / local_frame_host_interceptor.cc [blame]

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/public/test/local_frame_host_interceptor.h"

#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"

namespace content {

LocalFrameHostInterceptor::LocalFrameHostInterceptor(
    blink::AssociatedInterfaceProvider* provider) {
  provider->GetInterface(
      local_frame_host_remote_.BindNewEndpointAndPassReceiver());
  provider->OverrideBinderForTesting(
      blink::mojom::LocalFrameHost::Name_,
      base::BindRepeating(&LocalFrameHostInterceptor::BindFrameHostReceiver,
                          base::Unretained(this)));
}

LocalFrameHostInterceptor::~LocalFrameHostInterceptor() = default;

blink::mojom::LocalFrameHost*
LocalFrameHostInterceptor::GetForwardingInterface() {
  return local_frame_host_remote_.get();
}

void LocalFrameHostInterceptor::BindFrameHostReceiver(
    mojo::ScopedInterfaceEndpointHandle handle) {
  receiver_.Bind(mojo::PendingAssociatedReceiver<blink::mojom::LocalFrameHost>(
      std::move(handle)));
}

}  // namespace content