| 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_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ |
| 6 #define CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ | 6 #define CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // uses captive_portal::CaptivePortalService which can only be accessed on the | 49 // uses captive_portal::CaptivePortalService which can only be accessed on the |
| 50 // UI thread. | 50 // UI thread. |
| 51 class SSLErrorHandler : public content::WebContentsUserData<SSLErrorHandler>, | 51 class SSLErrorHandler : public content::WebContentsUserData<SSLErrorHandler>, |
| 52 public content::WebContentsObserver, | 52 public content::WebContentsObserver, |
| 53 public content::NotificationObserver { | 53 public content::NotificationObserver { |
| 54 public: | 54 public: |
| 55 typedef base::Callback<void(content::WebContents*)> TimerStartedCallback; | 55 typedef base::Callback<void(content::WebContents*)> TimerStartedCallback; |
| 56 | 56 |
| 57 // Entry point for the class. The parameters are the same as SSLBlockingPage | 57 // Entry point for the class. The parameters are the same as SSLBlockingPage |
| 58 // constructor. | 58 // constructor. |
| 59 static void HandleSSLError(content::WebContents* web_contents, | 59 static void HandleSSLError( |
| 60 int cert_error, | 60 content::WebContents* web_contents, |
| 61 const net::SSLInfo& ssl_info, | 61 int cert_error, |
| 62 const GURL& request_url, | 62 const net::SSLInfo& ssl_info, |
| 63 int options_mask, | 63 const GURL& request_url, |
| 64 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, | 64 int options_mask, |
| 65 const base::Callback<void(bool)>& callback); | 65 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, |
| 66 const base::Callback<void(content::CertificateRequestResultType)>& |
| 67 callback); |
| 66 | 68 |
| 67 // Testing methods. | 69 // Testing methods. |
| 68 static void SetInterstitialDelayForTest(base::TimeDelta delay); | 70 static void SetInterstitialDelayForTest(base::TimeDelta delay); |
| 69 // The callback pointer must remain valid for the duration of error handling. | 71 // The callback pointer must remain valid for the duration of error handling. |
| 70 static void SetInterstitialTimerStartedCallbackForTest( | 72 static void SetInterstitialTimerStartedCallbackForTest( |
| 71 TimerStartedCallback* callback); | 73 TimerStartedCallback* callback); |
| 72 static void SetClockForTest(base::Clock* testing_clock); | 74 static void SetClockForTest(base::Clock* testing_clock); |
| 73 | 75 |
| 74 protected: | 76 protected: |
| 75 // The parameters are the same as SSLBlockingPage's constructor. | 77 // The parameters are the same as SSLBlockingPage's constructor. |
| 76 SSLErrorHandler(content::WebContents* web_contents, | 78 SSLErrorHandler(content::WebContents* web_contents, |
| 77 int cert_error, | 79 int cert_error, |
| 78 const net::SSLInfo& ssl_info, | 80 const net::SSLInfo& ssl_info, |
| 79 const GURL& request_url, | 81 const GURL& request_url, |
| 80 int options_mask, | 82 int options_mask, |
| 81 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, | 83 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, |
| 82 const base::Callback<void(bool)>& callback); | 84 const base::Callback< |
| 85 void(content::CertificateRequestResultType)>& callback); |
| 83 | 86 |
| 84 ~SSLErrorHandler() override; | 87 ~SSLErrorHandler() override; |
| 85 | 88 |
| 86 // Called when an SSL cert error is encountered. Triggers a captive portal | 89 // Called when an SSL cert error is encountered. Triggers a captive portal |
| 87 // check and fires a one shot timer to wait for a "captive portal detected" | 90 // check and fires a one shot timer to wait for a "captive portal detected" |
| 88 // result to arrive. | 91 // result to arrive. |
| 89 void StartHandlingError(); | 92 void StartHandlingError(); |
| 90 const base::OneShotTimer& get_timer() const { return timer_; } | 93 const base::OneShotTimer& get_timer() const { return timer_; } |
| 91 | 94 |
| 92 // These are virtual for tests: | 95 // These are virtual for tests: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 128 |
| 126 // Deletes the SSLErrorHandler. This method is called when the page | 129 // Deletes the SSLErrorHandler. This method is called when the page |
| 127 // load stops or when there is a new navigation. | 130 // load stops or when there is a new navigation. |
| 128 void DeleteSSLErrorHandler(); | 131 void DeleteSSLErrorHandler(); |
| 129 | 132 |
| 130 content::WebContents* web_contents_; | 133 content::WebContents* web_contents_; |
| 131 const int cert_error_; | 134 const int cert_error_; |
| 132 const net::SSLInfo ssl_info_; | 135 const net::SSLInfo ssl_info_; |
| 133 const GURL request_url_; | 136 const GURL request_url_; |
| 134 const int options_mask_; | 137 const int options_mask_; |
| 135 base::Callback<void(bool)> callback_; | 138 base::Callback<void(content::CertificateRequestResultType)> callback_; |
| 136 Profile* const profile_; | 139 Profile* const profile_; |
| 137 | 140 |
| 138 content::NotificationRegistrar registrar_; | 141 content::NotificationRegistrar registrar_; |
| 139 base::OneShotTimer timer_; | 142 base::OneShotTimer timer_; |
| 140 | 143 |
| 141 std::unique_ptr<CommonNameMismatchHandler> common_name_mismatch_handler_; | 144 std::unique_ptr<CommonNameMismatchHandler> common_name_mismatch_handler_; |
| 142 | 145 |
| 143 std::unique_ptr<SSLCertReporter> ssl_cert_reporter_; | 146 std::unique_ptr<SSLCertReporter> ssl_cert_reporter_; |
| 144 | 147 |
| 145 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); | 148 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); |
| 146 }; | 149 }; |
| 147 | 150 |
| 148 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ | 151 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ |
| OLD | NEW |