| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/protocol/target_handler.h" | 5 #include "content/browser/devtools/protocol/target_handler.h" |
| 6 | 6 |
| 7 #include "content/browser/devtools/devtools_manager.h" | 7 #include "content/browser/devtools/devtools_manager.h" |
| 8 #include "content/browser/devtools/service_worker_devtools_agent_host.h" | 8 #include "content/browser/devtools/service_worker_devtools_agent_host.h" |
| 9 #include "content/browser/frame_host/frame_tree.h" | 9 #include "content/browser/frame_host/frame_tree.h" |
| 10 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 for (const auto& id_host : copy) | 248 for (const auto& id_host : copy) |
| 249 TargetDestroyedInternal(id_host.second); | 249 TargetDestroyedInternal(id_host.second); |
| 250 } | 250 } |
| 251 return Response::OK(); | 251 return Response::OK(); |
| 252 } | 252 } |
| 253 | 253 |
| 254 Response TargetHandler::SetAutoAttach( | 254 Response TargetHandler::SetAutoAttach( |
| 255 bool auto_attach, bool wait_for_debugger_on_start) { | 255 bool auto_attach, bool wait_for_debugger_on_start) { |
| 256 wait_for_debugger_on_start_ = wait_for_debugger_on_start; | 256 wait_for_debugger_on_start_ = wait_for_debugger_on_start; |
| 257 if (auto_attach_ == auto_attach) | 257 if (auto_attach_ == auto_attach) |
| 258 return Response::OK(); | 258 return Response::FallThrough(); |
| 259 auto_attach_ = auto_attach; | 259 auto_attach_ = auto_attach; |
| 260 if (auto_attach_) { | 260 if (auto_attach_) { |
| 261 ServiceWorkerDevToolsManager::GetInstance()->AddObserver(this); | 261 ServiceWorkerDevToolsManager::GetInstance()->AddObserver(this); |
| 262 UpdateServiceWorkers(); | 262 UpdateServiceWorkers(); |
| 263 UpdateFrames(); | 263 UpdateFrames(); |
| 264 } else { | 264 } else { |
| 265 ServiceWorkerDevToolsManager::GetInstance()->RemoveObserver(this); | 265 ServiceWorkerDevToolsManager::GetInstance()->RemoveObserver(this); |
| 266 HostsMap empty; | 266 HostsMap empty; |
| 267 ReattachTargetsOfType(empty, DevToolsAgentHost::kTypeFrame, false); | 267 ReattachTargetsOfType(empty, DevToolsAgentHost::kTypeFrame, false); |
| 268 ReattachTargetsOfType(empty, DevToolsAgentHost::kTypeServiceWorker, false); | 268 ReattachTargetsOfType(empty, DevToolsAgentHost::kTypeServiceWorker, false); |
| 269 } | 269 } |
| 270 return Response::OK(); | 270 return Response::FallThrough(); |
| 271 } | 271 } |
| 272 | 272 |
| 273 Response TargetHandler::SetAttachToFrames(bool value) { | 273 Response TargetHandler::SetAttachToFrames(bool value) { |
| 274 if (attach_to_frames_ == value) | 274 if (attach_to_frames_ == value) |
| 275 return Response::OK(); | 275 return Response::OK(); |
| 276 attach_to_frames_ = value; | 276 attach_to_frames_ = value; |
| 277 if (attach_to_frames_) { | 277 if (attach_to_frames_) { |
| 278 UpdateFrames(); | 278 UpdateFrames(); |
| 279 } else { | 279 } else { |
| 280 HostsMap empty; | 280 HostsMap empty; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 306 DevToolsAgentHost* agent_host = it->second.get(); | 306 DevToolsAgentHost* agent_host = it->second.get(); |
| 307 DetachFromTargetInternal(agent_host); | 307 DetachFromTargetInternal(agent_host); |
| 308 return Response::OK(); | 308 return Response::OK(); |
| 309 } | 309 } |
| 310 | 310 |
| 311 Response TargetHandler::SendMessageToTarget( | 311 Response TargetHandler::SendMessageToTarget( |
| 312 const std::string& target_id, | 312 const std::string& target_id, |
| 313 const std::string& message) { | 313 const std::string& message) { |
| 314 auto it = attached_hosts_.find(target_id); | 314 auto it = attached_hosts_.find(target_id); |
| 315 if (it == attached_hosts_.end()) | 315 if (it == attached_hosts_.end()) |
| 316 return Response::InternalError("Not attached to the target"); | 316 return Response::FallThrough(); |
| 317 it->second->DispatchProtocolMessage(this, message); | 317 it->second->DispatchProtocolMessage(this, message); |
| 318 return Response::OK(); | 318 return Response::OK(); |
| 319 } | 319 } |
| 320 | 320 |
| 321 Response TargetHandler::GetTargetInfo( | 321 Response TargetHandler::GetTargetInfo( |
| 322 const std::string& target_id, | 322 const std::string& target_id, |
| 323 scoped_refptr<TargetInfo>* target_info) { | 323 scoped_refptr<TargetInfo>* target_info) { |
| 324 // TODO(dgozman): only allow reported hosts. | 324 // TODO(dgozman): only allow reported hosts. |
| 325 scoped_refptr<DevToolsAgentHost> agent_host( | 325 scoped_refptr<DevToolsAgentHost> agent_host( |
| 326 DevToolsAgentHost::GetForId(target_id)); | 326 DevToolsAgentHost::GetForId(target_id)); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 } | 458 } |
| 459 | 459 |
| 460 void TargetHandler::WorkerDestroyed( | 460 void TargetHandler::WorkerDestroyed( |
| 461 ServiceWorkerDevToolsAgentHost* host) { | 461 ServiceWorkerDevToolsAgentHost* host) { |
| 462 UpdateServiceWorkers(); | 462 UpdateServiceWorkers(); |
| 463 } | 463 } |
| 464 | 464 |
| 465 } // namespace target | 465 } // namespace target |
| 466 } // namespace devtools | 466 } // namespace devtools |
| 467 } // namespace content | 467 } // namespace content |
| OLD | NEW |