forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbindings_manager_cast.h
59 lines (45 loc) · 2.03 KB
/
bindings_manager_cast.h
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
50
51
52
53
54
55
56
57
58
59
// Copyright 2019 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.
#ifndef CHROMECAST_BINDINGS_BINDINGS_MANAGER_CAST_H_
#define CHROMECAST_BINDINGS_BINDINGS_MANAGER_CAST_H_
#include <map>
#include <string>
#include "base/callback.h"
#include "chromecast/bindings/bindings_manager.h"
#include "chromecast/browser/cast_web_contents.h"
#include "mojo/public/cpp/bindings/connector.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/system/message_pipe.h"
namespace chromecast {
namespace bindings {
// Implements the CastOS BindingsManager.
class BindingsManagerCast : public BindingsManager,
public CastWebContents::Observer,
public blink::WebMessagePort::MessageReceiver {
public:
explicit BindingsManagerCast(chromecast::CastWebContents* cast_web_contents);
~BindingsManagerCast() override;
// The document and its statically-declared subresources are loaded.
// BindingsManagerCast will inject all registered bindings at this time.
// BindingsManagerCast will post a message that conveys an end of MessagePort
// to the loaded page, so that the NamedMessagePort binding could utilize the
// port to communicate with the native part.
void OnPageLoaded();
// BindingsManager implementation.
void AddBinding(base::StringPiece binding_name,
base::StringPiece binding_script) override;
private:
// CastWebContents::Observer implementation.
void OnPageStateChanged(CastWebContents* cast_web_contents) override;
// blink::WebMessagePort::MessageReceiver implementation:
bool OnMessage(blink::WebMessagePort::Message message) override;
void OnPipeError() override;
chromecast::CastWebContents* cast_web_contents_;
// Receives messages from JS.
blink::WebMessagePort blink_port_;
DISALLOW_COPY_AND_ASSIGN(BindingsManagerCast);
};
} // namespace bindings
} // namespace chromecast
#endif // CHROMECAST_BINDINGS_BINDINGS_MANAGER_CAST_H_