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/certificate_error_reporter.h" | 19 #include "chrome/browser/net/certificate_error_reporter.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/safe_browsing/ping_manager.h" | 21 #include "chrome/browser/safe_browsing/ping_manager.h" |
22 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 22 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
23 #include "chrome/browser/safe_browsing/ui_manager.h" | 23 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 24 #include "chrome/browser/ssl/cert_logger.pb.h" |
| 25 #include "chrome/browser/ssl/certificate_error_report.h" |
24 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" | 26 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
25 #include "chrome/browser/ssl/ssl_blocking_page.h" | 27 #include "chrome/browser/ssl/ssl_blocking_page.h" |
26 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
27 #include "chrome/browser/ui/browser_commands.h" | 29 #include "chrome/browser/ui/browser_commands.h" |
28 #include "chrome/browser/ui/browser_navigator.h" | 30 #include "chrome/browser/ui/browser_navigator.h" |
29 #include "chrome/browser/ui/browser_tabstrip.h" | 31 #include "chrome/browser/ui/browser_tabstrip.h" |
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
31 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
32 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
33 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 class MockReporter : public CertificateErrorReporter { | 206 class MockReporter : public CertificateErrorReporter { |
205 public: | 207 public: |
206 explicit MockReporter(net::URLRequestContext* request_context, | 208 explicit MockReporter(net::URLRequestContext* request_context, |
207 const GURL& upload_url, | 209 const GURL& upload_url, |
208 CookiesPreference cookies_preference) | 210 CookiesPreference cookies_preference) |
209 : CertificateErrorReporter(request_context, | 211 : CertificateErrorReporter(request_context, |
210 upload_url, | 212 upload_url, |
211 cookies_preference) {} | 213 cookies_preference) {} |
212 | 214 |
213 void SendReport(CertificateErrorReporter::ReportType type, | 215 void SendReport(CertificateErrorReporter::ReportType type, |
214 const std::string& hostname, | 216 const std::string& serialized_report) override { |
215 const net::SSLInfo& ssl_info) override { | 217 CertificateErrorReport report; |
| 218 ASSERT_TRUE(report.InitializeFromString(serialized_report)); |
216 EXPECT_EQ(CertificateErrorReporter::REPORT_TYPE_EXTENDED_REPORTING, type); | 219 EXPECT_EQ(CertificateErrorReporter::REPORT_TYPE_EXTENDED_REPORTING, type); |
217 latest_hostname_reported_ = hostname; | 220 latest_hostname_reported_ = report.hostname(); |
218 } | 221 } |
219 | 222 |
220 const std::string& latest_hostname_reported() { | 223 const std::string& latest_hostname_reported() { |
221 return latest_hostname_reported_; | 224 return latest_hostname_reported_; |
222 } | 225 } |
223 | 226 |
224 private: | 227 private: |
225 std::string latest_hostname_reported_; | 228 std::string latest_hostname_reported_; |
226 }; | 229 }; |
227 | 230 |
(...skipping 12 matching lines...) Expand all Loading... |
240 const scoped_refptr<SafeBrowsingUIManager>& safe_browsing_ui_manager, | 243 const scoped_refptr<SafeBrowsingUIManager>& safe_browsing_ui_manager, |
241 const base::Closure& report_sent_callback) | 244 const base::Closure& report_sent_callback) |
242 : safe_browsing_ui_manager_(safe_browsing_ui_manager), | 245 : safe_browsing_ui_manager_(safe_browsing_ui_manager), |
243 reported_(false), | 246 reported_(false), |
244 expect_report_(false), | 247 expect_report_(false), |
245 report_sent_callback_(report_sent_callback) {} | 248 report_sent_callback_(report_sent_callback) {} |
246 | 249 |
247 ~MockSSLCertReporter() override { EXPECT_EQ(expect_report_, reported_); } | 250 ~MockSSLCertReporter() override { EXPECT_EQ(expect_report_, reported_); } |
248 | 251 |
249 // SSLCertReporter implementation | 252 // SSLCertReporter implementation |
250 void ReportInvalidCertificateChain(const std::string& hostname, | 253 void ReportInvalidCertificateChain( |
251 const net::SSLInfo& ssl_info) override { | 254 const std::string& serialized_report) override { |
252 reported_ = true; | 255 reported_ = true; |
253 if (expect_report_) { | 256 if (expect_report_) { |
254 safe_browsing_ui_manager_->ReportInvalidCertificateChain( | 257 safe_browsing_ui_manager_->ReportInvalidCertificateChain( |
255 hostname, ssl_info, report_sent_callback_); | 258 serialized_report, report_sent_callback_); |
256 } | 259 } |
257 } | 260 } |
258 | 261 |
259 void set_expect_report(bool expect_report) { expect_report_ = expect_report; } | 262 void set_expect_report(bool expect_report) { expect_report_ = expect_report; } |
260 | 263 |
261 private: | 264 private: |
262 const scoped_refptr<SafeBrowsingUIManager> safe_browsing_ui_manager_; | 265 const scoped_refptr<SafeBrowsingUIManager> safe_browsing_ui_manager_; |
263 bool reported_; | 266 bool reported_; |
264 bool expect_report_; | 267 bool expect_report_; |
265 base::Closure report_sent_callback_; | 268 base::Closure report_sent_callback_; |
(...skipping 2104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2370 | 2373 |
2371 // Visit a page over https that contains a frame with a redirect. | 2374 // Visit a page over https that contains a frame with a redirect. |
2372 | 2375 |
2373 // XMLHttpRequest insecure content in synchronous mode. | 2376 // XMLHttpRequest insecure content in synchronous mode. |
2374 | 2377 |
2375 // XMLHttpRequest insecure content in asynchronous mode. | 2378 // XMLHttpRequest insecure content in asynchronous mode. |
2376 | 2379 |
2377 // XMLHttpRequest over bad ssl in synchronous mode. | 2380 // XMLHttpRequest over bad ssl in synchronous mode. |
2378 | 2381 |
2379 // XMLHttpRequest over OK ssl in synchronous mode. | 2382 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |