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. | |
|
mmenke
2014/11/26 18:57:49
Should give details on how it does this...The asyn
meacer
2014/12/08 22:29:51
Done.
| |
| 27 // It deletes itself when the interstitial page is closed. | |
|
mmenke
2014/11/26 18:57:49
nit: Somewhat weird to use a double break between
meacer
2014/12/08 22:29:51
Done.
| |
| 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); | |
| 50 | |
| 51 private: | |
| 52 void Handle(); | |
|
mmenke
2014/11/26 18:57:49
"Handle" is a rather unclear... Suggest just Hand
meacer
2014/12/08 22:29:51
I like "StartHandlingError".
| |
| 53 void OnTimerExpired(); | |
|
mmenke
2014/11/26 18:57:49
Should document these methods.
meacer
2014/12/08 22:29:51
Done.
| |
| 54 | |
| 55 // These are virtual for tests: | |
| 56 virtual void CheckForCaptivePortal(); | |
| 57 virtual void ShowCaptivePortalInterstitial(); | |
| 58 virtual void ShowSSLInterstitial(); | |
| 59 | |
| 60 // content::NotificationObserver: | |
| 61 void Observe( | |
| 62 int type, | |
| 63 const content::NotificationSource& source, | |
| 64 const content::NotificationDetails& details) override; | |
| 65 | |
| 66 // content::WebContentsObserver: | |
| 67 void DidStartNavigationToPendingEntry( | |
| 68 const GURL& url, | |
| 69 content::NavigationController::ReloadType reload_type) override; | |
| 70 void DidStopLoading( | |
| 71 content::RenderViewHost* render_view_host) override; | |
| 72 void WebContentsDestroyed() override; | |
| 73 | |
| 74 content::WebContents* web_contents_; | |
|
mmenke
2014/11/26 18:57:49
Not needed. See WebContentsObserver::web_contents
meacer
2014/12/08 22:29:51
Done.
| |
| 75 const int cert_error_; | |
| 76 const net::SSLInfo ssl_info_; | |
| 77 const GURL request_url_; | |
| 78 const int options_mask_; | |
| 79 const base::Callback<void(bool)> callback_; | |
| 80 | |
| 81 // Time to wait before displaying the SSL interstitial. If a captive portal | |
| 82 // arrives before this, the captive portal interstitial is displayed instead. | |
| 83 base::TimeDelta ssl_interstitial_display_delay_; | |
| 84 content::NotificationRegistrar registrar_; | |
| 85 base::OneShotTimer<SSLErrorHandler> timer_; | |
| 86 | |
| 87 friend class TestSSLErrorHandler; | |
| 88 | |
| 89 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); | |
| 90 }; | |
| 91 | |
| 92 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ | |
| OLD | NEW |