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/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 28 matching lines...) Expand all Loading... | |
| 39 #include "grit/chromium_strings.h" | 39 #include "grit/chromium_strings.h" |
| 40 #include "grit/generated_resources.h" | 40 #include "grit/generated_resources.h" |
| 41 #include "net/base/hash_value.h" | 41 #include "net/base/hash_value.h" |
| 42 #include "net/base/net_errors.h" | 42 #include "net/base/net_errors.h" |
| 43 #include "net/base/net_util.h" | 43 #include "net/base/net_util.h" |
| 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) | |
| 50 #include "chrome/browser/captive_portal/captive_portal_service.h" | |
| 51 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | |
| 52 #endif | |
| 53 | |
| 54 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 55 #include "base/base_paths_win.h" | 50 #include "base/base_paths_win.h" |
| 56 #include "base/path_service.h" | 51 #include "base/path_service.h" |
| 57 #include "base/strings/string16.h" | 52 #include "base/strings/string16.h" |
| 58 #include "base/win/windows_version.h" | 53 #include "base/win/windows_version.h" |
| 59 #endif | 54 #endif |
| 60 | 55 |
| 61 #if defined(OS_CHROMEOS) | 56 #if defined(OS_CHROMEOS) |
| 62 #include "chrome/browser/profiles/profile_manager.h" | 57 #include "chrome/browser/profiles/profile_manager.h" |
| 63 #include "chrome/browser/ui/chrome_pages.h" | 58 #include "chrome/browser/ui/chrome_pages.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 DONT_PROCEED_NAME, | 114 DONT_PROCEED_NAME, |
| 120 DONT_PROCEED_DATE, | 115 DONT_PROCEED_DATE, |
| 121 DONT_PROCEED_AUTHORITY, | 116 DONT_PROCEED_AUTHORITY, |
| 122 MORE, | 117 MORE, |
| 123 SHOW_UNDERSTAND, // Used by the summer 2013 Finch trial. Deprecated. | 118 SHOW_UNDERSTAND, // Used by the summer 2013 Finch trial. Deprecated. |
| 124 SHOW_INTERNAL_HOSTNAME, | 119 SHOW_INTERNAL_HOSTNAME, |
| 125 PROCEED_INTERNAL_HOSTNAME, | 120 PROCEED_INTERNAL_HOSTNAME, |
| 126 SHOW_NEW_SITE, | 121 SHOW_NEW_SITE, |
| 127 PROCEED_NEW_SITE, | 122 PROCEED_NEW_SITE, |
| 128 PROCEED_MANUAL_NONOVERRIDABLE, | 123 PROCEED_MANUAL_NONOVERRIDABLE, |
| 129 CAPTIVE_PORTAL_DETECTION_ENABLED, | 124 DEPRECATED_CAPTIVE_PORTAL_DETECTION_ENABLED, // Captive Portal errors moved |
| 130 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE, | 125 DEPRECATED_CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE, // to |
| 131 CAPTIVE_PORTAL_PROBE_COMPLETED, | 126 DEPRECATED_CAPTIVE_PORTAL_PROBE_COMPLETED, // ssl_error_classification. |
| 132 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE, | 127 DEPRECATED_CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE, |
| 133 CAPTIVE_PORTAL_NO_RESPONSE, | 128 DEPRECATED_CAPTIVE_PORTAL_NO_RESPONSE, |
| 134 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE, | 129 DEPRECATED_CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE, |
| 135 CAPTIVE_PORTAL_DETECTED, | 130 DEPRECATED_CAPTIVE_PORTAL_DETECTED, |
| 136 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE, | 131 DEPRECATED_CAPTIVE_PORTAL_DETECTED_OVERRIDABLE, |
| 137 UNUSED_BLOCKING_PAGE_EVENT, | 132 UNUSED_BLOCKING_PAGE_EVENT, |
| 138 }; | 133 }; |
| 139 | 134 |
| 140 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { | 135 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { |
| 141 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", | 136 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", |
| 142 event, | 137 event, |
| 143 UNUSED_BLOCKING_PAGE_EVENT); | 138 UNUSED_BLOCKING_PAGE_EVENT); |
| 144 } | 139 } |
| 145 | 140 |
| 146 void RecordSSLBlockingPageDetailedStats( | 141 void RecordSSLBlockingPageDetailedStats( |
| 147 bool proceed, | 142 bool proceed, |
| 148 int cert_error, | 143 int cert_error, |
| 149 bool overridable, | 144 bool overridable, |
| 150 bool internal, | 145 bool internal, |
| 151 int num_visits, | 146 int num_visits) { |
| 152 bool captive_portal_detection_enabled, | |
| 153 bool captive_portal_probe_completed, | |
| 154 bool captive_portal_no_response, | |
| 155 bool captive_portal_detected) { | |
| 156 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", | 147 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", |
| 157 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); | 148 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); |
| 158 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
| 159 if (captive_portal_detection_enabled) | |
| 160 RecordSSLBlockingPageEventStats( | |
| 161 overridable ? | |
| 162 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE : | |
| 163 CAPTIVE_PORTAL_DETECTION_ENABLED); | |
| 164 if (captive_portal_probe_completed) | |
| 165 RecordSSLBlockingPageEventStats( | |
| 166 overridable ? | |
| 167 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE : | |
| 168 CAPTIVE_PORTAL_PROBE_COMPLETED); | |
| 169 // Log only one of portal detected and no response results. | |
| 170 if (captive_portal_detected) | |
| 171 RecordSSLBlockingPageEventStats( | |
| 172 overridable ? | |
| 173 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE : | |
| 174 CAPTIVE_PORTAL_DETECTED); | |
| 175 else if (captive_portal_no_response) | |
| 176 RecordSSLBlockingPageEventStats( | |
| 177 overridable ? | |
| 178 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE : | |
| 179 CAPTIVE_PORTAL_NO_RESPONSE); | |
| 180 #endif | |
| 181 if (!overridable) { | 149 if (!overridable) { |
| 182 if (proceed) { | 150 if (proceed) { |
| 183 RecordSSLBlockingPageEventStats(PROCEED_MANUAL_NONOVERRIDABLE); | 151 RecordSSLBlockingPageEventStats(PROCEED_MANUAL_NONOVERRIDABLE); |
| 184 } | 152 } |
| 185 // Overridable is false if the user didn't have any option except to turn | 153 // Overridable is false if the user didn't have any option except to turn |
| 186 // back. If that's the case, don't record some of the metrics. | 154 // back. If that's the case, don't record some of the metrics. |
| 187 return; | 155 return; |
| 188 } | 156 } |
| 189 if (num_visits == 0) | 157 if (num_visits == 0) |
| 190 RecordSSLBlockingPageEventStats(SHOW_NEW_SITE); | 158 RecordSSLBlockingPageEventStats(SHOW_NEW_SITE); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 const base::Callback<void(bool)>& callback) | 282 const base::Callback<void(bool)>& callback) |
| 315 : callback_(callback), | 283 : callback_(callback), |
| 316 web_contents_(web_contents), | 284 web_contents_(web_contents), |
| 317 cert_error_(cert_error), | 285 cert_error_(cert_error), |
| 318 ssl_info_(ssl_info), | 286 ssl_info_(ssl_info), |
| 319 request_url_(request_url), | 287 request_url_(request_url), |
| 320 overridable_(overridable), | 288 overridable_(overridable), |
| 321 strict_enforcement_(strict_enforcement), | 289 strict_enforcement_(strict_enforcement), |
| 322 internal_(false), | 290 internal_(false), |
| 323 num_visits_(-1), | 291 num_visits_(-1), |
| 324 captive_portal_detection_enabled_(false), | |
| 325 captive_portal_probe_completed_(false), | |
| 326 captive_portal_no_response_(false), | |
| 327 captive_portal_detected_(false), | |
| 328 trial_condition_(GetTrialCondition()) { | 292 trial_condition_(GetTrialCondition()) { |
| 329 Profile* profile = Profile::FromBrowserContext( | 293 Profile* profile = Profile::FromBrowserContext( |
| 330 web_contents->GetBrowserContext()); | 294 web_contents->GetBrowserContext()); |
| 331 // For UMA stats. | 295 // For UMA stats. |
| 332 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) | 296 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) |
| 333 internal_ = true; | 297 internal_ = true; |
| 334 RecordSSLBlockingPageEventStats(SHOW_ALL); | 298 RecordSSLBlockingPageEventStats(SHOW_ALL); |
| 335 if (overridable_ && !strict_enforcement_) { | 299 if (overridable_ && !strict_enforcement_) { |
| 336 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); | 300 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); |
| 337 if (internal_) | 301 if (internal_) |
| 338 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); | 302 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); |
| 339 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 303 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 340 profile, Profile::EXPLICIT_ACCESS); | 304 profile, Profile::EXPLICIT_ACCESS); |
| 341 if (history_service) { | 305 if (history_service) { |
| 342 history_service->GetVisibleVisitCountToHost( | 306 history_service->GetVisibleVisitCountToHost( |
| 343 request_url_, | 307 request_url_, |
| 344 base::Bind(&SSLBlockingPage::OnGotHistoryCount, | 308 base::Bind(&SSLBlockingPage::OnGotHistoryCount, |
| 345 base::Unretained(this)), | 309 base::Unretained(this)), |
| 346 &request_tracker_); | 310 &request_tracker_); |
| 347 } | 311 } |
| 348 } | 312 } |
| 313 | |
| 314 SSLErrorClassification ssl_error_classification( | |
| 315 web_contents_, | |
| 316 base::Time::NowFromSystemTime(), | |
| 317 cert_error_, | |
| 318 *ssl_info_.cert.get()); | |
| 349 if (SSLErrorInfo::NetErrorToErrorType(cert_error_) == | 319 if (SSLErrorInfo::NetErrorToErrorType(cert_error_) == |
| 350 SSLErrorInfo::CERT_DATE_INVALID) { | 320 SSLErrorInfo::CERT_DATE_INVALID) { |
| 351 SSLErrorClassification::RecordUMAStatistics(overridable_ && | 321 ssl_error_classification.RecordUMAStatistics( |
| 352 !strict_enforcement_); | 322 overridable_ && !strict_enforcement_); |
| 353 } | 323 } |
| 354 | 324 |
| 355 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 325 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 356 CaptivePortalService* captive_portal_service = | 326 ssl_error_classification.RecordCaptivePortalUMAStatistics( |
| 357 CaptivePortalServiceFactory::GetForProfile(profile); | 327 overridable_ && !strict_enforcement_); |
| 358 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); | 328 #elif |
|
felt
2014/07/29 01:47:53
I'm confused about what's going on here:
* Why is
radhikabhar
2014/07/29 17:56:56
* My logic was-
#if defined(ENABLE_CAPTIVE_PORTAL_
| |
| 359 captive_portal_service ->DetectCaptivePortal(); | 329 if (SSLErrorInfo::NetErrorToErrorType(cert_error_) == |
| 360 registrar_.Add(this, | 330 SSLErrorInfo::CERT_DATE_INVALID) { |
| 361 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, | 331 ssl_error_classification.InvalidDateSeverityScore(); |
| 362 content::Source<Profile>(profile)); | 332 } |
|
felt
2014/07/29 01:47:53
Also, this if-statement seems redundant to the cod
radhikabhar
2014/07/29 17:56:56
I was thinking way ahead into the CL for the commo
| |
| 363 #endif | 333 #endif |
| 364 | 334 |
| 365 interstitial_page_ = InterstitialPage::Create( | 335 interstitial_page_ = InterstitialPage::Create( |
| 366 web_contents_, true, request_url, this); | 336 web_contents_, true, request_url, this); |
| 367 interstitial_page_->Show(); | 337 interstitial_page_->Show(); |
| 368 } | 338 } |
| 369 | 339 |
| 370 SSLBlockingPage::~SSLBlockingPage() { | 340 SSLBlockingPage::~SSLBlockingPage() { |
| 371 if (!callback_.is_null()) { | 341 if (!callback_.is_null()) { |
| 372 RecordSSLBlockingPageDetailedStats(false, | 342 RecordSSLBlockingPageDetailedStats(false, |
| 373 cert_error_, | 343 cert_error_, |
| 374 overridable_ && !strict_enforcement_, | 344 overridable_ && !strict_enforcement_, |
| 375 internal_, | 345 internal_, |
| 376 num_visits_, | 346 num_visits_); |
| 377 captive_portal_detection_enabled_, | |
| 378 captive_portal_probe_completed_, | |
| 379 captive_portal_no_response_, | |
| 380 captive_portal_detected_); | |
| 381 // The page is closed without the user having chosen what to do, default to | 347 // The page is closed without the user having chosen what to do, default to |
| 382 // deny. | 348 // deny. |
| 383 NotifyDenyCertificate(); | 349 NotifyDenyCertificate(); |
| 384 } | 350 } |
| 385 } | 351 } |
| 386 | 352 |
| 387 std::string SSLBlockingPage::GetHTMLContents() { | 353 std::string SSLBlockingPage::GetHTMLContents() { |
| 388 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text) | 354 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text) |
| 389 return GetHTMLContentsV1(); | 355 return GetHTMLContentsV1(); |
| 390 return GetHTMLContentsV2(); | 356 return GetHTMLContentsV2(); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 Profile* profile = Profile::FromBrowserContext( | 683 Profile* profile = Profile::FromBrowserContext( |
| 718 web_contents_->GetBrowserContext()); | 684 web_contents_->GetBrowserContext()); |
| 719 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); | 685 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); |
| 720 } | 686 } |
| 721 | 687 |
| 722 void SSLBlockingPage::OnProceed() { | 688 void SSLBlockingPage::OnProceed() { |
| 723 RecordSSLBlockingPageDetailedStats(true, | 689 RecordSSLBlockingPageDetailedStats(true, |
| 724 cert_error_, | 690 cert_error_, |
| 725 overridable_ && !strict_enforcement_, | 691 overridable_ && !strict_enforcement_, |
| 726 internal_, | 692 internal_, |
| 727 num_visits_, | 693 num_visits_); |
| 728 captive_portal_detection_enabled_, | |
| 729 captive_portal_probe_completed_, | |
| 730 captive_portal_no_response_, | |
| 731 captive_portal_detected_); | |
| 732 // Accepting the certificate resumes the loading of the page. | 694 // Accepting the certificate resumes the loading of the page. |
| 733 NotifyAllowCertificate(); | 695 NotifyAllowCertificate(); |
| 734 } | 696 } |
| 735 | 697 |
| 736 void SSLBlockingPage::OnDontProceed() { | 698 void SSLBlockingPage::OnDontProceed() { |
| 737 RecordSSLBlockingPageDetailedStats(false, | 699 RecordSSLBlockingPageDetailedStats(false, |
| 738 cert_error_, | 700 cert_error_, |
| 739 overridable_ && !strict_enforcement_, | 701 overridable_ && !strict_enforcement_, |
| 740 internal_, | 702 internal_, |
| 741 num_visits_, | 703 num_visits_); |
| 742 captive_portal_detection_enabled_, | |
| 743 captive_portal_probe_completed_, | |
| 744 captive_portal_no_response_, | |
| 745 captive_portal_detected_); | |
| 746 NotifyDenyCertificate(); | 704 NotifyDenyCertificate(); |
| 747 } | 705 } |
| 748 | 706 |
| 749 void SSLBlockingPage::NotifyDenyCertificate() { | 707 void SSLBlockingPage::NotifyDenyCertificate() { |
| 750 // It's possible that callback_ may not exist if the user clicks "Proceed" | 708 // It's possible that callback_ may not exist if the user clicks "Proceed" |
| 751 // followed by pressing the back button before the interstitial is hidden. | 709 // followed by pressing the back button before the interstitial is hidden. |
| 752 // In that case the certificate will still be treated as allowed. | 710 // In that case the certificate will still be treated as allowed. |
| 753 if (callback_.is_null()) | 711 if (callback_.is_null()) |
| 754 return; | 712 return; |
| 755 | 713 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 779 for (; i < 5; i++) { | 737 for (; i < 5; i++) { |
| 780 strings->SetString(keys[i], std::string()); | 738 strings->SetString(keys[i], std::string()); |
| 781 } | 739 } |
| 782 } | 740 } |
| 783 | 741 |
| 784 void SSLBlockingPage::OnGotHistoryCount(bool success, | 742 void SSLBlockingPage::OnGotHistoryCount(bool success, |
| 785 int num_visits, | 743 int num_visits, |
| 786 base::Time first_visit) { | 744 base::Time first_visit) { |
| 787 num_visits_ = num_visits; | 745 num_visits_ = num_visits; |
| 788 } | 746 } |
| 789 | |
| 790 void SSLBlockingPage::Observe( | |
| 791 int type, | |
| 792 const content::NotificationSource& source, | |
| 793 const content::NotificationDetails& details) { | |
| 794 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | |
| 795 // When detection is disabled, captive portal service always sends | |
| 796 // RESULT_INTERNET_CONNECTED. Ignore any probe results in that case. | |
| 797 if (!captive_portal_detection_enabled_) | |
| 798 return; | |
| 799 if (type == chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT) { | |
| 800 captive_portal_probe_completed_ = true; | |
| 801 CaptivePortalService::Results* results = | |
| 802 content::Details<CaptivePortalService::Results>( | |
| 803 details).ptr(); | |
| 804 // If a captive portal was detected at any point when the interstitial was | |
| 805 // displayed, assume that the interstitial was caused by a captive portal. | |
| 806 // Example scenario: | |
| 807 // 1- Interstitial displayed and captive portal detected, setting the flag. | |
| 808 // 2- Captive portal detection automatically opens portal login page. | |
| 809 // 3- User logs in on the portal login page. | |
| 810 // A notification will be received here for RESULT_INTERNET_CONNECTED. Make | |
| 811 // sure we don't clear the captive portal flag, since the interstitial was | |
| 812 // potentially caused by the captive portal. | |
| 813 captive_portal_detected_ = captive_portal_detected_ || | |
| 814 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | |
| 815 // Also keep track of non-HTTP portals and error cases. | |
| 816 captive_portal_no_response_ = captive_portal_no_response_ || | |
| 817 (results->result == captive_portal::RESULT_NO_RESPONSE); | |
| 818 } | |
| 819 #endif | |
| 820 } | |
| OLD | NEW |