| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_wrapper.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 11 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 11 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 12 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 12 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 13 #include "content/browser/tab_contents/tab_contents.h" | |
| 14 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/web_contents.h" |
| 15 #include "net/base/cert_database.h" | 15 #include "net/base/cert_database.h" |
| 16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 17 #include "net/base/x509_certificate.h" | 17 #include "net/base/x509_certificate.h" |
| 18 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
| 19 | 19 |
| 20 using content::BrowserThread; | 20 using content::BrowserThread; |
| 21 using content::WebContents; |
| 21 | 22 |
| 22 SSLAddCertHandler::SSLAddCertHandler(net::URLRequest* request, | 23 SSLAddCertHandler::SSLAddCertHandler(net::URLRequest* request, |
| 23 net::X509Certificate* cert, | 24 net::X509Certificate* cert, |
| 24 int render_process_host_id, | 25 int render_process_host_id, |
| 25 int render_view_id) | 26 int render_view_id) |
| 26 : cert_(cert), | 27 : cert_(cert), |
| 27 render_process_host_id_(render_process_host_id), | 28 render_process_host_id_(render_process_host_id), |
| 28 render_view_id_(render_view_id) { | 29 render_view_id_(render_view_id) { |
| 29 ResourceDispatcherHostRequestInfo* info = | 30 ResourceDispatcherHostRequestInfo* info = |
| 30 ResourceDispatcherHost::InfoForRequest(request); | 31 ResourceDispatcherHost::InfoForRequest(request); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 BrowserThread::PostTask( | 80 BrowserThread::PostTask( |
| 80 BrowserThread::UI, FROM_HERE, | 81 BrowserThread::UI, FROM_HERE, |
| 81 base::Bind( | 82 base::Bind( |
| 82 &SSLAddCertHandler::CallAddClientCertificate, this, | 83 &SSLAddCertHandler::CallAddClientCertificate, this, |
| 83 add_cert, cert_error)); | 84 add_cert, cert_error)); |
| 84 | 85 |
| 85 Release(); | 86 Release(); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void SSLAddCertHandler::CallVerifyClientCertificateError(int cert_error) { | 89 void SSLAddCertHandler::CallVerifyClientCertificateError(int cert_error) { |
| 89 TabContents* tab = tab_util::GetTabContentsByID( | 90 WebContents* tab = tab_util::GetWebContentsByID( |
| 90 render_process_host_id_, render_view_id_); | 91 render_process_host_id_, render_view_id_); |
| 91 if (!tab) | 92 if (!tab) |
| 92 return; | 93 return; |
| 93 | 94 |
| 94 TabContentsWrapper* wrapper = | 95 TabContentsWrapper* wrapper = |
| 95 TabContentsWrapper::GetCurrentWrapperForContents(tab); | 96 TabContentsWrapper::GetCurrentWrapperForContents(tab); |
| 96 wrapper->ssl_helper()->OnVerifyClientCertificateError(this, cert_error); | 97 wrapper->ssl_helper()->OnVerifyClientCertificateError(this, cert_error); |
| 97 } | 98 } |
| 98 | 99 |
| 99 void SSLAddCertHandler::CallAddClientCertificate(bool add_cert, | 100 void SSLAddCertHandler::CallAddClientCertificate(bool add_cert, |
| 100 int cert_error) { | 101 int cert_error) { |
| 101 TabContents* tab = tab_util::GetTabContentsByID( | 102 WebContents* tab = tab_util::GetWebContentsByID( |
| 102 render_process_host_id_, render_view_id_); | 103 render_process_host_id_, render_view_id_); |
| 103 if (!tab) | 104 if (!tab) |
| 104 return; | 105 return; |
| 105 | 106 |
| 106 TabContentsWrapper* wrapper = | 107 TabContentsWrapper* wrapper = |
| 107 TabContentsWrapper::GetCurrentWrapperForContents(tab); | 108 TabContentsWrapper::GetCurrentWrapperForContents(tab); |
| 108 if (add_cert) { | 109 if (add_cert) { |
| 109 if (cert_error == net::OK) { | 110 if (cert_error == net::OK) { |
| 110 wrapper->ssl_helper()->OnAddClientCertificateSuccess(this); | 111 wrapper->ssl_helper()->OnAddClientCertificateSuccess(this); |
| 111 } else { | 112 } else { |
| 112 wrapper->ssl_helper()->OnAddClientCertificateError(this, cert_error); | 113 wrapper->ssl_helper()->OnAddClientCertificateError(this, cert_error); |
| 113 } | 114 } |
| 114 } | 115 } |
| 115 wrapper->ssl_helper()->OnAddClientCertificateFinished(this); | 116 wrapper->ssl_helper()->OnAddClientCertificateFinished(this); |
| 116 } | 117 } |
| OLD | NEW |