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

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

Issue 2449193002: Attempt an on-demand time fetch when encountering a date invalid error (Closed)
Patch Set: meacer nits Created 4 years, 1 month 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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h"
12 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
13 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ssl/common_name_mismatch_handler.h" 16 #include "chrome/browser/ssl/common_name_mismatch_handler.h"
16 #include "chrome/browser/ssl/ssl_cert_reporter.h" 17 #include "chrome/browser/ssl/ssl_cert_reporter.h"
17 #include "components/ssl_errors/error_classification.h" 18 #include "components/ssl_errors/error_classification.h"
18 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
20 #include "content/public/browser/restore_type.h" 21 #include "content/public/browser/restore_type.h"
21 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
22 #include "content/public/browser/web_contents_user_data.h" 23 #include "content/public/browser/web_contents_user_data.h"
23 #include "net/ssl/ssl_info.h" 24 #include "net/ssl/ssl_info.h"
24 #include "url/gurl.h" 25 #include "url/gurl.h"
25 26
26 class CommonNameMismatchHandler; 27 class CommonNameMismatchHandler;
27 class Profile; 28 class Profile;
28 29
29 namespace base { 30 namespace base {
30 class Clock; 31 class Clock;
31 } 32 }
32 33
33 namespace content { 34 namespace content {
34 class WebContents; 35 class WebContents;
35 } 36 }
36 37
38 namespace network_time {
39 class NetworkTimeTracker;
40 }
41
37 // This class is responsible for deciding what type of interstitial to show for 42 // This class is responsible for deciding what type of interstitial to show for
38 // an SSL validation error. The display of the interstitial might be delayed by 43 // an SSL validation error. The display of the interstitial might be delayed by
39 // a few seconds (2 by default) while trying to determine the cause of the 44 // a few seconds (2 by default) while trying to determine the cause of the
40 // error. During this window, the class will: check for a clock error, wait for 45 // error. During this window, the class will: check for a clock error, wait for
41 // a name-mismatch suggested URL, or wait for a captive portal result to arrive. 46 // a name-mismatch suggested URL, or wait for a captive portal result to arrive.
42 // If there is a name mismatch error and a corresponding suggested URL 47 // If there is a name mismatch error and a corresponding suggested URL
43 // result arrives in this window, the user is redirected to the suggested URL. 48 // result arrives in this window, the user is redirected to the suggested URL.
44 // Failing that, if a captive portal detected result arrives in the time window, 49 // Failing that, if a captive portal detected result arrives in the time window,
45 // a captive portal error page is shown. If none of these potential error 50 // a captive portal error page is shown. If none of these potential error
46 // causes match, an SSL interstitial is shown. 51 // causes match, an SSL interstitial is shown.
(...skipping 18 matching lines...) Expand all
65 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, 70 std::unique_ptr<SSLCertReporter> ssl_cert_reporter,
66 const base::Callback<void(content::CertificateRequestResultType)>& 71 const base::Callback<void(content::CertificateRequestResultType)>&
67 callback); 72 callback);
68 73
69 // Testing methods. 74 // Testing methods.
70 static void SetInterstitialDelayForTest(base::TimeDelta delay); 75 static void SetInterstitialDelayForTest(base::TimeDelta delay);
71 // The callback pointer must remain valid for the duration of error handling. 76 // The callback pointer must remain valid for the duration of error handling.
72 static void SetInterstitialTimerStartedCallbackForTest( 77 static void SetInterstitialTimerStartedCallbackForTest(
73 TimerStartedCallback* callback); 78 TimerStartedCallback* callback);
74 static void SetClockForTest(base::Clock* testing_clock); 79 static void SetClockForTest(base::Clock* testing_clock);
80 static void SetNetworkTimeTrackerForTest(
81 network_time::NetworkTimeTracker* tracker);
75 82
76 protected: 83 protected:
77 // The parameters are the same as SSLBlockingPage's constructor. 84 // The parameters are the same as SSLBlockingPage's constructor.
78 SSLErrorHandler(content::WebContents* web_contents, 85 SSLErrorHandler(content::WebContents* web_contents,
79 int cert_error, 86 int cert_error,
80 const net::SSLInfo& ssl_info, 87 const net::SSLInfo& ssl_info,
81 const GURL& request_url, 88 const GURL& request_url,
82 int options_mask, 89 int options_mask,
83 std::unique_ptr<SSLCertReporter> ssl_cert_reporter, 90 std::unique_ptr<SSLCertReporter> ssl_cert_reporter,
84 const base::Callback< 91 const base::Callback<
85 void(content::CertificateRequestResultType)>& callback); 92 void(content::CertificateRequestResultType)>& callback);
86 93
87 ~SSLErrorHandler() override; 94 ~SSLErrorHandler() override;
88 95
89 // Called when an SSL cert error is encountered. Triggers a captive portal 96 // Called when an SSL cert error is encountered. Triggers a captive portal
90 // check and fires a one shot timer to wait for a "captive portal detected" 97 // check and fires a one shot timer to wait for a "captive portal detected"
91 // result to arrive. 98 // result to arrive.
92 void StartHandlingError(); 99 void StartHandlingError();
93 const base::OneShotTimer& get_timer() const { return timer_; } 100 const base::OneShotTimer& get_timer() const { return timer_; }
94 101
95 // These are virtual for tests: 102 // These are virtual for tests:
96 virtual void CheckForCaptivePortal(); 103 virtual void CheckForCaptivePortal();
97 virtual bool GetSuggestedUrl(const std::vector<std::string>& dns_names, 104 virtual bool GetSuggestedUrl(const std::vector<std::string>& dns_names,
98 GURL* suggested_url) const; 105 GURL* suggested_url) const;
99 virtual void CheckSuggestedUrl(const GURL& suggested_url); 106 virtual void CheckSuggestedUrl(const GURL& suggested_url);
100 virtual void NavigateToSuggestedURL(const GURL& suggested_url); 107 virtual void NavigateToSuggestedURL(const GURL& suggested_url);
101 virtual bool IsErrorOverridable() const; 108 virtual bool IsErrorOverridable() const;
102 virtual void ShowCaptivePortalInterstitial(const GURL& landing_url); 109 virtual void ShowCaptivePortalInterstitial(const GURL& landing_url);
103 virtual void ShowSSLInterstitial(); 110 virtual void ShowSSLInterstitial();
104 111 virtual void ShowBadClockInterstitial(const base::Time& now,
105 void ShowBadClockInterstitial(const base::Time& now, 112 ssl_errors::ClockState clock_state);
106 ssl_errors::ClockState clock_state);
107 113
108 // Gets the result of whether the suggested URL is valid. Displays 114 // Gets the result of whether the suggested URL is valid. Displays
109 // common name mismatch interstitial or ssl interstitial accordingly. 115 // common name mismatch interstitial or ssl interstitial accordingly.
110 void CommonNameMismatchHandlerCallback( 116 void CommonNameMismatchHandlerCallback(
111 const CommonNameMismatchHandler::SuggestedUrlCheckResult& result, 117 const CommonNameMismatchHandler::SuggestedUrlCheckResult& result,
112 const GURL& suggested_url); 118 const GURL& suggested_url);
113 119
114 private: 120 private:
115 // content::NotificationObserver: 121 // content::NotificationObserver:
116 void Observe( 122 void Observe(
117 int type, 123 int type,
118 const content::NotificationSource& source, 124 const content::NotificationSource& source,
119 const content::NotificationDetails& details) override; 125 const content::NotificationDetails& details) override;
120 126
121 // content::WebContentsObserver: 127 // content::WebContentsObserver:
122 void DidStartNavigationToPendingEntry( 128 void DidStartNavigationToPendingEntry(
123 const GURL& url, 129 const GURL& url,
124 content::ReloadType reload_type) override; 130 content::ReloadType reload_type) override;
125 131
126 // content::WebContentsObserver: 132 // content::WebContentsObserver:
127 void NavigationStopped() override; 133 void NavigationStopped() override;
128 134
129 // Deletes the SSLErrorHandler. This method is called when the page 135 // Deletes the SSLErrorHandler. This method is called when the page
130 // load stops or when there is a new navigation. 136 // load stops or when there is a new navigation.
131 void DeleteSSLErrorHandler(); 137 void DeleteSSLErrorHandler();
132 138
139 void HandleCertDateInvalidError();
140 void HandleCertDateInvalidErrorImpl();
141
133 content::WebContents* web_contents_; 142 content::WebContents* web_contents_;
134 const int cert_error_; 143 const int cert_error_;
135 const net::SSLInfo ssl_info_; 144 const net::SSLInfo ssl_info_;
136 const GURL request_url_; 145 const GURL request_url_;
137 const int options_mask_; 146 const int options_mask_;
138 base::Callback<void(content::CertificateRequestResultType)> callback_; 147 base::Callback<void(content::CertificateRequestResultType)> callback_;
139 Profile* const profile_; 148 Profile* const profile_;
140 149
141 content::NotificationRegistrar registrar_; 150 content::NotificationRegistrar registrar_;
142 base::OneShotTimer timer_; 151 base::OneShotTimer timer_;
143 152
144 std::unique_ptr<CommonNameMismatchHandler> common_name_mismatch_handler_; 153 std::unique_ptr<CommonNameMismatchHandler> common_name_mismatch_handler_;
145 154
146 std::unique_ptr<SSLCertReporter> ssl_cert_reporter_; 155 std::unique_ptr<SSLCertReporter> ssl_cert_reporter_;
147 156
157 base::WeakPtrFactory<SSLErrorHandler> weak_ptr_factory_;
158
148 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); 159 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler);
149 }; 160 };
150 161
151 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ 162 #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