| 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/build_time.h" | 7 #include "base/build_time.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "content/public/browser/render_process_host.h" | 38 #include "content/public/browser/render_process_host.h" |
| 39 #include "content/public/browser/render_view_host.h" | 39 #include "content/public/browser/render_view_host.h" |
| 40 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
| 41 #include "content/public/common/renderer_preferences.h" | 41 #include "content/public/common/renderer_preferences.h" |
| 42 #include "content/public/common/ssl_status.h" | 42 #include "content/public/common/ssl_status.h" |
| 43 #include "grit/browser_resources.h" | 43 #include "grit/browser_resources.h" |
| 44 #include "net/base/hash_value.h" | 44 #include "net/base/hash_value.h" |
| 45 #include "net/base/net_errors.h" | 45 #include "net/base/net_errors.h" |
| 46 #include "net/base/net_util.h" | 46 #include "net/base/net_util.h" |
| 47 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
| 48 #include "ui/base/resource/resource_bundle.h" | |
| 49 #include "ui/base/webui/jstemplate_builder.h" | |
| 50 #include "ui/base/webui/web_ui_util.h" | |
| 51 | 48 |
| 52 #if defined(ENABLE_EXTENSIONS) | 49 #if defined(ENABLE_EXTENSIONS) |
| 53 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s
ampling.h" | 50 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s
ampling.h" |
| 54 #endif | 51 #endif |
| 55 | 52 |
| 56 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
| 57 #include "base/base_paths_win.h" | 54 #include "base/base_paths_win.h" |
| 58 #include "base/path_service.h" | 55 #include "base/path_service.h" |
| 59 #include "base/strings/string16.h" | 56 #include "base/strings/string16.h" |
| 60 #include "base/win/windows_version.h" | 57 #include "base/win/windows_version.h" |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 if (SSLErrorInfo::NetErrorToErrorType(error) != | 307 if (SSLErrorInfo::NetErrorToErrorType(error) != |
| 311 SSLErrorInfo::CERT_DATE_INVALID) { | 308 SSLErrorInfo::CERT_DATE_INVALID) { |
| 312 return false; | 309 return false; |
| 313 } | 310 } |
| 314 return SSLErrorClassification::IsUserClockInThePast(now) || | 311 return SSLErrorClassification::IsUserClockInThePast(now) || |
| 315 SSLErrorClassification::IsUserClockInTheFuture(now); | 312 SSLErrorClassification::IsUserClockInTheFuture(now); |
| 316 } | 313 } |
| 317 | 314 |
| 318 } // namespace | 315 } // namespace |
| 319 | 316 |
| 317 // static |
| 318 const void* SSLBlockingPage::kTypeForTesting = |
| 319 &SSLBlockingPage::kTypeForTesting; |
| 320 |
| 320 // Note that we always create a navigation entry with SSL errors. | 321 // Note that we always create a navigation entry with SSL errors. |
| 321 // No error happening loading a sub-resource triggers an interstitial so far. | 322 // No error happening loading a sub-resource triggers an interstitial so far. |
| 322 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, | 323 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, |
| 323 int cert_error, | 324 int cert_error, |
| 324 const net::SSLInfo& ssl_info, | 325 const net::SSLInfo& ssl_info, |
| 325 const GURL& request_url, | 326 const GURL& request_url, |
| 326 int options_mask, | 327 int options_mask, |
| 327 const base::Callback<void(bool)>& callback) | 328 const base::Callback<void(bool)>& callback) |
| 328 : callback_(callback), | 329 : SecurityInterstitialPage(web_contents, request_url), |
| 329 web_contents_(web_contents), | 330 callback_(callback), |
| 330 cert_error_(cert_error), | 331 cert_error_(cert_error), |
| 331 ssl_info_(ssl_info), | 332 ssl_info_(ssl_info), |
| 332 request_url_(request_url), | |
| 333 overridable_(options_mask & OVERRIDABLE && | 333 overridable_(options_mask & OVERRIDABLE && |
| 334 !(options_mask & STRICT_ENFORCEMENT)), | 334 !(options_mask & STRICT_ENFORCEMENT)), |
| 335 danger_overridable_(true), | 335 danger_overridable_(true), |
| 336 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), | 336 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), |
| 337 interstitial_page_(NULL), | |
| 338 internal_(false), | 337 internal_(false), |
| 339 num_visits_(-1), | 338 num_visits_(-1), |
| 340 expired_but_previously_allowed_( | 339 expired_but_previously_allowed_( |
| 341 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0) { | 340 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0) { |
| 342 Profile* profile = Profile::FromBrowserContext( | 341 Profile* profile = Profile::FromBrowserContext( |
| 343 web_contents->GetBrowserContext()); | 342 web_contents->GetBrowserContext()); |
| 344 // For UMA stats. | 343 // For UMA stats. |
| 345 if (SSLErrorClassification::IsHostnameNonUniqueOrDotless( | 344 if (SSLErrorClassification::IsHostnameNonUniqueOrDotless( |
| 346 request_url_.HostNoBrackets())) | 345 request_url.HostNoBrackets())) |
| 347 internal_ = true; | 346 internal_ = true; |
| 348 RecordSSLBlockingPageEventStats(SHOW_ALL); | 347 RecordSSLBlockingPageEventStats(SHOW_ALL); |
| 349 if (overridable_) { | 348 if (overridable_) { |
| 350 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); | 349 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); |
| 351 if (internal_) | 350 if (internal_) |
| 352 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); | 351 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); |
| 353 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 352 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 354 profile, Profile::EXPLICIT_ACCESS); | 353 profile, Profile::EXPLICIT_ACCESS); |
| 355 if (history_service) { | 354 if (history_service) { |
| 356 history_service->GetVisibleVisitCountToHost( | 355 history_service->GetVisibleVisitCountToHost( |
| 357 request_url_, | 356 request_url, |
| 358 base::Bind(&SSLBlockingPage::OnGotHistoryCount, | 357 base::Bind(&SSLBlockingPage::OnGotHistoryCount, |
| 359 base::Unretained(this)), | 358 base::Unretained(this)), |
| 360 &request_tracker_); | 359 &request_tracker_); |
| 361 } | 360 } |
| 362 } | 361 } |
| 363 | 362 |
| 364 ssl_error_classification_.reset(new SSLErrorClassification( | 363 ssl_error_classification_.reset(new SSLErrorClassification( |
| 365 web_contents_, | 364 web_contents, |
| 366 base::Time::NowFromSystemTime(), | 365 base::Time::NowFromSystemTime(), |
| 367 request_url_, | 366 request_url, |
| 368 cert_error_, | 367 cert_error_, |
| 369 *ssl_info_.cert.get())); | 368 *ssl_info_.cert.get())); |
| 370 ssl_error_classification_->RecordUMAStatistics(overridable_); | 369 ssl_error_classification_->RecordUMAStatistics(overridable_); |
| 371 | 370 |
| 372 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 371 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 373 ssl_error_classification_->RecordCaptivePortalUMAStatistics(overridable_); | 372 ssl_error_classification_->RecordCaptivePortalUMAStatistics(overridable_); |
| 374 #endif | 373 #endif |
| 375 | 374 |
| 376 #if defined(ENABLE_EXTENSIONS) | 375 #if defined(ENABLE_EXTENSIONS) |
| 377 // ExperienceSampling: Set up new sampling event for this interstitial. | 376 // ExperienceSampling: Set up new sampling event for this interstitial. |
| 378 std::string event_name(kEventNameBase); | 377 std::string event_name(kEventNameBase); |
| 379 if (overridable_ && !strict_enforcement_) | 378 if (overridable_ && !strict_enforcement_) |
| 380 event_name.append(kEventOverridable); | 379 event_name.append(kEventOverridable); |
| 381 else | 380 else |
| 382 event_name.append(kEventNotOverridable); | 381 event_name.append(kEventNotOverridable); |
| 383 event_name.append(net::ErrorToString(cert_error_)); | 382 event_name.append(net::ErrorToString(cert_error_)); |
| 384 sampling_event_.reset(new ExperienceSamplingEvent( | 383 sampling_event_.reset(new ExperienceSamplingEvent( |
| 385 event_name, | 384 event_name, |
| 386 request_url_, | 385 request_url, |
| 387 web_contents_->GetLastCommittedURL(), | 386 web_contents->GetLastCommittedURL(), |
| 388 web_contents_->GetBrowserContext())); | 387 web_contents->GetBrowserContext())); |
| 389 #endif | 388 #endif |
| 390 | 389 |
| 391 // Creating an interstitial without showing (e.g. from chrome://interstitials) | 390 // Creating an interstitial without showing (e.g. from chrome://interstitials) |
| 392 // it leaks memory, so don't create it here. | 391 // it leaks memory, so don't create it here. |
| 393 } | 392 } |
| 394 | 393 |
| 394 bool SSLBlockingPage::ShouldCreateNewNavigation() const { |
| 395 return true; |
| 396 } |
| 397 |
| 398 const void* SSLBlockingPage::GetTypeForTesting() const { |
| 399 return SSLBlockingPage::kTypeForTesting; |
| 400 } |
| 401 |
| 395 SSLBlockingPage::~SSLBlockingPage() { | 402 SSLBlockingPage::~SSLBlockingPage() { |
| 396 // InvalidCommonNameSeverityScore() and InvalidDateSeverityScore() are in the | 403 // InvalidCommonNameSeverityScore() and InvalidDateSeverityScore() are in the |
| 397 // destructor because they depend on knowing whether captive portal detection | 404 // destructor because they depend on knowing whether captive portal detection |
| 398 // happened before the user made a decision. | 405 // happened before the user made a decision. |
| 399 SSLErrorInfo::ErrorType type = | 406 SSLErrorInfo::ErrorType type = |
| 400 SSLErrorInfo::NetErrorToErrorType(cert_error_); | 407 SSLErrorInfo::NetErrorToErrorType(cert_error_); |
| 401 switch (type) { | 408 switch (type) { |
| 402 case SSLErrorInfo::CERT_DATE_INVALID: | 409 case SSLErrorInfo::CERT_DATE_INVALID: |
| 403 ssl_error_classification_->InvalidDateSeverityScore(); | 410 ssl_error_classification_->InvalidDateSeverityScore(); |
| 404 break; | 411 break; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 417 overridable_, | 424 overridable_, |
| 418 internal_, | 425 internal_, |
| 419 num_visits_, | 426 num_visits_, |
| 420 expired_but_previously_allowed_); | 427 expired_but_previously_allowed_); |
| 421 // The page is closed without the user having chosen what to do, default to | 428 // The page is closed without the user having chosen what to do, default to |
| 422 // deny. | 429 // deny. |
| 423 NotifyDenyCertificate(); | 430 NotifyDenyCertificate(); |
| 424 } | 431 } |
| 425 } | 432 } |
| 426 | 433 |
| 427 void SSLBlockingPage::Show() { | 434 void SSLBlockingPage::PopulateInterstitialStrings( |
| 428 DCHECK(!interstitial_page_); | 435 base::DictionaryValue* load_time_data) { |
| 429 interstitial_page_ = InterstitialPage::Create( | 436 CHECK(load_time_data); |
| 430 web_contents_, true, request_url_, this); | 437 base::string16 url(GetFormattedHostName()); |
| 431 interstitial_page_->Show(); | 438 // Shared values for both the overridable and non-overridable versions. |
| 432 } | 439 load_time_data->SetString("type", "SSL"); |
| 433 | |
| 434 std::string SSLBlockingPage::GetHTMLContents() { | |
| 435 base::DictionaryValue load_time_data; | |
| 436 base::string16 url(ASCIIToUTF16(request_url_.host())); | |
| 437 if (base::i18n::IsRTL()) | |
| 438 base::i18n::WrapStringWithLTRFormatting(&url); | |
| 439 webui::SetFontAndTextDirection(&load_time_data); | |
| 440 | |
| 441 load_time_data.SetString("type", "SSL"); | |
| 442 | 440 |
| 443 // Shared UI configuration for all SSL interstitials. | 441 // Shared UI configuration for all SSL interstitials. |
| 444 base::Time now = base::Time::NowFromSystemTime(); | 442 base::Time now = base::Time::NowFromSystemTime(); |
| 445 bool bad_clock = IsErrorDueToBadClock(now, cert_error_); | 443 bool bad_clock = IsErrorDueToBadClock(now, cert_error_); |
| 446 | 444 |
| 447 load_time_data.SetString("errorCode", net::ErrorToString(cert_error_)); | 445 load_time_data->SetString("errorCode", net::ErrorToString(cert_error_)); |
| 448 load_time_data.SetString( | 446 load_time_data->SetString( |
| 449 "openDetails", | 447 "openDetails", |
| 450 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); | 448 l10n_util::GetStringUTF16(IDS_SSL_V2_OPEN_DETAILS_BUTTON)); |
| 451 load_time_data.SetString( | 449 load_time_data->SetString( |
| 452 "closeDetails", | 450 "closeDetails", |
| 453 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); | 451 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOSE_DETAILS_BUTTON)); |
| 454 | 452 |
| 455 // Conditional UI configuration. | 453 // Conditional UI configuration. |
| 456 if (bad_clock) { | 454 if (bad_clock) { |
| 457 load_time_data.SetBoolean("bad_clock", true); | 455 load_time_data->SetBoolean("bad_clock", true); |
| 458 load_time_data.SetBoolean("overridable", false); | 456 load_time_data->SetBoolean("overridable", false); |
| 459 | 457 |
| 460 #if defined(OS_IOS) | 458 #if defined(OS_IOS) |
| 461 load_time_data.SetBoolean("hide_primary_button", true); | 459 load_time_data->SetBoolean("hide_primary_button", true); |
| 462 #else | 460 #else |
| 463 load_time_data.SetBoolean("hide_primary_button", false); | 461 load_time_data->SetBoolean("hide_primary_button", false); |
| 464 #endif | 462 #endif |
| 465 | 463 |
| 466 // We're showing the SSL clock warning to be helpful, but we haven't warned | 464 // We're showing the SSL clock warning to be helpful, but we haven't warned |
| 467 // them about the risks. (And there might still be an SSL error after they | 465 // them about the risks. (And there might still be an SSL error after they |
| 468 // fix their clock.) Thus, we don't allow the "danger" override in this | 466 // fix their clock.) Thus, we don't allow the "danger" override in this |
| 469 // case. | 467 // case. |
| 470 danger_overridable_ = false; | 468 danger_overridable_ = false; |
| 471 | 469 |
| 472 int heading_string = SSLErrorClassification::IsUserClockInTheFuture(now) ? | 470 int heading_string = SSLErrorClassification::IsUserClockInTheFuture(now) ? |
| 473 IDS_SSL_V2_CLOCK_AHEAD_HEADING : | 471 IDS_SSL_V2_CLOCK_AHEAD_HEADING : |
| 474 IDS_SSL_V2_CLOCK_BEHIND_HEADING; | 472 IDS_SSL_V2_CLOCK_BEHIND_HEADING; |
| 475 | 473 |
| 476 load_time_data.SetString( | 474 load_time_data->SetString( |
| 477 "tabTitle", | 475 "tabTitle", |
| 478 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_TITLE)); | 476 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_TITLE)); |
| 479 load_time_data.SetString( | 477 load_time_data->SetString( |
| 480 "heading", | 478 "heading", |
| 481 l10n_util::GetStringUTF16(heading_string)); | 479 l10n_util::GetStringUTF16(heading_string)); |
| 482 load_time_data.SetString("primaryParagraph", | 480 load_time_data->SetString("primaryParagraph", |
| 483 l10n_util::GetStringFUTF16( | 481 l10n_util::GetStringFUTF16( |
| 484 IDS_SSL_V2_CLOCK_PRIMARY_PARAGRAPH , | 482 IDS_SSL_V2_CLOCK_PRIMARY_PARAGRAPH , |
| 485 url, | 483 url, |
| 486 base::TimeFormatFriendlyDateAndTime(now))); | 484 base::TimeFormatFriendlyDateAndTime(now))); |
| 487 | 485 |
| 488 load_time_data.SetString( | 486 load_time_data->SetString( |
| 489 "primaryButtonText", | 487 "primaryButtonText", |
| 490 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_UPDATE_DATE_AND_TIME)); | 488 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_UPDATE_DATE_AND_TIME)); |
| 491 load_time_data.SetString( | 489 load_time_data->SetString( |
| 492 "explanationParagraph", | 490 "explanationParagraph", |
| 493 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_EXPLANATION)); | 491 l10n_util::GetStringUTF16(IDS_SSL_V2_CLOCK_EXPLANATION)); |
| 494 | 492 |
| 495 // The interstitial template expects this string, but we're not using it. So | 493 // The interstitial template expects this string, but we're not using it. So |
| 496 // we send a blank string for now. | 494 // we send a blank string for now. |
| 497 load_time_data.SetString("finalParagraph", std::string()); | 495 load_time_data->SetString("finalParagraph", std::string()); |
| 498 } else { | 496 } else { |
| 499 load_time_data.SetBoolean("bad_clock", false); | 497 load_time_data->SetBoolean("bad_clock", false); |
| 500 | 498 |
| 501 load_time_data.SetString( | 499 load_time_data->SetString( |
| 502 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); | 500 "tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); |
| 503 load_time_data.SetString( | 501 load_time_data->SetString( |
| 504 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); | 502 "heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); |
| 505 load_time_data.SetString( | 503 load_time_data->SetString( |
| 506 "primaryParagraph", | 504 "primaryParagraph", |
| 507 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); | 505 l10n_util::GetStringFUTF16(IDS_SSL_V2_PRIMARY_PARAGRAPH, url)); |
| 508 | 506 |
| 509 if (overridable_) { | 507 if (overridable_) { |
| 510 load_time_data.SetBoolean("overridable", true); | 508 load_time_data->SetBoolean("overridable", true); |
| 511 | 509 |
| 512 SSLErrorInfo error_info = | 510 SSLErrorInfo error_info = |
| 513 SSLErrorInfo::CreateError( | 511 SSLErrorInfo::CreateError( |
| 514 SSLErrorInfo::NetErrorToErrorType(cert_error_), | 512 SSLErrorInfo::NetErrorToErrorType(cert_error_), |
| 515 ssl_info_.cert.get(), | 513 ssl_info_.cert.get(), |
| 516 request_url_); | 514 request_url_); |
| 517 load_time_data.SetString("explanationParagraph", error_info.details()); | 515 load_time_data->SetString("explanationParagraph", error_info.details()); |
| 518 load_time_data.SetString( | 516 load_time_data->SetString( |
| 519 "primaryButtonText", | 517 "primaryButtonText", |
| 520 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); | 518 l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); |
| 521 load_time_data.SetString( | 519 load_time_data->SetString( |
| 522 "finalParagraph", | 520 "finalParagraph", |
| 523 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, | 521 l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, |
| 524 url)); | 522 url)); |
| 525 } else { | 523 } else { |
| 526 load_time_data.SetBoolean("overridable", false); | 524 load_time_data->SetBoolean("overridable", false); |
| 527 | 525 |
| 528 SSLErrorInfo::ErrorType type = | 526 SSLErrorInfo::ErrorType type = |
| 529 SSLErrorInfo::NetErrorToErrorType(cert_error_); | 527 SSLErrorInfo::NetErrorToErrorType(cert_error_); |
| 530 if (type == SSLErrorInfo::CERT_INVALID && SSLErrorClassification:: | 528 if (type == SSLErrorInfo::CERT_INVALID && SSLErrorClassification:: |
| 531 MaybeWindowsLacksSHA256Support()) { | 529 MaybeWindowsLacksSHA256Support()) { |
| 532 load_time_data.SetString( | 530 load_time_data->SetString( |
| 533 "explanationParagraph", | 531 "explanationParagraph", |
| 534 l10n_util::GetStringFUTF16( | 532 l10n_util::GetStringFUTF16( |
| 535 IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3, url)); | 533 IDS_SSL_NONOVERRIDABLE_MORE_INVALID_SP3, url)); |
| 536 } else { | 534 } else { |
| 537 load_time_data.SetString("explanationParagraph", | 535 load_time_data->SetString("explanationParagraph", |
| 538 l10n_util::GetStringFUTF16( | 536 l10n_util::GetStringFUTF16( |
| 539 IDS_SSL_NONOVERRIDABLE_MORE, url)); | 537 IDS_SSL_NONOVERRIDABLE_MORE, url)); |
| 540 } | 538 } |
| 541 load_time_data.SetString( | 539 load_time_data->SetString( |
| 542 "primaryButtonText", | 540 "primaryButtonText", |
| 543 l10n_util::GetStringUTF16(IDS_SSL_RELOAD)); | 541 l10n_util::GetStringUTF16(IDS_SSL_RELOAD)); |
| 544 // Customize the help link depending on the specific error type. | 542 // Customize the help link depending on the specific error type. |
| 545 // Only mark as HSTS if none of the more specific error types apply, | 543 // Only mark as HSTS if none of the more specific error types apply, |
| 546 // and use INVALID as a fallback if no other string is appropriate. | 544 // and use INVALID as a fallback if no other string is appropriate. |
| 547 load_time_data.SetInteger("errorType", type); | 545 load_time_data->SetInteger("errorType", type); |
| 548 int help_string = IDS_SSL_NONOVERRIDABLE_INVALID; | 546 int help_string = IDS_SSL_NONOVERRIDABLE_INVALID; |
| 549 switch (type) { | 547 switch (type) { |
| 550 case SSLErrorInfo::CERT_REVOKED: | 548 case SSLErrorInfo::CERT_REVOKED: |
| 551 help_string = IDS_SSL_NONOVERRIDABLE_REVOKED; | 549 help_string = IDS_SSL_NONOVERRIDABLE_REVOKED; |
| 552 break; | 550 break; |
| 553 case SSLErrorInfo::CERT_PINNED_KEY_MISSING: | 551 case SSLErrorInfo::CERT_PINNED_KEY_MISSING: |
| 554 help_string = IDS_SSL_NONOVERRIDABLE_PINNED; | 552 help_string = IDS_SSL_NONOVERRIDABLE_PINNED; |
| 555 break; | 553 break; |
| 556 case SSLErrorInfo::CERT_INVALID: | 554 case SSLErrorInfo::CERT_INVALID: |
| 557 help_string = IDS_SSL_NONOVERRIDABLE_INVALID; | 555 help_string = IDS_SSL_NONOVERRIDABLE_INVALID; |
| 558 break; | 556 break; |
| 559 default: | 557 default: |
| 560 if (strict_enforcement_) | 558 if (strict_enforcement_) |
| 561 help_string = IDS_SSL_NONOVERRIDABLE_HSTS; | 559 help_string = IDS_SSL_NONOVERRIDABLE_HSTS; |
| 562 } | 560 } |
| 563 load_time_data.SetString( | 561 load_time_data->SetString( |
| 564 "finalParagraph", l10n_util::GetStringFUTF16(help_string, url)); | 562 "finalParagraph", l10n_util::GetStringFUTF16(help_string, url)); |
| 565 } | 563 } |
| 566 } | 564 } |
| 567 | 565 |
| 568 // Set debugging information at the bottom of the warning. | 566 // Set debugging information at the bottom of the warning. |
| 569 load_time_data.SetString( | 567 load_time_data->SetString( |
| 570 "subject", ssl_info_.cert->subject().GetDisplayName()); | 568 "subject", ssl_info_.cert->subject().GetDisplayName()); |
| 571 load_time_data.SetString( | 569 load_time_data->SetString( |
| 572 "issuer", ssl_info_.cert->issuer().GetDisplayName()); | 570 "issuer", ssl_info_.cert->issuer().GetDisplayName()); |
| 573 load_time_data.SetString( | 571 load_time_data->SetString( |
| 574 "expirationDate", | 572 "expirationDate", |
| 575 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry())); | 573 base::TimeFormatShortDate(ssl_info_.cert->valid_expiry())); |
| 576 load_time_data.SetString( | 574 load_time_data->SetString( |
| 577 "currentDate", base::TimeFormatShortDate(now)); | 575 "currentDate", base::TimeFormatShortDate(now)); |
| 578 std::vector<std::string> encoded_chain; | 576 std::vector<std::string> encoded_chain; |
| 579 ssl_info_.cert->GetPEMEncodedChain(&encoded_chain); | 577 ssl_info_.cert->GetPEMEncodedChain(&encoded_chain); |
| 580 load_time_data.SetString("pem", JoinString(encoded_chain, std::string())); | 578 load_time_data->SetString("pem", JoinString(encoded_chain, std::string())); |
| 581 | |
| 582 base::StringPiece html( | |
| 583 ResourceBundle::GetSharedInstance().GetRawDataResource( | |
| 584 IDR_SECURITY_INTERSTITIAL_HTML)); | |
| 585 return webui::GetI18nTemplateHtml(html, &load_time_data); | |
| 586 } | 579 } |
| 587 | 580 |
| 588 void SSLBlockingPage::OverrideEntry(NavigationEntry* entry) { | 581 void SSLBlockingPage::OverrideEntry(NavigationEntry* entry) { |
| 589 int cert_id = content::CertStore::GetInstance()->StoreCert( | 582 int cert_id = content::CertStore::GetInstance()->StoreCert( |
| 590 ssl_info_.cert.get(), web_contents_->GetRenderProcessHost()->GetID()); | 583 ssl_info_.cert.get(), web_contents()->GetRenderProcessHost()->GetID()); |
| 591 DCHECK(cert_id); | 584 DCHECK(cert_id); |
| 592 | 585 |
| 593 entry->GetSSL().security_style = | 586 entry->GetSSL().security_style = |
| 594 content::SECURITY_STYLE_AUTHENTICATION_BROKEN; | 587 content::SECURITY_STYLE_AUTHENTICATION_BROKEN; |
| 595 entry->GetSSL().cert_id = cert_id; | 588 entry->GetSSL().cert_id = cert_id; |
| 596 entry->GetSSL().cert_status = ssl_info_.cert_status; | 589 entry->GetSSL().cert_status = ssl_info_.cert_status; |
| 597 entry->GetSSL().security_bits = ssl_info_.security_bits; | 590 entry->GetSSL().security_bits = ssl_info_.security_bits; |
| 598 } | 591 } |
| 599 | 592 |
| 600 // This handles the commands sent from the interstitial JavaScript. They are | 593 // This handles the commands sent from the interstitial JavaScript. They are |
| 601 // defined in chrome/browser/resources/ssl/ssl_errors_common.js. | 594 // defined in chrome/browser/resources/ssl/ssl_errors_common.js. |
| 602 // DO NOT reorder or change this logic without also changing the JavaScript! | 595 // DO NOT reorder or change this logic without also changing the JavaScript! |
| 603 void SSLBlockingPage::CommandReceived(const std::string& command) { | 596 void SSLBlockingPage::CommandReceived(const std::string& command) { |
| 604 int cmd = 0; | 597 int cmd = 0; |
| 605 bool retval = base::StringToInt(command, &cmd); | 598 bool retval = base::StringToInt(command, &cmd); |
| 606 DCHECK(retval); | 599 DCHECK(retval); |
| 607 switch (cmd) { | 600 switch (cmd) { |
| 608 case CMD_DONT_PROCEED: { | 601 case CMD_DONT_PROCEED: { |
| 609 interstitial_page_->DontProceed(); | 602 interstitial_page()->DontProceed(); |
| 610 break; | 603 break; |
| 611 } | 604 } |
| 612 case CMD_PROCEED: { | 605 case CMD_PROCEED: { |
| 613 if (danger_overridable_) { | 606 if (danger_overridable_) { |
| 614 interstitial_page_->Proceed(); | 607 interstitial_page()->Proceed(); |
| 615 } | 608 } |
| 616 break; | 609 break; |
| 617 } | 610 } |
| 618 case CMD_MORE: { | 611 case CMD_MORE: { |
| 619 RecordSSLBlockingPageEventStats(MORE); | 612 RecordSSLBlockingPageEventStats(MORE); |
| 620 #if defined(ENABLE_EXTENSIONS) | 613 #if defined(ENABLE_EXTENSIONS) |
| 621 if (sampling_event_.get()) | 614 if (sampling_event_.get()) |
| 622 sampling_event_->set_has_viewed_details(true); | 615 sampling_event_->set_has_viewed_details(true); |
| 623 #endif | 616 #endif |
| 624 break; | 617 break; |
| 625 } | 618 } |
| 626 case CMD_RELOAD: { | 619 case CMD_RELOAD: { |
| 627 // The interstitial can't refresh itself. | 620 // The interstitial can't refresh itself. |
| 628 web_contents_->GetController().Reload(true); | 621 web_contents()->GetController().Reload(true); |
| 629 break; | 622 break; |
| 630 } | 623 } |
| 631 case CMD_HELP: { | 624 case CMD_HELP: { |
| 632 content::NavigationController::LoadURLParams help_page_params( | 625 content::NavigationController::LoadURLParams help_page_params( |
| 633 google_util::AppendGoogleLocaleParam( | 626 google_util::AppendGoogleLocaleParam( |
| 634 GURL(kHelpURL), g_browser_process->GetApplicationLocale())); | 627 GURL(kHelpURL), g_browser_process->GetApplicationLocale())); |
| 635 #if defined(ENABLE_EXTENSIONS) | 628 #if defined(ENABLE_EXTENSIONS) |
| 636 if (sampling_event_.get()) | 629 if (sampling_event_.get()) |
| 637 sampling_event_->set_has_viewed_learn_more(true); | 630 sampling_event_->set_has_viewed_learn_more(true); |
| 638 #endif | 631 #endif |
| 639 web_contents_->GetController().LoadURLWithParams(help_page_params); | 632 web_contents()->GetController().LoadURLWithParams(help_page_params); |
| 640 break; | 633 break; |
| 641 } | 634 } |
| 642 case CMD_CLOCK: { | 635 case CMD_CLOCK: { |
| 643 LaunchDateAndTimeSettings(); | 636 LaunchDateAndTimeSettings(); |
| 644 break; | 637 break; |
| 645 } | 638 } |
| 646 default: { | 639 default: { |
| 647 NOTREACHED(); | 640 NOTREACHED(); |
| 648 } | 641 } |
| 649 } | 642 } |
| 650 } | 643 } |
| 651 | 644 |
| 652 void SSLBlockingPage::OverrideRendererPrefs( | 645 void SSLBlockingPage::OverrideRendererPrefs( |
| 653 content::RendererPreferences* prefs) { | 646 content::RendererPreferences* prefs) { |
| 654 Profile* profile = Profile::FromBrowserContext( | 647 Profile* profile = Profile::FromBrowserContext( |
| 655 web_contents_->GetBrowserContext()); | 648 web_contents()->GetBrowserContext()); |
| 656 renderer_preferences_util::UpdateFromSystemSettings( | 649 renderer_preferences_util::UpdateFromSystemSettings( |
| 657 prefs, profile, web_contents_); | 650 prefs, profile, web_contents()); |
| 658 } | 651 } |
| 659 | 652 |
| 660 void SSLBlockingPage::OnProceed() { | 653 void SSLBlockingPage::OnProceed() { |
| 661 RecordSSLBlockingPageDetailedStats(true, | 654 RecordSSLBlockingPageDetailedStats(true, |
| 662 cert_error_, | 655 cert_error_, |
| 663 overridable_, | 656 overridable_, |
| 664 internal_, | 657 internal_, |
| 665 num_visits_, | 658 num_visits_, |
| 666 expired_but_previously_allowed_); | 659 expired_but_previously_allowed_); |
| 667 #if defined(ENABLE_EXTENSIONS) | 660 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 for (; i < 5; i++) { | 716 for (; i < 5; i++) { |
| 724 strings->SetString(keys[i], std::string()); | 717 strings->SetString(keys[i], std::string()); |
| 725 } | 718 } |
| 726 } | 719 } |
| 727 | 720 |
| 728 void SSLBlockingPage::OnGotHistoryCount(bool success, | 721 void SSLBlockingPage::OnGotHistoryCount(bool success, |
| 729 int num_visits, | 722 int num_visits, |
| 730 base::Time first_visit) { | 723 base::Time first_visit) { |
| 731 num_visits_ = num_visits; | 724 num_visits_ = num_visits; |
| 732 } | 725 } |
| OLD | NEW |