Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
|
mmenke
2014/06/24 18:09:27
nit: --(c)
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ | |
| 6 #define CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback_forward.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/weak_ptr.h" | |
| 13 #include "base/timer/timer.h" | |
| 14 #include "chrome/browser/chrome_notification_types.h" | |
| 15 #include "content/public/browser/notification_observer.h" | |
| 16 #include "content/public/browser/notification_registrar.h" | |
| 17 #include "content/public/browser/web_contents_observer.h" | |
| 18 #include "net/ssl/ssl_info.h" | |
| 19 #include "url/gurl.h" | |
| 20 | |
| 21 namespace content { | |
| 22 class RenderViewHost; | |
| 23 class WebContents; | |
| 24 } | |
| 25 | |
| 26 // This class is responsible for deciding whether to show an SSL warning or a | |
| 27 // captive portal error page. | |
| 28 // It deletes itself when the interstitial page is closed. | |
| 29 // | |
| 30 // This class should only be used on the UI thread because its implementation | |
| 31 // uses captive_portal::CaptivePortalService which can only be accessed on the | |
| 32 // UI thread. | |
| 33 class SSLErrorHandler : public content::WebContentsObserver, | |
| 34 public content::NotificationObserver { | |
| 35 public: | |
| 36 SSLErrorHandler(content::WebContents* web_contents, | |
| 37 int cert_error, | |
| 38 const net::SSLInfo& ssl_info, | |
| 39 const GURL& request_url, | |
| 40 bool overridable, | |
| 41 bool strict_enforcement, | |
| 42 const base::Callback<void(bool)>& callback); | |
| 43 virtual ~SSLErrorHandler(); | |
| 44 | |
| 45 void Handle(); | |
| 46 virtual void OnCaptivePortalResult(); | |
| 47 virtual void OnTimerExpired(); | |
|
mmenke
2014/06/24 18:09:27
Suggest moving these down to the protected section
| |
| 48 bool handled() const { return handled_; } | |
| 49 | |
| 50 protected: | |
| 51 // Only used in tests. | |
| 52 void set_ssl_interstitial_display_delay(base::TimeDelta delay) { | |
| 53 ssl_interstitial_display_delay_ = delay; | |
| 54 } | |
| 55 base::OneShotTimer<SSLErrorHandler> timer_; | |
|
mmenke
2014/06/24 18:09:27
Rather than making timer_ protected (Which Google
meacer
2014/10/22 23:04:29
Done.
| |
| 56 | |
| 57 private: | |
| 58 // content::WebContentsObserver: | |
| 59 virtual void DidStopLoading( | |
| 60 content::RenderViewHost* render_view_host) OVERRIDE; | |
| 61 virtual void WebContentsDestroyed() OVERRIDE; | |
| 62 | |
| 63 // content::NotificationObserver: | |
| 64 virtual void Observe( | |
| 65 int type, | |
| 66 const content::NotificationSource& source, | |
| 67 const content::NotificationDetails& details) OVERRIDE; | |
| 68 | |
| 69 virtual void ShowSSLInterstitial(); | |
| 70 virtual void ShowCaptivePortalInterstitial(); | |
| 71 virtual void CheckForCaptivePortal(); | |
| 72 | |
| 73 content::WebContents* web_contents_; | |
| 74 const int cert_error_; | |
| 75 const net::SSLInfo ssl_info_; | |
| 76 const GURL request_url_; | |
| 77 const bool overridable_; | |
| 78 const bool strict_enforcement_; | |
| 79 const base::Callback<void(bool)> callback_; | |
| 80 bool handled_; | |
| 81 | |
| 82 // Time to wait before displaying the SSL interstitial. If a captive portal | |
| 83 // arrives before this, the captive portal interstitial is displayed instead. | |
| 84 base::TimeDelta ssl_interstitial_display_delay_; | |
| 85 | |
| 86 content::NotificationRegistrar registrar_; | |
| 87 | |
| 88 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); | |
| 89 }; | |
| 90 | |
| 91 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ | |
| OLD | NEW |