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

Side by Side Diff: chrome/browser/ssl/ssl_blocking_page.cc

Issue 935663004: Add checkbox for reporting invalid TLS/SSL cert chains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: style fixes: base::Closure and const-refs 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
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.h ('k') | chrome/browser/ssl/ssl_browser_tests.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 (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 "chrome/browser/ssl/ssl_blocking_page.h" 5 #include "chrome/browser/ssl/ssl_blocking_page.h"
6 6
7 #include "base/build_time.h" 7 #include "base/build_time.h"
8 #include "base/callback_helpers.h"
8 #include "base/command_line.h" 9 #include "base/command_line.h"
9 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
10 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
12 #include "base/memory/ref_counted.h"
11 #include "base/metrics/field_trial.h" 13 #include "base/metrics/field_trial.h"
12 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
15 #include "base/prefs/pref_service.h"
13 #include "base/process/launch.h" 16 #include "base/process/launch.h"
14 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_piece.h" 18 #include "base/strings/string_piece.h"
16 #include "base/strings/string_util.h" 19 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
19 #include "base/time/time.h" 22 #include "base/time/time.h"
20 #include "base/values.h" 23 #include "base/values.h"
21 #include "chrome/browser/browser_process.h" 24 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/chrome_notification_types.h" 25 #include "chrome/browser/chrome_notification_types.h"
26 #include "chrome/browser/net/certificate_error_reporter.h"
23 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/renderer_preferences_util.h" 28 #include "chrome/browser/renderer_preferences_util.h"
25 #include "chrome/browser/ssl/ssl_error_classification.h" 29 #include "chrome/browser/ssl/ssl_error_classification.h"
26 #include "chrome/browser/ssl/ssl_error_info.h" 30 #include "chrome/browser/ssl/ssl_error_info.h"
27 #include "chrome/common/chrome_switches.h" 31 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/pref_names.h"
28 #include "chrome/grit/chromium_strings.h" 33 #include "chrome/grit/chromium_strings.h"
29 #include "chrome/grit/generated_resources.h" 34 #include "chrome/grit/generated_resources.h"
30 #include "components/google/core/browser/google_util.h" 35 #include "components/google/core/browser/google_util.h"
36 #include "content/public/browser/browser_thread.h"
31 #include "content/public/browser/cert_store.h" 37 #include "content/public/browser/cert_store.h"
32 #include "content/public/browser/interstitial_page.h" 38 #include "content/public/browser/interstitial_page.h"
33 #include "content/public/browser/interstitial_page_delegate.h" 39 #include "content/public/browser/interstitial_page_delegate.h"
34 #include "content/public/browser/navigation_controller.h" 40 #include "content/public/browser/navigation_controller.h"
35 #include "content/public/browser/navigation_entry.h" 41 #include "content/public/browser/navigation_entry.h"
36 #include "content/public/browser/notification_service.h" 42 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/notification_types.h" 43 #include "content/public/browser/notification_types.h"
38 #include "content/public/browser/render_process_host.h" 44 #include "content/public/browser/render_process_host.h"
39 #include "content/public/browser/render_view_host.h" 45 #include "content/public/browser/render_view_host.h"
40 #include "content/public/browser/web_contents.h" 46 #include "content/public/browser/web_contents.h"
41 #include "content/public/common/renderer_preferences.h" 47 #include "content/public/common/renderer_preferences.h"
42 #include "content/public/common/ssl_status.h" 48 #include "content/public/common/ssl_status.h"
43 #include "grit/browser_resources.h" 49 #include "grit/browser_resources.h"
44 #include "net/base/hash_value.h" 50 #include "net/base/hash_value.h"
45 #include "net/base/net_errors.h" 51 #include "net/base/net_errors.h"
46 #include "net/base/net_util.h" 52 #include "net/base/net_util.h"
53 #include "net/url_request/url_request_context.h"
54 #include "net/url_request/url_request_context_getter.h"
47 #include "ui/base/l10n/l10n_util.h" 55 #include "ui/base/l10n/l10n_util.h"
48 56
49 #if defined(OS_WIN) 57 #if defined(OS_WIN)
50 #include "base/base_paths_win.h" 58 #include "base/base_paths_win.h"
51 #include "base/path_service.h" 59 #include "base/path_service.h"
52 #include "base/strings/string16.h" 60 #include "base/strings/string16.h"
53 #include "base/win/windows_version.h" 61 #include "base/win/windows_version.h"
54 #endif 62 #endif
55 63
56 #if defined(OS_ANDROID) 64 #if defined(OS_ANDROID)
57 #include "chrome/browser/android/intent_helper.h" 65 #include "chrome/browser/android/intent_helper.h"
58 #endif 66 #endif
59 67
60 #if defined(OS_CHROMEOS) 68 #if defined(OS_CHROMEOS)
61 #include "chrome/browser/profiles/profile_manager.h" 69 #include "chrome/browser/profiles/profile_manager.h"
62 #include "chrome/browser/ui/chrome_pages.h" 70 #include "chrome/browser/ui/chrome_pages.h"
63 #include "chrome/common/url_constants.h" 71 #include "chrome/common/url_constants.h"
64 #endif 72 #endif
65 73
66 using base::ASCIIToUTF16; 74 using base::ASCIIToUTF16;
67 using base::TimeTicks; 75 using base::TimeTicks;
76 using chrome_browser_net::CertificateErrorReporter;
77 using content::BrowserThread;
68 using content::InterstitialPage; 78 using content::InterstitialPage;
69 using content::InterstitialPageDelegate; 79 using content::InterstitialPageDelegate;
70 using content::NavigationController; 80 using content::NavigationController;
71 using content::NavigationEntry; 81 using content::NavigationEntry;
72 82
73 namespace { 83 namespace {
74 84
75 // URL for help page. 85 // URL for help page.
76 const char kHelpURL[] = "https://support.google.com/chrome/answer/4454607"; 86 const char kHelpURL[] = "https://support.google.com/chrome/answer/4454607";
77 87
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 214
205 bool IsErrorDueToBadClock(const base::Time& now, int error) { 215 bool IsErrorDueToBadClock(const base::Time& now, int error) {
206 if (SSLErrorInfo::NetErrorToErrorType(error) != 216 if (SSLErrorInfo::NetErrorToErrorType(error) !=
207 SSLErrorInfo::CERT_DATE_INVALID) { 217 SSLErrorInfo::CERT_DATE_INVALID) {
208 return false; 218 return false;
209 } 219 }
210 return SSLErrorClassification::IsUserClockInThePast(now) || 220 return SSLErrorClassification::IsUserClockInThePast(now) ||
211 SSLErrorClassification::IsUserClockInTheFuture(now); 221 SSLErrorClassification::IsUserClockInTheFuture(now);
212 } 222 }
213 223
224 // A helper function that actually sends the cert collection report over
225 // the network.
226 void FinishCertCollectionInternal(
227 const scoped_refptr<CertificateErrorReporter>& reporter,
228 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter,
229 const std::string& hostname,
230 const net::SSLInfo& ssl_info) {
231 DCHECK_CURRENTLY_ON(BrowserThread::IO);
232 DCHECK(reporter);
233 reporter->SendReport(CertificateErrorReporter::REPORT_TYPE_EXTENDED_REPORTING,
234 request_context_getter->GetURLRequestContext(), hostname,
235 ssl_info);
236 }
237
214 } // namespace 238 } // namespace
215 239
216 // static 240 // static
217 InterstitialPageDelegate::TypeID SSLBlockingPage::kTypeForTesting = 241 InterstitialPageDelegate::TypeID SSLBlockingPage::kTypeForTesting =
218 &SSLBlockingPage::kTypeForTesting; 242 &SSLBlockingPage::kTypeForTesting;
219 243
220 // Note that we always create a navigation entry with SSL errors. 244 // Note that we always create a navigation entry with SSL errors.
221 // No error happening loading a sub-resource triggers an interstitial so far. 245 // No error happening loading a sub-resource triggers an interstitial so far.
222 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, 246 SSLBlockingPage::SSLBlockingPage(
223 int cert_error, 247 content::WebContents* web_contents,
224 const net::SSLInfo& ssl_info, 248 int cert_error,
225 const GURL& request_url, 249 const net::SSLInfo& ssl_info,
226 int options_mask, 250 const GURL& request_url,
227 const base::Time& time_triggered, 251 int options_mask,
228 const base::Callback<void(bool)>& callback) 252 const base::Time& time_triggered,
253 const scoped_refptr<CertificateErrorReporter>& certificate_error_reporter,
254 const base::Callback<void(bool)>& callback)
229 : SecurityInterstitialPage(web_contents, request_url), 255 : SecurityInterstitialPage(web_contents, request_url),
230 callback_(callback), 256 callback_(callback),
231 cert_error_(cert_error), 257 cert_error_(cert_error),
232 ssl_info_(ssl_info), 258 ssl_info_(ssl_info),
233 overridable_(IsOptionsOverridable(options_mask)), 259 overridable_(IsOptionsOverridable(options_mask)),
234 danger_overridable_(true), 260 danger_overridable_(true),
235 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), 261 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0),
236 expired_but_previously_allowed_( 262 expired_but_previously_allowed_(
237 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0), 263 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0),
238 time_triggered_(time_triggered) { 264 time_triggered_(time_triggered),
265 certificate_error_reporter_(certificate_error_reporter) {
239 interstitial_reason_ = 266 interstitial_reason_ =
240 IsErrorDueToBadClock(time_triggered_, cert_error_) ? 267 IsErrorDueToBadClock(time_triggered_, cert_error_) ?
241 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL; 268 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL;
242 269
243 // We collapse the Rappor metric name to just "ssl" so we don't leak 270 // We collapse the Rappor metric name to just "ssl" so we don't leak
244 // the "overridable" bit. We skip Rappor altogether for bad clocks. 271 // the "overridable" bit. We skip Rappor altogether for bad clocks.
245 // This must be done after calculating |interstitial_reason_| above. 272 // This must be done after calculating |interstitial_reason_| above.
246 metrics_helper_.reset(new SecurityInterstitialMetricsHelper( 273 metrics_helper_.reset(new SecurityInterstitialMetricsHelper(
247 web_contents, request_url, GetUmaHistogramPrefix(), kSSLRapporPrefix, 274 web_contents, request_url, GetUmaHistogramPrefix(), kSSLRapporPrefix,
248 (interstitial_reason_ == SSL_REASON_BAD_CLOCK 275 (interstitial_reason_ == SSL_REASON_BAD_CLOCK
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 load_time_data->SetString("type", "SSL"); 326 load_time_data->SetString("type", "SSL");
300 327
301 // Shared UI configuration for all SSL interstitials. 328 // Shared UI configuration for all SSL interstitials.
302 load_time_data->SetString("errorCode", net::ErrorToString(cert_error_)); 329 load_time_data->SetString("errorCode", net::ErrorToString(cert_error_));
303 load_time_data->SetString( 330 load_time_data->SetString(
304 "openDetails", 331 "openDetails",
305 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); 332 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON));
306 load_time_data->SetString( 333 load_time_data->SetString(
307 "closeDetails", 334 "closeDetails",
308 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); 335 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON));
309
310 // Conditional UI configuration. 336 // Conditional UI configuration.
311 if (interstitial_reason_ == SSL_REASON_BAD_CLOCK) { 337 if (interstitial_reason_ == SSL_REASON_BAD_CLOCK) {
312 load_time_data->SetBoolean("bad_clock", true); 338 load_time_data->SetBoolean("bad_clock", true);
313 load_time_data->SetBoolean("overridable", false); 339 load_time_data->SetBoolean("overridable", false);
314 340
315 #if defined(OS_IOS) 341 #if defined(OS_IOS)
316 load_time_data->SetBoolean("hide_primary_button", true); 342 load_time_data->SetBoolean("hide_primary_button", true);
317 #else 343 #else
318 load_time_data->SetBoolean("hide_primary_button", false); 344 load_time_data->SetBoolean("hide_primary_button", false);
319 #endif 345 #endif
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 // Set debugging information at the bottom of the warning. 451 // Set debugging information at the bottom of the warning.
426 load_time_data->SetString( 452 load_time_data->SetString(
427 "subject", ssl_info_.cert->subject().GetDisplayName()); 453 "subject", ssl_info_.cert->subject().GetDisplayName());
428 load_time_data->SetString( 454 load_time_data->SetString(
429 "issuer", ssl_info_.cert->issuer().GetDisplayName()); 455 "issuer", ssl_info_.cert->issuer().GetDisplayName());
430 load_time_data->SetString( 456 load_time_data->SetString(
431 "expirationDate", 457 "expirationDate",
432 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry())); 458 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry()));
433 load_time_data->SetString( 459 load_time_data->SetString(
434 "currentDate", base::TimeFormatShortDate(time_triggered_)); 460 "currentDate", base::TimeFormatShortDate(time_triggered_));
461
435 std::vector<std::string> encoded_chain; 462 std::vector<std::string> encoded_chain;
436 ssl_info_.cert->GetPEMEncodedChain( 463 ssl_info_.cert->GetPEMEncodedChain(
437 &encoded_chain); 464 &encoded_chain);
438 load_time_data->SetString( 465 load_time_data->SetString(
439 "pem", JoinString(encoded_chain, std::string())); 466 "pem", JoinString(encoded_chain, std::string()));
467
468 PopulateExtendedReportingOption(load_time_data);
469 }
470
471 void SSLBlockingPage::PopulateExtendedReportingOption(
472 base::DictionaryValue* load_time_data) {
473 // Only show the checkbox if not off-the-record and if the
474 // command-line option is set.
475 const bool show = !web_contents()->GetBrowserContext()->IsOffTheRecord() &&
476 base::CommandLine::ForCurrentProcess()->HasSwitch(
477 switches::kEnableInvalidCertCollection);
478
479 load_time_data->SetBoolean(interstitials::kDisplayCheckBox, show);
480 if (!show)
481 return;
482
483 load_time_data->SetBoolean(
484 interstitials::kBoxChecked,
485 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled));
486
487 const std::string privacy_link = base::StringPrintf(
488 interstitials::kPrivacyLinkHtml,
489 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str());
490
491 load_time_data->SetString(
492 interstitials::kOptInLink,
493 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE,
494 base::UTF8ToUTF16(privacy_link)));
440 } 495 }
441 496
442 void SSLBlockingPage::OverrideEntry(NavigationEntry* entry) { 497 void SSLBlockingPage::OverrideEntry(NavigationEntry* entry) {
443 int cert_id = content::CertStore::GetInstance()->StoreCert( 498 int cert_id = content::CertStore::GetInstance()->StoreCert(
444 ssl_info_.cert.get(), web_contents()->GetRenderProcessHost()->GetID()); 499 ssl_info_.cert.get(), web_contents()->GetRenderProcessHost()->GetID());
445 DCHECK(cert_id); 500 DCHECK(cert_id);
446 501
447 entry->GetSSL().security_style = 502 entry->GetSSL().security_style =
448 content::SECURITY_STYLE_AUTHENTICATION_BROKEN; 503 content::SECURITY_STYLE_AUTHENTICATION_BROKEN;
449 entry->GetSSL().cert_id = cert_id; 504 entry->GetSSL().cert_id = cert_id;
450 entry->GetSSL().cert_status = ssl_info_.cert_status; 505 entry->GetSSL().cert_status = ssl_info_.cert_status;
451 entry->GetSSL().security_bits = ssl_info_.security_bits; 506 entry->GetSSL().security_bits = ssl_info_.security_bits;
452 } 507 }
453 508
509 void SSLBlockingPage::SetCertificateErrorReporterForTesting(
510 const scoped_refptr<CertificateErrorReporter>& certificate_error_reporter) {
511 certificate_error_reporter_ = certificate_error_reporter;
512 }
513
454 // This handles the commands sent from the interstitial JavaScript. They are 514 // This handles the commands sent from the interstitial JavaScript. They are
455 // defined in chrome/browser/resources/ssl/ssl_errors_common.js. 515 // defined in chrome/browser/resources/ssl/ssl_errors_common.js.
456 // DO NOT reorder or change this logic without also changing the JavaScript! 516 // DO NOT reorder or change this logic without also changing the JavaScript!
457 void SSLBlockingPage::CommandReceived(const std::string& command) { 517 void SSLBlockingPage::CommandReceived(const std::string& command) {
458 int cmd = 0; 518 int cmd = 0;
459 bool retval = base::StringToInt(command, &cmd); 519 bool retval = base::StringToInt(command, &cmd);
460 DCHECK(retval); 520 DCHECK(retval);
461 switch (cmd) { 521 switch (cmd) {
462 case CMD_DONT_PROCEED: { 522 case CMD_DONT_PROCEED: {
463 interstitial_page()->DontProceed(); 523 interstitial_page()->DontProceed();
464 break; 524 break;
465 } 525 }
466 case CMD_PROCEED: { 526 case CMD_PROCEED: {
467 if (danger_overridable_) { 527 if (danger_overridable_) {
468 interstitial_page()->Proceed(); 528 interstitial_page()->Proceed();
469 } 529 }
470 break; 530 break;
471 } 531 }
532 case CMD_DO_REPORT: {
533 SetReportingPreference(true);
534 break;
535 }
536 case CMD_DONT_REPORT: {
537 SetReportingPreference(false);
538 break;
539 }
472 case CMD_MORE: { 540 case CMD_MORE: {
473 metrics_helper_->RecordUserInteraction( 541 metrics_helper_->RecordUserInteraction(
474 SecurityInterstitialMetricsHelper::SHOW_ADVANCED); 542 SecurityInterstitialMetricsHelper::SHOW_ADVANCED);
475 break; 543 break;
476 } 544 }
477 case CMD_RELOAD: { 545 case CMD_RELOAD: {
478 metrics_helper_->RecordUserInteraction( 546 metrics_helper_->RecordUserInteraction(
479 SecurityInterstitialMetricsHelper::RELOAD); 547 SecurityInterstitialMetricsHelper::RELOAD);
480 // The interstitial can't refresh itself. 548 // The interstitial can't refresh itself.
481 web_contents()->GetController().Reload(true); 549 web_contents()->GetController().Reload(true);
(...skipping 24 matching lines...) Expand all
506 content::RendererPreferences* prefs) { 574 content::RendererPreferences* prefs) {
507 Profile* profile = Profile::FromBrowserContext( 575 Profile* profile = Profile::FromBrowserContext(
508 web_contents()->GetBrowserContext()); 576 web_contents()->GetBrowserContext());
509 renderer_preferences_util::UpdateFromSystemSettings( 577 renderer_preferences_util::UpdateFromSystemSettings(
510 prefs, profile, web_contents()); 578 prefs, profile, web_contents());
511 } 579 }
512 580
513 void SSLBlockingPage::OnProceed() { 581 void SSLBlockingPage::OnProceed() {
514 metrics_helper_->RecordUserDecision( 582 metrics_helper_->RecordUserDecision(
515 SecurityInterstitialMetricsHelper::PROCEED); 583 SecurityInterstitialMetricsHelper::PROCEED);
584
585 // Finish collection information about invalid certificates, if the
586 // user opted in to.
587 FinishCertCollection();
588
516 RecordSSLExpirationPageEventState( 589 RecordSSLExpirationPageEventState(
517 expired_but_previously_allowed_, true, overridable_); 590 expired_but_previously_allowed_, true, overridable_);
518 // Accepting the certificate resumes the loading of the page. 591 // Accepting the certificate resumes the loading of the page.
519 NotifyAllowCertificate(); 592 NotifyAllowCertificate();
520 } 593 }
521 594
522 void SSLBlockingPage::OnDontProceed() { 595 void SSLBlockingPage::OnDontProceed() {
523 metrics_helper_->RecordUserDecision( 596 metrics_helper_->RecordUserDecision(
524 SecurityInterstitialMetricsHelper::DONT_PROCEED); 597 SecurityInterstitialMetricsHelper::DONT_PROCEED);
598
599 // Finish collection information about invalid certificates, if the
600 // user opted in to.
601 FinishCertCollection();
602
525 RecordSSLExpirationPageEventState( 603 RecordSSLExpirationPageEventState(
526 expired_but_previously_allowed_, false, overridable_); 604 expired_but_previously_allowed_, false, overridable_);
527 NotifyDenyCertificate(); 605 NotifyDenyCertificate();
528 } 606 }
529 607
530 void SSLBlockingPage::NotifyDenyCertificate() { 608 void SSLBlockingPage::NotifyDenyCertificate() {
531 // It's possible that callback_ may not exist if the user clicks "Proceed" 609 // It's possible that callback_ may not exist if the user clicks "Proceed"
532 // followed by pressing the back button before the interstitial is hidden. 610 // followed by pressing the back button before the interstitial is hidden.
533 // In that case the certificate will still be treated as allowed. 611 // In that case the certificate will still be treated as allowed.
534 if (callback_.is_null()) 612 if (callback_.is_null())
(...skipping 27 matching lines...) Expand all
562 std::string SSLBlockingPage::GetSamplingEventName() const { 640 std::string SSLBlockingPage::GetSamplingEventName() const {
563 std::string event_name(kEventNameBase); 641 std::string event_name(kEventNameBase);
564 if (overridable_) 642 if (overridable_)
565 event_name.append(kEventOverridable); 643 event_name.append(kEventOverridable);
566 else 644 else
567 event_name.append(kEventNotOverridable); 645 event_name.append(kEventNotOverridable);
568 event_name.append(net::ErrorToString(cert_error_)); 646 event_name.append(net::ErrorToString(cert_error_));
569 return event_name; 647 return event_name;
570 } 648 }
571 649
650 void SSLBlockingPage::FinishCertCollection() {
651 base::ScopedClosureRunner scoped_callback(
652 certificate_report_callback_for_testing_);
653
654 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
655 switches::kEnableInvalidCertCollection) ||
656 web_contents()->GetBrowserContext()->IsOffTheRecord()) {
657 return;
658 }
659
660 const bool enabled =
661 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled);
662 UMA_HISTOGRAM_BOOLEAN("SB2.ExtendedReportingIsEnabled", enabled);
663
664 if (!enabled || !certificate_error_reporter_)
665 return;
666
667 scoped_refptr<net::URLRequestContextGetter> request_context_getter =
668 web_contents()->GetBrowserContext()->GetRequestContext();
669 BrowserThread::PostTaskAndReply(
670 BrowserThread::IO, FROM_HERE,
671 base::Bind(FinishCertCollectionInternal, certificate_error_reporter_,
672 request_context_getter, request_url().host(), ssl_info_),
673 scoped_callback.Release());
674 }
675
572 // static 676 // static
573 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) { 677 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) {
574 return (options_mask & SSLBlockingPage::OVERRIDABLE) && 678 return (options_mask & SSLBlockingPage::OVERRIDABLE) &&
575 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT); 679 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT);
576 } 680 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.h ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698