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 StopObserving(); | 60 StopObserving(); |
61 delegate_.reset(); | 61 delegate_.reset(); |
62 } | 62 } |
63 | 63 |
64 void SSLClientAuthObserver::Observe( | 64 void SSLClientAuthObserver::Observe( |
65 int type, | 65 int type, |
66 const content::NotificationSource& source, | 66 const content::NotificationSource& source, |
67 const content::NotificationDetails& details) { | 67 const content::NotificationDetails& details) { |
68 DVLOG(1) << "SSLClientAuthObserver::Observe " << this; | 68 DVLOG(1) << "SSLClientAuthObserver::Observe " << this; |
69 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 69 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
70 DCHECK(type == chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED); | 70 DCHECK_EQ(chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, type); |
71 | 71 |
72 CertDetails* cert_details = content::Details<CertDetails>(details).ptr(); | 72 CertDetails* cert_details = content::Details<CertDetails>(details).ptr(); |
73 if (!cert_details->first->host_and_port.Equals( | 73 if (!cert_details->first->host_and_port.Equals( |
74 cert_request_info_->host_and_port)) | 74 cert_request_info_->host_and_port)) |
75 return; | 75 return; |
76 | 76 |
77 DVLOG(1) << this << " got matching notification and selecting cert " | 77 DVLOG(1) << this << " got matching notification and selecting cert " |
78 << cert_details->second; | 78 << cert_details->second; |
79 StopObserving(); | 79 StopObserving(); |
80 delegate_->ContinueWithCertificate(cert_details->second); | 80 delegate_->ContinueWithCertificate(cert_details->second); |
81 delegate_.reset(); | 81 delegate_.reset(); |
82 OnCertSelectedByNotification(); | 82 OnCertSelectedByNotification(); |
83 } | 83 } |
84 | 84 |
85 void SSLClientAuthObserver::StartObserving() { | 85 void SSLClientAuthObserver::StartObserving() { |
86 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 86 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
87 notification_registrar_.Add( | 87 notification_registrar_.Add( |
88 this, chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, | 88 this, chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, |
89 content::Source<content::BrowserContext>(browser_context_)); | 89 content::Source<content::BrowserContext>(browser_context_)); |
90 } | 90 } |
91 | 91 |
92 void SSLClientAuthObserver::StopObserving() { | 92 void SSLClientAuthObserver::StopObserving() { |
93 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 93 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
94 notification_registrar_.RemoveAll(); | 94 notification_registrar_.RemoveAll(); |
95 } | 95 } |
OLD | NEW |