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

Side by Side 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: Expand browser tests Created 6 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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. It makes this decision by delaying the display of
27 // SSL interstitial for a few seconds (2 by default), and waiting for a captive
28 // portal result to arrive during this window. If a captive portal detected
29 // result arrives in this window, a captive portal error page is shown.
30 // Otherwise, an SSL interstitial is shown.
31 //
32 // This class deletes itself when the interstitial page is closed. It should
33 // only be used on the UI thread because its implementation uses
34 // captive_portal::CaptivePortalService which can only be accessed on the UI
35 // thread.
36 class SSLErrorHandler : public content::WebContentsObserver,
37 public content::NotificationObserver {
38 public:
39 SSLErrorHandler(content::WebContents* web_contents,
40 int cert_error,
41 const net::SSLInfo& ssl_info,
42 const GURL& request_url,
43 int options_mask,
44 const base::TimeDelta ssl_error_delay,
45 const base::Callback<void(bool)>& callback);
46 ~SSLErrorHandler() override;
47
48 static void HandleSSLError(content::WebContents* web_contents,
49 int cert_error,
50 const net::SSLInfo& ssl_info,
51 const GURL& request_url,
52 int options_mask,
53 const base::Callback<void(bool)>& callback);
54
55 private:
56 // Called when an SSL cert error is encountered. Triggers a captive portal
57 // check and fires a one shot timer to wait for a "captive portal detected"
58 // result to arrive.
59 void StartHandlingError();
60 // Callback for the one-shot timer. When the timer expires, an SSL error is
61 // immediately displayed.
62 void OnTimerExpired();
63
64 // These are virtual for tests:
65 virtual void CheckForCaptivePortal();
66 virtual void ShowCaptivePortalInterstitial();
67 virtual void ShowSSLInterstitial();
68
69 // content::NotificationObserver:
70 void Observe(
71 int type,
72 const content::NotificationSource& source,
73 const content::NotificationDetails& details) override;
74
75 // content::WebContentsObserver:
76 void DidStartNavigationToPendingEntry(
77 const GURL& url,
78 content::NavigationController::ReloadType reload_type) override;
79 void DidStopLoading(
80 content::RenderViewHost* render_view_host) override;
81 void WebContentsDestroyed() override;
82
83 const int cert_error_;
84 const net::SSLInfo ssl_info_;
85 const GURL request_url_;
86 const int options_mask_;
87 const base::Callback<void(bool)> callback_;
88
89 // Time to wait before displaying the SSL interstitial. If a captive portal
90 // arrives before this, the captive portal interstitial is displayed instead.
91 base::TimeDelta ssl_interstitial_display_delay_;
92 content::NotificationRegistrar registrar_;
93 base::OneShotTimer<SSLErrorHandler> timer_;
94
95 friend class TestSSLErrorHandler;
mmenke 2014/12/09 22:42:26 friend classes should go first....But is this even
meacer 2014/12/10 22:48:03 Done.
96
97 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler);
98 };
99
100 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698