summaryrefslogtreecommitdiff
path: root/chromium/headless/public/headless_devtools_client.h
blob: 1b8073e81b54d3a686e04502f526be5a08f29da5 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// Copyright 2016 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_DEVTOOLS_CLIENT_H_
#define HEADLESS_PUBLIC_HEADLESS_DEVTOOLS_CLIENT_H_

#include <memory>

#include "base/macros.h"
#include "headless/public/headless_export.h"

namespace headless {

namespace accessibility {
class Domain;
}
namespace animation {
class Domain;
}
namespace application_cache {
class Domain;
}
namespace browser {
class Domain;
}
namespace cache_storage {
class Domain;
}
namespace console {
class Domain;
}
namespace css {
class Domain;
}
namespace database {
class Domain;
}
namespace debugger {
class Domain;
}
namespace device_orientation {
class Domain;
}
namespace dom {
class Domain;
}
namespace dom_debugger {
class Domain;
}
namespace dom_storage {
class Domain;
}
namespace emulation {
class Domain;
}
namespace heap_profiler {
class Domain;
}
namespace indexeddb {
class Domain;
}
namespace input {
class Domain;
}
namespace inspector {
class Domain;
}
namespace io {
class Domain;
}
namespace layer_tree {
class Domain;
}
namespace log {
class Domain;
}
namespace memory {
class Domain;
}
namespace network {
class Domain;
}
namespace page {
class Domain;
}
namespace profiler {
class Domain;
}
namespace runtime {
class Domain;
}
namespace security {
class Domain;
}
namespace service_worker {
class Domain;
}
namespace target {
class Domain;
}
namespace tracing {
class Domain;
}

// An interface for controlling and receiving events from a devtools target.
class HEADLESS_EXPORT HeadlessDevToolsClient {
 public:
  virtual ~HeadlessDevToolsClient() {}

  static std::unique_ptr<HeadlessDevToolsClient> Create();

  // DevTools commands are split into domains which corresponds to the getters
  // below. Each domain can be used to send commands and to subscribe to events.
  //
  // See http://chromedevtools.github.io/debugger-protocol-viewer/ for
  // the capabilities of each domain.
  virtual accessibility::Domain* GetAccessibility() = 0;
  virtual animation::Domain* GetAnimation() = 0;
  virtual application_cache::Domain* GetApplicationCache() = 0;
  virtual browser::Domain* GetBrowser() = 0;
  virtual cache_storage::Domain* GetCacheStorage() = 0;
  virtual console::Domain* GetConsole() = 0;
  virtual css::Domain* GetCSS() = 0;
  virtual database::Domain* GetDatabase() = 0;
  virtual debugger::Domain* GetDebugger() = 0;
  virtual device_orientation::Domain* GetDeviceOrientation() = 0;
  virtual dom::Domain* GetDOM() = 0;
  virtual dom_debugger::Domain* GetDOMDebugger() = 0;
  virtual dom_storage::Domain* GetDOMStorage() = 0;
  virtual emulation::Domain* GetEmulation() = 0;
  virtual heap_profiler::Domain* GetHeapProfiler() = 0;
  virtual indexeddb::Domain* GetIndexedDB() = 0;
  virtual input::Domain* GetInput() = 0;
  virtual inspector::Domain* GetInspector() = 0;
  virtual io::Domain* GetIO() = 0;
  virtual layer_tree::Domain* GetLayerTree() = 0;
  virtual log::Domain* GetLog() = 0;
  virtual memory::Domain* GetMemory() = 0;
  virtual network::Domain* GetNetwork() = 0;
  virtual page::Domain* GetPage() = 0;
  virtual profiler::Domain* GetProfiler() = 0;
  virtual runtime::Domain* GetRuntime() = 0;
  virtual security::Domain* GetSecurity() = 0;
  virtual service_worker::Domain* GetServiceWorker() = 0;
  virtual target::Domain* GetTarget() = 0;
  virtual tracing::Domain* GetTracing() = 0;

  class HEADLESS_EXPORT RawProtocolListener {
   public:
    RawProtocolListener() {}
    virtual ~RawProtocolListener() {}

    // Returns true if the listener handled the message.
    virtual bool OnProtocolMessage(
        const std::string& devtools_agent_host_id,
        const std::string& json_message,
        const base::DictionaryValue& parsed_message) = 0;

   private:
    DISALLOW_COPY_AND_ASSIGN(RawProtocolListener);
  };

  virtual void SetRawProtocolListener(
      RawProtocolListener* raw_protocol_listener) = 0;

  // Generates an odd numbered ID.
  virtual int GetNextRawDevToolsMessageId() = 0;

  // The id within the message must be odd to prevent collisions.
  virtual void SendRawDevToolsMessage(const std::string& json_message) = 0;
  virtual void SendRawDevToolsMessage(const base::DictionaryValue& message) = 0;

  // TODO(skyostil): Add notification for disconnection.

 private:
  friend class HeadlessDevToolsClientImpl;

  HeadlessDevToolsClient() {}

  DISALLOW_COPY_AND_ASSIGN(HeadlessDevToolsClient);
};

}  // namespace headless

#endif  // HEADLESS_PUBLIC_HEADLESS_DEVTOOLS_CLIENT_H_