| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/devtools/render_frame_devtools_agent_host.h" | 5 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 BrowserContext* RenderFrameDevToolsAgentHost::GetBrowserContext() { | 171 BrowserContext* RenderFrameDevToolsAgentHost::GetBrowserContext() { |
| 172 WebContents* contents = web_contents(); | 172 WebContents* contents = web_contents(); |
| 173 return contents ? contents->GetBrowserContext() : nullptr; | 173 return contents ? contents->GetBrowserContext() : nullptr; |
| 174 } | 174 } |
| 175 | 175 |
| 176 WebContents* RenderFrameDevToolsAgentHost::GetWebContents() { | 176 WebContents* RenderFrameDevToolsAgentHost::GetWebContents() { |
| 177 return web_contents(); | 177 return web_contents(); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void RenderFrameDevToolsAgentHost::SendMessageToAgent(IPC::Message* msg) { | 180 void RenderFrameDevToolsAgentHost::Attach() { |
| 181 if (!render_frame_host_) | 181 if (render_frame_host_) { |
| 182 return; | 182 render_frame_host_->Send(new DevToolsAgentMsg_Attach( |
| 183 msg->set_routing_id(render_frame_host_->GetRoutingID()); | 183 render_frame_host_->GetRoutingID(), GetId())); |
| 184 render_frame_host_->Send(msg); | 184 } |
| 185 OnClientAttached(); |
| 185 } | 186 } |
| 186 | 187 |
| 187 void RenderFrameDevToolsAgentHost::OnClientAttached(bool reattached) { | 188 void RenderFrameDevToolsAgentHost::Detach() { |
| 189 if (render_frame_host_) { |
| 190 render_frame_host_->Send(new DevToolsAgentMsg_Detach( |
| 191 render_frame_host_->GetRoutingID())); |
| 192 } |
| 193 OnClientDetached(); |
| 194 } |
| 195 |
| 196 bool RenderFrameDevToolsAgentHost::DispatchProtocolMessage( |
| 197 const std::string& message) { |
| 198 if (DevToolsAgentHostImpl::DispatchProtocolMessage(message)) |
| 199 return true; |
| 200 |
| 201 if (render_frame_host_) { |
| 202 render_frame_host_->Send(new DevToolsAgentMsg_DispatchOnInspectorBackend( |
| 203 render_frame_host_->GetRoutingID(), message)); |
| 204 } |
| 205 return true; |
| 206 } |
| 207 |
| 208 void RenderFrameDevToolsAgentHost::InspectElement(int x, int y) { |
| 209 if (render_frame_host_) { |
| 210 render_frame_host_->Send(new DevToolsAgentMsg_InspectElement( |
| 211 render_frame_host_->GetRoutingID(), GetId(), x, y)); |
| 212 } |
| 213 } |
| 214 |
| 215 void RenderFrameDevToolsAgentHost::OnClientAttached() { |
| 188 if (!render_frame_host_) | 216 if (!render_frame_host_) |
| 189 return; | 217 return; |
| 190 | 218 |
| 191 InnerOnClientAttached(); | 219 InnerOnClientAttached(); |
| 192 | 220 |
| 193 // TODO(kaznacheev): Move this call back to DevToolsManager when | 221 // TODO(kaznacheev): Move this call back to DevToolsManager when |
| 194 // extensions::ProcessManager no longer relies on this notification. | 222 // extensions::ProcessManager no longer relies on this notification. |
| 195 if (!reattaching_) | 223 if (!reattaching_) |
| 196 DevToolsAgentHostImpl::NotifyCallbacks(this, true); | 224 DevToolsAgentHostImpl::NotifyCallbacks(this, true); |
| 197 } | 225 } |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 if (web_contents()) { | 497 if (web_contents()) { |
| 470 web_contents()->ClosePage(); | 498 web_contents()->ClosePage(); |
| 471 return true; | 499 return true; |
| 472 } | 500 } |
| 473 return false; | 501 return false; |
| 474 } | 502 } |
| 475 | 503 |
| 476 void RenderFrameDevToolsAgentHost::ConnectRenderFrameHost( | 504 void RenderFrameDevToolsAgentHost::ConnectRenderFrameHost( |
| 477 RenderFrameHost* rfh) { | 505 RenderFrameHost* rfh) { |
| 478 SetRenderFrameHost(rfh); | 506 SetRenderFrameHost(rfh); |
| 479 if (IsAttached()) | 507 if (IsAttached() && render_frame_host_) { |
| 480 Reattach(); | 508 render_frame_host_->Send(new DevToolsAgentMsg_Reattach( |
| 509 render_frame_host_->GetRoutingID(), GetId(), state_cookie_)); |
| 510 OnClientAttached(); |
| 511 } |
| 481 } | 512 } |
| 482 | 513 |
| 483 void RenderFrameDevToolsAgentHost::DisconnectRenderFrameHost() { | 514 void RenderFrameDevToolsAgentHost::DisconnectRenderFrameHost() { |
| 484 ClientDetachedFromRenderer(); | 515 ClientDetachedFromRenderer(); |
| 485 ClearRenderFrameHost(); | 516 ClearRenderFrameHost(); |
| 486 } | 517 } |
| 487 | 518 |
| 488 void RenderFrameDevToolsAgentHost::RenderFrameCrashed() { | 519 void RenderFrameDevToolsAgentHost::RenderFrameCrashed() { |
| 489 inspector_handler_->TargetCrashed(); | 520 inspector_handler_->TargetCrashed(); |
| 490 } | 521 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 if (!IsAttached() || !render_frame_host_) | 559 if (!IsAttached() || !render_frame_host_) |
| 529 return; | 560 return; |
| 530 ProcessChunkedMessageFromAgent(message); | 561 ProcessChunkedMessageFromAgent(message); |
| 531 } | 562 } |
| 532 | 563 |
| 533 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 564 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
| 534 return render_frame_host_ && render_frame_host_->GetParent(); | 565 return render_frame_host_ && render_frame_host_->GetParent(); |
| 535 } | 566 } |
| 536 | 567 |
| 537 } // namespace content | 568 } // namespace content |
| OLD | NEW |