OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_blocking_page.h" | 5 #include "chrome/browser/ssl/ssl_blocking_page.h" |
6 | 6 |
7 #include "base/build_time.h" | 7 #include "base/build_time.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/history/history_service_factory.h" | 20 #include "chrome/browser/history/history_service_factory.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/renderer_preferences_util.h" | 22 #include "chrome/browser/renderer_preferences_util.h" |
23 #include "chrome/browser/ssl/ssl_error_classification.h" | |
23 #include "chrome/browser/ssl/ssl_error_info.h" | 24 #include "chrome/browser/ssl/ssl_error_info.h" |
24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
25 #include "content/public/browser/cert_store.h" | 26 #include "content/public/browser/cert_store.h" |
26 #include "content/public/browser/interstitial_page.h" | 27 #include "content/public/browser/interstitial_page.h" |
27 #include "content/public/browser/navigation_controller.h" | 28 #include "content/public/browser/navigation_controller.h" |
28 #include "content/public/browser/navigation_entry.h" | 29 #include "content/public/browser/navigation_entry.h" |
29 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/notification_types.h" | 31 #include "content/public/browser/notification_types.h" |
31 #include "content/public/browser/render_process_host.h" | 32 #include "content/public/browser/render_process_host.h" |
32 #include "content/public/browser/render_view_host.h" | 33 #include "content/public/browser/render_view_host.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 else | 209 else |
209 RecordSSLBlockingPageEventStats(DONT_PROCEED_AUTHORITY); | 210 RecordSSLBlockingPageEventStats(DONT_PROCEED_AUTHORITY); |
210 break; | 211 break; |
211 } | 212 } |
212 default: { | 213 default: { |
213 break; | 214 break; |
214 } | 215 } |
215 } | 216 } |
216 } | 217 } |
217 | 218 |
218 // Events for UMA. Do not reorder or change! | |
219 enum SSLInterstitialCause { | |
220 CLOCK_PAST, | |
221 CLOCK_FUTURE, | |
222 UNUSED_INTERSTITIAL_CAUSE_ENTRY, | |
223 }; | |
224 | |
225 void RecordSSLInterstitialCause(bool overridable, SSLInterstitialCause event) { | |
226 if (overridable) { | |
227 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.overridable", | |
228 event, | |
229 UNUSED_INTERSTITIAL_CAUSE_ENTRY); | |
230 } else { | |
231 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.nonoverridable", | |
232 event, | |
233 UNUSED_INTERSTITIAL_CAUSE_ENTRY); | |
234 } | |
235 } | |
236 | |
237 // The cause of most clock errors (CMOS battery causing clock reset) will | |
238 // fall backwards, not forwards. IsErrorProbablyCausedByClock therefore only | |
239 // returns true for clocks set early, and histograms clocks set far into the | |
240 // future to see if there are more future-clocks than expected. | |
241 bool IsErrorProbablyCausedByClock(bool overridable, int cert_info) { | |
242 if (SSLErrorInfo::NetErrorToErrorType(cert_info) != | |
243 SSLErrorInfo::CERT_DATE_INVALID) { | |
244 return false; | |
245 } | |
246 const base::Time current_time = base::Time::NowFromSystemTime(); | |
247 const base::Time build_time = base::GetBuildTime(); | |
248 if (current_time < build_time - base::TimeDelta::FromDays(2)) { | |
249 RecordSSLInterstitialCause(overridable, CLOCK_PAST); | |
250 return true; | |
251 } | |
252 if (current_time > build_time + base::TimeDelta::FromDays(365)) | |
253 RecordSSLInterstitialCause(overridable, CLOCK_FUTURE); | |
254 return false; | |
255 } | |
256 | |
257 } // namespace | 219 } // namespace |
258 | 220 |
259 // Note that we always create a navigation entry with SSL errors. | 221 // Note that we always create a navigation entry with SSL errors. |
260 // No error happening loading a sub-resource triggers an interstitial so far. | 222 // No error happening loading a sub-resource triggers an interstitial so far. |
261 SSLBlockingPage::SSLBlockingPage( | 223 SSLBlockingPage::SSLBlockingPage( |
262 content::WebContents* web_contents, | 224 content::WebContents* web_contents, |
263 int cert_error, | 225 int cert_error, |
264 const net::SSLInfo& ssl_info, | 226 const net::SSLInfo& ssl_info, |
265 const GURL& request_url, | 227 const GURL& request_url, |
266 bool overridable, | 228 bool overridable, |
(...skipping 26 matching lines...) Expand all Loading... | |
293 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 255 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
294 profile, Profile::EXPLICIT_ACCESS); | 256 profile, Profile::EXPLICIT_ACCESS); |
295 if (history_service) { | 257 if (history_service) { |
296 history_service->GetVisibleVisitCountToHost( | 258 history_service->GetVisibleVisitCountToHost( |
297 request_url_, | 259 request_url_, |
298 base::Bind(&SSLBlockingPage::OnGotHistoryCount, | 260 base::Bind(&SSLBlockingPage::OnGotHistoryCount, |
299 base::Unretained(this)), | 261 base::Unretained(this)), |
300 &request_tracker_); | 262 &request_tracker_); |
301 } | 263 } |
302 } | 264 } |
265 if (SSLErrorInfo::NetErrorToErrorType(cert_error_) == | |
266 SSLErrorInfo::CERT_DATE_INVALID) { | |
267 SSLErrorClassification ssl_error(base::Time::NowFromSystemTime(), | |
268 ssl_info_.cert.get()); | |
269 ssl_error.RecordUMAStatistics(overridable_ && !strict_enforcement_); | |
270 } | |
303 | 271 |
304 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 272 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
305 CaptivePortalService* captive_portal_service = | 273 CaptivePortalService* captive_portal_service = |
306 CaptivePortalServiceFactory::GetForProfile(profile); | 274 CaptivePortalServiceFactory::GetForProfile(profile); |
307 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); | 275 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); |
308 captive_portal_service ->DetectCaptivePortal(); | 276 captive_portal_service ->DetectCaptivePortal(); |
309 registrar_.Add(this, | 277 registrar_.Add(this, |
310 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, | 278 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, |
311 content::Source<Profile>(profile)); | 279 content::Source<Profile>(profile)); |
312 #endif | 280 #endif |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 load_time_data.SetString("trialCondition", trial_condition_); | 485 load_time_data.SetString("trialCondition", trial_condition_); |
518 | 486 |
519 // Shared values for both the overridable and non-overridable versions. | 487 // Shared values for both the overridable and non-overridable versions. |
520 load_time_data.SetBoolean("ssl", true); | 488 load_time_data.SetBoolean("ssl", true); |
521 load_time_data.SetBoolean( | 489 load_time_data.SetBoolean( |
522 "overridable", overridable_ && !strict_enforcement_); | 490 "overridable", overridable_ && !strict_enforcement_); |
523 load_time_data.SetString( | 491 load_time_data.SetString( |
524 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); | 492 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); |
525 load_time_data.SetString( | 493 load_time_data.SetString( |
526 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); | 494 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); |
527 if (IsErrorProbablyCausedByClock( | 495 if ((SSLErrorClassification::IsUserClockInThePast( |
528 overridable_ && !strict_enforcement_, cert_error_)) { | 496 base::Time::NowFromSystemTime())) |
497 && (SSLErrorInfo::NetErrorToErrorType(cert_error_) == | |
palmer
2014/07/10 21:40:04
Style nit: Usually, more parentheses is more good,
radhikabhar
2014/07/11 04:16:14
Done.
| |
498 SSLErrorInfo::CERT_DATE_INVALID)) { | |
529 load_time_data.SetString("primaryParagraph", | 499 load_time_data.SetString("primaryParagraph", |
530 l10n_util::GetStringFUTF16( | 500 l10n_util::GetStringFUTF16( |
531 IDS_SSL_CLOCK_ERROR, | 501 IDS_SSL_CLOCK_ERROR, |
532 url, | 502 url, |
533 base::TimeFormatShortDate(base::Time::Now()))); | 503 base::TimeFormatShortDate(base::Time::Now()))); |
534 } else { | 504 } else { |
535 load_time_data.SetString( | 505 load_time_data.SetString( |
536 "primaryParagraph", | 506 "primaryParagraph", |
537 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); | 507 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); |
538 } | 508 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
752 // sure we don't clear the captive portal flag, since the interstitial was | 722 // sure we don't clear the captive portal flag, since the interstitial was |
753 // potentially caused by the captive portal. | 723 // potentially caused by the captive portal. |
754 captive_portal_detected_ = captive_portal_detected_ || | 724 captive_portal_detected_ = captive_portal_detected_ || |
755 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 725 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
756 // Also keep track of non-HTTP portals and error cases. | 726 // Also keep track of non-HTTP portals and error cases. |
757 captive_portal_no_response_ = captive_portal_no_response_ || | 727 captive_portal_no_response_ = captive_portal_no_response_ || |
758 (results->result == captive_portal::RESULT_NO_RESPONSE); | 728 (results->result == captive_portal::RESULT_NO_RESPONSE); |
759 } | 729 } |
760 #endif | 730 #endif |
761 } | 731 } |
OLD | NEW |