Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 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/timer/timer.h" | |
| 13 #include "chrome/browser/chrome_notification_types.h" | |
| 14 #include "content/public/browser/notification_observer.h" | |
| 15 #include "content/public/browser/notification_registrar.h" | |
| 16 #include "content/public/browser/web_contents_observer.h" | |
| 17 #include "net/ssl/ssl_info.h" | |
| 18 #include "url/gurl.h" | |
| 19 | |
| 20 namespace content { | |
| 21 class RenderViewHost; | |
| 22 class WebContents; | |
| 23 } | |
| 24 | |
| 25 // This class is responsible for deciding whether to show an SSL warning or a | |
| 26 // captive portal error page. | |
| 27 // It deletes itself when the interstitial page is closed. | |
| 28 // | |
| 29 // This class should only be used on the UI thread because its implementation | |
| 30 // uses captive_portal::CaptivePortalService which can only be accessed on the | |
| 31 // UI thread. | |
| 32 class SSLErrorHandler : public content::WebContentsObserver, | |
| 33 public content::NotificationObserver { | |
| 34 public: | |
| 35 SSLErrorHandler(content::WebContents* web_contents, | |
| 36 int cert_error, | |
| 37 const net::SSLInfo& ssl_info, | |
| 38 const GURL& request_url, | |
| 39 int options_mask, | |
| 40 const base::TimeDelta ssl_error_delay, | |
| 41 const base::Callback<void(bool)>& callback); | |
| 42 ~SSLErrorHandler() override; | |
| 43 | |
| 44 static void HandleSSLError(content::WebContents* web_contents, | |
| 45 int cert_error, | |
| 46 const net::SSLInfo& ssl_info, | |
| 47 const GURL& request_url, | |
| 48 int options_mask, | |
| 49 const base::Callback<void(bool)>& callback); | |
|
mmenke
2014/11/10 17:32:08
Most non-override methods.
meacer
2014/11/25 01:39:52
Sorry, not sure what you mean here.
mmenke
2014/11/25 15:23:13
Erm...that makes two of us. I'm sure I had a very
| |
| 50 | |
| 51 private: | |
| 52 void Handle(); | |
| 53 virtual void CheckForCaptivePortal(); | |
| 54 virtual void ShowCaptivePortalInterstitial(); | |
| 55 virtual void ShowSSLInterstitial(); | |
|
mmenke
2014/11/10 17:32:08
Suggest mentioning these are virtual for tests.
meacer
2014/11/25 01:39:52
Done.
| |
| 56 void OnTimerExpired(); | |
|
mmenke
2014/11/10 17:32:08
nit: Should generally have blank lines between no
meacer
2014/11/25 01:39:52
Done.
| |
| 57 | |
| 58 // content::NotificationObserver: | |
| 59 void Observe( | |
| 60 int type, | |
| 61 const content::NotificationSource& source, | |
| 62 const content::NotificationDetails& details) override; | |
| 63 | |
| 64 // content::WebContentsObserver: | |
| 65 void DidStartNavigationToPendingEntry( | |
| 66 const GURL& url, | |
| 67 content::NavigationController::ReloadType reload_type) override; | |
| 68 void DidStopLoading( | |
| 69 content::RenderViewHost* render_view_host) override; | |
| 70 void WebContentsDestroyed() override; | |
| 71 | |
| 72 content::WebContents* web_contents_; | |
| 73 const int cert_error_; | |
| 74 const net::SSLInfo ssl_info_; | |
| 75 const GURL request_url_; | |
| 76 const int options_mask_; | |
| 77 const base::Callback<void(bool)> callback_; | |
| 78 | |
| 79 // Time to wait before displaying the SSL interstitial. If a captive portal | |
| 80 // arrives before this, the captive portal interstitial is displayed instead. | |
| 81 base::TimeDelta ssl_interstitial_display_delay_; | |
| 82 content::NotificationRegistrar registrar_; | |
| 83 base::OneShotTimer<SSLErrorHandler> timer_; | |
| 84 | |
| 85 friend class TestSSLErrorHandler; | |
| 86 | |
| 87 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); | |
| 88 }; | |
| 89 | |
| 90 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ | |
| OLD | NEW |