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