Chromium Code Reviews| 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 710fc84c4c9fe3849bf3da7f42ed82419ba44d11..92df1317fb28038e2c0558c7a642b6b0572dea1d 100644 |
| --- a/headless/lib/browser/headless_web_contents_impl.cc |
| +++ b/headless/lib/browser/headless_web_contents_impl.cc |
| @@ -102,6 +102,22 @@ class HeadlessWebContentsImpl::Delegate : public content::WebContentsDelegate { |
| contents->GetRenderViewHost()->GetWidget()->Focus(); |
| } |
| + void CloseContents(content::WebContents* source) override { |
| + std::vector<HeadlessWebContents*> all_contents = |
| + browser_context_->GetAllWebContents(); |
| + |
| + for (HeadlessWebContents* wc : all_contents) { |
| + if (wc == nullptr) { |
|
Sami
2017/03/13 12:40:28
nit: You can just do "if (!wc)"
|
| + continue; |
| + } |
| + HeadlessWebContentsImpl* hwc = HeadlessWebContentsImpl::From(wc); |
| + if (hwc->web_contents() == source) { |
| + wc->Close(); |
| + return; |
| + } |
| + } |
| + } |
| + |
| private: |
| HeadlessBrowserContextImpl* browser_context_; // Not owned. |
| DISALLOW_COPY_AND_ASSIGN(Delegate); |