Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Unified Diff: headless/lib/browser/headless_web_contents_impl.cc

Issue 2119063002: Add commands to manage tabs and contexts to Browser Domain (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix name Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: headless/lib/browser/headless_web_contents_impl.cc
diff --git a/headless/lib/browser/headless_web_contents_impl.cc b/headless/lib/browser/headless_web_contents_impl.cc
index b07cb2c7edef0e809b0bd0e3b756426ba09f6c88..0b10161f5cc562fc0652cebb3ef6103a3541a80c 100644
--- a/headless/lib/browser/headless_web_contents_impl.cc
+++ b/headless/lib/browser/headless_web_contents_impl.cc
@@ -27,6 +27,14 @@
namespace headless {
+// static
+HeadlessWebContentsImpl* HeadlessWebContentsImpl::From(
+ HeadlessWebContents* web_contents) {
+ // This downcast is safe because there is only one implementation of
+ // HeadlessWebContents.
+ return static_cast<HeadlessWebContentsImpl*>(web_contents);
+}
+
class WebContentsObserverAdapter : public content::WebContentsObserver {
public:
WebContentsObserverAdapter(content::WebContents* web_contents,
@@ -114,6 +122,7 @@ HeadlessWebContentsImpl::HeadlessWebContentsImpl(
HeadlessBrowserImpl* browser)
: web_contents_delegate_(new HeadlessWebContentsImpl::Delegate(browser)),
web_contents_(web_contents),
+ agent_host_(content::DevToolsAgentHost::GetOrCreateFor(web_contents)),
browser_(browser) {
web_contents_->SetDelegate(web_contents_delegate_.get());
}
@@ -137,6 +146,10 @@ void HeadlessWebContentsImpl::Close() {
browser_->DestroyWebContents(this);
}
+std::string HeadlessWebContentsImpl::GetDevtoolsAgentHostId() {
+ return agent_host_->GetId();
+}
+
void HeadlessWebContentsImpl::AddObserver(Observer* observer) {
DCHECK(observer_map_.find(observer) == observer_map_.end());
observer_map_[observer] = base::WrapUnique(
@@ -154,8 +167,6 @@ HeadlessDevToolsTarget* HeadlessWebContentsImpl::GetDevToolsTarget() {
}
void HeadlessWebContentsImpl::AttachClient(HeadlessDevToolsClient* client) {
- if (!agent_host_)
- agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents());
HeadlessDevToolsClientImpl::From(client)->AttachToHost(agent_host_.get());
}

Powered by Google App Engine
This is Rietveld 408576698