OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef COMPONENTS_WEB_VIEW_FRAME_DEVTOOLS_AGENT_H_ | |
6 #define COMPONENTS_WEB_VIEW_FRAME_DEVTOOLS_AGENT_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <map> | |
11 #include <string> | |
12 | |
13 #include "base/macros.h" | |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "components/devtools_service/public/interfaces/devtools_service.mojom.h
" | |
16 #include "components/web_view/frame.h" | |
17 #include "mojo/public/cpp/bindings/binding.h" | |
18 | |
19 namespace base { | |
20 class DictionaryValue; | |
21 } | |
22 | |
23 namespace mojo { | |
24 class Shell; | |
25 } | |
26 | |
27 namespace web_view { | |
28 | |
29 class FrameDevToolsAgentDelegate; | |
30 | |
31 // FrameDevToolsAgent relays messages between the DevTools service and the | |
32 // DevTools agent of the frame that it attaches to. | |
33 // It persists state across frame navigations and also intercepts | |
34 // "Page.navigate" requests. | |
35 class FrameDevToolsAgent : public devtools_service::DevToolsAgent { | |
36 public: | |
37 FrameDevToolsAgent(mojo::Shell* shell, FrameDevToolsAgentDelegate* delegate); | |
38 ~FrameDevToolsAgent() override; | |
39 | |
40 // Attaches this agent to a new frame. |forward_agent| is the DevToolsAgent | |
41 // interface provided by the frame. DevTools-related properties are added to | |
42 // |devtools_properties|, which should be passed to the frame to initialize | |
43 // its DevTools agent. | |
44 void AttachFrame(devtools_service::DevToolsAgentPtr forward_agent, | |
45 Frame::ClientPropertyMap* devtools_properties); | |
46 | |
47 private: | |
48 class FrameDevToolsAgentClient; | |
49 | |
50 void RegisterAgentIfNecessary(); | |
51 | |
52 void HandlePageNavigateRequest(const base::DictionaryValue* request); | |
53 | |
54 // devtools_service::DevToolsAgent implementation. | |
55 void SetClient(devtools_service::DevToolsAgentClientPtr client) override; | |
56 void DispatchProtocolMessage(const mojo::String& message) override; | |
57 | |
58 // The following methods are called by |client_impl_|. | |
59 void OnReceivedClientMessage(int32_t call_id, | |
60 const mojo::String& message, | |
61 const mojo::String& state); | |
62 void OnForwardClientClosed(); | |
63 | |
64 mojo::Shell* const shell_; | |
65 FrameDevToolsAgentDelegate* const delegate_; | |
66 | |
67 const std::string id_; | |
68 | |
69 scoped_ptr<FrameDevToolsAgentClient> client_impl_; | |
70 | |
71 mojo::Binding<DevToolsAgent> binding_; | |
72 // The DevToolsAgent interface provided by the frame. This class will forward | |
73 // DevToolsAgent method calls it receives to |forward_agent_|. | |
74 devtools_service::DevToolsAgentPtr forward_agent_; | |
75 | |
76 std::string state_; | |
77 std::map<int, std::string> pending_messages_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(FrameDevToolsAgent); | |
80 }; | |
81 | |
82 } // namespace web_view | |
83 | |
84 #endif // COMPONENTS_WEB_VIEW_FRAME_DEVTOOLS_AGENT_H_ | |
OLD | NEW |