OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "components/certificate_reporting/error_report.h" | 5 #include "components/certificate_reporting/error_report.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "components/certificate_reporting/cert_logger.pb.h" | 12 #include "components/certificate_reporting/cert_logger.pb.h" |
| 13 #include "components/network_time/network_time_tracker.h" |
13 #include "net/cert/cert_status_flags.h" | 14 #include "net/cert/cert_status_flags.h" |
14 #include "net/cert/x509_certificate.h" | 15 #include "net/cert/x509_certificate.h" |
15 #include "net/ssl/ssl_info.h" | 16 #include "net/ssl/ssl_info.h" |
16 | 17 |
| 18 using network_time::NetworkTimeTracker; |
| 19 |
17 namespace certificate_reporting { | 20 namespace certificate_reporting { |
18 | 21 |
19 namespace { | 22 namespace { |
20 | 23 |
21 void AddCertStatusToReportErrors(net::CertStatus cert_status, | 24 void AddCertStatusToReportErrors(net::CertStatus cert_status, |
22 CertLoggerRequest* report) { | 25 CertLoggerRequest* report) { |
23 #define COPY_CERT_STATUS(error) RENAME_CERT_STATUS(error, CERT_##error) | 26 #define COPY_CERT_STATUS(error) RENAME_CERT_STATUS(error, CERT_##error) |
24 #define RENAME_CERT_STATUS(status_error, logger_error) \ | 27 #define RENAME_CERT_STATUS(status_error, logger_error) \ |
25 if (cert_status & net::CERT_STATUS_##status_error) \ | 28 if (cert_status & net::CERT_STATUS_##status_error) \ |
26 report->add_cert_error(CertLoggerRequest::ERR_##logger_error); | 29 report->add_cert_error(CertLoggerRequest::ERR_##logger_error); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 case INTERSTITIAL_CLOCK: | 116 case INTERSTITIAL_CLOCK: |
114 interstitial_info->set_interstitial_reason( | 117 interstitial_info->set_interstitial_reason( |
115 CertLoggerInterstitialInfo::INTERSTITIAL_CLOCK); | 118 CertLoggerInterstitialInfo::INTERSTITIAL_CLOCK); |
116 break; | 119 break; |
117 } | 120 } |
118 | 121 |
119 interstitial_info->set_user_proceeded(proceed_decision == USER_PROCEEDED); | 122 interstitial_info->set_user_proceeded(proceed_decision == USER_PROCEEDED); |
120 interstitial_info->set_overridable(overridable == INTERSTITIAL_OVERRIDABLE); | 123 interstitial_info->set_overridable(overridable == INTERSTITIAL_OVERRIDABLE); |
121 } | 124 } |
122 | 125 |
| 126 void ErrorReport::AddNetworkTimeInfo( |
| 127 const NetworkTimeTracker* network_time_tracker) { |
| 128 CertLoggerFeaturesInfo* features_info = cert_report_->mutable_features_info(); |
| 129 CertLoggerFeaturesInfo::NetworkTimeQueryingInfo* network_time_info = |
| 130 features_info->mutable_network_time_querying_info(); |
| 131 network_time_info->set_network_time_queries_enabled( |
| 132 network_time_tracker->AreTimeFetchesEnabled()); |
| 133 NetworkTimeTracker::FetchBehavior behavior = |
| 134 network_time_tracker->GetFetchBehavior(); |
| 135 CertLoggerFeaturesInfo::NetworkTimeQueryingInfo::NetworkTimeFetchBehavior |
| 136 report_behavior; |
| 137 |
| 138 switch (behavior) { |
| 139 case NetworkTimeTracker::FETCH_BEHAVIOR_UNKNOWN: |
| 140 report_behavior = CertLoggerFeaturesInfo::NetworkTimeQueryingInfo:: |
| 141 NETWORK_TIME_FETCHES_UNKNOWN; |
| 142 break; |
| 143 case NetworkTimeTracker::FETCHES_IN_BACKGROUND_ONLY: |
| 144 report_behavior = CertLoggerFeaturesInfo::NetworkTimeQueryingInfo:: |
| 145 NETWORK_TIME_FETCHES_BACKGROUND_ONLY; |
| 146 break; |
| 147 case NetworkTimeTracker::FETCHES_ON_DEMAND_ONLY: |
| 148 report_behavior = CertLoggerFeaturesInfo::NetworkTimeQueryingInfo:: |
| 149 NETWORK_TIME_FETCHES_ON_DEMAND_ONLY; |
| 150 break; |
| 151 case NetworkTimeTracker::FETCHES_IN_BACKGROUND_AND_ON_DEMAND: |
| 152 report_behavior = CertLoggerFeaturesInfo::NetworkTimeQueryingInfo:: |
| 153 NETWORK_TIME_FETCHES_IN_BACKGROUND_AND_ON_DEMAND; |
| 154 break; |
| 155 } |
| 156 network_time_info->set_network_time_query_behavior(report_behavior); |
| 157 } |
| 158 |
123 const std::string& ErrorReport::hostname() const { | 159 const std::string& ErrorReport::hostname() const { |
124 return cert_report_->hostname(); | 160 return cert_report_->hostname(); |
125 } | 161 } |
126 | 162 |
127 } // namespace certificate_reporting | 163 } // namespace certificate_reporting |
OLD | NEW |