forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
identification_settings_manager_renderer.cc
49 lines (40 loc) · 1.71 KB
/
identification_settings_manager_renderer.cc
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromecast/renderer/identification_settings_manager_renderer.h"
#include <utility>
#include "base/bind.h"
#include "base/callback.h"
#include "base/check.h"
#include "content/public/renderer/render_frame.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
namespace chromecast {
IdentificationSettingsManagerRenderer::IdentificationSettingsManagerRenderer(
content::RenderFrame* render_frame,
base::OnceCallback<void()> on_removed_callback)
: content::RenderFrameObserver(render_frame),
on_removed_callback_(std::move(on_removed_callback)) {
// base::Unretained is safe here since |this| won't get more binding requests
// after |render_frame| is gone.
render_frame->GetAssociatedInterfaceRegistry()->AddInterface(
base::BindRepeating(&IdentificationSettingsManagerRenderer::
OnIdentificationSettingsManagerAssociatedRequest,
base::Unretained(this)));
}
IdentificationSettingsManagerRenderer::
~IdentificationSettingsManagerRenderer() {
if (on_removed_callback_) {
std::move(on_removed_callback_).Run();
}
}
void IdentificationSettingsManagerRenderer::OnDestruct() {
DCHECK(on_removed_callback_);
std::move(on_removed_callback_).Run();
}
void IdentificationSettingsManagerRenderer::
OnIdentificationSettingsManagerAssociatedRequest(
mojo::PendingAssociatedReceiver<mojom::IdentificationSettingsManager>
receiver) {
associated_receiver_.Bind(std::move(receiver));
}
} // namespace chromecast