blob: b8f0fa22288da1dfa07f348957ca8347e0807cf5 (
plain)
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
|
// Copyright 2017 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 HEADLESS_PUBLIC_HEADLESS_TAB_SOCKET_H_
#define HEADLESS_PUBLIC_HEADLESS_TAB_SOCKET_H_
#include <string>
#include "base/macros.h"
#include "headless/public/headless_export.h"
namespace headless {
// A bidirectional communications channel between C++ and JS.
class HEADLESS_EXPORT HeadlessTabSocket {
public:
class HEADLESS_EXPORT Listener {
public:
Listener() {}
virtual ~Listener() {}
// The |message| may be potentially sent by untrusted web content so it
// should be validated carefully.
virtual void OnMessageFromTab(const std::string& message) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(Listener);
};
virtual void SendMessageToTab(const std::string& message) = 0;
virtual void SetListener(Listener* listener) = 0;
protected:
HeadlessTabSocket() {}
virtual ~HeadlessTabSocket() {}
private:
DISALLOW_COPY_AND_ASSIGN(HeadlessTabSocket);
};
} // namespace headless
#endif // HEADLESS_PUBLIC_HEADLESS_TAB_SOCKET_H_
|