| 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" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/build_time.h" | 9 #include "base/build_time.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
| 26 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
| 27 #include "chrome/browser/interstitials/chrome_metrics_helper.h" | 27 #include "chrome/browser/interstitials/chrome_metrics_helper.h" |
| 28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 29 #include "chrome/browser/renderer_preferences_util.h" | 29 #include "chrome/browser/renderer_preferences_util.h" |
| 30 #include "chrome/browser/ssl/cert_report_helper.h" | 30 #include "chrome/browser/ssl/cert_report_helper.h" |
| 31 #include "chrome/browser/ssl/certificate_error_report.h" | 31 #include "chrome/browser/ssl/certificate_error_report.h" |
| 32 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 32 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
| 33 #include "chrome/browser/ssl/ssl_error_classification.h" | 33 #include "chrome/browser/ssl/ssl_error_classification.h" |
| 34 #include "chrome/browser/ssl/ssl_error_info.h" | 34 #include "chrome/browser/ssl/ssl_error_info.h" |
| 35 #include "chrome/browser/ui/browser_navigator.h" |
| 35 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
| 37 #include "chrome/grit/chromium_strings.h" | 38 #include "chrome/grit/chromium_strings.h" |
| 38 #include "chrome/grit/generated_resources.h" | 39 #include "chrome/grit/generated_resources.h" |
| 39 #include "components/google/core/browser/google_util.h" | 40 #include "components/google/core/browser/google_util.h" |
| 40 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
| 41 #include "content/public/browser/cert_store.h" | 42 #include "content/public/browser/cert_store.h" |
| 42 #include "content/public/browser/interstitial_page.h" | 43 #include "content/public/browser/interstitial_page.h" |
| 43 #include "content/public/browser/interstitial_page_delegate.h" | 44 #include "content/public/browser/interstitial_page_delegate.h" |
| 44 #include "content/public/browser/navigation_controller.h" | 45 #include "content/public/browser/navigation_controller.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 231 |
| 231 // Note that we always create a navigation entry with SSL errors. | 232 // Note that we always create a navigation entry with SSL errors. |
| 232 // No error happening loading a sub-resource triggers an interstitial so far. | 233 // No error happening loading a sub-resource triggers an interstitial so far. |
| 233 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, | 234 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, |
| 234 int cert_error, | 235 int cert_error, |
| 235 const net::SSLInfo& ssl_info, | 236 const net::SSLInfo& ssl_info, |
| 236 const GURL& request_url, | 237 const GURL& request_url, |
| 237 int options_mask, | 238 int options_mask, |
| 238 const base::Time& time_triggered, | 239 const base::Time& time_triggered, |
| 239 scoped_ptr<SSLCertReporter> ssl_cert_reporter, | 240 scoped_ptr<SSLCertReporter> ssl_cert_reporter, |
| 240 const base::Callback<void(bool)>& callback) | 241 const base::Callback<void(bool)>& callback, |
| 242 const GURL& suggested_url) |
| 241 : SecurityInterstitialPage(web_contents, request_url), | 243 : SecurityInterstitialPage(web_contents, request_url), |
| 242 callback_(callback), | 244 callback_(callback), |
| 243 cert_error_(cert_error), | 245 cert_error_(cert_error), |
| 244 ssl_info_(ssl_info), | 246 ssl_info_(ssl_info), |
| 245 overridable_(IsOverridable( | 247 overridable_(IsOverridable( |
| 246 options_mask, | 248 options_mask, |
| 247 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), | 249 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), |
| 248 danger_overridable_(DoesPolicyAllowDangerOverride( | 250 danger_overridable_(DoesPolicyAllowDangerOverride( |
| 249 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), | 251 Profile::FromBrowserContext(web_contents->GetBrowserContext()))), |
| 250 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), | 252 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), |
| 251 expired_but_previously_allowed_( | 253 expired_but_previously_allowed_( |
| 252 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0), | 254 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0), |
| 253 time_triggered_(time_triggered) { | 255 time_triggered_(time_triggered), |
| 256 suggested_url_(suggested_url) { |
| 254 interstitial_reason_ = | 257 interstitial_reason_ = |
| 255 IsErrorDueToBadClock(time_triggered_, cert_error_) ? | 258 IsErrorDueToBadClock(time_triggered_, cert_error_) ? |
| 256 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL; | 259 SSL_REASON_BAD_CLOCK : SSL_REASON_SSL; |
| 257 | 260 |
| 258 // We collapse the Rappor metric name to just "ssl" so we don't leak | 261 // We collapse the Rappor metric name to just "ssl" so we don't leak |
| 259 // the "overridable" bit. We skip Rappor altogether for bad clocks. | 262 // the "overridable" bit. We skip Rappor altogether for bad clocks. |
| 260 // This must be done after calculating |interstitial_reason_| above. | 263 // This must be done after calculating |interstitial_reason_| above. |
| 261 security_interstitials::MetricsHelper::ReportDetails reporting_info; | 264 security_interstitials::MetricsHelper::ReportDetails reporting_info; |
| 262 reporting_info.metric_prefix = GetUmaHistogramPrefix(); | 265 reporting_info.metric_prefix = GetUmaHistogramPrefix(); |
| 263 reporting_info.rappor_prefix = kSSLRapporPrefix; | 266 reporting_info.rappor_prefix = kSSLRapporPrefix; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 load_time_data->SetBoolean("bad_clock", false); | 379 load_time_data->SetBoolean("bad_clock", false); |
| 377 | 380 |
| 378 load_time_data->SetString( | 381 load_time_data->SetString( |
| 379 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); | 382 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); |
| 380 load_time_data->SetString( | 383 load_time_data->SetString( |
| 381 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); | 384 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); |
| 382 load_time_data->SetString( | 385 load_time_data->SetString( |
| 383 "primaryParagraph", | 386 "primaryParagraph", |
| 384 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); | 387 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); |
| 385 | 388 |
| 389 load_time_data->SetBoolean("common_name_mismatch", false); |
| 390 // If suggested URL is not empty, display a modified message |
| 391 // with a link to suggested_url. |
| 392 if (!suggested_url_.is_empty()) { |
| 393 load_time_data->SetBoolean("common_name_mismatch", true); |
| 394 load_time_data->SetString( |
| 395 "primaryParagraph", |
| 396 l10n_util::GetStringFUTF16( |
| 397 IDS_SSL_COMMON_NAME_MISMATCH_PRIMARY_PARAGRAPH, |
| 398 base::UTF8ToUTF16(request_url().host()), |
| 399 base::UTF8ToUTF16(suggested_url_.host()))); |
| 400 } |
| 401 |
| 386 if (overridable_) { | 402 if (overridable_) { |
| 387 load_time_data->SetBoolean("overridable", true); | 403 load_time_data->SetBoolean("overridable", true); |
| 388 | 404 |
| 389 SSLErrorInfo error_info = | 405 SSLErrorInfo error_info = |
| 390 SSLErrorInfo::CreateError( | 406 SSLErrorInfo::CreateError( |
| 391 SSLErrorInfo::NetErrorToErrorType(cert_error_), | 407 SSLErrorInfo::NetErrorToErrorType(cert_error_), |
| 392 ssl_info_.cert.get(), | 408 ssl_info_.cert.get(), |
| 393 request_url()); | 409 request_url()); |
| 410 |
| 394 load_time_data->SetString("explanationParagraph", error_info.details()); | 411 load_time_data->SetString("explanationParagraph", error_info.details()); |
| 395 load_time_data->SetString( | 412 load_time_data->SetString( |
| 396 "primaryButtonText", | 413 "primaryButtonText", |
| 397 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); | 414 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); |
| 398 load_time_data->SetString( | 415 load_time_data->SetString( |
| 399 "finalParagraph", | 416 "finalParagraph", |
| 400 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, | 417 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, |
| 401 url)); | 418 url)); |
| 402 } else { | 419 } else { |
| 403 load_time_data->SetBoolean("overridable", false); | 420 load_time_data->SetBoolean("overridable", false); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 case CMD_OPEN_DATE_SETTINGS: { | 550 case CMD_OPEN_DATE_SETTINGS: { |
| 534 metrics_helper()->RecordUserInteraction( | 551 metrics_helper()->RecordUserInteraction( |
| 535 security_interstitials::MetricsHelper::OPEN_TIME_SETTINGS); | 552 security_interstitials::MetricsHelper::OPEN_TIME_SETTINGS); |
| 536 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 553 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
| 537 base::Bind(&LaunchDateAndTimeSettings)); | 554 base::Bind(&LaunchDateAndTimeSettings)); |
| 538 break; | 555 break; |
| 539 } | 556 } |
| 540 case CMD_OPEN_REPORTING_PRIVACY: | 557 case CMD_OPEN_REPORTING_PRIVACY: |
| 541 OpenExtendedReportingPrivacyPolicy(); | 558 OpenExtendedReportingPrivacyPolicy(); |
| 542 break; | 559 break; |
| 560 case CMD_NAVIGATE_SUGGESTED_URL: |
| 561 OpenSuggestedURL(); |
| 562 break; |
| 543 case CMD_OPEN_DIAGNOSTIC: | 563 case CMD_OPEN_DIAGNOSTIC: |
| 544 // Google doesn't currently have a transparency report for SSL. | 564 // Google doesn't currently have a transparency report for SSL. |
| 545 NOTREACHED() << "Unexpected command: " << command; | 565 NOTREACHED() << "Unexpected command: " << command; |
| 546 } | 566 } |
| 547 } | 567 } |
| 548 | 568 |
| 549 void SSLBlockingPage::OverrideRendererPrefs( | 569 void SSLBlockingPage::OverrideRendererPrefs( |
| 550 content::RendererPreferences* prefs) { | 570 content::RendererPreferences* prefs) { |
| 551 Profile* profile = Profile::FromBrowserContext( | 571 Profile* profile = Profile::FromBrowserContext( |
| 552 web_contents()->GetBrowserContext()); | 572 web_contents()->GetBrowserContext()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 std::string SSLBlockingPage::GetSamplingEventName() const { | 651 std::string SSLBlockingPage::GetSamplingEventName() const { |
| 632 std::string event_name(kEventNameBase); | 652 std::string event_name(kEventNameBase); |
| 633 if (overridable_) | 653 if (overridable_) |
| 634 event_name.append(kEventOverridable); | 654 event_name.append(kEventOverridable); |
| 635 else | 655 else |
| 636 event_name.append(kEventNotOverridable); | 656 event_name.append(kEventNotOverridable); |
| 637 event_name.append(net::ErrorToString(cert_error_)); | 657 event_name.append(net::ErrorToString(cert_error_)); |
| 638 return event_name; | 658 return event_name; |
| 639 } | 659 } |
| 640 | 660 |
| 661 void SSLBlockingPage::OpenSuggestedURL() const { |
| 662 content::NavigationController::LoadURLParams load_params(suggested_url_); |
| 663 load_params.transition_type = ui::PAGE_TRANSITION_LINK; |
| 664 web_contents()->GetController().LoadURLWithParams(load_params); |
| 665 } |
| 666 |
| 641 // static | 667 // static |
| 642 bool SSLBlockingPage::IsOverridable(int options_mask, | 668 bool SSLBlockingPage::IsOverridable(int options_mask, |
| 643 const Profile* const profile) { | 669 const Profile* const profile) { |
| 644 const bool is_overridable = | 670 const bool is_overridable = |
| 645 (options_mask & SSLBlockingPage::OVERRIDABLE) && | 671 (options_mask & SSLBlockingPage::OVERRIDABLE) && |
| 646 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT) && | 672 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT) && |
| 647 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); | 673 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); |
| 648 return is_overridable; | 674 return is_overridable; |
| 649 } | 675 } |
| 650 | 676 |
| 651 // static | 677 // static |
| 652 bool SSLBlockingPage::DoesPolicyAllowDangerOverride( | 678 bool SSLBlockingPage::DoesPolicyAllowDangerOverride( |
| 653 const Profile* const profile) { | 679 const Profile* const profile) { |
| 654 return profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); | 680 return profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); |
| 655 } | 681 } |
| OLD | NEW |