blob: dca30289f14e57371cadeaae85854adea5d58393 [file] [log] [blame]
rockotf62002a2016-09-15 00:08:591// Copyright 2016 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
5#include "content/public/browser/web_contents_binding_set.h"
6
7#include <utility>
8
9#include "base/logging.h"
10#include "content/browser/web_contents/web_contents_impl.h"
11
12namespace content {
13
14void WebContentsBindingSet::Binder::OnRequestForFrame(
15 RenderFrameHost* render_frame_host,
16 mojo::ScopedInterfaceEndpointHandle handle) {
17 NOTREACHED();
18}
19
Ken Rockot3b799c62019-04-25 17:38:1020void WebContentsBindingSet::Binder::CloseAllBindings() {
21 NOTREACHED();
22}
23
rockotf62002a2016-09-15 00:08:5924WebContentsBindingSet::WebContentsBindingSet(WebContents* web_contents,
Ken Rockot3b799c62019-04-25 17:38:1025 const std::string& interface_name)
rockot96c63e32017-03-20 23:23:0326 : remove_callback_(static_cast<WebContentsImpl*>(web_contents)
Ken Rockot3b799c62019-04-25 17:38:1027 ->AddBindingSet(interface_name, this)) {}
rockotf62002a2016-09-15 00:08:5928
29WebContentsBindingSet::~WebContentsBindingSet() {
danakjf4b9e942019-11-29 15:43:0430 std::move(remove_callback_).Run();
rockotf62002a2016-09-15 00:08:5931}
32
rockot8bbad222017-03-22 04:34:0533// static
34WebContentsBindingSet* WebContentsBindingSet::GetForWebContents(
35 WebContents* web_contents,
36 const char* interface_name) {
37 return static_cast<WebContentsImpl*>(web_contents)
38 ->GetBindingSet(interface_name);
39}
40
rockotf62002a2016-09-15 00:08:5941void WebContentsBindingSet::CloseAllBindings() {
Ken Rockot3b799c62019-04-25 17:38:1042 binder_->CloseAllBindings();
43 binder_ = nullptr;
rockotf62002a2016-09-15 00:08:5944}
45
46void WebContentsBindingSet::OnRequestForFrame(
47 RenderFrameHost* render_frame_host,
48 mojo::ScopedInterfaceEndpointHandle handle) {
Ken Rockot3b799c62019-04-25 17:38:1049 if (binder_)
50 binder_->OnRequestForFrame(render_frame_host, std::move(handle));
rockotf62002a2016-09-15 00:08:5951}
52
53} // namespace content