| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_add_cert_handler.h" | 5 #include "chrome/browser/ssl/ssl_add_cert_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" | 8 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" |
| 9 #include "chrome/browser/tab_contents/tab_util.h" | 9 #include "chrome/browser/tab_contents/tab_util.h" |
| 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 AddRef(); | 32 AddRef(); |
| 33 // Delay adding the certificate until the next mainloop iteration. | 33 // Delay adding the certificate until the next mainloop iteration. |
| 34 BrowserThread::PostTask( | 34 BrowserThread::PostTask( |
| 35 BrowserThread::IO, FROM_HERE, | 35 BrowserThread::IO, FROM_HERE, |
| 36 base::Bind(&SSLAddCertHandler::Run, this)); | 36 base::Bind(&SSLAddCertHandler::Run, this)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 SSLAddCertHandler::~SSLAddCertHandler() {} | 39 SSLAddCertHandler::~SSLAddCertHandler() {} |
| 40 | 40 |
| 41 void SSLAddCertHandler::Run() { | 41 void SSLAddCertHandler::Run() { |
| 42 int cert_error; | 42 int cert_error = net::CertDatabase::GetInstance()->CheckUserCert(cert_); |
| 43 { | |
| 44 net::CertDatabase db; | |
| 45 cert_error = db.CheckUserCert(cert_); | |
| 46 } | |
| 47 if (cert_error != net::OK) { | 43 if (cert_error != net::OK) { |
| 48 LOG_IF(ERROR, cert_error == net::ERR_NO_PRIVATE_KEY_FOR_CERT) | 44 LOG_IF(ERROR, cert_error == net::ERR_NO_PRIVATE_KEY_FOR_CERT) |
| 49 << "No corresponding private key in store for cert: " | 45 << "No corresponding private key in store for cert: " |
| 50 << (cert_.get() ? cert_->subject().GetDisplayName() : "NULL"); | 46 << (cert_.get() ? cert_->subject().GetDisplayName() : "NULL"); |
| 51 | 47 |
| 52 BrowserThread::PostTask( | 48 BrowserThread::PostTask( |
| 53 BrowserThread::UI, FROM_HERE, | 49 BrowserThread::UI, FROM_HERE, |
| 54 base::Bind( | 50 base::Bind( |
| 55 &SSLAddCertHandler::CallVerifyClientCertificateError, this, | 51 &SSLAddCertHandler::CallVerifyClientCertificateError, this, |
| 56 cert_error)); | 52 cert_error)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 67 | 63 |
| 68 #if !defined(OS_MACOSX) | 64 #if !defined(OS_MACOSX) |
| 69 void SSLAddCertHandler::AskToAddCert() { | 65 void SSLAddCertHandler::AskToAddCert() { |
| 70 // TODO(snej): Someone should add Windows and GTK implementations with UI. | 66 // TODO(snej): Someone should add Windows and GTK implementations with UI. |
| 71 Finished(true); | 67 Finished(true); |
| 72 } | 68 } |
| 73 #endif | 69 #endif |
| 74 | 70 |
| 75 void SSLAddCertHandler::Finished(bool add_cert) { | 71 void SSLAddCertHandler::Finished(bool add_cert) { |
| 76 int cert_error = net::OK; | 72 int cert_error = net::OK; |
| 77 if (add_cert) { | 73 if (add_cert) |
| 78 net::CertDatabase db; | 74 cert_error = net::CertDatabase::GetInstance()->AddUserCert(cert_); |
| 79 cert_error = db.AddUserCert(cert_); | |
| 80 } | |
| 81 | 75 |
| 82 BrowserThread::PostTask( | 76 BrowserThread::PostTask( |
| 83 BrowserThread::UI, FROM_HERE, | 77 BrowserThread::UI, FROM_HERE, |
| 84 base::Bind( | 78 base::Bind( |
| 85 &SSLAddCertHandler::CallAddClientCertificate, this, | 79 &SSLAddCertHandler::CallAddClientCertificate, this, |
| 86 add_cert, cert_error)); | 80 add_cert, cert_error)); |
| 87 | 81 |
| 88 Release(); | 82 Release(); |
| 89 } | 83 } |
| 90 | 84 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 108 TabContents* tab_contents = TabContents::FromWebContents(tab); | 102 TabContents* tab_contents = TabContents::FromWebContents(tab); |
| 109 if (add_cert) { | 103 if (add_cert) { |
| 110 if (cert_error == net::OK) { | 104 if (cert_error == net::OK) { |
| 111 tab_contents->ssl_helper()->OnAddClientCertificateSuccess(this); | 105 tab_contents->ssl_helper()->OnAddClientCertificateSuccess(this); |
| 112 } else { | 106 } else { |
| 113 tab_contents->ssl_helper()->OnAddClientCertificateError(this, cert_error); | 107 tab_contents->ssl_helper()->OnAddClientCertificateError(this, cert_error); |
| 114 } | 108 } |
| 115 } | 109 } |
| 116 tab_contents->ssl_helper()->OnAddClientCertificateFinished(this); | 110 tab_contents->ssl_helper()->OnAddClientCertificateFinished(this); |
| 117 } | 111 } |
| OLD | NEW |