| 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" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ssl/common_name_mismatch_handler.h" |
| 14 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 16 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
| 15 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 19 #include "content/public/browser/web_contents_observer.h" |
| 18 #include "content/public/browser/web_contents_user_data.h" | 20 #include "content/public/browser/web_contents_user_data.h" |
| 19 #include "net/ssl/ssl_info.h" | 21 #include "net/ssl/ssl_info.h" |
| 20 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 21 | 23 |
| 22 namespace content { | 24 namespace content { |
| 23 class RenderViewHost; | 25 class RenderViewHost; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 54 int options_mask, | 56 int options_mask, |
| 55 scoped_ptr<SSLCertReporter> ssl_cert_reporter, | 57 scoped_ptr<SSLCertReporter> ssl_cert_reporter, |
| 56 const base::Callback<void(bool)>& callback); | 58 const base::Callback<void(bool)>& callback); |
| 57 | 59 |
| 58 static void SetInterstitialDelayTypeForTest(InterstitialDelayType delay); | 60 static void SetInterstitialDelayTypeForTest(InterstitialDelayType delay); |
| 59 | 61 |
| 60 typedef base::Callback<void(content::WebContents*)> TimerStartedCallback; | 62 typedef base::Callback<void(content::WebContents*)> TimerStartedCallback; |
| 61 static void SetInterstitialTimerStartedCallbackForTest( | 63 static void SetInterstitialTimerStartedCallbackForTest( |
| 62 TimerStartedCallback* callback); | 64 TimerStartedCallback* callback); |
| 63 | 65 |
| 66 // Gets the result of whether the suggested URL is valid. Displays |
| 67 // common name mismatch interstitial or ssl interstitial accordingly. |
| 68 void CommonNameMismatchHandlerCallback( |
| 69 const CommonNameMismatchHandler::Results& results); |
| 70 |
| 64 protected: | 71 protected: |
| 65 SSLErrorHandler(content::WebContents* web_contents, | 72 SSLErrorHandler(content::WebContents* web_contents, |
| 66 int cert_error, | 73 int cert_error, |
| 67 const net::SSLInfo& ssl_info, | 74 const net::SSLInfo& ssl_info, |
| 68 const GURL& request_url, | 75 const GURL& request_url, |
| 69 int options_mask, | 76 int options_mask, |
| 70 scoped_ptr<SSLCertReporter> ssl_cert_reporter, | 77 scoped_ptr<SSLCertReporter> ssl_cert_reporter, |
| 71 const base::Callback<void(bool)>& callback); | 78 const base::Callback<void(bool)>& callback); |
| 72 | 79 |
| 73 ~SSLErrorHandler() override; | 80 ~SSLErrorHandler() override; |
| 74 | 81 |
| 75 // Called when an SSL cert error is encountered. Triggers a captive portal | 82 // Called when an SSL cert error is encountered. Triggers a captive portal |
| 76 // check and fires a one shot timer to wait for a "captive portal detected" | 83 // check and fires a one shot timer to wait for a "captive portal detected" |
| 77 // result to arrive. | 84 // result to arrive. |
| 78 void StartHandlingError(); | 85 void StartHandlingError(); |
| 79 const base::OneShotTimer<SSLErrorHandler>& get_timer() const { | 86 const base::OneShotTimer<SSLErrorHandler>& get_timer() const { |
| 80 return timer_; | 87 return timer_; |
| 81 } | 88 } |
| 82 | 89 |
| 83 private: | 90 private: |
| 84 // Callback for the one-shot timer. When the timer expires, an SSL error is | 91 // Callback for the one-shot timer. When the timer expires, an SSL error is |
| 85 // immediately displayed. | 92 // immediately displayed. |
| 86 void OnTimerExpired(); | 93 void OnTimerExpired(); |
| 87 | 94 |
| 88 // These are virtual for tests: | 95 // These are virtual for tests: |
| 89 virtual void CheckForCaptivePortal(); | 96 virtual void CheckForCaptivePortal(); |
| 90 virtual void ShowCaptivePortalInterstitial(const GURL& landing_url); | 97 virtual void ShowCaptivePortalInterstitial(const GURL& landing_url); |
| 91 virtual void ShowSSLInterstitial(); | 98 virtual void ShowSSLInterstitial(); |
| 99 virtual bool GetSuggestedUrl(const std::vector<std::string>& dns_names, |
| 100 GURL* suggested_url) const; |
| 101 virtual void CheckSuggestedUrl(const GURL& suggested_url); |
| 102 virtual void NavigateToSuggestedURL(const GURL& suggested_url); |
| 92 | 103 |
| 93 // content::NotificationObserver: | 104 // content::NotificationObserver: |
| 94 void Observe( | 105 void Observe( |
| 95 int type, | 106 int type, |
| 96 const content::NotificationSource& source, | 107 const content::NotificationSource& source, |
| 97 const content::NotificationDetails& details) override; | 108 const content::NotificationDetails& details) override; |
| 98 | 109 |
| 99 // content::WebContentsObserver: | 110 // content::WebContentsObserver: |
| 100 void DidStartNavigationToPendingEntry( | 111 void DidStartNavigationToPendingEntry( |
| 101 const GURL& url, | 112 const GURL& url, |
| 102 content::NavigationController::ReloadType reload_type) override; | 113 content::NavigationController::ReloadType reload_type) override; |
| 103 | 114 |
| 104 // content::WebContentsObserver: | 115 // content::WebContentsObserver: |
| 105 void NavigationStopped() override; | 116 void NavigationStopped() override; |
| 106 | 117 |
| 107 // Deletes the SSLErrorHandler. This method is called when the page | 118 // Deletes the SSLErrorHandler. This method is called when the page |
| 108 // load stops or when there is a new navigation. | 119 // load stops or when there is a new navigation. |
| 109 void DeleteSSLErrorHandler(); | 120 void DeleteSSLErrorHandler(); |
| 110 | 121 |
| 111 content::WebContents* web_contents_; | 122 content::WebContents* web_contents_; |
| 112 const int cert_error_; | 123 const int cert_error_; |
| 113 const net::SSLInfo ssl_info_; | 124 const net::SSLInfo ssl_info_; |
| 114 const GURL request_url_; | 125 const GURL request_url_; |
| 115 const int options_mask_; | 126 const int options_mask_; |
| 116 base::Callback<void(bool)> callback_; | 127 base::Callback<void(bool)> callback_; |
| 128 Profile* const profile_; |
| 117 | 129 |
| 118 content::NotificationRegistrar registrar_; | 130 content::NotificationRegistrar registrar_; |
| 119 base::OneShotTimer<SSLErrorHandler> timer_; | 131 base::OneShotTimer<SSLErrorHandler> timer_; |
| 120 | 132 |
| 133 scoped_ptr<CommonNameMismatchHandler> common_name_mismatch_handler_; |
| 134 |
| 121 scoped_ptr<SSLCertReporter> ssl_cert_reporter_; | 135 scoped_ptr<SSLCertReporter> ssl_cert_reporter_; |
| 122 | 136 |
| 123 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); | 137 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); |
| 124 }; | 138 }; |
| 125 | 139 |
| 126 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ | 140 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ |
| OLD | NEW |