Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1792)

Unified Diff: chrome/browser/ssl/ssl_error_handler.h

Issue 318213002: Add custom interstitial for captive portals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unnecessary change Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..62a59e784f0a14d5b75c5ebd9741d7f5bbccf8ce
--- /dev/null
+++ b/chrome/browser/ssl/ssl_error_handler.h
@@ -0,0 +1,116 @@
+// 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/memory/weak_ptr.h"
+#include "base/metrics/histogram.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;
+
+ void Handle();
+ virtual void OnCaptivePortalResult();
+ virtual void OnTimerExpired();
+
+ protected:
+ // Only used in tests.
+ bool handled() const {
Ryan Sleevi 2014/10/29 23:17:32 was_handled_for_testing then? Are all of these fo
meacer 2014/11/06 21:21:56 Done.
+ return handled_;
+ }
+
+ int captive_portal_check_count() const {
+ return captive_portal_check_count_;
+ }
+
+ int ssl_interstitial_show_count() const {
+ return ssl_interstitial_show_count_;
+ }
+
+ int captive_portal_interstitial_show_count() const {
+ return captive_portal_interstitial_show_count_;
+ }
+
+ bool TimerRunning() const {
+ return timer_.IsRunning();
+ }
+
+ void DontCreateInterstitials() {
+ create_interstitials_ = false;
+ }
+
+ 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;
+
+ bool overridable() const;
+ void ShowSSLInterstitial();
+ void ShowCaptivePortalInterstitial();
+ void CheckForCaptivePortal();
+
+ 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_;
+ bool handled_;
+ int captive_portal_check_count_;
+ int ssl_interstitial_show_count_;
+ int captive_portal_interstitial_show_count_;
+
+ // 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_;
+ // If true, interstitials will be created.
+ bool create_interstitials_;
+ bool timer_expired_;
+ content::NotificationRegistrar registrar_;
+ base::OneShotTimer<SSLErrorHandler> timer_;
+
+ DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler);
+};
+
+#endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698