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