Index: chrome/browser/ssl/ssl_error_handler.h |
diff --git a/chrome/browser/ssl/ssl_error_handler.h b/chrome/browser/ssl/ssl_error_handler.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b73c0e6208d04486fecee9a5156550e95034ecac |
--- /dev/null |
+++ b/chrome/browser/ssl/ssl_error_handler.h |
@@ -0,0 +1,90 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ |
+#define CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ |
+ |
+#include <string> |
+ |
+#include "base/callback_forward.h" |
+#include "base/macros.h" |
+#include "base/timer/timer.h" |
+#include "chrome/browser/chrome_notification_types.h" |
+#include "content/public/browser/notification_observer.h" |
+#include "content/public/browser/notification_registrar.h" |
+#include "content/public/browser/web_contents_observer.h" |
+#include "net/ssl/ssl_info.h" |
+#include "url/gurl.h" |
+ |
+namespace content { |
+class RenderViewHost; |
+class WebContents; |
+} |
+ |
+// This class is responsible for deciding whether to show an SSL warning or a |
+// captive portal error page. |
+// It deletes itself when the interstitial page is closed. |
+// |
+// This class should only be used on the UI thread because its implementation |
+// uses captive_portal::CaptivePortalService which can only be accessed on the |
+// UI thread. |
+class SSLErrorHandler : public content::WebContentsObserver, |
+ public content::NotificationObserver { |
+ public: |
+ SSLErrorHandler(content::WebContents* web_contents, |
+ int cert_error, |
+ const net::SSLInfo& ssl_info, |
+ const GURL& request_url, |
+ int options_mask, |
+ const base::TimeDelta ssl_error_delay, |
+ const base::Callback<void(bool)>& callback); |
+ ~SSLErrorHandler() override; |
+ |
+ static void HandleSSLError(content::WebContents* web_contents, |
+ int cert_error, |
+ const net::SSLInfo& ssl_info, |
+ const GURL& request_url, |
+ int options_mask, |
+ 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
|
+ |
+ private: |
+ void Handle(); |
+ virtual void CheckForCaptivePortal(); |
+ virtual void ShowCaptivePortalInterstitial(); |
+ 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.
|
+ 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.
|
+ |
+ // content::NotificationObserver: |
+ void Observe( |
+ int type, |
+ const content::NotificationSource& source, |
+ const content::NotificationDetails& details) override; |
+ |
+ // content::WebContentsObserver: |
+ void DidStartNavigationToPendingEntry( |
+ const GURL& url, |
+ content::NavigationController::ReloadType reload_type) override; |
+ void DidStopLoading( |
+ content::RenderViewHost* render_view_host) override; |
+ void WebContentsDestroyed() override; |
+ |
+ content::WebContents* web_contents_; |
+ const int cert_error_; |
+ const net::SSLInfo ssl_info_; |
+ const GURL request_url_; |
+ const int options_mask_; |
+ const base::Callback<void(bool)> callback_; |
+ |
+ // Time to wait before displaying the SSL interstitial. If a captive portal |
+ // arrives before this, the captive portal interstitial is displayed instead. |
+ base::TimeDelta ssl_interstitial_display_delay_; |
+ content::NotificationRegistrar registrar_; |
+ base::OneShotTimer<SSLErrorHandler> timer_; |
+ |
+ friend class TestSSLErrorHandler; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); |
+}; |
+ |
+#endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ |