| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "ui/base/l10n/l10n_util.h" | 44 #include "ui/base/l10n/l10n_util.h" |
| 45 #include "ui/base/resource/resource_bundle.h" | 45 #include "ui/base/resource/resource_bundle.h" |
| 46 #include "ui/base/webui/jstemplate_builder.h" | 46 #include "ui/base/webui/jstemplate_builder.h" |
| 47 #include "ui/base/webui/web_ui_util.h" | 47 #include "ui/base/webui/web_ui_util.h" |
| 48 | 48 |
| 49 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 49 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 50 #include "chrome/browser/captive_portal/captive_portal_service.h" | 50 #include "chrome/browser/captive_portal/captive_portal_service.h" |
| 51 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 51 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
| 52 #endif | 52 #endif |
| 53 | 53 |
| 54 #if defined(ENABLE_EXTENSIONS) |
| 55 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s
ampling.h" |
| 56 #endif |
| 57 |
| 54 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 55 #include "base/base_paths_win.h" | 59 #include "base/base_paths_win.h" |
| 56 #include "base/path_service.h" | 60 #include "base/path_service.h" |
| 57 #include "base/strings/string16.h" | 61 #include "base/strings/string16.h" |
| 58 #include "base/win/windows_version.h" | 62 #include "base/win/windows_version.h" |
| 59 #endif | 63 #endif |
| 60 | 64 |
| 61 #if defined(OS_CHROMEOS) | 65 #if defined(OS_CHROMEOS) |
| 62 #include "chrome/browser/profiles/profile_manager.h" | 66 #include "chrome/browser/profiles/profile_manager.h" |
| 63 #include "chrome/browser/ui/chrome_pages.h" | 67 #include "chrome/browser/ui/chrome_pages.h" |
| 64 #include "chrome/common/url_constants.h" | 68 #include "chrome/common/url_constants.h" |
| 65 #endif | 69 #endif |
| 66 | 70 |
| 67 using base::ASCIIToUTF16; | 71 using base::ASCIIToUTF16; |
| 68 using base::TimeTicks; | 72 using base::TimeTicks; |
| 69 using content::InterstitialPage; | 73 using content::InterstitialPage; |
| 70 using content::NavigationController; | 74 using content::NavigationController; |
| 71 using content::NavigationEntry; | 75 using content::NavigationEntry; |
| 72 | 76 |
| 77 #if defined(ENABLE_EXTENSIONS) |
| 78 using extensions::ExperienceSamplingEvent; |
| 79 #endif |
| 80 |
| 73 namespace { | 81 namespace { |
| 74 | 82 |
| 83 // Constants for the Experience Sampling instrumentation. |
| 84 #if defined(ENABLE_EXTENSIONS) |
| 85 const char kEventNameBase[] = "ssl_interstitial_"; |
| 86 const char kEventNotOverridable[] = "notoverridable_"; |
| 87 const char kEventOverridable[] = "overridable_"; |
| 88 #endif |
| 89 |
| 75 // Events for UMA. Do not reorder or change! | 90 // Events for UMA. Do not reorder or change! |
| 76 enum SSLBlockingPageEvent { | 91 enum SSLBlockingPageEvent { |
| 77 SHOW_ALL, | 92 SHOW_ALL, |
| 78 SHOW_OVERRIDABLE, | 93 SHOW_OVERRIDABLE, |
| 79 PROCEED_OVERRIDABLE, | 94 PROCEED_OVERRIDABLE, |
| 80 PROCEED_NAME, | 95 PROCEED_NAME, |
| 81 PROCEED_DATE, | 96 PROCEED_DATE, |
| 82 PROCEED_AUTHORITY, | 97 PROCEED_AUTHORITY, |
| 83 DONT_PROCEED_OVERRIDABLE, | 98 DONT_PROCEED_OVERRIDABLE, |
| 84 DONT_PROCEED_NAME, | 99 DONT_PROCEED_NAME, |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 335 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 321 CaptivePortalService* captive_portal_service = | 336 CaptivePortalService* captive_portal_service = |
| 322 CaptivePortalServiceFactory::GetForProfile(profile); | 337 CaptivePortalServiceFactory::GetForProfile(profile); |
| 323 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); | 338 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); |
| 324 captive_portal_service ->DetectCaptivePortal(); | 339 captive_portal_service ->DetectCaptivePortal(); |
| 325 registrar_.Add(this, | 340 registrar_.Add(this, |
| 326 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, | 341 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, |
| 327 content::Source<Profile>(profile)); | 342 content::Source<Profile>(profile)); |
| 328 #endif | 343 #endif |
| 329 | 344 |
| 345 #if defined(ENABLE_EXTENSIONS) |
| 346 // ExperienceSampling: Set up new sampling event for this interstitial. |
| 347 std::string event_name(kEventNameBase); |
| 348 if (overridable_ && !strict_enforcement_) |
| 349 event_name.append(kEventOverridable); |
| 350 else |
| 351 event_name.append(kEventNotOverridable); |
| 352 event_name.append(net::ErrorToString(cert_error_)); |
| 353 sampling_event_.reset(new ExperienceSamplingEvent( |
| 354 event_name, |
| 355 request_url_, |
| 356 web_contents_->GetLastCommittedURL(), |
| 357 web_contents_->GetBrowserContext())); |
| 358 #endif |
| 359 |
| 330 // Creating an interstitial without showing (e.g. from chrome://interstitials) | 360 // Creating an interstitial without showing (e.g. from chrome://interstitials) |
| 331 // it leaks memory, so don't create it here. | 361 // it leaks memory, so don't create it here. |
| 332 } | 362 } |
| 333 | 363 |
| 334 SSLBlockingPage::~SSLBlockingPage() { | 364 SSLBlockingPage::~SSLBlockingPage() { |
| 335 if (!callback_.is_null()) { | 365 if (!callback_.is_null()) { |
| 336 RecordSSLBlockingPageDetailedStats(false, | 366 RecordSSLBlockingPageDetailedStats(false, |
| 337 cert_error_, | 367 cert_error_, |
| 338 overridable_ && !strict_enforcement_, | 368 overridable_ && !strict_enforcement_, |
| 339 internal_, | 369 internal_, |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 case CMD_DONT_PROCEED: { | 507 case CMD_DONT_PROCEED: { |
| 478 interstitial_page_->DontProceed(); | 508 interstitial_page_->DontProceed(); |
| 479 break; | 509 break; |
| 480 } | 510 } |
| 481 case CMD_PROCEED: { | 511 case CMD_PROCEED: { |
| 482 interstitial_page_->Proceed(); | 512 interstitial_page_->Proceed(); |
| 483 break; | 513 break; |
| 484 } | 514 } |
| 485 case CMD_MORE: { | 515 case CMD_MORE: { |
| 486 RecordSSLBlockingPageEventStats(MORE); | 516 RecordSSLBlockingPageEventStats(MORE); |
| 517 #if defined(ENABLE_EXTENSIONS) |
| 518 if (sampling_event_.get()) |
| 519 sampling_event_->set_has_viewed_details(true); |
| 520 #endif |
| 487 break; | 521 break; |
| 488 } | 522 } |
| 489 case CMD_RELOAD: { | 523 case CMD_RELOAD: { |
| 490 // The interstitial can't refresh itself. | 524 // The interstitial can't refresh itself. |
| 491 web_contents_->GetController().Reload(true); | 525 web_contents_->GetController().Reload(true); |
| 492 break; | 526 break; |
| 493 } | 527 } |
| 494 case CMD_HELP: { | 528 case CMD_HELP: { |
| 495 content::NavigationController::LoadURLParams help_page_params(GURL( | 529 content::NavigationController::LoadURLParams help_page_params(GURL( |
| 496 "https://support.google.com/chrome/answer/4454607")); | 530 "https://support.google.com/chrome/answer/4454607")); |
| 531 #if defined(ENABLE_EXTENSIONS) |
| 532 if (sampling_event_.get()) |
| 533 sampling_event_->set_has_viewed_learn_more(true); |
| 534 #endif |
| 497 web_contents_->GetController().LoadURLWithParams(help_page_params); | 535 web_contents_->GetController().LoadURLWithParams(help_page_params); |
| 498 break; | 536 break; |
| 499 } | 537 } |
| 500 case CMD_CLOCK: { | 538 case CMD_CLOCK: { |
| 501 LaunchDateAndTimeSettings(); | 539 LaunchDateAndTimeSettings(); |
| 502 break; | 540 break; |
| 503 } | 541 } |
| 504 default: { | 542 default: { |
| 505 NOTREACHED(); | 543 NOTREACHED(); |
| 506 } | 544 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 517 void SSLBlockingPage::OnProceed() { | 555 void SSLBlockingPage::OnProceed() { |
| 518 RecordSSLBlockingPageDetailedStats(true, | 556 RecordSSLBlockingPageDetailedStats(true, |
| 519 cert_error_, | 557 cert_error_, |
| 520 overridable_ && !strict_enforcement_, | 558 overridable_ && !strict_enforcement_, |
| 521 internal_, | 559 internal_, |
| 522 num_visits_, | 560 num_visits_, |
| 523 captive_portal_detection_enabled_, | 561 captive_portal_detection_enabled_, |
| 524 captive_portal_probe_completed_, | 562 captive_portal_probe_completed_, |
| 525 captive_portal_no_response_, | 563 captive_portal_no_response_, |
| 526 captive_portal_detected_); | 564 captive_portal_detected_); |
| 565 #if defined(ENABLE_EXTENSIONS) |
| 566 // ExperienceSampling: Notify that user decided to proceed. |
| 567 if (sampling_event_.get()) |
| 568 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed); |
| 569 #endif |
| 527 // Accepting the certificate resumes the loading of the page. | 570 // Accepting the certificate resumes the loading of the page. |
| 528 NotifyAllowCertificate(); | 571 NotifyAllowCertificate(); |
| 529 } | 572 } |
| 530 | 573 |
| 531 void SSLBlockingPage::OnDontProceed() { | 574 void SSLBlockingPage::OnDontProceed() { |
| 532 RecordSSLBlockingPageDetailedStats(false, | 575 RecordSSLBlockingPageDetailedStats(false, |
| 533 cert_error_, | 576 cert_error_, |
| 534 overridable_ && !strict_enforcement_, | 577 overridable_ && !strict_enforcement_, |
| 535 internal_, | 578 internal_, |
| 536 num_visits_, | 579 num_visits_, |
| 537 captive_portal_detection_enabled_, | 580 captive_portal_detection_enabled_, |
| 538 captive_portal_probe_completed_, | 581 captive_portal_probe_completed_, |
| 539 captive_portal_no_response_, | 582 captive_portal_no_response_, |
| 540 captive_portal_detected_); | 583 captive_portal_detected_); |
| 584 #if defined(ENABLE_EXTENSIONS) |
| 585 // ExperienceSampling: Notify that user decided to not proceed. |
| 586 // This also occurs if the user navigates away or closes the tab. |
| 587 if (sampling_event_.get()) |
| 588 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny); |
| 589 #endif |
| 541 NotifyDenyCertificate(); | 590 NotifyDenyCertificate(); |
| 542 } | 591 } |
| 543 | 592 |
| 544 void SSLBlockingPage::NotifyDenyCertificate() { | 593 void SSLBlockingPage::NotifyDenyCertificate() { |
| 545 // It's possible that callback_ may not exist if the user clicks "Proceed" | 594 // It's possible that callback_ may not exist if the user clicks "Proceed" |
| 546 // followed by pressing the back button before the interstitial is hidden. | 595 // followed by pressing the back button before the interstitial is hidden. |
| 547 // In that case the certificate will still be treated as allowed. | 596 // In that case the certificate will still be treated as allowed. |
| 548 if (callback_.is_null()) | 597 if (callback_.is_null()) |
| 549 return; | 598 return; |
| 550 | 599 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 // sure we don't clear the captive portal flag, since the interstitial was | 655 // sure we don't clear the captive portal flag, since the interstitial was |
| 607 // potentially caused by the captive portal. | 656 // potentially caused by the captive portal. |
| 608 captive_portal_detected_ = captive_portal_detected_ || | 657 captive_portal_detected_ = captive_portal_detected_ || |
| 609 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 658 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
| 610 // Also keep track of non-HTTP portals and error cases. | 659 // Also keep track of non-HTTP portals and error cases. |
| 611 captive_portal_no_response_ = captive_portal_no_response_ || | 660 captive_portal_no_response_ = captive_portal_no_response_ || |
| 612 (results->result == captive_portal::RESULT_NO_RESPONSE); | 661 (results->result == captive_portal::RESULT_NO_RESPONSE); |
| 613 } | 662 } |
| 614 #endif | 663 #endif |
| 615 } | 664 } |
| OLD | NEW |