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

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

Issue 2733293004: Override CloseContents in HeadlessWebContentsImpl Delegate so that the json/close endpoint works wi… (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..168da5d68bf471675a7b325f39073ba5cc0a2275 100644
--- a/headless/lib/browser/headless_web_contents_impl.cc
+++ b/headless/lib/browser/headless_web_contents_impl.cc
@@ -102,6 +102,19 @@ class HeadlessWebContentsImpl::Delegate : public content::WebContentsDelegate {
contents->GetRenderViewHost()->GetWidget()->Focus();
}
+ void CloseContents(content::WebContents* source) override {
+ std::vector<HeadlessWebContents*> allContents =
Sami 2017/03/08 10:47:24 s/allContents/all_contents/
+ browser_context_->GetAllWebContents();
+
+ for (HeadlessWebContents* wc : allContents) {
+ HeadlessWebContentsImpl* hwc = HeadlessWebContentsImpl::From(wc);
+ if (hwc->web_contents() == source) {
+ wc->Close();
+ return;
+ }
+ }
+ }
+
private:
HeadlessBrowserContextImpl* browser_context_; // Not owned.
DISALLOW_COPY_AND_ASSIGN(Delegate);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698