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

Side by Side Diff: chrome/browser/ssl/ssl_error_handler.h

Issue 1004283004: Destroy SSLErrorHandler on new navigations so that it can properly be recreated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mmenke comments Created 5 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ 5 #ifndef CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_
6 #define CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ 6 #define CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/timer/timer.h" 12 #include "base/timer/timer.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/web_contents_observer.h"
16 #include "content/public/browser/web_contents_user_data.h" 17 #include "content/public/browser/web_contents_user_data.h"
17 #include "net/ssl/ssl_info.h" 18 #include "net/ssl/ssl_info.h"
18 #include "url/gurl.h" 19 #include "url/gurl.h"
19 20
20 namespace content { 21 namespace content {
21 class RenderViewHost; 22 class RenderViewHost;
22 class WebContents; 23 class WebContents;
23 } 24 }
24 25
25 // This class is responsible for deciding whether to show an SSL warning or a 26 // 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 // 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 // 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 // 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 // result arrives in this window, a captive portal error page is shown.
30 // Otherwise, an SSL interstitial is shown. 31 // Otherwise, an SSL interstitial is shown.
31 // 32 //
32 // An SSLErrorHandler is associated with a particular WebContents, and is 33 // An SSLErrorHandler is associated with a particular WebContents, and is
33 // deleted if the WebContents is destroyed, or an interstitial is displayed. 34 // deleted if the WebContents is destroyed, or an interstitial is displayed.
34 // It should only be used on the UI thread because its implementation uses 35 // It should only be used on the UI thread because its implementation uses
35 // captive_portal::CaptivePortalService which can only be accessed on the UI 36 // captive_portal::CaptivePortalService which can only be accessed on the UI
36 // thread. 37 // thread.
37 class SSLErrorHandler : public content::WebContentsUserData<SSLErrorHandler>, 38 class SSLErrorHandler : public content::WebContentsUserData<SSLErrorHandler>,
39 public content::WebContentsObserver,
38 public content::NotificationObserver { 40 public content::NotificationObserver {
39 public: 41 public:
40 // Type of the delay to display the SSL interstitial. 42 // Type of the delay to display the SSL interstitial.
41 enum InterstitialDelayType { 43 enum InterstitialDelayType {
42 NORMAL, // Default interstitial timer delay used in production. 44 NORMAL, // Default interstitial timer delay used in production.
43 NONE, // No interstitial timer delay (i.e. zero), used in tests. 45 NONE, // No interstitial timer delay (i.e. zero), used in tests.
44 LONG // Very long interstitial timer delay (ie. an hour), used in tests. 46 LONG // Very long interstitial timer delay (ie. an hour), used in tests.
45 }; 47 };
46 48
47 static void HandleSSLError(content::WebContents* web_contents, 49 static void HandleSSLError(content::WebContents* web_contents,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 virtual void CheckForCaptivePortal(); 86 virtual void CheckForCaptivePortal();
85 virtual void ShowCaptivePortalInterstitial(const GURL& landing_url); 87 virtual void ShowCaptivePortalInterstitial(const GURL& landing_url);
86 virtual void ShowSSLInterstitial(); 88 virtual void ShowSSLInterstitial();
87 89
88 // content::NotificationObserver: 90 // content::NotificationObserver:
89 void Observe( 91 void Observe(
90 int type, 92 int type,
91 const content::NotificationSource& source, 93 const content::NotificationSource& source,
92 const content::NotificationDetails& details) override; 94 const content::NotificationDetails& details) override;
93 95
96 // content::WebContentsObserver:
97 void DidStartNavigationToPendingEntry(
98 const GURL& url,
99 content::NavigationController::ReloadType reload_type) override;
100
94 content::WebContents* web_contents_; 101 content::WebContents* web_contents_;
95 const int cert_error_; 102 const int cert_error_;
96 const net::SSLInfo ssl_info_; 103 const net::SSLInfo ssl_info_;
97 const GURL request_url_; 104 const GURL request_url_;
98 const int options_mask_; 105 const int options_mask_;
99 const base::Callback<void(bool)> callback_; 106 base::Callback<void(bool)> callback_;
100 107
101 content::NotificationRegistrar registrar_; 108 content::NotificationRegistrar registrar_;
102 base::OneShotTimer<SSLErrorHandler> timer_; 109 base::OneShotTimer<SSLErrorHandler> timer_;
103 110
104 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); 111 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler);
105 }; 112 };
106 113
107 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ 114 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/captive_portal/captive_portal_browsertest.cc ('k') | chrome/browser/ssl/ssl_error_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698