Delete unused downloads page asset.
[chromium-blink-merge.git] / mandoline / tab / frame_devtools_agent.h
blobed1641626114883e9a2e5442e5eb852315cdef5f
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 MANDOLINE_TAB_FRAME_DEVTOOLS_AGENT_H_
6 #define MANDOLINE_TAB_FRAME_DEVTOOLS_AGENT_H_
8 #include <map>
9 #include <string>
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/devtools_service/public/interfaces/devtools_service.mojom.h"
14 #include "mandoline/tab/frame.h"
15 #include "third_party/mojo/src/mojo/public/cpp/bindings/binding.h"
17 namespace base {
18 class DictionaryValue;
21 namespace mojo {
22 class ApplicationImpl;
25 namespace web_view {
27 class FrameDevToolsAgentDelegate;
29 // FrameDevToolsAgent relays messages between the DevTools service and the
30 // DevTools agent of the frame that it attaches to.
31 // It persists state across frame navigations and also intercepts
32 // "Page.navigate" requests.
33 class FrameDevToolsAgent : public devtools_service::DevToolsAgent {
34 public:
35 FrameDevToolsAgent(mojo::ApplicationImpl* app,
36 FrameDevToolsAgentDelegate* delegate);
37 ~FrameDevToolsAgent() override;
39 // Attaches this agent to a new frame. |forward_agent| is the DevToolsAgent
40 // interface provided by the frame. DevTools-related properties are added to
41 // |devtools_properties|, which should be passed to the frame to initialize
42 // its DevTools agent.
43 void AttachFrame(devtools_service::DevToolsAgentPtr forward_agent,
44 mandoline::Frame::ClientPropertyMap* devtools_properties);
46 private:
47 class FrameDevToolsAgentClient;
49 void RegisterAgentIfNecessary();
51 void HandlePageNavigateRequest(const base::DictionaryValue* request);
53 // devtools_service::DevToolsAgent implementation.
54 void SetClient(devtools_service::DevToolsAgentClientPtr client) override;
55 void DispatchProtocolMessage(const mojo::String& message) override;
57 // The following methods are called by |client_impl_|.
58 void OnReceivedClientMessage(int32_t call_id,
59 const mojo::String& message,
60 const mojo::String& state);
61 void OnForwardClientClosed();
63 mojo::ApplicationImpl* const app_;
64 FrameDevToolsAgentDelegate* const delegate_;
66 const std::string id_;
68 scoped_ptr<FrameDevToolsAgentClient> client_impl_;
70 mojo::Binding<DevToolsAgent> binding_;
71 // The DevToolsAgent interface provided by the frame. This class will forward
72 // DevToolsAgent method calls it receives to |forward_agent_|.
73 devtools_service::DevToolsAgentPtr forward_agent_;
75 std::string state_;
76 std::map<int, std::string> pending_messages_;
78 DISALLOW_COPY_AND_ASSIGN(FrameDevToolsAgent);
81 } // namespace web_view
83 #endif // MANDOLINE_TAB_FRAME_DEVTOOLS_AGENT_H_