| 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/devtools_session.h" | 5 #include "content/browser/devtools/devtools_session.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "content/browser/devtools/devtools_agent_host_impl.h" | 9 #include "content/browser/devtools/devtools_agent_host_impl.h" |
| 10 #include "content/browser/devtools/devtools_manager.h" | 10 #include "content/browser/devtools/devtools_manager.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 for (auto& pair : handlers_) | 43 for (auto& pair : handlers_) |
| 44 pair.second->SetRenderFrameHost(host_); | 44 pair.second->SetRenderFrameHost(host_); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void DevToolsSession::SetFallThroughForNotFound(bool value) { | 47 void DevToolsSession::SetFallThroughForNotFound(bool value) { |
| 48 dispatcher_->setFallThroughForNotFound(value); | 48 dispatcher_->setFallThroughForNotFound(value); |
| 49 } | 49 } |
| 50 | 50 |
| 51 protocol::Response::Status DevToolsSession::Dispatch( | 51 protocol::Response::Status DevToolsSession::Dispatch( |
| 52 const std::string& message, | 52 const std::string& message, |
| 53 bool offer_to_delegate, | |
| 54 int* call_id, | 53 int* call_id, |
| 55 std::string* method) { | 54 std::string* method) { |
| 56 std::unique_ptr<base::Value> value = base::JSONReader::Read(message); | 55 std::unique_ptr<base::Value> value = base::JSONReader::Read(message); |
| 57 | 56 |
| 58 DevToolsManagerDelegate* delegate = offer_to_delegate ? | 57 DevToolsManagerDelegate* delegate = |
| 59 DevToolsManager::GetInstance()->delegate() : nullptr; | 58 DevToolsManager::GetInstance()->delegate(); |
| 60 if (value && value->IsType(base::Value::Type::DICTIONARY) && delegate) { | 59 if (value && value->IsType(base::Value::Type::DICTIONARY) && delegate) { |
| 61 std::unique_ptr<base::DictionaryValue> response(delegate->HandleCommand( | 60 std::unique_ptr<base::DictionaryValue> response(delegate->HandleCommand( |
| 62 agent_host_, | 61 agent_host_, |
| 63 static_cast<base::DictionaryValue*>(value.get()))); | 62 static_cast<base::DictionaryValue*>(value.get()))); |
| 64 if (response) { | 63 if (response) { |
| 65 std::string json; | 64 std::string json; |
| 66 base::JSONWriter::Write(*response.get(), &json); | 65 base::JSONWriter::Write(*response.get(), &json); |
| 67 agent_host_->SendMessageToClient(session_id_, json); | 66 agent_host_->SendMessageToClient(session_id_, json); |
| 68 return protocol::Response::kSuccess; | 67 return protocol::Response::kSuccess; |
| 69 } | 68 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 89 | 88 |
| 90 protocol::DevToolsDomainHandler* DevToolsSession::GetHandlerByName( | 89 protocol::DevToolsDomainHandler* DevToolsSession::GetHandlerByName( |
| 91 const std::string& name) { | 90 const std::string& name) { |
| 92 auto it = handlers_.find(name); | 91 auto it = handlers_.find(name); |
| 93 if (it == handlers_.end()) | 92 if (it == handlers_.end()) |
| 94 return nullptr; | 93 return nullptr; |
| 95 return it->second.get(); | 94 return it->second.get(); |
| 96 } | 95 } |
| 97 | 96 |
| 98 } // namespace content | 97 } // namespace content |
| OLD | NEW |