Prevent app list doodle from being pinch-to-zoomed.
[chromium-blink-merge.git] / net / cert / mock_cert_verifier.h
blob1ccfe6221b73f0c79d4ba46def35ed353674a26d
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 #ifndef NET_CERT_MOCK_CERT_VERIFIER_H_
6 #define NET_CERT_MOCK_CERT_VERIFIER_H_
8 #include <list>
10 #include "net/cert/cert_verifier.h"
11 #include "net/cert/cert_verify_result.h"
13 namespace net {
15 class MockCertVerifier : public CertVerifier {
16 public:
17 // Creates a new MockCertVerifier. By default, any call to Verify() will
18 // result in the cert status being flagged as CERT_STATUS_INVALID and return
19 // an ERR_CERT_INVALID network error code. This behaviour can be overridden
20 // by calling set_default_result() to change the default return value for
21 // Verify() or by calling one of the AddResult*() methods to specifically
22 // handle a certificate or certificate and host.
23 MockCertVerifier();
25 ~MockCertVerifier() override;
27 // CertVerifier implementation
28 int Verify(X509Certificate* cert,
29 const std::string& hostname,
30 const std::string& ocsp_response,
31 int flags,
32 CRLSet* crl_set,
33 CertVerifyResult* verify_result,
34 const CompletionCallback& callback,
35 RequestHandle* out_req,
36 const BoundNetLog& net_log) override;
37 void CancelRequest(RequestHandle req) override;
39 // Sets the default return value for Verify() for certificates/hosts that do
40 // not have explicit results added via the AddResult*() methods.
41 void set_default_result(int default_result) {
42 default_result_ = default_result;
45 // Adds a rule that will cause any call to Verify() for |cert| to return rv,
46 // copying |verify_result| into the verified result.
47 // Note: Only the primary certificate of |cert| is checked. Any intermediate
48 // certificates will be ignored.
49 void AddResultForCert(X509Certificate* cert,
50 const CertVerifyResult& verify_result,
51 int rv);
53 // Same as AddResultForCert(), but further restricts it to only return for
54 // hostnames that match |host_pattern|.
55 void AddResultForCertAndHost(X509Certificate* cert,
56 const std::string& host_pattern,
57 const CertVerifyResult& verify_result,
58 int rv);
60 private:
61 struct Rule;
62 typedef std::list<Rule> RuleList;
64 int default_result_;
65 RuleList rules_;
68 } // namespace net
70 #endif // NET_CERT_MOCK_CERT_VERIFIER_H_