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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 load_time_data.SetString("trialCondition", trial_condition_); | 479 load_time_data.SetString("trialCondition", trial_condition_); |
518 | 480 |
519 // Shared values for both the overridable and non-overridable versions. | 481 // Shared values for both the overridable and non-overridable versions. |
520 load_time_data.SetBoolean("ssl", true); | 482 load_time_data.SetBoolean("ssl", true); |
521 load_time_data.SetBoolean( | 483 load_time_data.SetBoolean( |
522 "overridable", overridable_ && !strict_enforcement_); | 484 "overridable", overridable_ && !strict_enforcement_); |
523 load_time_data.SetString( | 485 load_time_data.SetString( |
524 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); | 486 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); |
525 load_time_data.SetString( | 487 load_time_data.SetString( |
526 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); | 488 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); |
527 if (IsErrorProbablyCausedByClock( | 489 if ((SSLErrorClassification::IsUserClockInThePast( |
528 overridable_ && !strict_enforcement_, cert_error_)) { | 490 overridable_ && !strict_enforcement_, base::Time::NowFromSystemTime())) |
| 491 && (SSLErrorInfo::NetErrorToErrorType(cert_error_) == |
| 492 SSLErrorInfo::CERT_DATE_INVALID)) { |
529 load_time_data.SetString("primaryParagraph", | 493 load_time_data.SetString("primaryParagraph", |
530 l10n_util::GetStringFUTF16( | 494 l10n_util::GetStringFUTF16( |
531 IDS_SSL_CLOCK_ERROR, | 495 IDS_SSL_CLOCK_ERROR, |
532 url, | 496 url, |
533 base::TimeFormatShortDate(base::Time::Now()))); | 497 base::TimeFormatShortDate(base::Time::Now()))); |
534 } else { | 498 } else { |
535 load_time_data.SetString( | 499 load_time_data.SetString( |
536 "primaryParagraph", | 500 "primaryParagraph", |
537 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); | 501 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); |
538 } | 502 } |
(...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 | 716 // sure we don't clear the captive portal flag, since the interstitial was |
753 // potentially caused by the captive portal. | 717 // potentially caused by the captive portal. |
754 captive_portal_detected_ = captive_portal_detected_ || | 718 captive_portal_detected_ = captive_portal_detected_ || |
755 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 719 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
756 // Also keep track of non-HTTP portals and error cases. | 720 // Also keep track of non-HTTP portals and error cases. |
757 captive_portal_no_response_ = captive_portal_no_response_ || | 721 captive_portal_no_response_ = captive_portal_no_response_ || |
758 (results->result == captive_portal::RESULT_NO_RESPONSE); | 722 (results->result == captive_portal::RESULT_NO_RESPONSE); |
759 } | 723 } |
760 #endif | 724 #endif |
761 } | 725 } |
OLD | NEW |