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