Index: headless/lib/browser/headless_browser_impl.cc |
diff --git a/headless/lib/browser/headless_browser_impl.cc b/headless/lib/browser/headless_browser_impl.cc |
index 747639ca3f68c116562f531cef63a57c8e19a0b6..c21bb2cafc747159bf0f2b299da43d9754b0cff1 100644 |
--- a/headless/lib/browser/headless_browser_impl.cc |
+++ b/headless/lib/browser/headless_browser_impl.cc |
@@ -13,11 +13,13 @@ |
#include "base/threading/thread_task_runner_handle.h" |
#include "content/public/app/content_main.h" |
#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/devtools_agent_host.h" |
#include "content/public/browser/web_contents.h" |
#include "content/public/common/content_switches.h" |
#include "headless/app/headless_shell_switches.h" |
#include "headless/lib/browser/headless_browser_context_impl.h" |
#include "headless/lib/browser/headless_browser_main_parts.h" |
+#include "headless/lib/browser/headless_devtools_client_impl.h" |
#include "headless/lib/browser/headless_web_contents_impl.h" |
#include "headless/lib/headless_content_main_delegate.h" |
#include "net/http/http_util.h" |
@@ -32,6 +34,10 @@ |
#include "sandbox/win/src/sandbox_types.h" |
#endif |
+namespace content { |
+class DevToolsAgentHost; |
+} |
+ |
namespace headless { |
namespace { |
@@ -67,6 +73,7 @@ HeadlessBrowserImpl::HeadlessBrowserImpl( |
options_(std::move(options)), |
browser_main_parts_(nullptr), |
default_browser_context_(nullptr), |
+ agent_host_(nullptr), |
weak_ptr_factory_(this) {} |
HeadlessBrowserImpl::~HeadlessBrowserImpl() {} |
@@ -133,6 +140,10 @@ void HeadlessBrowserImpl::set_browser_main_parts( |
} |
void HeadlessBrowserImpl::RunOnStartCallback() { |
+ // We don't support the tethering domain on this agent host. |
+ agent_host_ = content::DevToolsAgentHost::CreateForBrowser( |
+ nullptr, content::DevToolsAgentHost::CreateServerSocketCallback()); |
+ |
PlatformCreateWindow(); |
on_start_callback_.Run(this); |
on_start_callback_ = base::Callback<void(HeadlessBrowser*)>(); |
@@ -200,6 +211,32 @@ HeadlessBrowserContext* HeadlessBrowserImpl::GetBrowserContextForId( |
return find_it->second.get(); |
} |
+HeadlessDevToolsTarget* HeadlessBrowserImpl::GetDevToolsTarget() { |
+ return agent_host_ ? this : nullptr; |
+} |
+ |
+bool HeadlessBrowserImpl::AttachClient(HeadlessDevToolsClient* client) { |
+ DCHECK(agent_host_); |
+ return HeadlessDevToolsClientImpl::From(client)->AttachToHost( |
+ agent_host_.get()); |
+} |
+ |
+void HeadlessBrowserImpl::ForceAttachClient(HeadlessDevToolsClient* client) { |
+ DCHECK(agent_host_); |
+ HeadlessDevToolsClientImpl::From(client)->ForceAttachToHost( |
+ agent_host_.get()); |
+} |
+ |
+void HeadlessBrowserImpl::DetachClient(HeadlessDevToolsClient* client) { |
+ DCHECK(agent_host_); |
+ HeadlessDevToolsClientImpl::From(client)->DetachFromHost(agent_host_.get()); |
+} |
+ |
+bool HeadlessBrowserImpl::IsAttached() { |
+ DCHECK(agent_host_); |
+ return agent_host_->IsAttached(); |
+} |
+ |
void RunChildProcessIfNeeded(int argc, const char** argv) { |
base::CommandLine::Init(argc, argv); |
const base::CommandLine& command_line( |