| Index: content/browser/devtools/devtools_session.cc
|
| diff --git a/content/browser/devtools/devtools_session.cc b/content/browser/devtools/devtools_session.cc
|
| index 60ccb85ebebdd22377769751c2bcd04697f7bb2a..c11aa30fd1111da98c308d01f9ea47ff2aab45b6 100644
|
| --- a/content/browser/devtools/devtools_session.cc
|
| +++ b/content/browser/devtools/devtools_session.cc
|
| @@ -15,26 +15,48 @@ namespace content {
|
|
|
| DevToolsSession::DevToolsSession(
|
| DevToolsAgentHostImpl* agent_host,
|
| + DevToolsAgentHostClient* client,
|
| int session_id)
|
| : agent_host_(agent_host),
|
| + client_(client),
|
| session_id_(session_id),
|
| + host_(nullptr),
|
| dispatcher_(new protocol::UberDispatcher(this)) {
|
| }
|
|
|
| -DevToolsSession::~DevToolsSession() {}
|
| -
|
| -void DevToolsSession::ResetDispatcher() {
|
| +DevToolsSession::~DevToolsSession() {
|
| dispatcher_.reset();
|
| + for (auto& pair : handlers_)
|
| + pair.second->Disable();
|
| + handlers_.clear();
|
| +}
|
| +
|
| +void DevToolsSession::AddHandler(
|
| + std::unique_ptr<protocol::DevToolsDomainHandler> handler) {
|
| + handler->Wire(dispatcher_.get());
|
| + handler->SetRenderFrameHost(host_);
|
| + handlers_[handler->name()] = std::move(handler);
|
| +}
|
| +
|
| +void DevToolsSession::SetRenderFrameHost(RenderFrameHostImpl* host) {
|
| + host_ = host;
|
| + for (auto& pair : handlers_)
|
| + pair.second->SetRenderFrameHost(host_);
|
| +}
|
| +
|
| +void DevToolsSession::SetFallThroughForNotFound(bool value) {
|
| + dispatcher_->setFallThroughForNotFound(value);
|
| }
|
|
|
| protocol::Response::Status DevToolsSession::Dispatch(
|
| const std::string& message,
|
| + bool offer_to_delegate,
|
| int* call_id,
|
| std::string* method) {
|
| std::unique_ptr<base::Value> value = base::JSONReader::Read(message);
|
|
|
| - DevToolsManagerDelegate* delegate =
|
| - DevToolsManager::GetInstance()->delegate();
|
| + DevToolsManagerDelegate* delegate = offer_to_delegate ?
|
| + DevToolsManager::GetInstance()->delegate() : nullptr;
|
| if (value && value->IsType(base::Value::Type::DICTIONARY) && delegate) {
|
| std::unique_ptr<base::DictionaryValue> response(delegate->HandleCommand(
|
| agent_host_,
|
| @@ -65,4 +87,12 @@ void DevToolsSession::sendProtocolNotification(
|
| void DevToolsSession::flushProtocolNotifications() {
|
| }
|
|
|
| +protocol::DevToolsDomainHandler* DevToolsSession::GetHandlerByName(
|
| + const std::string& name) {
|
| + auto it = handlers_.find(name);
|
| + if (it == handlers_.end())
|
| + return nullptr;
|
| + return it->second.get();
|
| +}
|
| +
|
| } // namespace content
|
|
|