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

Unified Diff: content/browser/ssl/ssl_manager.cc

Issue 2213193005: Make SSLErrorHandler UI-thread-only and not-refcounted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove UI-thread dereference for DCHECK Created 4 years, 4 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 | « content/browser/ssl/ssl_error_handler.cc ('k') | content/browser/ssl/ssl_policy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/ssl/ssl_manager.cc
diff --git a/content/browser/ssl/ssl_manager.cc b/content/browser/ssl/ssl_manager.cc
index bcec11679a6e451713bf1442581e70bdbb97f3bc..f4ca569436376dab7e24e70b5fedae096747ce31 100644
--- a/content/browser/ssl/ssl_manager.cc
+++ b/content/browser/ssl/ssl_manager.cc
@@ -44,6 +44,35 @@ class SSLManagerSet : public base::SupportsUserData::Data {
DISALLOW_COPY_AND_ASSIGN(SSLManagerSet);
};
+void HandleSSLErrorOnUI(
+ const base::Callback<WebContents*(void)>& web_contents_getter,
+ const base::WeakPtr<SSLErrorHandler::Delegate>& delegate,
+ const ResourceType resource_type,
+ const GURL& url,
+ const net::SSLInfo& ssl_info,
+ bool fatal) {
+ content::WebContents* web_contents = web_contents_getter.Run();
+ std::unique_ptr<SSLErrorHandler> handler(new SSLErrorHandler(
+ web_contents, delegate, resource_type, url, ssl_info, fatal));
+
+ if (!web_contents) {
+ // Requests can fail to dispatch because they don't have a WebContents. See
+ // https://crbug.com/86537. In this case we have to make a decision in this
+ // function, so we ignore revocation check failures.
+ if (net::IsCertStatusMinorError(ssl_info.cert_status)) {
+ handler->ContinueRequest();
+ } else {
+ handler->CancelRequest();
+ }
+ return;
+ }
+
+ SSLManager* manager =
+ static_cast<NavigationControllerImpl*>(&web_contents->GetController())
+ ->ssl_manager();
+ manager->policy()->OnCertError(std::move(handler));
+}
+
} // namespace
// static
@@ -61,14 +90,12 @@ void SSLManager::OnSSLCertificateError(
<< " url: " << url.spec()
<< " cert_status: " << std::hex << ssl_info.cert_status;
- // A certificate error occurred. Construct a SSLErrorHandler object and
- // hand it over to the UI thread for processing.
+ // A certificate error occurred. Construct a SSLErrorHandler object
+ // on the UI thread for processing.
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
- base::Bind(
- &SSLErrorHandler::Dispatch,
- new SSLErrorHandler(delegate, resource_type, url, ssl_info, fatal),
- web_contents_getter));
+ base::Bind(&HandleSSLErrorOnUI, web_contents_getter, delegate,
+ resource_type, url, ssl_info, fatal));
}
// static
« no previous file with comments | « content/browser/ssl/ssl_error_handler.cc ('k') | content/browser/ssl/ssl_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698