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

Side by Side Diff: headless/lib/browser/headless_web_contents_impl.cc

Issue 2531313002: Expose the full API for attaching devtools clients: (Closed)
Patch Set: Addressed code review comments Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "headless/lib/browser/headless_web_contents_impl.h" 5 #include "headless/lib/browser/headless_web_contents_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 void HeadlessWebContentsImpl::RenderProcessHostDestroyed( 233 void HeadlessWebContentsImpl::RenderProcessHostDestroyed(
234 content::RenderProcessHost* host) { 234 content::RenderProcessHost* host) {
235 DCHECK_EQ(render_process_host_, host); 235 DCHECK_EQ(render_process_host_, host);
236 render_process_host_ = nullptr; 236 render_process_host_ = nullptr;
237 } 237 }
238 238
239 HeadlessDevToolsTarget* HeadlessWebContentsImpl::GetDevToolsTarget() { 239 HeadlessDevToolsTarget* HeadlessWebContentsImpl::GetDevToolsTarget() {
240 return web_contents()->GetMainFrame()->IsRenderFrameLive() ? this : nullptr; 240 return web_contents()->GetMainFrame()->IsRenderFrameLive() ? this : nullptr;
241 } 241 }
242 242
243 void HeadlessWebContentsImpl::AttachClient(HeadlessDevToolsClient* client) { 243 bool HeadlessWebContentsImpl::AttachClient(HeadlessDevToolsClient* client) {
244 HeadlessDevToolsClientImpl::From(client)->AttachToHost(agent_host_.get()); 244 return HeadlessDevToolsClientImpl::From(client)->AttachToHost(
245 agent_host_.get());
246 }
247
248 void HeadlessWebContentsImpl::ForceAttachClient(
249 HeadlessDevToolsClient* client) {
250 HeadlessDevToolsClientImpl::From(client)->ForceAttachToHost(
251 agent_host_.get());
245 } 252 }
246 253
247 void HeadlessWebContentsImpl::DetachClient(HeadlessDevToolsClient* client) { 254 void HeadlessWebContentsImpl::DetachClient(HeadlessDevToolsClient* client) {
248 DCHECK(agent_host_); 255 DCHECK(agent_host_);
249 HeadlessDevToolsClientImpl::From(client)->DetachFromHost(agent_host_.get()); 256 HeadlessDevToolsClientImpl::From(client)->DetachFromHost(agent_host_.get());
250 } 257 }
251 258
259 bool HeadlessWebContentsImpl::IsAttached() {
260 DCHECK(agent_host_);
261 return agent_host_->IsAttached();
262 }
263
252 content::WebContents* HeadlessWebContentsImpl::web_contents() const { 264 content::WebContents* HeadlessWebContentsImpl::web_contents() const {
253 return web_contents_.get(); 265 return web_contents_.get();
254 } 266 }
255 267
256 HeadlessBrowserImpl* HeadlessWebContentsImpl::browser() const { 268 HeadlessBrowserImpl* HeadlessWebContentsImpl::browser() const {
257 return browser_context_->browser(); 269 return browser_context_->browser();
258 } 270 }
259 271
260 HeadlessBrowserContextImpl* HeadlessWebContentsImpl::browser_context() const { 272 HeadlessBrowserContextImpl* HeadlessWebContentsImpl::browser_context() const {
261 return browser_context_; 273 return browser_context_;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 HeadlessWebContents::Builder::MojoService::MojoService() {} 309 HeadlessWebContents::Builder::MojoService::MojoService() {}
298 310
299 HeadlessWebContents::Builder::MojoService::MojoService( 311 HeadlessWebContents::Builder::MojoService::MojoService(
300 const std::string& service_name, 312 const std::string& service_name,
301 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory) 313 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& service_factory)
302 : service_name(service_name), service_factory(service_factory) {} 314 : service_name(service_name), service_factory(service_factory) {}
303 315
304 HeadlessWebContents::Builder::MojoService::~MojoService() {} 316 HeadlessWebContents::Builder::MojoService::~MojoService() {}
305 317
306 } // namespace headless 318 } // namespace headless
OLDNEW
« no previous file with comments | « headless/lib/browser/headless_web_contents_impl.h ('k') | headless/lib/headless_devtools_client_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698