BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / components / certificate_reporting / error_reporter.h
blob3bfc1d4629892a8b97355dc2b82476852c79281d
1 // Copyright 2015 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 COMPONENTS_CERTIFICATE_REPORTING_CERTIFICATE_ERROR_REPORTER_H_
6 #define COMPONENTS_CERTIFICATE_REPORTING_CERTIFICATE_ERROR_REPORTER_H_
8 #include <set>
9 #include <string>
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "net/url_request/certificate_report_sender.h"
14 #include "url/gurl.h"
16 namespace net {
17 class URLRequestContext;
18 class SSLInfo;
21 namespace certificate_reporting {
23 class EncryptedCertLoggerRequest;
25 // Provides functionality for sending reports about invalid SSL
26 // certificate chains to a report collection server.
27 class ErrorReporter {
28 public:
29 // Creates a certificate error reporter that will send certificate
30 // error reports to |upload_url|, using |request_context| as the
31 // context for the reports. |cookies_preference| controls whether
32 // cookies will be sent along with the reports.
33 ErrorReporter(
34 net::URLRequestContext* request_context,
35 const GURL& upload_url,
36 net::CertificateReportSender::CookiesPreference cookies_preference);
38 // Allows tests to use a server public key with known private key and
39 // a mock CertificateReportSender. |server_public_key| must outlive
40 // the ErrorReporter.
41 ErrorReporter(
42 const GURL& upload_url,
43 const uint8 server_public_key[/* 32 */],
44 const uint32 server_public_key_version,
45 scoped_ptr<net::CertificateReportSender> certificate_report_sender);
47 virtual ~ErrorReporter();
49 // Sends a certificate report to the report collection server. The
50 // |serialized_report| is expected to be a serialized protobuf
51 // containing information about the hostname, certificate chain, and
52 // certificate errors encountered when validating the chain.
54 // |SendReport| actually sends the report over the network; callers are
55 // responsible for enforcing any preconditions (such as obtaining user
56 // opt-in, only sending reports for certain hostnames, checking for
57 // incognito mode, etc.).
59 // On some platforms (but not all), ErrorReporter can use
60 // an HTTP endpoint to send encrypted extended reporting reports. On
61 // unsupported platforms, callers must send extended reporting reports
62 // over SSL.
63 virtual void SendExtendedReportingReport(
64 const std::string& serialized_report);
66 // Whether sending reports over HTTP is supported.
67 static bool IsHttpUploadUrlSupported();
69 #if defined(USE_OPENSSL)
70 // Used by tests.
71 static bool DecryptErrorReport(
72 const uint8 server_private_key[32],
73 const EncryptedCertLoggerRequest& encrypted_report,
74 std::string* decrypted_serialized_report);
75 #endif
77 private:
78 scoped_ptr<net::CertificateReportSender> certificate_report_sender_;
80 const GURL upload_url_;
82 const uint8* server_public_key_;
83 const uint32 server_public_key_version_;
85 DISALLOW_COPY_AND_ASSIGN(ErrorReporter);
88 } // namespace certificate_reporting
90 #endif // COMPONENTS_CERTIFICATE_REPORTING_CERTIFICATE_ERROR_REPORTER_H_