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

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: removed the call to web_contents_.Close() from the headless web contents destructor. This call caus… 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..42db63f54b4a54db9ff9f3a30e7866ca076fc92d 100644
--- a/headless/lib/browser/headless_web_contents_impl.cc
+++ b/headless/lib/browser/headless_web_contents_impl.cc
@@ -102,6 +102,26 @@ class HeadlessWebContentsImpl::Delegate : public content::WebContentsDelegate {
contents->GetRenderViewHost()->GetWidget()->Focus();
}
+ void CloseContents(content::WebContents* source) override {
+ if (!browser_context_) {
+ return;
+ }
+
+ std::vector<HeadlessWebContents*> all_contents =
+ browser_context_->GetAllWebContents();
+
+ for (HeadlessWebContents* wc : all_contents) {
+ 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);
@@ -157,7 +177,6 @@ HeadlessWebContentsImpl::HeadlessWebContentsImpl(
}
HeadlessWebContentsImpl::~HeadlessWebContentsImpl() {
- web_contents_->Close();
if (render_process_host_)
render_process_host_->RemoveObserver(this);
}
« 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