| 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 <tuple> | 7 #include <tuple> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "content/browser/bad_message.h" |
| 13 #include "content/browser/child_process_security_policy_impl.h" | 14 #include "content/browser/child_process_security_policy_impl.h" |
| 14 #include "content/browser/devtools/devtools_frame_trace_recorder.h" | 15 #include "content/browser/devtools/devtools_frame_trace_recorder.h" |
| 15 #include "content/browser/devtools/devtools_protocol_handler.h" | 16 #include "content/browser/devtools/devtools_protocol_handler.h" |
| 16 #include "content/browser/devtools/page_navigation_throttle.h" | 17 #include "content/browser/devtools/page_navigation_throttle.h" |
| 17 #include "content/browser/devtools/protocol/browser_handler.h" | 18 #include "content/browser/devtools/protocol/browser_handler.h" |
| 18 #include "content/browser/devtools/protocol/dom_handler.h" | 19 #include "content/browser/devtools/protocol/dom_handler.h" |
| 19 #include "content/browser/devtools/protocol/emulation_handler.h" | 20 #include "content/browser/devtools/protocol/emulation_handler.h" |
| 20 #include "content/browser/devtools/protocol/input_handler.h" | 21 #include "content/browser/devtools/protocol/input_handler.h" |
| 21 #include "content/browser/devtools/protocol/inspector_handler.h" | 22 #include "content/browser/devtools/protocol/inspector_handler.h" |
| 22 #include "content/browser/devtools/protocol/io_handler.h" | 23 #include "content/browser/devtools/protocol/io_handler.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 RenderFrameHostImpl* host() const { return host_; } | 99 RenderFrameHostImpl* host() const { return host_; } |
| 99 | 100 |
| 100 void Attach(); | 101 void Attach(); |
| 101 void Reattach(FrameHostHolder* old); | 102 void Reattach(FrameHostHolder* old); |
| 102 void Detach(); | 103 void Detach(); |
| 103 void DispatchProtocolMessage(int session_id, | 104 void DispatchProtocolMessage(int session_id, |
| 104 int call_id, | 105 int call_id, |
| 105 const std::string& method, | 106 const std::string& method, |
| 106 const std::string& message); | 107 const std::string& message); |
| 107 void InspectElement(int session_id, int x, int y); | 108 void InspectElement(int session_id, int x, int y); |
| 108 void ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk); | 109 bool ProcessChunkedMessageFromAgent(const DevToolsMessageChunk& chunk); |
| 109 void Suspend(); | 110 void Suspend(); |
| 110 void Resume(); | 111 void Resume(); |
| 111 | 112 |
| 112 private: | 113 private: |
| 113 void GrantPolicy(); | 114 void GrantPolicy(); |
| 114 void RevokePolicy(); | 115 void RevokePolicy(); |
| 115 void SendMessageToClient(int session_id, const std::string& message); | 116 void SendMessageToClient(int session_id, const std::string& message); |
| 116 | 117 |
| 117 RenderFrameDevToolsAgentHost* agent_; | 118 RenderFrameDevToolsAgentHost* agent_; |
| 118 RenderFrameHostImpl* host_; | 119 RenderFrameHostImpl* host_; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 sent_messages_[call_id] = { session_id, method, message }; | 211 sent_messages_[call_id] = { session_id, method, message }; |
| 211 } | 212 } |
| 212 | 213 |
| 213 void RenderFrameDevToolsAgentHost::FrameHostHolder::InspectElement( | 214 void RenderFrameDevToolsAgentHost::FrameHostHolder::InspectElement( |
| 214 int session_id, int x, int y) { | 215 int session_id, int x, int y) { |
| 215 DCHECK(attached_); | 216 DCHECK(attached_); |
| 216 host_->Send(new DevToolsAgentMsg_InspectElement( | 217 host_->Send(new DevToolsAgentMsg_InspectElement( |
| 217 host_->GetRoutingID(), session_id, x, y)); | 218 host_->GetRoutingID(), session_id, x, y)); |
| 218 } | 219 } |
| 219 | 220 |
| 220 void | 221 bool |
| 221 RenderFrameDevToolsAgentHost::FrameHostHolder::ProcessChunkedMessageFromAgent( | 222 RenderFrameDevToolsAgentHost::FrameHostHolder::ProcessChunkedMessageFromAgent( |
| 222 const DevToolsMessageChunk& chunk) { | 223 const DevToolsMessageChunk& chunk) { |
| 223 chunk_processor_.ProcessChunkedMessageFromAgent(chunk); | 224 return chunk_processor_.ProcessChunkedMessageFromAgent(chunk); |
| 224 } | 225 } |
| 225 | 226 |
| 226 void RenderFrameDevToolsAgentHost::FrameHostHolder::SendMessageToClient( | 227 void RenderFrameDevToolsAgentHost::FrameHostHolder::SendMessageToClient( |
| 227 int session_id, | 228 int session_id, |
| 228 const std::string& message) { | 229 const std::string& message) { |
| 229 sent_messages_.erase(chunk_processor_.last_call_id()); | 230 sent_messages_.erase(chunk_processor_.last_call_id()); |
| 230 if (suspended_) | 231 if (suspended_) |
| 231 pending_messages_.push_back(std::make_pair(session_id, message)); | 232 pending_messages_.push_back(std::make_pair(session_id, message)); |
| 232 else | 233 else |
| 233 agent_->SendMessageToClient(session_id, message); | 234 agent_->SendMessageToClient(session_id, message); |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 if (frame_trace_recorder_ && tracing_handler_->did_initiate_recording()) { | 909 if (frame_trace_recorder_ && tracing_handler_->did_initiate_recording()) { |
| 909 frame_trace_recorder_->OnSynchronousSwapCompositorFrame( | 910 frame_trace_recorder_->OnSynchronousSwapCompositorFrame( |
| 910 current_ ? current_->host() : nullptr, | 911 current_ ? current_->host() : nullptr, |
| 911 frame_metadata); | 912 frame_metadata); |
| 912 } | 913 } |
| 913 } | 914 } |
| 914 | 915 |
| 915 void RenderFrameDevToolsAgentHost::OnDispatchOnInspectorFrontend( | 916 void RenderFrameDevToolsAgentHost::OnDispatchOnInspectorFrontend( |
| 916 RenderFrameHost* sender, | 917 RenderFrameHost* sender, |
| 917 const DevToolsMessageChunk& message) { | 918 const DevToolsMessageChunk& message) { |
| 919 bool success = true; |
| 918 if (current_ && current_->host() == sender) | 920 if (current_ && current_->host() == sender) |
| 919 current_->ProcessChunkedMessageFromAgent(message); | 921 success = current_->ProcessChunkedMessageFromAgent(message); |
| 920 else if (pending_ && pending_->host() == sender) | 922 else if (pending_ && pending_->host() == sender) |
| 921 pending_->ProcessChunkedMessageFromAgent(message); | 923 success = pending_->ProcessChunkedMessageFromAgent(message); |
| 924 if (!success) { |
| 925 bad_message::ReceivedBadMessage( |
| 926 sender->GetProcess(), |
| 927 bad_message::RFH_INCONSISTENT_DEVTOOLS_MESSAGE); |
| 928 } |
| 922 } | 929 } |
| 923 | 930 |
| 924 void RenderFrameDevToolsAgentHost::OnRequestNewWindow( | 931 void RenderFrameDevToolsAgentHost::OnRequestNewWindow( |
| 925 RenderFrameHost* sender, | 932 RenderFrameHost* sender, |
| 926 int new_routing_id) { | 933 int new_routing_id) { |
| 927 RenderFrameHostImpl* frame_host = RenderFrameHostImpl::FromID( | 934 RenderFrameHostImpl* frame_host = RenderFrameHostImpl::FromID( |
| 928 sender->GetProcess()->GetID(), new_routing_id); | 935 sender->GetProcess()->GetID(), new_routing_id); |
| 929 | 936 |
| 930 bool success = false; | 937 bool success = false; |
| 931 if (IsAttached() && sender->GetRoutingID() != new_routing_id && frame_host) { | 938 if (IsAttached() && sender->GetRoutingID() != new_routing_id && frame_host) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 943 RenderFrameHost* host) { | 950 RenderFrameHost* host) { |
| 944 return (current_ && current_->host() == host) || | 951 return (current_ && current_->host() == host) || |
| 945 (pending_ && pending_->host() == host); | 952 (pending_ && pending_->host() == host); |
| 946 } | 953 } |
| 947 | 954 |
| 948 bool RenderFrameDevToolsAgentHost::IsChildFrame() { | 955 bool RenderFrameDevToolsAgentHost::IsChildFrame() { |
| 949 return current_ && current_->host()->GetParent(); | 956 return current_ && current_->host()->GetParent(); |
| 950 } | 957 } |
| 951 | 958 |
| 952 } // namespace content | 959 } // namespace content |
| OLD | NEW |