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 #include "components/web_view/frame_devtools_agent.h" | 5 #include "components/web_view/frame_devtools_agent.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 } | 54 } |
55 | 55 |
56 ~FrameDevToolsAgentClient() override {} | 56 ~FrameDevToolsAgentClient() override {} |
57 | 57 |
58 void OnAttachedFrame() { | 58 void OnAttachedFrame() { |
59 DCHECK(owner_->forward_agent_); | 59 DCHECK(owner_->forward_agent_); |
60 | 60 |
61 if (binding_.is_bound()) | 61 if (binding_.is_bound()) |
62 binding_.Close(); | 62 binding_.Close(); |
63 | 63 |
64 DevToolsAgentClientPtr client; | 64 owner_->forward_agent_->SetClient(binding_.CreateInterfacePtrAndBind()); |
65 binding_.Bind(&client); | |
66 owner_->forward_agent_->SetClient(std::move(client)); | |
67 } | 65 } |
68 | 66 |
69 private: | 67 private: |
70 // DevToolsAgentClient implementation. | 68 // DevToolsAgentClient implementation. |
71 void DispatchProtocolMessage(int32_t call_id, | 69 void DispatchProtocolMessage(int32_t call_id, |
72 const String& message, | 70 const String& message, |
73 const String& state) override { | 71 const String& state) override { |
74 DCHECK(forward_client_); | 72 DCHECK(forward_client_); |
75 owner_->OnReceivedClientMessage(call_id, message, state); | 73 owner_->OnReceivedClientMessage(call_id, message, state); |
76 // The state is used to persist state across frame navigations. There is no | 74 // The state is used to persist state across frame navigations. There is no |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 forward_agent_->DispatchProtocolMessage(item.second); | 117 forward_agent_->DispatchProtocolMessage(item.second); |
120 } | 118 } |
121 | 119 |
122 void FrameDevToolsAgent::RegisterAgentIfNecessary() { | 120 void FrameDevToolsAgent::RegisterAgentIfNecessary() { |
123 if (binding_.is_bound()) | 121 if (binding_.is_bound()) |
124 return; | 122 return; |
125 | 123 |
126 DevToolsRegistryPtr devtools_registry; | 124 DevToolsRegistryPtr devtools_registry; |
127 app_->ConnectToService("mojo:devtools_service", &devtools_registry); | 125 app_->ConnectToService("mojo:devtools_service", &devtools_registry); |
128 | 126 |
129 DevToolsAgentPtr agent; | 127 devtools_registry->RegisterAgent(id_, binding_.CreateInterfacePtrAndBind()); |
130 binding_.Bind(&agent); | |
131 devtools_registry->RegisterAgent(id_, std::move(agent)); | |
132 } | 128 } |
133 | 129 |
134 void FrameDevToolsAgent::HandlePageNavigateRequest( | 130 void FrameDevToolsAgent::HandlePageNavigateRequest( |
135 const base::DictionaryValue* request) { | 131 const base::DictionaryValue* request) { |
136 std::string method; | 132 std::string method; |
137 if (!request->GetString("method", &method) || method != "Page.navigate") | 133 if (!request->GetString("method", &method) || method != "Page.navigate") |
138 return; | 134 return; |
139 | 135 |
140 std::string url_string; | 136 std::string url_string; |
141 if (!request->GetString("params.url", &url_string)) | 137 if (!request->GetString("params.url", &url_string)) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 pending_messages_.erase(call_id); | 187 pending_messages_.erase(call_id); |
192 } | 188 } |
193 | 189 |
194 void FrameDevToolsAgent::OnForwardClientClosed() { | 190 void FrameDevToolsAgent::OnForwardClientClosed() { |
195 client_impl_.reset(); | 191 client_impl_.reset(); |
196 state_.clear(); | 192 state_.clear(); |
197 pending_messages_.clear(); | 193 pending_messages_.clear(); |
198 } | 194 } |
199 | 195 |
200 } // namespace web_view | 196 } // namespace web_view |
OLD | NEW |