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/ssl/ssl_tab_helper.h" | 8 #include "chrome/browser/ssl/ssl_tab_helper.h" |
9 #include "chrome/browser/tab_contents/tab_util.h" | 9 #include "chrome/browser/tab_contents/tab_util.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 AddRef(); | 31 AddRef(); |
32 // Delay adding the certificate until the next mainloop iteration. | 32 // Delay adding the certificate until the next mainloop iteration. |
33 BrowserThread::PostTask( | 33 BrowserThread::PostTask( |
34 BrowserThread::IO, FROM_HERE, | 34 BrowserThread::IO, FROM_HERE, |
35 base::Bind(&SSLAddCertHandler::Run, this)); | 35 base::Bind(&SSLAddCertHandler::Run, this)); |
36 } | 36 } |
37 | 37 |
38 SSLAddCertHandler::~SSLAddCertHandler() {} | 38 SSLAddCertHandler::~SSLAddCertHandler() {} |
39 | 39 |
40 void SSLAddCertHandler::Run() { | 40 void SSLAddCertHandler::Run() { |
41 int cert_error = net::CertDatabase::GetInstance()->CheckUserCert(cert_); | 41 int cert_error = net::CertDatabase::GetInstance()->CheckUserCert(cert_.get()); |
42 if (cert_error != net::OK) { | 42 if (cert_error != net::OK) { |
43 LOG_IF(ERROR, cert_error == net::ERR_NO_PRIVATE_KEY_FOR_CERT) | 43 LOG_IF(ERROR, cert_error == net::ERR_NO_PRIVATE_KEY_FOR_CERT) |
44 << "No corresponding private key in store for cert: " | 44 << "No corresponding private key in store for cert: " |
45 << (cert_.get() ? cert_->subject().GetDisplayName() : "NULL"); | 45 << (cert_.get() ? cert_->subject().GetDisplayName() : "NULL"); |
46 | 46 |
47 BrowserThread::PostTask( | 47 BrowserThread::PostTask( |
48 BrowserThread::UI, FROM_HERE, | 48 BrowserThread::UI, FROM_HERE, |
49 base::Bind( | 49 base::Bind( |
50 &SSLAddCertHandler::CallVerifyClientCertificateError, this, | 50 &SSLAddCertHandler::CallVerifyClientCertificateError, this, |
51 cert_error)); | 51 cert_error)); |
(...skipping 11 matching lines...) Expand all Loading... |
63 #if !defined(OS_MACOSX) | 63 #if !defined(OS_MACOSX) |
64 void SSLAddCertHandler::AskToAddCert() { | 64 void SSLAddCertHandler::AskToAddCert() { |
65 // TODO(snej): Someone should add Windows and GTK implementations with UI. | 65 // TODO(snej): Someone should add Windows and GTK implementations with UI. |
66 Finished(true); | 66 Finished(true); |
67 } | 67 } |
68 #endif | 68 #endif |
69 | 69 |
70 void SSLAddCertHandler::Finished(bool add_cert) { | 70 void SSLAddCertHandler::Finished(bool add_cert) { |
71 int cert_error = net::OK; | 71 int cert_error = net::OK; |
72 if (add_cert) | 72 if (add_cert) |
73 cert_error = net::CertDatabase::GetInstance()->AddUserCert(cert_); | 73 cert_error = net::CertDatabase::GetInstance()->AddUserCert(cert_.get()); |
74 | 74 |
75 BrowserThread::PostTask( | 75 BrowserThread::PostTask( |
76 BrowserThread::UI, FROM_HERE, | 76 BrowserThread::UI, FROM_HERE, |
77 base::Bind( | 77 base::Bind( |
78 &SSLAddCertHandler::CallAddClientCertificate, this, | 78 &SSLAddCertHandler::CallAddClientCertificate, this, |
79 add_cert, cert_error)); | 79 add_cert, cert_error)); |
80 | 80 |
81 Release(); | 81 Release(); |
82 } | 82 } |
83 | 83 |
(...skipping 17 matching lines...) Expand all Loading... |
101 SSLTabHelper* ssl_tab_helper = SSLTabHelper::FromWebContents(tab); | 101 SSLTabHelper* ssl_tab_helper = SSLTabHelper::FromWebContents(tab); |
102 if (add_cert) { | 102 if (add_cert) { |
103 if (cert_error == net::OK) { | 103 if (cert_error == net::OK) { |
104 ssl_tab_helper->OnAddClientCertificateSuccess(this); | 104 ssl_tab_helper->OnAddClientCertificateSuccess(this); |
105 } else { | 105 } else { |
106 ssl_tab_helper->OnAddClientCertificateError(this, cert_error); | 106 ssl_tab_helper->OnAddClientCertificateError(this, cert_error); |
107 } | 107 } |
108 } | 108 } |
109 ssl_tab_helper->OnAddClientCertificateFinished(this); | 109 ssl_tab_helper->OnAddClientCertificateFinished(this); |
110 } | 110 } |
OLD | NEW |