Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SSL_SSL_CERT_ERROR_HANDLER_H_ | |
| 6 #define CHROME_BROWSER_SSL_SSL_CERT_ERROR_HANDLER_H_ | |
| 7 | |
| 8 #include "chrome/browser/ssl/ssl_error_handler.h" | |
| 9 #include "chrome/browser/ssl/ssl_manager.h" | |
| 10 #include "net/base/ssl_info.h" | |
| 11 #include "net/base/x509_certificate.h" | |
| 12 | |
| 13 // A CertError represents an error that occurred with the certificate in an | |
| 14 // SSL session. A CertError object exists both on the IO thread and on the UI | |
| 15 // thread and allows us to cancel/continue a request it is associated with. | |
| 16 class SSLCertErrorHandler : public SSLErrorHandler { | |
| 17 public: | |
| 18 // Construct on the IO thread. | |
| 19 // We mark this method as private because it is tricky to correctly | |
|
jcampan
2009/05/14 17:02:40
It is not private anymore, fix comment?
| |
| 20 // construct a CertError object. | |
| 21 SSLCertErrorHandler(ResourceDispatcherHost* rdh, | |
| 22 URLRequest* request, | |
| 23 ResourceType::Type resource_type, | |
| 24 const std::string& frame_origin, | |
| 25 const std::string& main_frame_origin, | |
| 26 int cert_error, | |
| 27 net::X509Certificate* cert, | |
| 28 MessageLoop* ui_loop) | |
| 29 : SSLErrorHandler(rdh, request, resource_type, frame_origin, | |
| 30 main_frame_origin, ui_loop), | |
| 31 cert_error_(cert_error) { | |
| 32 DCHECK(request == resource_dispatcher_host_->GetURLRequest(request_id_)); | |
| 33 | |
| 34 // We cannot use the request->ssl_info(), it's not been initialized yet, so | |
| 35 // we have to set the fields manually. | |
| 36 ssl_info_.cert = cert; | |
| 37 ssl_info_.SetCertError(cert_error); | |
| 38 } | |
| 39 | |
| 40 virtual SSLCertErrorHandler* AsSSLCertErrorHandler() { return this; } | |
| 41 | |
| 42 // These accessors are available on either thread | |
| 43 const net::SSLInfo& ssl_info() const { return ssl_info_; } | |
| 44 int cert_error() const { return cert_error_; } | |
| 45 | |
| 46 private: | |
| 47 // SSLErrorHandler methods | |
| 48 virtual void OnDispatchFailed() { CancelRequest(); } | |
| 49 virtual void OnDispatched() { manager_->OnCertError(this); } | |
| 50 | |
| 51 // These read-only members may be accessed on any thread. | |
| 52 net::SSLInfo ssl_info_; | |
| 53 const int cert_error_; // The error we represent. | |
| 54 | |
| 55 DISALLOW_COPY_AND_ASSIGN(SSLCertErrorHandler); | |
| 56 }; | |
| 57 | |
| 58 #endif // CHROME_BROWSER_SSL_SSL_CERT_ERROR_HANDLER_H_ | |
| OLD | NEW |