OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
18 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" | 18 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" |
| 19 #include "chrome/browser/net/cert_logger.pb.h" |
19 #include "chrome/browser/net/certificate_error_reporter.h" | 20 #include "chrome/browser/net/certificate_error_reporter.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/safe_browsing/ping_manager.h" | 22 #include "chrome/browser/safe_browsing/ping_manager.h" |
22 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 23 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
23 #include "chrome/browser/safe_browsing/ui_manager.h" | 24 #include "chrome/browser/safe_browsing/ui_manager.h" |
24 #include "chrome/browser/ssl/ssl_blocking_page.h" | 25 #include "chrome/browser/ssl/ssl_blocking_page.h" |
25 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/browser_commands.h" | 27 #include "chrome/browser/ui/browser_commands.h" |
27 #include "chrome/browser/ui/browser_navigator.h" | 28 #include "chrome/browser/ui/browser_navigator.h" |
28 #include "chrome/browser/ui/browser_tabstrip.h" | 29 #include "chrome/browser/ui/browser_tabstrip.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // network. | 202 // network. |
202 class MockReporter : public CertificateErrorReporter { | 203 class MockReporter : public CertificateErrorReporter { |
203 public: | 204 public: |
204 explicit MockReporter(net::URLRequestContext* request_context, | 205 explicit MockReporter(net::URLRequestContext* request_context, |
205 const GURL& upload_url, | 206 const GURL& upload_url, |
206 CookiesPreference cookies_preference) | 207 CookiesPreference cookies_preference) |
207 : CertificateErrorReporter(request_context, | 208 : CertificateErrorReporter(request_context, |
208 upload_url, | 209 upload_url, |
209 cookies_preference) {} | 210 cookies_preference) {} |
210 | 211 |
211 void SendReport(CertificateErrorReporter::ReportType type, | 212 void SendReport( |
212 const std::string& hostname, | 213 CertificateErrorReporter::ReportType type, |
213 const net::SSLInfo& ssl_info) override { | 214 const chrome_browser_net::CertLoggerRequest& report) override { |
214 EXPECT_EQ(CertificateErrorReporter::REPORT_TYPE_EXTENDED_REPORTING, type); | 215 EXPECT_EQ(CertificateErrorReporter::REPORT_TYPE_EXTENDED_REPORTING, type); |
215 latest_hostname_reported_ = hostname; | 216 latest_hostname_reported_ = report.hostname(); |
216 } | 217 } |
217 | 218 |
218 const std::string& latest_hostname_reported() { | 219 const std::string& latest_hostname_reported() { |
219 return latest_hostname_reported_; | 220 return latest_hostname_reported_; |
220 } | 221 } |
221 | 222 |
222 private: | 223 private: |
223 std::string latest_hostname_reported_; | 224 std::string latest_hostname_reported_; |
224 }; | 225 }; |
225 | 226 |
(...skipping 12 matching lines...) Expand all Loading... |
238 const scoped_refptr<SafeBrowsingUIManager>& safe_browsing_ui_manager, | 239 const scoped_refptr<SafeBrowsingUIManager>& safe_browsing_ui_manager, |
239 const base::Closure& report_sent_callback) | 240 const base::Closure& report_sent_callback) |
240 : safe_browsing_ui_manager_(safe_browsing_ui_manager), | 241 : safe_browsing_ui_manager_(safe_browsing_ui_manager), |
241 reported_(false), | 242 reported_(false), |
242 expect_report_(false), | 243 expect_report_(false), |
243 report_sent_callback_(report_sent_callback) {} | 244 report_sent_callback_(report_sent_callback) {} |
244 | 245 |
245 ~MockSSLCertReporter() override { EXPECT_EQ(expect_report_, reported_); } | 246 ~MockSSLCertReporter() override { EXPECT_EQ(expect_report_, reported_); } |
246 | 247 |
247 // SSLCertReporter implementation | 248 // SSLCertReporter implementation |
248 void ReportInvalidCertificateChain(const std::string& hostname, | 249 void SendReport( |
249 const net::SSLInfo& ssl_info) override { | 250 const chrome_browser_net::CertLoggerRequest& report) override { |
250 reported_ = true; | 251 reported_ = true; |
251 if (expect_report_) { | 252 if (expect_report_) { |
252 safe_browsing_ui_manager_->ReportInvalidCertificateChain( | 253 safe_browsing_ui_manager_->ReportInvalidCertificateChain( |
253 hostname, ssl_info, report_sent_callback_); | 254 report, report_sent_callback_); |
254 } | 255 } |
255 } | 256 } |
256 | 257 |
257 void set_expect_report(bool expect_report) { expect_report_ = expect_report; } | 258 void set_expect_report(bool expect_report) { expect_report_ = expect_report; } |
258 | 259 |
259 private: | 260 private: |
260 const scoped_refptr<SafeBrowsingUIManager> safe_browsing_ui_manager_; | 261 const scoped_refptr<SafeBrowsingUIManager> safe_browsing_ui_manager_; |
261 bool reported_; | 262 bool reported_; |
262 bool expect_report_; | 263 bool expect_report_; |
263 base::Closure report_sent_callback_; | 264 base::Closure report_sent_callback_; |
(...skipping 2007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 | 2272 |
2272 // Visit a page over https that contains a frame with a redirect. | 2273 // Visit a page over https that contains a frame with a redirect. |
2273 | 2274 |
2274 // XMLHttpRequest insecure content in synchronous mode. | 2275 // XMLHttpRequest insecure content in synchronous mode. |
2275 | 2276 |
2276 // XMLHttpRequest insecure content in asynchronous mode. | 2277 // XMLHttpRequest insecure content in asynchronous mode. |
2277 | 2278 |
2278 // XMLHttpRequest over bad ssl in synchronous mode. | 2279 // XMLHttpRequest over bad ssl in synchronous mode. |
2279 | 2280 |
2280 // XMLHttpRequest over OK ssl in synchronous mode. | 2281 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |