| 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_client_auth_observer.h" | 5 #include "chrome/browser/ssl/ssl_client_auth_observer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // Stop observing now that the delegate has been resolved. | 60 // Stop observing now that the delegate has been resolved. |
| 61 StopObserving(); | 61 StopObserving(); |
| 62 delegate_.reset(); | 62 delegate_.reset(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void SSLClientAuthObserver::Observe( | 65 void SSLClientAuthObserver::Observe( |
| 66 int type, | 66 int type, |
| 67 const content::NotificationSource& source, | 67 const content::NotificationSource& source, |
| 68 const content::NotificationDetails& details) { | 68 const content::NotificationDetails& details) { |
| 69 DVLOG(1) << "SSLClientAuthObserver::Observe " << this; | 69 DVLOG(1) << "SSLClientAuthObserver::Observe " << this; |
| 70 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 70 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 71 DCHECK(type == chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED); | 71 DCHECK(type == chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED); |
| 72 | 72 |
| 73 CertDetails* cert_details = content::Details<CertDetails>(details).ptr(); | 73 CertDetails* cert_details = content::Details<CertDetails>(details).ptr(); |
| 74 if (!cert_details->first->host_and_port.Equals( | 74 if (!cert_details->first->host_and_port.Equals( |
| 75 cert_request_info_->host_and_port)) | 75 cert_request_info_->host_and_port)) |
| 76 return; | 76 return; |
| 77 | 77 |
| 78 DVLOG(1) << this << " got matching notification and selecting cert " | 78 DVLOG(1) << this << " got matching notification and selecting cert " |
| 79 << cert_details->second; | 79 << cert_details->second; |
| 80 StopObserving(); | 80 StopObserving(); |
| 81 delegate_->ContinueWithCertificate(cert_details->second); | 81 delegate_->ContinueWithCertificate(cert_details->second); |
| 82 delegate_.reset(); | 82 delegate_.reset(); |
| 83 OnCertSelectedByNotification(); | 83 OnCertSelectedByNotification(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void SSLClientAuthObserver::StartObserving() { | 86 void SSLClientAuthObserver::StartObserving() { |
| 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 87 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 88 notification_registrar_.Add( | 88 notification_registrar_.Add( |
| 89 this, chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, | 89 this, chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, |
| 90 content::Source<content::BrowserContext>(browser_context_)); | 90 content::Source<content::BrowserContext>(browser_context_)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void SSLClientAuthObserver::StopObserving() { | 93 void SSLClientAuthObserver::StopObserving() { |
| 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 94 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 95 notification_registrar_.RemoveAll(); | 95 notification_registrar_.RemoveAll(); |
| 96 } | 96 } |
| OLD | NEW |