| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" | 4 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" |
| 5 | 5 |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
| 9 #include "base/time/clock.h" | 9 #include "base/time/clock.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 12 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 13 #include "components/certificate_reporting/error_report.h" | 13 #include "components/certificate_reporting/error_report.h" |
| 14 #include "components/prefs/pref_service.h" | 14 #include "components/prefs/pref_service.h" |
| 15 #include "components/safe_browsing_db/safe_browsing_prefs.h" | 15 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // URL to upload invalid certificate chain reports. An HTTP URL is used because | 20 // URL to upload invalid certificate chain reports. An HTTP URL is used because |
| 21 // a client seeing an invalid cert might not be able to make an HTTPS connection | 21 // a client seeing an invalid cert might not be able to make an HTTPS connection |
| 22 // to report it. | 22 // to report it. |
| 23 const char kExtendedReportingUploadUrl[] = | 23 const char kExtendedReportingUploadUrl[] = |
| 24 "http://safebrowsing.googleusercontent.com/safebrowsing/clientreport/"; | 24 "http://safebrowsing.googleusercontent.com/safebrowsing/clientreport/" |
| 25 "chrome-certs"; |
| 25 | 26 |
| 26 // Compare function that orders Reports in reverse chronological order (i.e. | 27 // Compare function that orders Reports in reverse chronological order (i.e. |
| 27 // oldest item is last). | 28 // oldest item is last). |
| 28 bool ReportCompareFunc(const CertificateReportingService::Report& item1, | 29 bool ReportCompareFunc(const CertificateReportingService::Report& item1, |
| 29 const CertificateReportingService::Report& item2) { | 30 const CertificateReportingService::Report& item2) { |
| 30 return item1.creation_time > item2.creation_time; | 31 return item1.creation_time > item2.creation_time; |
| 31 } | 32 } |
| 32 | 33 |
| 33 // Records an UMA histogram of the net errors when certificate reports | 34 // Records an UMA histogram of the net errors when certificate reports |
| 34 // fail to send. | 35 // fail to send. |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 321 } |
| 321 | 322 |
| 322 void CertificateReportingService::OnPreferenceChanged() { | 323 void CertificateReportingService::OnPreferenceChanged() { |
| 323 safe_browsing::SafeBrowsingService* safe_browsing_service_ = | 324 safe_browsing::SafeBrowsingService* safe_browsing_service_ = |
| 324 g_browser_process->safe_browsing_service(); | 325 g_browser_process->safe_browsing_service(); |
| 325 const bool enabled = safe_browsing_service_ && | 326 const bool enabled = safe_browsing_service_ && |
| 326 safe_browsing_service_->enabled_by_prefs() && | 327 safe_browsing_service_->enabled_by_prefs() && |
| 327 safe_browsing::IsExtendedReportingEnabled(pref_service_); | 328 safe_browsing::IsExtendedReportingEnabled(pref_service_); |
| 328 SetEnabled(enabled); | 329 SetEnabled(enabled); |
| 329 } | 330 } |
| OLD | NEW |