Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(663)

Side by Side Diff: chrome/browser/ssl/ssl_blocking_page.cc

Issue 376663002: Calculate severity score for date_invalid error (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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::RecordUMAStatistics(overridable_ &&
268 !strict_enforcement_);
269 }
303 270
304 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 271 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
305 CaptivePortalService* captive_portal_service = 272 CaptivePortalService* captive_portal_service =
306 CaptivePortalServiceFactory::GetForProfile(profile); 273 CaptivePortalServiceFactory::GetForProfile(profile);
307 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); 274 captive_portal_detection_enabled_ = captive_portal_service ->enabled();
308 captive_portal_service ->DetectCaptivePortal(); 275 captive_portal_service ->DetectCaptivePortal();
309 registrar_.Add(this, 276 registrar_.Add(this,
310 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, 277 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT,
311 content::Source<Profile>(profile)); 278 content::Source<Profile>(profile));
312 #endif 279 #endif
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 load_time_data.SetString("trialCondition", trial_condition_); 484 load_time_data.SetString("trialCondition", trial_condition_);
518 485
519 // Shared values for both the overridable and non-overridable versions. 486 // Shared values for both the overridable and non-overridable versions.
520 load_time_data.SetBoolean("ssl", true); 487 load_time_data.SetBoolean("ssl", true);
521 load_time_data.SetBoolean( 488 load_time_data.SetBoolean(
522 "overridable", overridable_ && !strict_enforcement_); 489 "overridable", overridable_ && !strict_enforcement_);
523 load_time_data.SetString( 490 load_time_data.SetString(
524 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); 491 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE));
525 load_time_data.SetString( 492 load_time_data.SetString(
526 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); 493 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING));
527 if (IsErrorProbablyCausedByClock( 494 if ((SSLErrorClassification::IsUserClockInThePast(
528 overridable_ && !strict_enforcement_, cert_error_)) { 495 base::Time::NowFromSystemTime()))
496 && (SSLErrorInfo::NetErrorToErrorType(cert_error_) ==
497 SSLErrorInfo::CERT_DATE_INVALID)) {
529 load_time_data.SetString("primaryParagraph", 498 load_time_data.SetString("primaryParagraph",
530 l10n_util::GetStringFUTF16( 499 l10n_util::GetStringFUTF16(
531 IDS_SSL_CLOCK_ERROR, 500 IDS_SSL_CLOCK_ERROR,
532 url, 501 url,
533 base::TimeFormatShortDate(base::Time::Now()))); 502 base::TimeFormatShortDate(base::Time::Now())));
534 } else { 503 } else {
535 load_time_data.SetString( 504 load_time_data.SetString(
536 "primaryParagraph", 505 "primaryParagraph",
537 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); 506 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url));
538 } 507 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 // sure we don't clear the captive portal flag, since the interstitial was 721 // sure we don't clear the captive portal flag, since the interstitial was
753 // potentially caused by the captive portal. 722 // potentially caused by the captive portal.
754 captive_portal_detected_ = captive_portal_detected_ || 723 captive_portal_detected_ = captive_portal_detected_ ||
755 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); 724 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL);
756 // Also keep track of non-HTTP portals and error cases. 725 // Also keep track of non-HTTP portals and error cases.
757 captive_portal_no_response_ = captive_portal_no_response_ || 726 captive_portal_no_response_ = captive_portal_no_response_ ||
758 (results->result == captive_portal::RESULT_NO_RESPONSE); 727 (results->result == captive_portal::RESULT_NO_RESPONSE);
759 } 728 }
760 #endif 729 #endif
761 } 730 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ssl/ssl_error_classification.h » ('j') | chrome/browser/ssl/ssl_error_classification.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698