OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/ssl/ssl_error_classification.h" | 5 #include "chrome/browser/ssl/ssl_error_classification.h" |
6 | 6 |
7 #include "base/build_time.h" | 7 #include "base/build_time.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "components/network_time/network_time_tracker.h" | 12 #include "components/network_time/network_time_tracker.h" |
13 #include "net/cert/x509_certificate.h" | 13 #include "net/cert/x509_certificate.h" |
14 | 14 |
15 using base::Time; | 15 using base::Time; |
16 using base::TimeTicks; | 16 using base::TimeTicks; |
17 using base::TimeDelta; | 17 using base::TimeDelta; |
18 | 18 |
| 19 #if defined(OS_WIN) |
| 20 #include "base/win/windows_version.h" |
| 21 #endif |
| 22 |
19 namespace { | 23 namespace { |
20 | 24 |
21 // Events for UMA. Do not reorder or change! | 25 // Events for UMA. Do not reorder or change! |
22 enum SSLInterstitialCause { | 26 enum SSLInterstitialCause { |
23 CLOCK_PAST, | 27 CLOCK_PAST, |
24 CLOCK_FUTURE, | 28 CLOCK_FUTURE, |
25 UNUSED_INTERSTITIAL_CAUSE_ENTRY, | 29 UNUSED_INTERSTITIAL_CAUSE_ENTRY, |
26 }; | 30 }; |
27 | 31 |
28 void RecordSSLInterstitialCause(bool overridable, SSLInterstitialCause event) { | 32 void RecordSSLInterstitialCause(bool overridable, SSLInterstitialCause event) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return false; | 113 return false; |
110 } | 114 } |
111 | 115 |
112 bool SSLErrorClassification::IsUserClockInTheFuture(base::Time time_now) { | 116 bool SSLErrorClassification::IsUserClockInTheFuture(base::Time time_now) { |
113 base::Time build_time = base::GetBuildTime(); | 117 base::Time build_time = base::GetBuildTime(); |
114 if (time_now > build_time + base::TimeDelta::FromDays(365)) | 118 if (time_now > build_time + base::TimeDelta::FromDays(365)) |
115 return true; | 119 return true; |
116 return false; | 120 return false; |
117 } | 121 } |
118 | 122 |
| 123 bool SSLErrorClassification::IsWindowsVersionSP3OrLower() { |
| 124 #if defined(OS_WIN) |
| 125 const base::win::OSInfo* os_info = base::win::OSInfo::GetInstance(); |
| 126 base::win::OSInfo::ServicePack service_pack = os_info->service_pack(); |
| 127 if (os_info->version() < base::win::VERSION_VISTA && service_pack.major < 3) |
| 128 return true; |
| 129 #endif |
| 130 return false; |
| 131 } |
| 132 |
119 void SSLErrorClassification::RecordUMAStatistics(bool overridable) { | 133 void SSLErrorClassification::RecordUMAStatistics(bool overridable) { |
120 if (IsUserClockInThePast(base::Time::NowFromSystemTime())) | 134 if (IsUserClockInThePast(base::Time::NowFromSystemTime())) |
121 RecordSSLInterstitialCause(overridable, CLOCK_PAST); | 135 RecordSSLInterstitialCause(overridable, CLOCK_PAST); |
122 if (IsUserClockInTheFuture(base::Time::NowFromSystemTime())) | 136 if (IsUserClockInTheFuture(base::Time::NowFromSystemTime())) |
123 RecordSSLInterstitialCause(overridable, CLOCK_FUTURE); | 137 RecordSSLInterstitialCause(overridable, CLOCK_FUTURE); |
124 } | 138 } |
OLD | NEW |