OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/mock_browsing_data_server_bound_cert_helper.h" | |
6 | |
7 #include "base/logging.h" | |
8 | |
9 MockBrowsingDataServerBoundCertHelper::MockBrowsingDataServerBoundCertHelper() | |
10 : BrowsingDataServerBoundCertHelper() {} | |
11 | |
12 MockBrowsingDataServerBoundCertHelper:: | |
13 ~MockBrowsingDataServerBoundCertHelper() {} | |
14 | |
15 void MockBrowsingDataServerBoundCertHelper::StartFetching( | |
16 const FetchResultCallback& callback) { | |
17 callback_ = callback; | |
18 } | |
19 | |
20 void MockBrowsingDataServerBoundCertHelper::DeleteServerBoundCert( | |
21 const std::string& server_id) { | |
22 CHECK(server_bound_certs_.find(server_id) != server_bound_certs_.end()); | |
23 server_bound_certs_[server_id] = false; | |
24 } | |
25 | |
26 void MockBrowsingDataServerBoundCertHelper::AddServerBoundCertSample( | |
27 const std::string& server_id) { | |
28 DCHECK(server_bound_certs_.find(server_id) == server_bound_certs_.end()); | |
29 server_bound_cert_list_.push_back( | |
30 net::ServerBoundCertStore::ServerBoundCert( | |
31 server_id, net::CLIENT_CERT_ECDSA_SIGN, | |
32 base::Time(), base::Time(), "key", "cert")); | |
33 server_bound_certs_[server_id] = true; | |
34 } | |
35 | |
36 void MockBrowsingDataServerBoundCertHelper::Notify() { | |
37 net::ServerBoundCertStore::ServerBoundCertList cert_list; | |
38 for (net::ServerBoundCertStore::ServerBoundCertList::iterator i = | |
39 server_bound_cert_list_.begin(); | |
40 i != server_bound_cert_list_.end(); ++i) { | |
41 if (server_bound_certs_[i->server_identifier()]) | |
42 cert_list.push_back(*i); | |
43 } | |
44 callback_.Run(cert_list); | |
45 } | |
46 | |
47 void MockBrowsingDataServerBoundCertHelper::Reset() { | |
48 for (std::map<const std::string, bool>::iterator i = | |
49 server_bound_certs_.begin(); | |
50 i != server_bound_certs_.end(); ++i) | |
51 i->second = true; | |
52 } | |
53 | |
54 bool MockBrowsingDataServerBoundCertHelper::AllDeleted() { | |
55 for (std::map<const std::string, bool>::const_iterator i = | |
56 server_bound_certs_.begin(); | |
57 i != server_bound_certs_.end(); ++i) | |
58 if (i->second) | |
59 return false; | |
60 return true; | |
61 } | |
OLD | NEW |