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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ssl/ssl_error_handler.h" 5 #include "chrome/browser/ssl/ssl_error_handler.h"
6 6
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 DCHECK(!callback || !callback->is_null()); 119 DCHECK(!callback || !callback->is_null());
120 g_timer_started_callback = callback; 120 g_timer_started_callback = callback;
121 } 121 }
122 122
123 SSLErrorHandler::SSLErrorHandler(content::WebContents* web_contents, 123 SSLErrorHandler::SSLErrorHandler(content::WebContents* web_contents,
124 int cert_error, 124 int cert_error,
125 const net::SSLInfo& ssl_info, 125 const net::SSLInfo& ssl_info,
126 const GURL& request_url, 126 const GURL& request_url,
127 int options_mask, 127 int options_mask,
128 const base::Callback<void(bool)>& callback) 128 const base::Callback<void(bool)>& callback)
129 : web_contents_(web_contents), 129 : content::WebContentsObserver(web_contents),
130 web_contents_(web_contents),
130 cert_error_(cert_error), 131 cert_error_(cert_error),
131 ssl_info_(ssl_info), 132 ssl_info_(ssl_info),
132 request_url_(request_url), 133 request_url_(request_url),
133 options_mask_(options_mask), 134 options_mask_(options_mask),
134 callback_(callback) { 135 callback_(callback) {
135 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 136 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
136 Profile* profile = Profile::FromBrowserContext( 137 Profile* profile = Profile::FromBrowserContext(
137 web_contents->GetBrowserContext()); 138 web_contents->GetBrowserContext());
138 registrar_.Add(this, 139 registrar_.Add(this,
139 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, 140 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 timer_.Stop(); 217 timer_.Stop();
217 CaptivePortalService::Results* results = 218 CaptivePortalService::Results* results =
218 content::Details<CaptivePortalService::Results>(details).ptr(); 219 content::Details<CaptivePortalService::Results>(details).ptr();
219 if (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL) 220 if (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL)
220 ShowCaptivePortalInterstitial(results->landing_url); 221 ShowCaptivePortalInterstitial(results->landing_url);
221 else 222 else
222 ShowSSLInterstitial(); 223 ShowSSLInterstitial();
223 } 224 }
224 #endif 225 #endif
225 } 226 }
227
228 // Destroy the error handler on all new navigations. This ensures that the
229 // handler is properly recreated when a hanging page is navigated to an SSL
230 // error, even when the tab's WebContents doesn't change.
231 void SSLErrorHandler::DidStartNavigationToPendingEntry(
232 const GURL& url,
233 content::NavigationController::ReloadType reload_type) {
234 // Need to explicity deny the certificate via the callback, otherwise memory
235 // is leaked.
236 if (!callback_.is_null()) {
237 callback_.Run(false);
238 callback_.Reset();
mmenke 2015/03/20 13:33:50 base::ResetAndReturn(callback_).Run(false)? That
meacer 2015/03/20 17:46:01 Done.
239 }
240 web_contents_->RemoveUserData(UserDataKey());
241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698