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

Unified Diff: chrome/browser/ssl/ssl_error_handler.cc

Issue 1004283004: Destroy SSLErrorHandler on new navigations so that it can properly be recreated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Deny the cert to fix the memory leak Created 5 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
Index: chrome/browser/ssl/ssl_error_handler.cc
diff --git a/chrome/browser/ssl/ssl_error_handler.cc b/chrome/browser/ssl/ssl_error_handler.cc
index c41a7acbaba8984f72d2c70b1e1ea86cfa10395b..edada5b2b2a54826228e333a1e52f13ca1d02d00 100644
--- a/chrome/browser/ssl/ssl_error_handler.cc
+++ b/chrome/browser/ssl/ssl_error_handler.cc
@@ -126,7 +126,8 @@ SSLErrorHandler::SSLErrorHandler(content::WebContents* web_contents,
const GURL& request_url,
int options_mask,
const base::Callback<void(bool)>& callback)
- : web_contents_(web_contents),
+ : content::WebContentsObserver(web_contents),
+ web_contents_(web_contents),
cert_error_(cert_error),
ssl_info_(ssl_info),
request_url_(request_url),
@@ -223,3 +224,18 @@ void SSLErrorHandler::Observe(
}
#endif
}
+
+// Destroy the error handler on all new navigations. This ensures that the
+// handler is properly recreated when a hanging page is navigated to an SSL
+// error, even when the tab's WebContents doesn't change.
+void SSLErrorHandler::DidStartNavigationToPendingEntry(
+ const GURL& url,
+ content::NavigationController::ReloadType reload_type) {
+ // Need to explicity deny the certificate via the callback, otherwise memory
+ // is leaked.
+ if (!callback_.is_null()) {
+ callback_.Run(false);
+ callback_.Reset();
mmenke 2015/03/20 13:33:50 base::ResetAndReturn(callback_).Run(false)? That
meacer 2015/03/20 17:46:01 Done.
+ }
+ web_contents_->RemoveUserData(UserDataKey());
+}

Powered by Google App Engine
This is Rietveld 408576698