| 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/browser_handler.h" | 5 #include "content/browser/devtools/protocol/browser_handler.h" |
| 6 | 6 |
| 7 #include "content/browser/devtools/devtools_manager.h" |
| 8 #include "content/public/browser/devtools_manager_delegate.h" |
| 9 |
| 7 namespace content { | 10 namespace content { |
| 8 namespace devtools { | 11 namespace devtools { |
| 9 namespace browser { | 12 namespace browser { |
| 10 | 13 |
| 11 using Response = DevToolsProtocolClient::Response; | 14 using Response = DevToolsProtocolClient::Response; |
| 12 | 15 |
| 13 BrowserHandler::BrowserHandler() { | 16 BrowserHandler::BrowserHandler() { |
| 14 } | 17 } |
| 15 | 18 |
| 16 BrowserHandler::~BrowserHandler() { | 19 BrowserHandler::~BrowserHandler() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 31 // For layering reasons this needs to be handled by | 34 // For layering reasons this needs to be handled by |
| 32 // DevToolsManagerDelegate::HandleCommand. | 35 // DevToolsManagerDelegate::HandleCommand. |
| 33 return Response::ServerError("Not supported"); | 36 return Response::ServerError("Not supported"); |
| 34 } | 37 } |
| 35 | 38 |
| 36 Response BrowserHandler::CreateTarget(const std::string& url, | 39 Response BrowserHandler::CreateTarget(const std::string& url, |
| 37 const int* width, | 40 const int* width, |
| 38 const int* height, | 41 const int* height, |
| 39 const std::string* context_id, | 42 const std::string* context_id, |
| 40 std::string* out_target_id) { | 43 std::string* out_target_id) { |
| 41 // For layering reasons this needs to be handled by | 44 DevToolsManagerDelegate* delegate = |
| 42 // DevToolsManagerDelegate::HandleCommand. | 45 DevToolsManager::GetInstance()->delegate(); |
| 43 return Response::ServerError("Not supported"); | 46 if (!delegate) |
| 47 return Response::ServerError("Not supported"); |
| 48 scoped_refptr<content::DevToolsAgentHost> agent_host = |
| 49 delegate->CreateNewTarget(GURL(url)); |
| 50 if (!agent_host) |
| 51 return Response::ServerError("Not supported"); |
| 52 *out_target_id = agent_host->GetId(); |
| 53 return Response::OK(); |
| 44 } | 54 } |
| 45 | 55 |
| 46 Response BrowserHandler::CloseTarget(const std::string& target_id, | 56 Response BrowserHandler::CloseTarget(const std::string& target_id, |
| 47 bool* out_success) { | 57 bool* out_success) { |
| 48 scoped_refptr<DevToolsAgentHost> agent_host = | 58 scoped_refptr<DevToolsAgentHost> agent_host = |
| 49 DevToolsAgentHost::GetForId(target_id); | 59 DevToolsAgentHost::GetForId(target_id); |
| 50 if (!agent_host) | 60 if (!agent_host) |
| 51 return Response::ServerError("No target with given id found"); | 61 return Response::ServerError("No target with given id found"); |
| 52 *out_success = agent_host->Close(); | 62 *out_success = agent_host->Close(); |
| 53 return Response::OK(); | 63 return Response::OK(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 set_message(message)); | 116 set_message(message)); |
| 107 } | 117 } |
| 108 | 118 |
| 109 void BrowserHandler::AgentHostClosed(DevToolsAgentHost* agent_host, | 119 void BrowserHandler::AgentHostClosed(DevToolsAgentHost* agent_host, |
| 110 bool replaced_with_another_client) { | 120 bool replaced_with_another_client) { |
| 111 } | 121 } |
| 112 | 122 |
| 113 } // namespace browser | 123 } // namespace browser |
| 114 } // namespace devtools | 124 } // namespace devtools |
| 115 } // namespace content | 125 } // namespace content |
| OLD | NEW |