| 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 "chrome/browser/ssl/ssl_blocking_page.h" | 5 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" |
| 7 #include "base/build_time.h" | 9 #include "base/build_time.h" |
| 10 #include "base/callback_helpers.h" |
| 8 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 9 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 10 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
| 11 #include "base/metrics/field_trial.h" | 14 #include "base/metrics/field_trial.h" |
| 12 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/prefs/pref_service.h" |
| 13 #include "base/process/launch.h" | 17 #include "base/process/launch.h" |
| 14 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
| 16 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/time/time.h" | 23 #include "base/time/time.h" |
| 20 #include "base/values.h" | 24 #include "base/values.h" |
| 21 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
| 27 #include "chrome/browser/interstitials/security_interstitial_metrics_helper.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/renderer_preferences_util.h" | 29 #include "chrome/browser/renderer_preferences_util.h" |
| 30 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 25 #include "chrome/browser/ssl/ssl_error_classification.h" | 31 #include "chrome/browser/ssl/ssl_error_classification.h" |
| 26 #include "chrome/browser/ssl/ssl_error_info.h" | 32 #include "chrome/browser/ssl/ssl_error_info.h" |
| 27 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/grit/chromium_strings.h" | 35 #include "chrome/grit/chromium_strings.h" |
| 29 #include "chrome/grit/generated_resources.h" | 36 #include "chrome/grit/generated_resources.h" |
| 30 #include "components/google/core/browser/google_util.h" | 37 #include "components/google/core/browser/google_util.h" |
| 31 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
| 32 #include "content/public/browser/cert_store.h" | 39 #include "content/public/browser/cert_store.h" |
| 33 #include "content/public/browser/interstitial_page.h" | 40 #include "content/public/browser/interstitial_page.h" |
| 34 #include "content/public/browser/interstitial_page_delegate.h" | 41 #include "content/public/browser/interstitial_page_delegate.h" |
| 35 #include "content/public/browser/navigation_controller.h" | 42 #include "content/public/browser/navigation_controller.h" |
| 36 #include "content/public/browser/navigation_entry.h" | 43 #include "content/public/browser/navigation_entry.h" |
| 37 #include "content/public/browser/notification_service.h" | 44 #include "content/public/browser/notification_service.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 221 } |
| 215 | 222 |
| 216 } // namespace | 223 } // namespace |
| 217 | 224 |
| 218 // static | 225 // static |
| 219 InterstitialPageDelegate::TypeID SSLBlockingPage::kTypeForTesting = | 226 InterstitialPageDelegate::TypeID SSLBlockingPage::kTypeForTesting = |
| 220 &SSLBlockingPage::kTypeForTesting; | 227 &SSLBlockingPage::kTypeForTesting; |
| 221 | 228 |
| 222 // Note that we always create a navigation entry with SSL errors. | 229 // Note that we always create a navigation entry with SSL errors. |
| 223 // No error happening loading a sub-resource triggers an interstitial so far. | 230 // No error happening loading a sub-resource triggers an interstitial so far. |
| 224 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, | 231 SSLBlockingPage::SSLBlockingPage( |
| 225 int cert_error, | 232 content::WebContents* web_contents, |
| 226 const net::SSLInfo& ssl_info, | 233 int cert_error, |
| 227 const GURL& request_url, | 234 const net::SSLInfo& ssl_info, |
| 228 int options_mask, | 235 const GURL& request_url, |
| 229 const base::Time& time_triggered, | 236 int options_mask, |
| 230 const base::Callback<void(bool)>& callback) | 237 const base::Time& time_triggered, |
| 238 SafeBrowsingUIManager* safe_browsing_ui_manager, |
| 239 const base::Callback<void(bool)>& callback) |
| 231 : SecurityInterstitialPage(web_contents, request_url), | 240 : SecurityInterstitialPage(web_contents, request_url), |
| 232 callback_(callback), | 241 callback_(callback), |
| 233 cert_error_(cert_error), | 242 cert_error_(cert_error), |
| 234 ssl_info_(ssl_info), | 243 ssl_info_(ssl_info), |
| 235 overridable_(IsOptionsOverridable(options_mask)), | 244 overridable_(IsOptionsOverridable(options_mask)), |
| 236 danger_overridable_(true), | 245 danger_overridable_(true), |
| 237 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), | 246 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), |
| 238 expired_but_previously_allowed_( | 247 expired_but_previously_allowed_( |
| 239 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0), | 248 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0), |
| 240 time_triggered_(time_triggered) { | 249 time_triggered_(time_triggered), |
| 250 safe_browsing_ui_manager_(safe_browsing_ui_manager) { |
| 241 interstitial_reason_ = | 251 interstitial_reason_ = |
| 242 IsErrorDueToBadClock(time_triggered_, cert_error_) ? | 252 IsErrorDueToBadClock(time_triggered_, cert_error_) ? |
| 243 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL; | 253 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL; |
| 244 | 254 |
| 245 // We collapse the Rappor metric name to just "ssl" so we don't leak | 255 // We collapse the Rappor metric name to just "ssl" so we don't leak |
| 246 // the "overridable" bit. We skip Rappor altogether for bad clocks. | 256 // the "overridable" bit. We skip Rappor altogether for bad clocks. |
| 247 // This must be done after calculating |interstitial_reason_| above. | 257 // This must be done after calculating |interstitial_reason_| above. |
| 248 metrics_helper_.reset(new SecurityInterstitialMetricsHelper( | 258 set_metrics_helper(new SecurityInterstitialMetricsHelper( |
| 249 web_contents, request_url, GetUmaHistogramPrefix(), kSSLRapporPrefix, | 259 web_contents, request_url, GetUmaHistogramPrefix(), kSSLRapporPrefix, |
| 250 (interstitial_reason_ == SSL_REASON_BAD_CLOCK | 260 (interstitial_reason_ == SSL_REASON_BAD_CLOCK |
| 251 ? SecurityInterstitialMetricsHelper::SKIP_RAPPOR | 261 ? SecurityInterstitialMetricsHelper::SKIP_RAPPOR |
| 252 : SecurityInterstitialMetricsHelper::REPORT_RAPPOR), | 262 : SecurityInterstitialMetricsHelper::REPORT_RAPPOR), |
| 253 GetSamplingEventName())); | 263 GetSamplingEventName())); |
| 254 | 264 |
| 255 metrics_helper_->RecordUserDecision(SecurityInterstitialMetricsHelper::SHOW); | 265 metrics_helper()->RecordUserDecision(SecurityInterstitialMetricsHelper::SHOW); |
| 256 metrics_helper_->RecordUserInteraction( | 266 metrics_helper()->RecordUserInteraction( |
| 257 SecurityInterstitialMetricsHelper::TOTAL_VISITS); | 267 SecurityInterstitialMetricsHelper::TOTAL_VISITS); |
| 258 | 268 |
| 259 ssl_error_classification_.reset(new SSLErrorClassification( | 269 ssl_error_classification_.reset(new SSLErrorClassification( |
| 260 web_contents, | 270 web_contents, |
| 261 time_triggered_, | 271 time_triggered_, |
| 262 request_url, | 272 request_url, |
| 263 cert_error_, | 273 cert_error_, |
| 264 *ssl_info_.cert.get())); | 274 *ssl_info_.cert.get())); |
| 265 ssl_error_classification_->RecordUMAStatistics(overridable_); | 275 ssl_error_classification_->RecordUMAStatistics(overridable_); |
| 266 | 276 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 278 | 288 |
| 279 SSLBlockingPage::~SSLBlockingPage() { | 289 SSLBlockingPage::~SSLBlockingPage() { |
| 280 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 290 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 281 // Captive portal detection results can arrive anytime during the interstitial | 291 // Captive portal detection results can arrive anytime during the interstitial |
| 282 // is being displayed, so record it when the interstitial is going away. | 292 // is being displayed, so record it when the interstitial is going away. |
| 283 ssl_error_classification_->RecordCaptivePortalUMAStatistics(overridable_); | 293 ssl_error_classification_->RecordCaptivePortalUMAStatistics(overridable_); |
| 284 #endif | 294 #endif |
| 285 if (!callback_.is_null()) { | 295 if (!callback_.is_null()) { |
| 286 // The page is closed without the user having chosen what to do, default to | 296 // The page is closed without the user having chosen what to do, default to |
| 287 // deny. | 297 // deny. |
| 288 metrics_helper_->RecordUserDecision( | 298 metrics_helper()->RecordUserDecision( |
| 289 SecurityInterstitialMetricsHelper::DONT_PROCEED); | 299 SecurityInterstitialMetricsHelper::DONT_PROCEED); |
| 290 RecordSSLExpirationPageEventState( | 300 RecordSSLExpirationPageEventState( |
| 291 expired_but_previously_allowed_, false, overridable_); | 301 expired_but_previously_allowed_, false, overridable_); |
| 292 NotifyDenyCertificate(); | 302 NotifyDenyCertificate(); |
| 293 } | 303 } |
| 294 } | 304 } |
| 295 | 305 |
| 296 void SSLBlockingPage::PopulateInterstitialStrings( | 306 void SSLBlockingPage::PopulateInterstitialStrings( |
| 297 base::DictionaryValue* load_time_data) { | 307 base::DictionaryValue* load_time_data) { |
| 298 CHECK(load_time_data); | 308 CHECK(load_time_data); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 load_time_data->SetString( | 442 load_time_data->SetString( |
| 433 "expirationDate", | 443 "expirationDate", |
| 434 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry())); | 444 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry())); |
| 435 load_time_data->SetString( | 445 load_time_data->SetString( |
| 436 "currentDate", base::TimeFormatShortDate(time_triggered_)); | 446 "currentDate", base::TimeFormatShortDate(time_triggered_)); |
| 437 std::vector<std::string> encoded_chain; | 447 std::vector<std::string> encoded_chain; |
| 438 ssl_info_.cert->GetPEMEncodedChain( | 448 ssl_info_.cert->GetPEMEncodedChain( |
| 439 &encoded_chain); | 449 &encoded_chain); |
| 440 load_time_data->SetString( | 450 load_time_data->SetString( |
| 441 "pem", JoinString(encoded_chain, std::string())); | 451 "pem", JoinString(encoded_chain, std::string())); |
| 452 |
| 453 PopulateExtendedReportingOption(load_time_data); |
| 454 } |
| 455 |
| 456 void SSLBlockingPage::PopulateExtendedReportingOption( |
| 457 base::DictionaryValue* load_time_data) { |
| 458 // Only show the checkbox if not off-the-record and if the |
| 459 // command-line option is set. |
| 460 const bool show = !web_contents()->GetBrowserContext()->IsOffTheRecord() && |
| 461 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 462 switches::kEnableInvalidCertCollection); |
| 463 |
| 464 load_time_data->SetBoolean(interstitials::kDisplayCheckBox, show); |
| 465 if (!show) |
| 466 return; |
| 467 |
| 468 load_time_data->SetBoolean( |
| 469 interstitials::kBoxChecked, |
| 470 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled)); |
| 471 |
| 472 const std::string privacy_link = base::StringPrintf( |
| 473 interstitials::kPrivacyLinkHtml, CMD_OPEN_REPORTING_PRIVACY, |
| 474 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str()); |
| 475 |
| 476 load_time_data->SetString( |
| 477 interstitials::kOptInLink, |
| 478 l10n_util::GetStringFUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, |
| 479 base::UTF8ToUTF16(privacy_link))); |
| 442 } | 480 } |
| 443 | 481 |
| 444 void SSLBlockingPage::OverrideEntry(NavigationEntry* entry) { | 482 void SSLBlockingPage::OverrideEntry(NavigationEntry* entry) { |
| 445 int cert_id = content::CertStore::GetInstance()->StoreCert( | 483 int cert_id = content::CertStore::GetInstance()->StoreCert( |
| 446 ssl_info_.cert.get(), web_contents()->GetRenderProcessHost()->GetID()); | 484 ssl_info_.cert.get(), web_contents()->GetRenderProcessHost()->GetID()); |
| 447 DCHECK(cert_id); | 485 DCHECK(cert_id); |
| 448 | 486 |
| 449 entry->GetSSL().security_style = | 487 entry->GetSSL().security_style = |
| 450 content::SECURITY_STYLE_AUTHENTICATION_BROKEN; | 488 content::SECURITY_STYLE_AUTHENTICATION_BROKEN; |
| 451 entry->GetSSL().cert_id = cert_id; | 489 entry->GetSSL().cert_id = cert_id; |
| 452 entry->GetSSL().cert_status = ssl_info_.cert_status; | 490 entry->GetSSL().cert_status = ssl_info_.cert_status; |
| 453 entry->GetSSL().security_bits = ssl_info_.security_bits; | 491 entry->GetSSL().security_bits = ssl_info_.security_bits; |
| 454 } | 492 } |
| 455 | 493 |
| 494 void SSLBlockingPage::SetCertificateReportCallbackForTesting( |
| 495 const base::Closure& callback) { |
| 496 certificate_report_callback_for_testing_ = callback; |
| 497 } |
| 498 |
| 456 // This handles the commands sent from the interstitial JavaScript. | 499 // This handles the commands sent from the interstitial JavaScript. |
| 457 // DO NOT reorder or change this logic without also changing the JavaScript! | 500 // DO NOT reorder or change this logic without also changing the JavaScript! |
| 458 void SSLBlockingPage::CommandReceived(const std::string& command) { | 501 void SSLBlockingPage::CommandReceived(const std::string& command) { |
| 459 if (command == "\"pageLoadComplete\"") { | 502 if (command == "\"pageLoadComplete\"") { |
| 460 // content::WaitForRenderFrameReady sends this message when the page | 503 // content::WaitForRenderFrameReady sends this message when the page |
| 461 // load completes. Ignore it. | 504 // load completes. Ignore it. |
| 462 return; | 505 return; |
| 463 } | 506 } |
| 464 | 507 |
| 465 int cmd = 0; | 508 int cmd = 0; |
| 466 bool retval = base::StringToInt(command, &cmd); | 509 bool retval = base::StringToInt(command, &cmd); |
| 467 DCHECK(retval); | 510 DCHECK(retval); |
| 468 switch (cmd) { | 511 switch (cmd) { |
| 469 case CMD_DONT_PROCEED: { | 512 case CMD_DONT_PROCEED: { |
| 470 interstitial_page()->DontProceed(); | 513 interstitial_page()->DontProceed(); |
| 471 break; | 514 break; |
| 472 } | 515 } |
| 473 case CMD_PROCEED: { | 516 case CMD_PROCEED: { |
| 474 if (danger_overridable_) { | 517 if (danger_overridable_) { |
| 475 interstitial_page()->Proceed(); | 518 interstitial_page()->Proceed(); |
| 476 } | 519 } |
| 477 break; | 520 break; |
| 478 } | 521 } |
| 522 case CMD_DO_REPORT: { |
| 523 SetReportingPreference(true); |
| 524 break; |
| 525 } |
| 526 case CMD_DONT_REPORT: { |
| 527 SetReportingPreference(false); |
| 528 break; |
| 529 } |
| 479 case CMD_SHOW_MORE_SECTION: { | 530 case CMD_SHOW_MORE_SECTION: { |
| 480 metrics_helper_->RecordUserInteraction( | 531 metrics_helper()->RecordUserInteraction( |
| 481 SecurityInterstitialMetricsHelper::SHOW_ADVANCED); | 532 SecurityInterstitialMetricsHelper::SHOW_ADVANCED); |
| 482 break; | 533 break; |
| 483 } | 534 } |
| 484 case CMD_OPEN_HELP_CENTER: { | 535 case CMD_OPEN_HELP_CENTER: { |
| 485 metrics_helper_->RecordUserInteraction( | 536 metrics_helper()->RecordUserInteraction( |
| 486 SecurityInterstitialMetricsHelper::SHOW_LEARN_MORE); | 537 SecurityInterstitialMetricsHelper::SHOW_LEARN_MORE); |
| 487 content::NavigationController::LoadURLParams help_page_params( | 538 content::NavigationController::LoadURLParams help_page_params( |
| 488 google_util::AppendGoogleLocaleParam( | 539 google_util::AppendGoogleLocaleParam( |
| 489 GURL(kHelpURL), g_browser_process->GetApplicationLocale())); | 540 GURL(kHelpURL), g_browser_process->GetApplicationLocale())); |
| 490 web_contents()->GetController().LoadURLWithParams(help_page_params); | 541 web_contents()->GetController().LoadURLWithParams(help_page_params); |
| 491 break; | 542 break; |
| 492 } | 543 } |
| 493 case CMD_RELOAD: { | 544 case CMD_RELOAD: { |
| 494 metrics_helper_->RecordUserInteraction( | 545 metrics_helper()->RecordUserInteraction( |
| 495 SecurityInterstitialMetricsHelper::RELOAD); | 546 SecurityInterstitialMetricsHelper::RELOAD); |
| 496 // The interstitial can't refresh itself. | 547 // The interstitial can't refresh itself. |
| 497 web_contents()->GetController().Reload(true); | 548 web_contents()->GetController().Reload(true); |
| 498 break; | 549 break; |
| 499 } | 550 } |
| 500 case CMD_OPEN_DATE_SETTINGS: { | 551 case CMD_OPEN_DATE_SETTINGS: { |
| 501 metrics_helper_->RecordUserInteraction( | 552 metrics_helper()->RecordUserInteraction( |
| 502 SecurityInterstitialMetricsHelper::OPEN_TIME_SETTINGS); | 553 SecurityInterstitialMetricsHelper::OPEN_TIME_SETTINGS); |
| 503 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 554 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
| 504 base::Bind(&LaunchDateAndTimeSettings)); | 555 base::Bind(&LaunchDateAndTimeSettings)); |
| 505 break; | 556 break; |
| 506 } | 557 } |
| 558 case CMD_OPEN_REPORTING_PRIVACY: |
| 559 OpenExtendedReportingPrivacyPolicy(); |
| 560 break; |
| 507 case CMD_OPEN_DIAGNOSTIC: | 561 case CMD_OPEN_DIAGNOSTIC: |
| 508 // Google doesn't currently have a transparency report for SSL. | 562 // Google doesn't currently have a transparency report for SSL. |
| 509 case CMD_DO_REPORT: | |
| 510 case CMD_DONT_REPORT: | |
| 511 case CMD_OPEN_REPORTING_PRIVACY: | |
| 512 // Chrome doesn't currently do Extended Reporting for SSL. | |
| 513 NOTREACHED() << "Unexpected command: " << command; | 563 NOTREACHED() << "Unexpected command: " << command; |
| 514 } | 564 } |
| 515 } | 565 } |
| 516 | 566 |
| 517 void SSLBlockingPage::OverrideRendererPrefs( | 567 void SSLBlockingPage::OverrideRendererPrefs( |
| 518 content::RendererPreferences* prefs) { | 568 content::RendererPreferences* prefs) { |
| 519 Profile* profile = Profile::FromBrowserContext( | 569 Profile* profile = Profile::FromBrowserContext( |
| 520 web_contents()->GetBrowserContext()); | 570 web_contents()->GetBrowserContext()); |
| 521 renderer_preferences_util::UpdateFromSystemSettings( | 571 renderer_preferences_util::UpdateFromSystemSettings( |
| 522 prefs, profile, web_contents()); | 572 prefs, profile, web_contents()); |
| 523 } | 573 } |
| 524 | 574 |
| 525 void SSLBlockingPage::OnProceed() { | 575 void SSLBlockingPage::OnProceed() { |
| 526 metrics_helper_->RecordUserDecision( | 576 metrics_helper()->RecordUserDecision( |
| 527 SecurityInterstitialMetricsHelper::PROCEED); | 577 SecurityInterstitialMetricsHelper::PROCEED); |
| 578 |
| 579 // Finish collecting information about invalid certificates, if the |
| 580 // user opted in to. |
| 581 FinishCertCollection(); |
| 582 |
| 528 RecordSSLExpirationPageEventState( | 583 RecordSSLExpirationPageEventState( |
| 529 expired_but_previously_allowed_, true, overridable_); | 584 expired_but_previously_allowed_, true, overridable_); |
| 530 // Accepting the certificate resumes the loading of the page. | 585 // Accepting the certificate resumes the loading of the page. |
| 531 NotifyAllowCertificate(); | 586 NotifyAllowCertificate(); |
| 532 } | 587 } |
| 533 | 588 |
| 534 void SSLBlockingPage::OnDontProceed() { | 589 void SSLBlockingPage::OnDontProceed() { |
| 535 metrics_helper_->RecordUserDecision( | 590 metrics_helper()->RecordUserDecision( |
| 536 SecurityInterstitialMetricsHelper::DONT_PROCEED); | 591 SecurityInterstitialMetricsHelper::DONT_PROCEED); |
| 592 |
| 593 // Finish collecting information about invalid certificates, if the |
| 594 // user opted in to. |
| 595 FinishCertCollection(); |
| 596 |
| 537 RecordSSLExpirationPageEventState( | 597 RecordSSLExpirationPageEventState( |
| 538 expired_but_previously_allowed_, false, overridable_); | 598 expired_but_previously_allowed_, false, overridable_); |
| 539 NotifyDenyCertificate(); | 599 NotifyDenyCertificate(); |
| 540 } | 600 } |
| 541 | 601 |
| 542 void SSLBlockingPage::NotifyDenyCertificate() { | 602 void SSLBlockingPage::NotifyDenyCertificate() { |
| 543 // It's possible that callback_ may not exist if the user clicks "Proceed" | 603 // It's possible that callback_ may not exist if the user clicks "Proceed" |
| 544 // followed by pressing the back button before the interstitial is hidden. | 604 // followed by pressing the back button before the interstitial is hidden. |
| 545 // In that case the certificate will still be treated as allowed. | 605 // In that case the certificate will still be treated as allowed. |
| 546 if (callback_.is_null()) | 606 if (callback_.is_null()) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 574 std::string SSLBlockingPage::GetSamplingEventName() const { | 634 std::string SSLBlockingPage::GetSamplingEventName() const { |
| 575 std::string event_name(kEventNameBase); | 635 std::string event_name(kEventNameBase); |
| 576 if (overridable_) | 636 if (overridable_) |
| 577 event_name.append(kEventOverridable); | 637 event_name.append(kEventOverridable); |
| 578 else | 638 else |
| 579 event_name.append(kEventNotOverridable); | 639 event_name.append(kEventNotOverridable); |
| 580 event_name.append(net::ErrorToString(cert_error_)); | 640 event_name.append(net::ErrorToString(cert_error_)); |
| 581 return event_name; | 641 return event_name; |
| 582 } | 642 } |
| 583 | 643 |
| 644 void SSLBlockingPage::FinishCertCollection() { |
| 645 base::ScopedClosureRunner scoped_callback( |
| 646 certificate_report_callback_for_testing_); |
| 647 |
| 648 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 649 switches::kEnableInvalidCertCollection) || |
| 650 web_contents()->GetBrowserContext()->IsOffTheRecord()) { |
| 651 return; |
| 652 } |
| 653 |
| 654 const bool enabled = |
| 655 IsPrefEnabled(prefs::kSafeBrowsingExtendedReportingEnabled); |
| 656 |
| 657 if (!enabled) |
| 658 return; |
| 659 |
| 660 metrics_helper()->RecordUserInteraction( |
| 661 SecurityInterstitialMetricsHelper::EXTENDED_REPORTING_IS_ENABLED); |
| 662 |
| 663 if (certificate_report_callback_for_testing_.is_null()) |
| 664 scoped_callback.Reset(base::Bind(&base::DoNothing)); |
| 665 |
| 666 safe_browsing_ui_manager_->ReportInvalidCertificateChain( |
| 667 request_url().host(), ssl_info_, scoped_callback.Release()); |
| 668 } |
| 669 |
| 584 // static | 670 // static |
| 585 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) { | 671 bool SSLBlockingPage::IsOptionsOverridable(int options_mask) { |
| 586 return (options_mask & SSLBlockingPage::OVERRIDABLE) && | 672 return (options_mask & SSLBlockingPage::OVERRIDABLE) && |
| 587 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT); | 673 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT); |
| 588 } | 674 } |
| OLD | NEW |