| 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 #ifndef CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ | 5 #ifndef CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ |
| 6 #define CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ | 6 #define CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ |
| 7 | 7 |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "content/public/browser/notification_observer.h" |
| 10 #include "content/public/browser/notification_registrar.h" |
| 9 #include "net/cert/x509_certificate.h" | 11 #include "net/cert/x509_certificate.h" |
| 10 | 12 |
| 13 namespace content { |
| 14 class WebContents; |
| 15 } |
| 16 |
| 11 // This class calculates the severity scores for the different type of SSL | 17 // This class calculates the severity scores for the different type of SSL |
| 12 // errors. | 18 // errors. |
| 13 class SSLErrorClassification { | 19 class SSLErrorClassification : public content::NotificationObserver { |
| 14 public: | 20 public: |
| 15 SSLErrorClassification(base::Time current_time, | 21 SSLErrorClassification(content::WebContents* web_contents, |
| 22 base::Time current_time, |
| 23 int cert_error, |
| 16 const net::X509Certificate& cert); | 24 const net::X509Certificate& cert); |
| 17 ~SSLErrorClassification(); | 25 virtual ~SSLErrorClassification(); |
| 18 | 26 |
| 19 // This method checks whether the user clock is in the past or not. | 27 // This method checks whether the system time is in the past. |
| 20 static bool IsUserClockInThePast(base::Time time_now); | 28 static bool IsUserClockInThePast(base::Time time_now); |
| 21 | 29 |
| 22 // This method checks whether the system time is too far in the future or | 30 // This method checks whether the system time is too far in the future or |
| 23 // the user is using a version of Chrome which is more than 1 year old. | 31 // the user is using a version of Chrome which is more than 1 year old. |
| 24 static bool IsUserClockInTheFuture(base::Time time_now); | 32 static bool IsUserClockInTheFuture(base::Time time_now); |
| 25 | 33 |
| 26 static bool IsWindowsVersionSP3OrLower(); | 34 static bool IsWindowsVersionSP3OrLower(); |
| 27 | 35 |
| 28 // A method which calculates the severity score when the ssl error is | 36 // A method which calculates the severity score when the ssl error is |
| 29 // CERT_DATE_INVALID. | 37 // CERT_DATE_INVALID. |
| 30 float InvalidDateSeverityScore() const; | 38 void InvalidDateSeverityScore() const; |
| 31 | 39 |
| 32 static void RecordUMAStatistics(bool overridable); | 40 void RecordUMAStatistics(bool overridable) const; |
| 41 void RecordCaptivePortalUMAStatistics(bool overridable) const; |
| 33 base::TimeDelta TimePassedSinceExpiry() const; | 42 base::TimeDelta TimePassedSinceExpiry() const; |
| 34 | 43 |
| 35 private: | 44 private: |
| 36 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassification, TestDateInvalidScore); | 45 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassificationTest, TestDateInvalidScore); |
| 37 | 46 |
| 38 float CalculateScoreTimePassedSinceExpiry() const; | 47 float CalculateScoreTimePassedSinceExpiry() const; |
| 48 float CalculateScoreEnvironments() const; |
| 39 | 49 |
| 50 // content::NotificationObserver: |
| 51 virtual void Observe( |
| 52 int type, |
| 53 const content::NotificationSource& source, |
| 54 const content::NotificationDetails& details) OVERRIDE; |
| 55 |
| 56 content::WebContents* web_contents_; |
| 40 // This stores the current time. | 57 // This stores the current time. |
| 41 base::Time current_time_; | 58 base::Time current_time_; |
| 42 | 59 int cert_error_; |
| 43 // This stores the certificate. | 60 // This stores the certificate. |
| 44 const net::X509Certificate& cert_; | 61 const net::X509Certificate& cert_; |
| 62 // Is captive portal detection enabled? |
| 63 bool captive_portal_detection_enabled_; |
| 64 // Did the probe complete before the interstitial was closed? |
| 65 bool captive_portal_probe_completed_; |
| 66 // Did the captive portal probe receive an error or get a non-HTTP response? |
| 67 bool captive_portal_no_response_; |
| 68 // Was a captive portal detected? |
| 69 bool captive_portal_detected_; |
| 70 |
| 71 content::NotificationRegistrar registrar_; |
| 45 }; | 72 }; |
| 46 | 73 |
| 47 #endif // CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ | 74 #endif // CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ |
| OLD | NEW |