1 // Copyright 2015 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.
5 #ifndef COMPONENTS_HTML_VIEWER_DEVTOOLS_AGENT_IMPL_H_
6 #define COMPONENTS_HTML_VIEWER_DEVTOOLS_AGENT_IMPL_H_
8 #include "base/macros.h"
9 #include "components/devtools_service/public/interfaces/devtools_service.mojom.h"
10 #include "third_party/WebKit/public/web/WebDevToolsAgentClient.h"
11 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
21 namespace html_viewer
{
23 class DevToolsAgentImpl
: public devtools_service::DevToolsAgent
,
24 public blink::WebDevToolsAgentClient
{
26 // |frame| must outlive this object.
27 DevToolsAgentImpl(blink::WebLocalFrame
* frame
, mojo::Shell
* shell
);
28 ~DevToolsAgentImpl() override
;
30 blink::WebLocalFrame
* frame() const { return frame_
; }
32 // Returns whether a "Page.navigate" command is being handled.
33 bool handling_page_navigate_request() const {
34 return handling_page_navigate_request_
;
38 // devtools_service::DevToolsAgent implementation.
39 void SetClient(devtools_service::DevToolsAgentClientPtr client
,
40 const mojo::String
& client_id
) override
;
41 void DispatchProtocolMessage(const mojo::String
& message
) override
;
43 // blink::WebDevToolsAgentClient implementation.
44 void sendProtocolMessage(int call_id
,
45 const blink::WebString
& response
,
46 const blink::WebString
& state
);
48 void OnConnectionError();
50 blink::WebLocalFrame
* const frame_
;
51 mojo::Binding
<DevToolsAgent
> binding_
;
52 devtools_service::DevToolsAgentClientPtr client_
;
54 bool handling_page_navigate_request_
;
56 DISALLOW_COPY_AND_ASSIGN(DevToolsAgentImpl
);
59 } // namespace html_viewer
61 #endif // COMPONENTS_HTML_VIEWER_DEVTOOLS_AGENT_IMPL_H_