OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 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> | |
mmenke
2014/06/20 16:07:09
nit: Line break after standard includes.
meacer
2014/06/20 23:28:15
Done.
| |
9 #include "base/callback.h" | |
10 #include "base/memory/weak_ptr.h" | |
mmenke
2014/06/20 16:07:09
include macros.h
meacer
2014/06/20 23:28:15
Done.
| |
11 #include "base/timer/timer.h" | |
12 #include "chrome/browser/chrome_notification_types.h" | |
13 #include "content/public/browser/notification_observer.h" | |
14 #include "content/public/browser/notification_registrar.h" | |
15 #include "content/public/browser/web_contents_observer.h" | |
16 #include "url/gurl.h" | |
17 | |
18 namespace content { | |
19 class RenderViewHost; | |
20 class WebContents; | |
21 } | |
22 | |
23 namespace net { | |
24 class SSLInfo; | |
25 } | |
26 | |
27 // This class is responsible for deciding whether to show an SSL warning or a | |
28 // captive portal error page. | |
29 // It deletes itself when the interstitial page is closed. | |
30 // | |
31 // This class should only be used on the UI thread because its implementation | |
32 // uses captive_portal::CaptivePortalService which can only be accessed on the | |
33 // UI thread. | |
34 class SSLErrorHandler : public content::WebContentsObserver, | |
35 public content::NotificationObserver { | |
36 public: | |
37 SSLErrorHandler(content::WebContents* web_contents, | |
38 int cert_error, | |
39 const net::SSLInfo& ssl_info, | |
40 const GURL& request_url, | |
41 bool overridable, | |
42 bool strict_enforcement, | |
43 const base::Callback<void(bool)>& callback); | |
44 virtual ~SSLErrorHandler(); | |
45 | |
46 void Handle(); | |
47 virtual void OnCaptivePortalResult(); | |
48 virtual void OnTimerExpired(); | |
49 bool handled() const { | |
50 return handled_; | |
51 } | |
mmenke
2014/06/20 16:07:09
nit: bool handled() const { return handled_; }
meacer
2014/06/20 23:28:15
Done.
| |
52 | |
53 protected: | |
54 // Only used in tests. | |
55 void set_ssl_interstitial_display_delay(base::TimeDelta delay) { | |
56 ssl_interstitial_display_delay_ = delay; | |
57 } | |
58 base::OneShotTimer<SSLErrorHandler> timer_; | |
59 | |
60 private: | |
61 // content::WebContentsObserver: | |
62 virtual void DidStopLoading( | |
63 content::RenderViewHost* render_view_host) OVERRIDE; | |
64 virtual void WebContentsDestroyed() OVERRIDE; | |
65 | |
66 // content::NotificationObserver: | |
67 virtual void Observe( | |
68 int type, | |
69 const content::NotificationSource& source, | |
70 const content::NotificationDetails& details) OVERRIDE; | |
71 | |
72 virtual void ShowSSLInterstitial(); | |
73 virtual void ShowCaptivePortalInterstitial(); | |
74 virtual void CheckForCaptivePortal(); | |
75 | |
76 content::WebContents* web_contents_; | |
77 int cert_error_; | |
78 const net::SSLInfo& ssl_info_; | |
79 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
| |
80 bool overridable_; | |
81 bool strict_enforcement_; | |
82 base::Callback<void(bool)> callback_; | |
83 bool handled_; | |
84 | |
85 // Time to wait before displaying the SSL interstitial. If a captive portal | |
86 // arrives before this, the captive portal interstitial is displayed instead. | |
87 base::TimeDelta ssl_interstitial_display_delay_; | |
88 | |
89 content::NotificationRegistrar registrar_; | |
90 | |
91 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); | |
92 }; | |
93 | |
94 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ | |
OLD | NEW |