Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / browsing_data / mock_browsing_data_server_bound_cert_helper.cc
blob85a02b9fcc1afbf77f48206f95129961a68a71a3
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.
5 #include "chrome/browser/browsing_data/mock_browsing_data_server_bound_cert_helper.h"
7 #include "base/logging.h"
9 MockBrowsingDataServerBoundCertHelper::MockBrowsingDataServerBoundCertHelper()
10 : BrowsingDataServerBoundCertHelper() {}
12 MockBrowsingDataServerBoundCertHelper::
13 ~MockBrowsingDataServerBoundCertHelper() {}
15 void MockBrowsingDataServerBoundCertHelper::StartFetching(
16 const FetchResultCallback& callback) {
17 callback_ = callback;
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;
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, base::Time(), base::Time(), "key", "cert"));
32 server_bound_certs_[server_id] = true;
35 void MockBrowsingDataServerBoundCertHelper::Notify() {
36 net::ServerBoundCertStore::ServerBoundCertList cert_list;
37 for (net::ServerBoundCertStore::ServerBoundCertList::iterator i =
38 server_bound_cert_list_.begin();
39 i != server_bound_cert_list_.end(); ++i) {
40 if (server_bound_certs_[i->server_identifier()])
41 cert_list.push_back(*i);
43 callback_.Run(cert_list);
46 void MockBrowsingDataServerBoundCertHelper::Reset() {
47 for (std::map<const std::string, bool>::iterator i =
48 server_bound_certs_.begin();
49 i != server_bound_certs_.end(); ++i)
50 i->second = true;
53 bool MockBrowsingDataServerBoundCertHelper::AllDeleted() {
54 for (std::map<const std::string, bool>::const_iterator i =
55 server_bound_certs_.begin();
56 i != server_bound_certs_.end(); ++i)
57 if (i->second)
58 return false;
59 return true;