diff --git content/public/browser/document_service_base.h content/public/browser/document_service_base.h index e92c412a44c62..520338835afa8 100644 --- content/public/browser/document_service_base.h +++ content/public/browser/document_service_base.h @@ -80,6 +80,8 @@ class DocumentServiceBase : public Interface, public WebContentsObserver { void DidFinishNavigation(NavigationHandle* navigation_handle) final { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); + if (!ShouldCloseOnFinishNavigation()) + return; if (!navigation_handle->HasCommitted() || navigation_handle->IsSameDocument() || @@ -98,6 +100,9 @@ class DocumentServiceBase : public Interface, public WebContentsObserver { } } + // Used for CEF bindings that outlive navigation. + virtual bool ShouldCloseOnFinishNavigation() const { return true; } + // Stops observing WebContents and delete |this|. void Close() { DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);