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..a65274ca764a65d48c43819a5a042f0f2f2c2c2b |
--- /dev/null |
+++ b/chrome/browser/ssl/ssl_error_handler.h |
@@ -0,0 +1,94 @@ |
+// Copyright (c) 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> |
mmenke
2014/06/20 16:07:09
nit: Line break after standard includes.
meacer
2014/06/20 23:28:15
Done.
|
+#include "base/callback.h" |
+#include "base/memory/weak_ptr.h" |
mmenke
2014/06/20 16:07:09
include macros.h
meacer
2014/06/20 23:28:15
Done.
|
+#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 "url/gurl.h" |
+ |
+namespace content { |
+class RenderViewHost; |
+class WebContents; |
+} |
+ |
+namespace net { |
+class SSLInfo; |
+} |
+ |
+// 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, |
+ bool overridable, |
+ bool strict_enforcement, |
+ const base::Callback<void(bool)>& callback); |
+ virtual ~SSLErrorHandler(); |
+ |
+ void Handle(); |
+ virtual void OnCaptivePortalResult(); |
+ virtual void OnTimerExpired(); |
+ bool handled() const { |
+ return handled_; |
+ } |
mmenke
2014/06/20 16:07:09
nit: bool handled() const { return handled_; }
meacer
2014/06/20 23:28:15
Done.
|
+ |
+ protected: |
+ // Only used in tests. |
+ void set_ssl_interstitial_display_delay(base::TimeDelta delay) { |
+ ssl_interstitial_display_delay_ = delay; |
+ } |
+ base::OneShotTimer<SSLErrorHandler> timer_; |
+ |
+ private: |
+ // content::WebContentsObserver: |
+ virtual void DidStopLoading( |
+ content::RenderViewHost* render_view_host) OVERRIDE; |
+ virtual void WebContentsDestroyed() OVERRIDE; |
+ |
+ // content::NotificationObserver: |
+ virtual void Observe( |
+ int type, |
+ const content::NotificationSource& source, |
+ const content::NotificationDetails& details) OVERRIDE; |
+ |
+ virtual void ShowSSLInterstitial(); |
+ virtual void ShowCaptivePortalInterstitial(); |
+ virtual void CheckForCaptivePortal(); |
+ |
+ content::WebContents* web_contents_; |
+ int cert_error_; |
+ const net::SSLInfo& ssl_info_; |
+ const GURL& request_url_; |
mmenke
2014/06/20 16:07:09
Who owns these? Seems like we should keep out own
meacer
2014/06/20 23:28:15
ssl_info is owned by net layer. We can certainly k
mmenke
2014/06/20 23:41:03
The net layer lives on another thread... It looks
|
+ bool overridable_; |
+ bool strict_enforcement_; |
+ base::Callback<void(bool)> callback_; |
+ bool handled_; |
+ |
+ // 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_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); |
+}; |
+ |
+#endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ |