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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 content::Details<CertDetails>(&details)); | 48 content::Details<CertDetails>(&details)); |
49 | 49 |
50 callback_.Run(certificate); | 50 callback_.Run(certificate); |
51 callback_.Reset(); | 51 callback_.Reset(); |
52 } | 52 } |
53 | 53 |
54 void SSLClientAuthObserver::Observe( | 54 void SSLClientAuthObserver::Observe( |
55 int type, | 55 int type, |
56 const content::NotificationSource& source, | 56 const content::NotificationSource& source, |
57 const content::NotificationDetails& details) { | 57 const content::NotificationDetails& details) { |
58 VLOG(1) << "SSLClientAuthObserver::Observe " << this; | 58 DVLOG(1) << "SSLClientAuthObserver::Observe " << this; |
59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
60 DCHECK(type == chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED); | 60 DCHECK(type == chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED); |
61 | 61 |
62 CertDetails* cert_details = content::Details<CertDetails>(details).ptr(); | 62 CertDetails* cert_details = content::Details<CertDetails>(details).ptr(); |
63 if (!cert_details->first->host_and_port.Equals( | 63 if (!cert_details->first->host_and_port.Equals( |
64 cert_request_info_->host_and_port)) | 64 cert_request_info_->host_and_port)) |
65 return; | 65 return; |
66 | 66 |
67 VLOG(1) << this << " got matching notification and selecting cert " | 67 DVLOG(1) << this << " got matching notification and selecting cert " |
68 << cert_details->second; | 68 << cert_details->second; |
69 StopObserving(); | 69 StopObserving(); |
70 callback_.Run(cert_details->second); | 70 callback_.Run(cert_details->second); |
71 callback_.Reset(); | 71 callback_.Reset(); |
72 OnCertSelectedByNotification(); | 72 OnCertSelectedByNotification(); |
73 } | 73 } |
74 | 74 |
75 void SSLClientAuthObserver::StartObserving() { | 75 void SSLClientAuthObserver::StartObserving() { |
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
77 notification_registrar_.Add( | 77 notification_registrar_.Add( |
78 this, chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, | 78 this, chrome::NOTIFICATION_SSL_CLIENT_AUTH_CERT_SELECTED, |
79 content::Source<content::BrowserContext>(browser_context_)); | 79 content::Source<content::BrowserContext>(browser_context_)); |
80 } | 80 } |
81 | 81 |
82 void SSLClientAuthObserver::StopObserving() { | 82 void SSLClientAuthObserver::StopObserving() { |
83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
84 notification_registrar_.RemoveAll(); | 84 notification_registrar_.RemoveAll(); |
85 } | 85 } |
OLD | NEW |