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

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

Issue 935663004: Add checkbox for reporting invalid TLS/SSL cert chains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment tweaks 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/memory/ref_counted.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 "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.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
26 namespace chrome_browser_net {
27 class CertificateErrorReporter;
28 }
29
25 // This class is responsible for deciding whether to show an SSL warning or a 30 // 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 31 // 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 32 // 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 33 // 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. 34 // result arrives in this window, a captive portal error page is shown.
30 // Otherwise, an SSL interstitial is shown. 35 // Otherwise, an SSL interstitial is shown.
31 // 36 //
32 // An SSLErrorHandler is associated with a particular WebContents, and is 37 // An SSLErrorHandler is associated with a particular WebContents, and is
33 // deleted if the WebContents is destroyed, or an interstitial is displayed. 38 // 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 39 // 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 40 // captive_portal::CaptivePortalService which can only be accessed on the UI
36 // thread. 41 // thread.
37 class SSLErrorHandler : public content::WebContentsUserData<SSLErrorHandler>, 42 class SSLErrorHandler : public content::WebContentsUserData<SSLErrorHandler>,
38 public content::NotificationObserver { 43 public content::NotificationObserver {
39 public: 44 public:
40 // Type of the delay to display the SSL interstitial. 45 // Type of the delay to display the SSL interstitial.
41 enum InterstitialDelayType { 46 enum InterstitialDelayType {
42 NORMAL, // Default interstitial timer delay used in production. 47 NORMAL, // Default interstitial timer delay used in production.
43 NONE, // No interstitial timer delay (i.e. zero), used in tests. 48 NONE, // No interstitial timer delay (i.e. zero), used in tests.
44 LONG // Very long interstitial timer delay (ie. an hour), used in tests. 49 LONG // Very long interstitial timer delay (ie. an hour), used in tests.
45 }; 50 };
46 51
47 static void HandleSSLError(content::WebContents* web_contents, 52 static void HandleSSLError(
48 int cert_error, 53 content::WebContents* web_contents,
49 const net::SSLInfo& ssl_info, 54 int cert_error,
50 const GURL& request_url, 55 const net::SSLInfo& ssl_info,
51 int options_mask, 56 const GURL& request_url,
52 const base::Callback<void(bool)>& callback); 57 int options_mask,
58 scoped_refptr<chrome_browser_net::CertificateErrorReporter>
Bernhard Bauer 2015/03/13 13:48:48 Pass as const-ref?
estark 2015/03/13 16:21:17 Done.
59 certificate_error_reporter,
60 const base::Callback<void(bool)>& callback);
53 61
54 static void SetInterstitialDelayTypeForTest(InterstitialDelayType delay); 62 static void SetInterstitialDelayTypeForTest(InterstitialDelayType delay);
55 63
56 typedef base::Callback<void(content::WebContents*)> TimerStartedCallback; 64 typedef base::Callback<void(content::WebContents*)> TimerStartedCallback;
57 static void SetInterstitialTimerStartedCallbackForTest( 65 static void SetInterstitialTimerStartedCallbackForTest(
58 TimerStartedCallback* callback); 66 TimerStartedCallback* callback);
59 67
60 protected: 68 protected:
61 SSLErrorHandler(content::WebContents* web_contents, 69 SSLErrorHandler(content::WebContents* web_contents,
62 int cert_error, 70 int cert_error,
63 const net::SSLInfo& ssl_info, 71 const net::SSLInfo& ssl_info,
64 const GURL& request_url, 72 const GURL& request_url,
65 int options_mask, 73 int options_mask,
74 scoped_refptr<chrome_browser_net::CertificateErrorReporter>
75 certificate_error_reporter,
66 const base::Callback<void(bool)>& callback); 76 const base::Callback<void(bool)>& callback);
67 77
68 ~SSLErrorHandler() override; 78 ~SSLErrorHandler() override;
69 79
70 // Called when an SSL cert error is encountered. Triggers a captive portal 80 // Called when an SSL cert error is encountered. Triggers a captive portal
71 // check and fires a one shot timer to wait for a "captive portal detected" 81 // check and fires a one shot timer to wait for a "captive portal detected"
72 // result to arrive. 82 // result to arrive.
73 void StartHandlingError(); 83 void StartHandlingError();
74 const base::OneShotTimer<SSLErrorHandler>& get_timer() const { 84 const base::OneShotTimer<SSLErrorHandler>& get_timer() const {
75 return timer_; 85 return timer_;
(...skipping 13 matching lines...) Expand all
89 void Observe( 99 void Observe(
90 int type, 100 int type,
91 const content::NotificationSource& source, 101 const content::NotificationSource& source,
92 const content::NotificationDetails& details) override; 102 const content::NotificationDetails& details) override;
93 103
94 content::WebContents* web_contents_; 104 content::WebContents* web_contents_;
95 const int cert_error_; 105 const int cert_error_;
96 const net::SSLInfo ssl_info_; 106 const net::SSLInfo ssl_info_;
97 const GURL request_url_; 107 const GURL request_url_;
98 const int options_mask_; 108 const int options_mask_;
109 scoped_refptr<chrome_browser_net::CertificateErrorReporter>
110 certificate_error_reporter_;
99 const base::Callback<void(bool)> callback_; 111 const base::Callback<void(bool)> callback_;
100 112
101 content::NotificationRegistrar registrar_; 113 content::NotificationRegistrar registrar_;
102 base::OneShotTimer<SSLErrorHandler> timer_; 114 base::OneShotTimer<SSLErrorHandler> timer_;
103 115
104 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler); 116 DISALLOW_COPY_AND_ASSIGN(SSLErrorHandler);
105 }; 117 };
106 118
107 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_ 119 #endif // CHROME_BROWSER_SSL_SSL_ERROR_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698