Chromium Code Reviews| 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) { |
|
nasko
2016/08/08 20:57:06
nit: Isn't fatal also const?
estark
2016/08/09 05:35:01
n/a per your hangout :)
|
| + content::WebContents* web_contents = web_contents_getter.Run(); |
| + std::unique_ptr<SSLErrorHandler> handler(new SSLErrorHandler( |
|
nasko
2016/08/08 20:57:06
nit: I'd construct the handler first, since it is
estark
2016/08/09 05:35:01
Ah, unfortunately no can do, since I'm passing it
|
| + 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 |