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

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

Issue 2610183004: Wrap SSL error handler configuration with a lazy instance (Closed)
Patch Set: Add ForTesting to config setter methods Created 3 years, 11 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
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | chrome/browser/ssl/ssl_error_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 11 matching lines...) Expand all
22 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
23 #include "content/public/browser/web_contents_user_data.h" 23 #include "content/public/browser/web_contents_user_data.h"
24 #include "net/ssl/ssl_info.h" 24 #include "net/ssl/ssl_info.h"
25 #include "url/gurl.h" 25 #include "url/gurl.h"
26 26
27 class CommonNameMismatchHandler; 27 class CommonNameMismatchHandler;
28 class Profile; 28 class Profile;
29 29
30 namespace base { 30 namespace base {
31 class Clock; 31 class Clock;
32 class TimeDelta;
32 } 33 }
33 34
34 namespace content { 35 namespace content {
35 class WebContents; 36 class WebContents;
36 } 37 }
37 38
38 namespace network_time { 39 namespace network_time {
39 class NetworkTimeTracker; 40 class NetworkTimeTracker;
40 } 41 }
41 42
42 // This class is responsible for deciding what type of interstitial to show for 43 // This class is responsible for deciding what type of interstitial to show for
43 // an SSL validation error. The display of the interstitial might be delayed by 44 // an SSL validation error. The display of the interstitial might be delayed by
44 // a few seconds (2 by default) while trying to determine the cause of the 45 // a few seconds while trying to determine the cause of the error. During this
45 // error. During this window, the class will: check for a clock error, wait for 46 // window, the class will: check for a clock error, wait for a name-mismatch
46 // a name-mismatch suggested URL, or wait for a captive portal result to arrive. 47 // suggested URL, or wait for a captive portal result to arrive. If there is a
47 // If there is a name mismatch error and a corresponding suggested URL 48 // name mismatch error and a corresponding suggested URL result arrives in this
48 // result arrives in this window, the user is redirected to the suggested URL. 49 // window, the user is redirected to the suggested URL.
49 // Failing that, if a captive portal detected result arrives in the time window, 50 // Failing that, if a captive portal detected result arrives in the time window,
50 // a captive portal error page is shown. If none of these potential error 51 // a captive portal error page is shown. If none of these potential error
51 // causes match, an SSL interstitial is shown. 52 // causes match, an SSL interstitial is shown.
52 // 53 //
53 // This class should only be used on the UI thread because its implementation 54 // This class should only be used on the UI thread because its implementation
54 // uses captive_portal::CaptivePortalService which can only be accessed on the 55 // uses captive_portal::CaptivePortalService which can only be accessed on the
55 // UI thread. 56 // UI thread.
56 class SSLErrorHandler : public content::WebContentsUserData<SSLErrorHandler>, 57 class SSLErrorHandler : public content::WebContentsUserData<SSLErrorHandler>,
57 public content::WebContentsObserver, 58 public content::WebContentsObserver,
58 public content::NotificationObserver { 59 public content::NotificationObserver {
59 public: 60 public:
60 typedef base::Callback<void(content::WebContents*)> TimerStartedCallback; 61 typedef base::Callback<void(content::WebContents*)> TimerStartedCallback;
61 62
62 // Entry point for the class. The parameters are the same as SSLBlockingPage 63 // Entry point for the class. The parameters are the same as SSLBlockingPage
63 // constructor. 64 // constructor.
64 static void HandleSSLError( 65 static void HandleSSLError(
65 content::WebContents* web_contents, 66 content::WebContents* web_contents,
66 int cert_error, 67 int cert_error,
67 const net::SSLInfo& ssl_info, 68 const net::SSLInfo& ssl_info,
68 const GURL& request_url, 69 const GURL& request_url,
69 int options_mask, 70 int options_mask,
70 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, 71 std::unique_ptr<SSLCertReporter> ssl_cert_reporter,
71 const base::Callback<void(content::CertificateRequestResultType)>& 72 const base::Callback<void(content::CertificateRequestResultType)>&
72 callback); 73 callback);
73 74
74 // Testing methods. 75 // Testing methods.
75 static void SetInterstitialDelayForTest(base::TimeDelta delay); 76 static void SetInterstitialDelayForTesting(const base::TimeDelta& delay);
76 // The callback pointer must remain valid for the duration of error handling. 77 // The callback pointer must remain valid for the duration of error handling.
77 static void SetInterstitialTimerStartedCallbackForTest( 78 static void SetInterstitialTimerStartedCallbackForTesting(
78 TimerStartedCallback* callback); 79 TimerStartedCallback* callback);
79 static void SetClockForTest(base::Clock* testing_clock); 80 static void SetClockForTesting(base::Clock* testing_clock);
80 static void SetNetworkTimeTrackerForTest( 81 static void SetNetworkTimeTrackerForTesting(
81 network_time::NetworkTimeTracker* tracker); 82 network_time::NetworkTimeTracker* tracker);
82 83
83 protected: 84 protected:
84 // The parameters are the same as SSLBlockingPage's constructor. 85 // The parameters are the same as SSLBlockingPage's constructor.
85 SSLErrorHandler(content::WebContents* web_contents, 86 SSLErrorHandler(content::WebContents* web_contents,
86 int cert_error, 87 int cert_error,
87 const net::SSLInfo& ssl_info, 88 const net::SSLInfo& ssl_info,
88 const GURL& request_url, 89 const GURL& request_url,
89 int options_mask, 90 int options_mask,
90 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, 91 std::unique_ptr<SSLCertReporter> ssl_cert_reporter,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 std::unique_ptr<CommonNameMismatchHandler> common_name_mismatch_handler_; 154 std::unique_ptr<CommonNameMismatchHandler> common_name_mismatch_handler_;
154 155
155 std::unique_ptr<SSLCertReporter> ssl_cert_reporter_; 156 std::unique_ptr<SSLCertReporter> ssl_cert_reporter_;
156 157
157 base::WeakPtrFactory<SSLErrorHandler> weak_ptr_factory_; 158 base::WeakPtrFactory<SSLErrorHandler> weak_ptr_factory_;
158 159
159 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); 160 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler);
160 }; 161 };
161 162
162 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ 163 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | chrome/browser/ssl/ssl_error_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698