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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "chrome/browser/ssl/ssl_error_classification.h" | 7 #include "chrome/browser/ssl/ssl_error_classification.h" |
8 | 8 |
9 #include "base/build_time.h" | 9 #include "base/build_time.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ssl/ssl_error_info.h" | 18 #include "chrome/browser/ssl/ssl_error_info.h" |
| 19 #include "content/public/browser/notification_service.h" |
| 20 #include "content/public/browser/web_contents.h" |
16 #include "net/base/net_util.h" | 21 #include "net/base/net_util.h" |
17 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 22 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
18 #include "net/cert/x509_cert_types.h" | 23 #include "net/cert/x509_cert_types.h" |
19 #include "net/cert/x509_certificate.h" | 24 #include "net/cert/x509_certificate.h" |
20 #include "url/gurl.h" | 25 #include "url/gurl.h" |
21 | 26 |
22 using base::Time; | 27 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
23 using base::TimeTicks; | 28 #include "chrome/browser/captive_portal/captive_portal_service.h" |
24 using base::TimeDelta; | 29 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
| 30 #endif |
25 | 31 |
26 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
27 #include "base/win/windows_version.h" | 33 #include "base/win/windows_version.h" |
28 #endif | 34 #endif |
29 | 35 |
| 36 using base::Time; |
| 37 using base::TimeTicks; |
| 38 using base::TimeDelta; |
| 39 |
30 namespace { | 40 namespace { |
31 | 41 |
32 // Events for UMA. Do not reorder or change! | 42 // Events for UMA. Do not reorder or change! |
33 enum SSLInterstitialCause { | 43 enum SSLInterstitialCause { |
34 CLOCK_PAST, | 44 CLOCK_PAST, |
35 CLOCK_FUTURE, | 45 CLOCK_FUTURE, |
36 WWW_SUBDOMAIN_MATCH, | 46 WWW_SUBDOMAIN_MATCH, |
37 SUBDOMAIN_MATCH, | 47 SUBDOMAIN_MATCH, |
38 SUBDOMAIN_INVERSE_MATCH, | 48 SUBDOMAIN_INVERSE_MATCH, |
39 SUBDOMAIN_OUTSIDE_WILDCARD, | 49 SUBDOMAIN_OUTSIDE_WILDCARD, |
40 HOST_NAME_NOT_KNOWN_TLD, | 50 HOST_NAME_NOT_KNOWN_TLD, |
41 LIKELY_MULTI_TENANT_HOSTING, | 51 LIKELY_MULTI_TENANT_HOSTING, |
42 UNUSED_INTERSTITIAL_CAUSE_ENTRY, | 52 UNUSED_INTERSTITIAL_CAUSE_ENTRY, |
43 }; | 53 }; |
44 | 54 |
| 55 // Events for UMA. Do not reorder or change! |
| 56 enum SSLInterstitialCauseCaptivePortal { |
| 57 CAPTIVE_PORTAL_DETECTION_ENABLED, |
| 58 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE, |
| 59 CAPTIVE_PORTAL_PROBE_COMPLETED, |
| 60 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE, |
| 61 CAPTIVE_PORTAL_NO_RESPONSE, |
| 62 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE, |
| 63 CAPTIVE_PORTAL_DETECTED, |
| 64 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE, |
| 65 UNUSED_CAPTIVE_PORTAL_EVENT, |
| 66 }; |
| 67 |
45 // Scores/weights which will be constant through all the SSL error types. | 68 // Scores/weights which will be constant through all the SSL error types. |
46 static const float kServerWeight = 0.5f; | 69 static const float kServerWeight = 0.5f; |
47 static const float kClientWeight = 0.5f; | 70 static const float kClientWeight = 0.5f; |
48 | 71 |
49 void RecordSSLInterstitialCause(bool overridable, SSLInterstitialCause event) { | 72 void RecordSSLInterstitialCause(bool overridable, SSLInterstitialCause event) { |
50 if (overridable) { | 73 if (overridable) { |
51 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.overridable", event, | 74 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.overridable", event, |
52 UNUSED_INTERSTITIAL_CAUSE_ENTRY); | 75 UNUSED_INTERSTITIAL_CAUSE_ENTRY); |
53 } else { | 76 } else { |
54 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.nonoverridable", event, | 77 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.nonoverridable", event, |
55 UNUSED_INTERSTITIAL_CAUSE_ENTRY); | 78 UNUSED_INTERSTITIAL_CAUSE_ENTRY); |
56 } | 79 } |
57 } | 80 } |
58 | 81 |
| 82 void RecordCaptivePortalEventStats(SSLInterstitialCauseCaptivePortal event) { |
| 83 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.captive_portal", |
| 84 event, |
| 85 UNUSED_CAPTIVE_PORTAL_EVENT); |
| 86 } |
| 87 |
59 int GetLevensteinDistance(const std::string& str1, | 88 int GetLevensteinDistance(const std::string& str1, |
60 const std::string& str2) { | 89 const std::string& str2) { |
61 if (str1 == str2) | 90 if (str1 == str2) |
62 return 0; | 91 return 0; |
63 if (str1.size() == 0) | 92 if (str1.size() == 0) |
64 return str2.size(); | 93 return str2.size(); |
65 if (str2.size() == 0) | 94 if (str2.size() == 0) |
66 return str1.size(); | 95 return str1.size(); |
67 std::vector<int> kFirstRow(str2.size() + 1, 0); | 96 std::vector<int> kFirstRow(str2.size() + 1, 0); |
68 std::vector<int> kSecondRow(str2.size() + 1, 0); | 97 std::vector<int> kSecondRow(str2.size() + 1, 0); |
69 | 98 |
70 for (size_t i = 0; i < kFirstRow.size(); ++i) | 99 for (size_t i = 0; i < kFirstRow.size(); ++i) |
71 kFirstRow[i] = i; | 100 kFirstRow[i] = i; |
72 for (size_t i = 0; i < str1.size(); ++i) { | 101 for (size_t i = 0; i < str1.size(); ++i) { |
73 kSecondRow[0] = i + 1; | 102 kSecondRow[0] = i + 1; |
74 for (size_t j = 0; j < str2.size(); ++j) { | 103 for (size_t j = 0; j < str2.size(); ++j) { |
75 int cost = str1[i] == str2[j] ? 0 : 1; | 104 int cost = str1[i] == str2[j] ? 0 : 1; |
76 kSecondRow[j+1] = std::min(std::min( | 105 kSecondRow[j+1] = std::min(std::min( |
77 kSecondRow[j] + 1, kFirstRow[j + 1] + 1), kFirstRow[j] + cost); | 106 kSecondRow[j] + 1, kFirstRow[j + 1] + 1), kFirstRow[j] + cost); |
78 } | 107 } |
79 for (size_t j = 0; j < kFirstRow.size(); j++) | 108 for (size_t j = 0; j < kFirstRow.size(); j++) |
80 kFirstRow[j] = kSecondRow[j]; | 109 kFirstRow[j] = kSecondRow[j]; |
81 } | 110 } |
82 return kSecondRow[str2.size()]; | 111 return kSecondRow[str2.size()]; |
83 } | 112 } |
84 | 113 |
85 } // namespace | 114 } // namespace |
86 | 115 |
87 SSLErrorClassification::SSLErrorClassification( | 116 SSLErrorClassification::SSLErrorClassification( |
| 117 content::WebContents* web_contents, |
88 const base::Time& current_time, | 118 const base::Time& current_time, |
89 const GURL& url, | 119 const GURL& url, |
| 120 int cert_error, |
90 const net::X509Certificate& cert) | 121 const net::X509Certificate& cert) |
91 : current_time_(current_time), | 122 : web_contents_(web_contents), |
| 123 current_time_(current_time), |
92 request_url_(url), | 124 request_url_(url), |
93 cert_(cert) { } | 125 cert_error_(cert_error), |
| 126 cert_(cert), |
| 127 captive_portal_detection_enabled_(false), |
| 128 captive_portal_probe_completed_(false), |
| 129 captive_portal_no_response_(false), |
| 130 captive_portal_detected_(false) { |
| 131 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 132 Profile* profile = Profile::FromBrowserContext( |
| 133 web_contents_->GetBrowserContext()); |
| 134 CaptivePortalService* captive_portal_service = |
| 135 CaptivePortalServiceFactory::GetForProfile(profile); |
| 136 captive_portal_detection_enabled_ = captive_portal_service->enabled(); |
| 137 captive_portal_service->DetectCaptivePortal(); |
| 138 registrar_.Add(this, |
| 139 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, |
| 140 content::Source<Profile>(profile)); |
| 141 #endif |
| 142 } |
94 | 143 |
95 SSLErrorClassification::~SSLErrorClassification() { } | 144 SSLErrorClassification::~SSLErrorClassification() { } |
96 | 145 |
97 float SSLErrorClassification::InvalidDateSeverityScore( | 146 void SSLErrorClassification::RecordCaptivePortalUMAStatistics( |
98 int cert_error) const { | 147 bool overridable) const { |
| 148 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 149 if (captive_portal_detection_enabled_) |
| 150 RecordCaptivePortalEventStats( |
| 151 overridable ? |
| 152 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE : |
| 153 CAPTIVE_PORTAL_DETECTION_ENABLED); |
| 154 if (captive_portal_probe_completed_) |
| 155 RecordCaptivePortalEventStats( |
| 156 overridable ? |
| 157 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE : |
| 158 CAPTIVE_PORTAL_PROBE_COMPLETED); |
| 159 // Log only one of portal detected and no response results. |
| 160 if (captive_portal_detected_) |
| 161 RecordCaptivePortalEventStats( |
| 162 overridable ? |
| 163 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE : |
| 164 CAPTIVE_PORTAL_DETECTED); |
| 165 else if (captive_portal_no_response_) |
| 166 RecordCaptivePortalEventStats( |
| 167 overridable ? |
| 168 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE : |
| 169 CAPTIVE_PORTAL_NO_RESPONSE); |
| 170 #endif |
| 171 } |
| 172 |
| 173 void SSLErrorClassification::InvalidDateSeverityScore() { |
99 SSLErrorInfo::ErrorType type = | 174 SSLErrorInfo::ErrorType type = |
100 SSLErrorInfo::NetErrorToErrorType(cert_error); | 175 SSLErrorInfo::NetErrorToErrorType(cert_error_); |
101 DCHECK(type == SSLErrorInfo::CERT_DATE_INVALID); | 176 DCHECK(type == SSLErrorInfo::CERT_DATE_INVALID); |
| 177 |
102 // Client-side characteristics. Check whether or not the system's clock is | 178 // Client-side characteristics. Check whether or not the system's clock is |
103 // wrong and whether or not the user has already encountered this error | 179 // wrong and whether or not the user has encountered this error before. |
104 // before. | |
105 float severity_date_score = 0.0f; | 180 float severity_date_score = 0.0f; |
106 | 181 |
107 static const float kCertificateExpiredWeight = 0.3f; | 182 static const float kCertificateExpiredWeight = 0.3f; |
108 static const float kNotYetValidWeight = 0.2f; | 183 static const float kNotYetValidWeight = 0.2f; |
109 | 184 |
110 static const float kSystemClockWeight = 0.75f; | 185 static const float kSystemClockWeight = 0.75f; |
111 static const float kSystemClockWrongWeight = 0.1f; | 186 static const float kSystemClockWrongWeight = 0.1f; |
112 static const float kSystemClockRightWeight = 1.0f; | 187 static const float kSystemClockRightWeight = 1.0f; |
113 | 188 |
114 if (IsUserClockInThePast(current_time_) || | 189 if (IsUserClockInThePast(current_time_) || |
115 IsUserClockInTheFuture(current_time_)) { | 190 IsUserClockInTheFuture(current_time_)) { |
116 severity_date_score += kClientWeight * kSystemClockWeight * | 191 severity_date_score += kClientWeight * kSystemClockWeight * |
117 kSystemClockWrongWeight; | 192 kSystemClockWrongWeight; |
118 } else { | 193 } else { |
119 severity_date_score += kClientWeight * kSystemClockWeight * | 194 severity_date_score += kClientWeight * kSystemClockWeight * |
120 kSystemClockRightWeight; | 195 kSystemClockRightWeight; |
121 } | 196 } |
122 // TODO(radhikabhar): (crbug.com/393262) Check website settings. | 197 // TODO(radhikabhar): (crbug.com/393262) Check website settings. |
123 | 198 |
124 // Server-side characteristics. Check whether the certificate has expired or | 199 // Server-side characteristics. Check whether the certificate has expired or |
125 // is not yet valid. If the certificate has expired then factor the time which | 200 // is not yet valid. If the certificate has expired then factor the time which |
126 // has passed since expiry. | 201 // has passed since expiry. |
127 if (cert_.HasExpired()) { | 202 if (cert_.HasExpired()) { |
128 severity_date_score += kServerWeight * kCertificateExpiredWeight * | 203 severity_date_score += kServerWeight * kCertificateExpiredWeight * |
129 CalculateScoreTimePassedSinceExpiry(); | 204 CalculateScoreTimePassedSinceExpiry(); |
130 } | 205 } |
131 if (current_time_ < cert_.valid_start()) | 206 if (current_time_ < cert_.valid_start()) |
132 severity_date_score += kServerWeight * kNotYetValidWeight; | 207 severity_date_score += kServerWeight * kNotYetValidWeight; |
133 return severity_date_score; | 208 // TODO(radhikabhar): Record the severity score in a histogram. This will be |
| 209 // in the next CL - just called the function in ssl_blocking_page.cc. |
134 } | 210 } |
135 | 211 |
136 float SSLErrorClassification::InvalidCommonNameSeverityScore( | 212 void SSLErrorClassification::InvalidCommonNameSeverityScore() { |
137 int cert_error) const { | |
138 SSLErrorInfo::ErrorType type = | 213 SSLErrorInfo::ErrorType type = |
139 SSLErrorInfo::NetErrorToErrorType(cert_error); | 214 SSLErrorInfo::NetErrorToErrorType(cert_error_); |
140 DCHECK(type == SSLErrorInfo::CERT_COMMON_NAME_INVALID); | 215 DCHECK(type == SSLErrorInfo::CERT_COMMON_NAME_INVALID); |
141 float severity_name_score = 0.0f; | 216 float severity_name_score = 0.0f; |
142 | 217 |
143 static const float kWWWDifferenceWeight = 0.3f; | 218 static const float kWWWDifferenceWeight = 0.3f; |
144 static const float kNameUnderAnyNamesWeight = 0.2f; | 219 static const float kNameUnderAnyNamesWeight = 0.2f; |
145 static const float kAnyNamesUnderNameWeight = 1.0f; | 220 static const float kAnyNamesUnderNameWeight = 1.0f; |
146 static const float kLikelyMultiTenantHostingWeight = 0.1f; | 221 static const float kLikelyMultiTenantHostingWeight = 0.1f; |
147 | 222 |
148 std::string host_name = request_url_.host(); | 223 std::string host_name = request_url_.host(); |
149 if (IsHostNameKnownTLD(host_name)) { | 224 if (IsHostNameKnownTLD(host_name)) { |
150 Tokens host_name_tokens = Tokenize(host_name); | 225 Tokens host_name_tokens = Tokenize(host_name); |
151 if (IsWWWSubDomainMatch()) | 226 if (IsWWWSubDomainMatch()) |
152 severity_name_score += kServerWeight * kWWWDifferenceWeight; | 227 severity_name_score += kServerWeight * kWWWDifferenceWeight; |
153 if (IsSubDomainOutsideWildcard(host_name_tokens)) | 228 if (IsSubDomainOutsideWildcard(host_name_tokens)) |
154 severity_name_score += kServerWeight * kWWWDifferenceWeight; | 229 severity_name_score += kServerWeight * kWWWDifferenceWeight; |
155 | 230 |
156 std::vector<std::string> dns_names; | 231 std::vector<std::string> dns_names; |
157 cert_.GetDNSNames(&dns_names); | 232 cert_.GetDNSNames(&dns_names); |
158 std::vector<Tokens> dns_name_tokens = GetTokenizedDNSNames(dns_names); | 233 std::vector<Tokens> dns_name_tokens = GetTokenizedDNSNames(dns_names); |
159 if (NameUnderAnyNames(host_name_tokens, dns_name_tokens)) | 234 if (NameUnderAnyNames(host_name_tokens, dns_name_tokens)) |
160 severity_name_score += kServerWeight * kNameUnderAnyNamesWeight; | 235 severity_name_score += kServerWeight * kNameUnderAnyNamesWeight; |
161 // Inverse case is more likely to be a MITM attack. | 236 // Inverse case is more likely to be a MITM attack. |
162 if (AnyNamesUnderName(dns_name_tokens, host_name_tokens)) | 237 if (AnyNamesUnderName(dns_name_tokens, host_name_tokens)) |
163 severity_name_score += kServerWeight * kAnyNamesUnderNameWeight; | 238 severity_name_score += kServerWeight * kAnyNamesUnderNameWeight; |
164 if (IsCertLikelyFromMultiTenantHosting()) | 239 if (IsCertLikelyFromMultiTenantHosting()) |
165 severity_name_score += kServerWeight * kLikelyMultiTenantHostingWeight; | 240 severity_name_score += kServerWeight * kLikelyMultiTenantHostingWeight; |
166 } | 241 } |
167 return severity_name_score; | 242 |
| 243 static const float kEnvironmentWeight = 0.25f; |
| 244 |
| 245 severity_name_score += kClientWeight * kEnvironmentWeight * |
| 246 CalculateScoreEnvironments(); |
| 247 // TODO(radhikabhar): Record the severity score in a histogram. Same as above |
| 248 // - this will be in the next CL. So just called the function in the |
| 249 // ssl_blocking_page.cc. |
168 } | 250 } |
169 | 251 |
170 void SSLErrorClassification::RecordUMAStatistics(bool overridable, | 252 void SSLErrorClassification::RecordUMAStatistics( |
171 int cert_error) { | 253 bool overridable) const { |
172 SSLErrorInfo::ErrorType type = | 254 SSLErrorInfo::ErrorType type = |
173 SSLErrorInfo::NetErrorToErrorType(cert_error); | 255 SSLErrorInfo::NetErrorToErrorType(cert_error_); |
174 switch (type) { | 256 switch (type) { |
175 case SSLErrorInfo::CERT_DATE_INVALID: { | 257 case SSLErrorInfo::CERT_DATE_INVALID: { |
176 if (IsUserClockInThePast(base::Time::NowFromSystemTime())) | 258 if (IsUserClockInThePast(base::Time::NowFromSystemTime())) |
177 RecordSSLInterstitialCause(overridable, CLOCK_PAST); | 259 RecordSSLInterstitialCause(overridable, CLOCK_PAST); |
178 if (IsUserClockInTheFuture(base::Time::NowFromSystemTime())) | 260 if (IsUserClockInTheFuture(base::Time::NowFromSystemTime())) |
179 RecordSSLInterstitialCause(overridable, CLOCK_FUTURE); | 261 RecordSSLInterstitialCause(overridable, CLOCK_FUTURE); |
180 break; | 262 break; |
181 } | 263 } |
182 case SSLErrorInfo::CERT_COMMON_NAME_INVALID: { | 264 case SSLErrorInfo::CERT_COMMON_NAME_INVALID: { |
183 std::string host_name = request_url_.host(); | 265 std::string host_name = request_url_.host(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 static const float kMediumThresholdWeight = 0.3f; | 303 static const float kMediumThresholdWeight = 0.3f; |
222 static const float kLowThresholdWeight = 0.2f; | 304 static const float kLowThresholdWeight = 0.2f; |
223 if (time_passed >= kHighThreshold) | 305 if (time_passed >= kHighThreshold) |
224 return kHighThresholdWeight; | 306 return kHighThresholdWeight; |
225 else if (time_passed >= kLowThreshold) | 307 else if (time_passed >= kLowThreshold) |
226 return kMediumThresholdWeight; | 308 return kMediumThresholdWeight; |
227 else | 309 else |
228 return kLowThresholdWeight; | 310 return kLowThresholdWeight; |
229 } | 311 } |
230 | 312 |
| 313 float SSLErrorClassification::CalculateScoreEnvironments() const { |
| 314 static const float kWifiWeight = 0.7f; |
| 315 static const float kCellularWeight = 0.7f; |
| 316 static const float kHotspotWeight = 0.2f; |
| 317 static const float kEthernetWeight = 0.7f; |
| 318 static const float kOtherWeight = 0.7f; |
| 319 net::NetworkChangeNotifier::ConnectionType type = |
| 320 net::NetworkChangeNotifier::GetConnectionType(); |
| 321 if (type == net::NetworkChangeNotifier::CONNECTION_WIFI) |
| 322 return kWifiWeight; |
| 323 if (type == net::NetworkChangeNotifier::CONNECTION_2G || |
| 324 type == net::NetworkChangeNotifier::CONNECTION_3G || |
| 325 type == net::NetworkChangeNotifier::CONNECTION_4G ) { |
| 326 return kCellularWeight; |
| 327 } |
| 328 if (type == net::NetworkChangeNotifier::CONNECTION_ETHERNET) |
| 329 return kEthernetWeight; |
| 330 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 331 // Assume if captive portals are detected then the user is connected using a |
| 332 // hot spot. |
| 333 if (captive_portal_probe_completed_ && captive_portal_detected_) |
| 334 return kHotspotWeight; |
| 335 #endif |
| 336 return kOtherWeight; |
| 337 } |
| 338 |
231 bool SSLErrorClassification::IsUserClockInThePast(const base::Time& time_now) { | 339 bool SSLErrorClassification::IsUserClockInThePast(const base::Time& time_now) { |
232 base::Time build_time = base::GetBuildTime(); | 340 base::Time build_time = base::GetBuildTime(); |
233 if (time_now < build_time - base::TimeDelta::FromDays(2)) | 341 if (time_now < build_time - base::TimeDelta::FromDays(2)) |
234 return true; | 342 return true; |
235 return false; | 343 return false; |
236 } | 344 } |
237 | 345 |
238 bool SSLErrorClassification::IsUserClockInTheFuture( | 346 bool SSLErrorClassification::IsUserClockInTheFuture( |
239 const base::Time& time_now) { | 347 const base::Time& time_now) { |
240 base::Time build_time = base::GetBuildTime(); | 348 base::Time build_time = base::GetBuildTime(); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 static const int kMinimumEditDsitance = 5; | 547 static const int kMinimumEditDsitance = 5; |
440 for (size_t i = 0; i < dns_names_size; ++i) { | 548 for (size_t i = 0; i < dns_names_size; ++i) { |
441 for (size_t j = i + 1; j < dns_names_size; ++j) { | 549 for (size_t j = i + 1; j < dns_names_size; ++j) { |
442 int edit_distance = GetLevensteinDistance(dns_names[i], dns_names[j]); | 550 int edit_distance = GetLevensteinDistance(dns_names[i], dns_names[j]); |
443 if (edit_distance < kMinimumEditDsitance) | 551 if (edit_distance < kMinimumEditDsitance) |
444 return false; | 552 return false; |
445 } | 553 } |
446 } | 554 } |
447 return true; | 555 return true; |
448 } | 556 } |
| 557 |
| 558 void SSLErrorClassification::Observe( |
| 559 int type, |
| 560 const content::NotificationSource& source, |
| 561 const content::NotificationDetails& details) { |
| 562 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 563 // When detection is disabled, captive portal service always sends |
| 564 // RESULT_INTERNET_CONNECTED. Ignore any probe results in that case. |
| 565 if (!captive_portal_detection_enabled_) |
| 566 return; |
| 567 if (type == chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT) { |
| 568 captive_portal_probe_completed_ = true; |
| 569 CaptivePortalService::Results* results = |
| 570 content::Details<CaptivePortalService::Results>( |
| 571 details).ptr(); |
| 572 // If a captive portal was detected at any point when the interstitial was |
| 573 // displayed, assume that the interstitial was caused by a captive portal. |
| 574 // Example scenario: |
| 575 // 1- Interstitial displayed and captive portal detected, setting the flag. |
| 576 // 2- Captive portal detection automatically opens portal login page. |
| 577 // 3- User logs in on the portal login page. |
| 578 // A notification will be received here for RESULT_INTERNET_CONNECTED. Make |
| 579 // sure we don't clear the captive protal flag, since the interstitial was |
| 580 // potentially caused by the captive portal. |
| 581 captive_portal_detected_ = captive_portal_detected_ || |
| 582 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
| 583 // Also keep track of non-HTTP portals and error cases. |
| 584 captive_portal_no_response_ = captive_portal_no_response_ || |
| 585 (results->result == captive_portal::RESULT_NO_RESPONSE); |
| 586 } |
| 587 #endif |
| 588 } |
OLD | NEW |