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

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: Fixed a nullptr issue 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..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);
« 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