| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/devtools/chrome_devtools_manager_delegate.h" | 5 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/browser/devtools/devtools_network_protocol_handler.h" | 9 #include "chrome/browser/devtools/devtools_network_protocol_handler.h" |
| 10 #include "chrome/browser/devtools/devtools_window.h" | 10 #include "chrome/browser/devtools/devtools_window.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 ChromeDevToolsManagerDelegate::ChromeDevToolsManagerDelegate() | 31 ChromeDevToolsManagerDelegate::ChromeDevToolsManagerDelegate() |
| 32 : network_protocol_handler_(new DevToolsNetworkProtocolHandler()) { | 32 : network_protocol_handler_(new DevToolsNetworkProtocolHandler()) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 ChromeDevToolsManagerDelegate::~ChromeDevToolsManagerDelegate() { | 35 ChromeDevToolsManagerDelegate::~ChromeDevToolsManagerDelegate() { |
| 36 } | 36 } |
| 37 | 37 |
| 38 void ChromeDevToolsManagerDelegate::Inspect( | 38 void ChromeDevToolsManagerDelegate::Inspect( |
| 39 content::DevToolsAgentHost* agent_host) { | 39 content::DevToolsAgentHost* agent_host) { |
| 40 Profile* profile = | 40 DevToolsWindow::OpenDevToolsWindow(agent_host, nullptr); |
| 41 Profile::FromBrowserContext(agent_host->GetBrowserContext()); | |
| 42 if (!profile) | |
| 43 return; | |
| 44 std::string type = agent_host->GetType(); | |
| 45 if (type == content::DevToolsAgentHost::kTypeSharedWorker || | |
| 46 type == content::DevToolsAgentHost::kTypeServiceWorker) { | |
| 47 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); | |
| 48 return; | |
| 49 } | |
| 50 if (type == content::DevToolsAgentHost::kTypeFrame) { | |
| 51 DevToolsWindow::OpenDevToolsWindow(profile, agent_host); | |
| 52 return; | |
| 53 } | |
| 54 content::WebContents* web_contents = agent_host->GetWebContents(); | |
| 55 if (web_contents) | |
| 56 DevToolsWindow::OpenDevToolsWindow(web_contents); | |
| 57 } | 41 } |
| 58 | 42 |
| 59 base::DictionaryValue* ChromeDevToolsManagerDelegate::HandleCommand( | 43 base::DictionaryValue* ChromeDevToolsManagerDelegate::HandleCommand( |
| 60 content::DevToolsAgentHost* agent_host, | 44 content::DevToolsAgentHost* agent_host, |
| 61 base::DictionaryValue* command_dict) { | 45 base::DictionaryValue* command_dict) { |
| 62 return network_protocol_handler_->HandleCommand(agent_host, command_dict); | 46 return network_protocol_handler_->HandleCommand(agent_host, command_dict); |
| 63 } | 47 } |
| 64 | 48 |
| 65 std::string ChromeDevToolsManagerDelegate::GetTargetType( | 49 std::string ChromeDevToolsManagerDelegate::GetTargetType( |
| 66 content::RenderFrameHost* host) { | 50 content::RenderFrameHost* host) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 std::string ChromeDevToolsManagerDelegate::GetFrontendResource( | 128 std::string ChromeDevToolsManagerDelegate::GetFrontendResource( |
| 145 const std::string& path) { | 129 const std::string& path) { |
| 146 return content::DevToolsFrontendHost::GetFrontendResource(path).as_string(); | 130 return content::DevToolsFrontendHost::GetFrontendResource(path).as_string(); |
| 147 } | 131 } |
| 148 | 132 |
| 149 void ChromeDevToolsManagerDelegate::DevToolsAgentStateChanged( | 133 void ChromeDevToolsManagerDelegate::DevToolsAgentStateChanged( |
| 150 content::DevToolsAgentHost* agent_host, | 134 content::DevToolsAgentHost* agent_host, |
| 151 bool attached) { | 135 bool attached) { |
| 152 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, attached); | 136 network_protocol_handler_->DevToolsAgentStateChanged(agent_host, attached); |
| 153 } | 137 } |
| OLD | NEW |