| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE, | 95 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE, |
| 96 CAPTIVE_PORTAL_PROBE_COMPLETED, | 96 CAPTIVE_PORTAL_PROBE_COMPLETED, |
| 97 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE, | 97 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE, |
| 98 CAPTIVE_PORTAL_NO_RESPONSE, | 98 CAPTIVE_PORTAL_NO_RESPONSE, |
| 99 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE, | 99 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE, |
| 100 CAPTIVE_PORTAL_DETECTED, | 100 CAPTIVE_PORTAL_DETECTED, |
| 101 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE, | 101 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE, |
| 102 UNUSED_BLOCKING_PAGE_EVENT, | 102 UNUSED_BLOCKING_PAGE_EVENT, |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 // Events for UMA. Do not reorder or change! |
| 106 enum SSLExpirationAndDecision { |
| 107 EXPIRED_AND_PROCEED, |
| 108 EXPIRED_AND_DO_NOT_PROCEED, |
| 109 NOT_EXPIRED_AND_PROCEED, |
| 110 NOT_EXPIRED_AND_DO_NOT_PROCEED, |
| 111 END_OF_SSL_EXPIRATION_AND_DECISION, |
| 112 }; |
| 113 |
| 105 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { | 114 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { |
| 106 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", | 115 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", |
| 107 event, | 116 event, |
| 108 UNUSED_BLOCKING_PAGE_EVENT); | 117 UNUSED_BLOCKING_PAGE_EVENT); |
| 109 } | 118 } |
| 110 | 119 |
| 111 void RecordSSLBlockingPageDetailedStats( | 120 void RecordSSLExpirationPageEventState(bool expired_but_previously_allowed, |
| 112 bool proceed, | 121 bool proceed, |
| 113 int cert_error, | 122 bool overridable) { |
| 114 bool overridable, | 123 SSLExpirationAndDecision event; |
| 115 bool internal, | 124 if (expired_but_previously_allowed && proceed) |
| 116 int num_visits, | 125 event = EXPIRED_AND_PROCEED; |
| 117 bool captive_portal_detection_enabled, | 126 else if (expired_but_previously_allowed && !proceed) |
| 118 bool captive_portal_probe_completed, | 127 event = EXPIRED_AND_DO_NOT_PROCEED; |
| 119 bool captive_portal_no_response, | 128 else if (!expired_but_previously_allowed && proceed) |
| 120 bool captive_portal_detected) { | 129 event = NOT_EXPIRED_AND_PROCEED; |
| 130 else |
| 131 event = NOT_EXPIRED_AND_DO_NOT_PROCEED; |
| 132 |
| 133 if (overridable) { |
| 134 UMA_HISTOGRAM_ENUMERATION( |
| 135 "interstitial.ssl.expiration_and_decision.overridable", |
| 136 event, |
| 137 END_OF_SSL_EXPIRATION_AND_DECISION); |
| 138 } else { |
| 139 UMA_HISTOGRAM_ENUMERATION( |
| 140 "interstitial.ssl.expiration_and_decision.nonoverridable", |
| 141 event, |
| 142 END_OF_SSL_EXPIRATION_AND_DECISION); |
| 143 } |
| 144 } |
| 145 |
| 146 void RecordSSLBlockingPageDetailedStats(bool proceed, |
| 147 int cert_error, |
| 148 bool overridable, |
| 149 bool internal, |
| 150 int num_visits, |
| 151 bool captive_portal_detection_enabled, |
| 152 bool captive_portal_probe_completed, |
| 153 bool captive_portal_no_response, |
| 154 bool captive_portal_detected, |
| 155 bool expired_but_previously_allowed) { |
| 121 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", | 156 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", |
| 122 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); | 157 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); |
| 158 RecordSSLExpirationPageEventState( |
| 159 expired_but_previously_allowed, proceed, overridable); |
| 123 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 160 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 124 if (captive_portal_detection_enabled) | 161 if (captive_portal_detection_enabled) |
| 125 RecordSSLBlockingPageEventStats( | 162 RecordSSLBlockingPageEventStats( |
| 126 overridable ? | 163 overridable ? |
| 127 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE : | 164 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE : |
| 128 CAPTIVE_PORTAL_DETECTION_ENABLED); | 165 CAPTIVE_PORTAL_DETECTION_ENABLED); |
| 129 if (captive_portal_probe_completed) | 166 if (captive_portal_probe_completed) |
| 130 RecordSSLBlockingPageEventStats( | 167 RecordSSLBlockingPageEventStats( |
| 131 overridable ? | 168 overridable ? |
| 132 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE : | 169 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE : |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 options.allow_new_privs = true; | 299 options.allow_new_privs = true; |
| 263 #endif | 300 #endif |
| 264 base::LaunchProcess(command, options, NULL); | 301 base::LaunchProcess(command, options, NULL); |
| 265 #endif | 302 #endif |
| 266 } | 303 } |
| 267 | 304 |
| 268 } // namespace | 305 } // namespace |
| 269 | 306 |
| 270 // Note that we always create a navigation entry with SSL errors. | 307 // Note that we always create a navigation entry with SSL errors. |
| 271 // No error happening loading a sub-resource triggers an interstitial so far. | 308 // No error happening loading a sub-resource triggers an interstitial so far. |
| 272 SSLBlockingPage::SSLBlockingPage( | 309 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, |
| 273 content::WebContents* web_contents, | 310 int cert_error, |
| 274 int cert_error, | 311 const net::SSLInfo& ssl_info, |
| 275 const net::SSLInfo& ssl_info, | 312 const GURL& request_url, |
| 276 const GURL& request_url, | 313 bool overridable, |
| 277 bool overridable, | 314 bool strict_enforcement, |
| 278 bool strict_enforcement, | 315 bool expired_but_previously_allowed, |
| 279 const base::Callback<void(bool)>& callback) | 316 const base::Callback<void(bool)>& callback) |
| 280 : callback_(callback), | 317 : callback_(callback), |
| 281 web_contents_(web_contents), | 318 web_contents_(web_contents), |
| 282 cert_error_(cert_error), | 319 cert_error_(cert_error), |
| 283 ssl_info_(ssl_info), | 320 ssl_info_(ssl_info), |
| 284 request_url_(request_url), | 321 request_url_(request_url), |
| 285 overridable_(overridable), | 322 overridable_(overridable), |
| 286 strict_enforcement_(strict_enforcement), | 323 strict_enforcement_(strict_enforcement), |
| 287 interstitial_page_(NULL), | 324 interstitial_page_(NULL), |
| 288 internal_(false), | 325 internal_(false), |
| 289 num_visits_(-1), | 326 num_visits_(-1), |
| 290 captive_portal_detection_enabled_(false), | 327 captive_portal_detection_enabled_(false), |
| 291 captive_portal_probe_completed_(false), | 328 captive_portal_probe_completed_(false), |
| 292 captive_portal_no_response_(false), | 329 captive_portal_no_response_(false), |
| 293 captive_portal_detected_(false) { | 330 captive_portal_detected_(false), |
| 331 expired_but_previously_allowed_(expired_but_previously_allowed) { |
| 294 Profile* profile = Profile::FromBrowserContext( | 332 Profile* profile = Profile::FromBrowserContext( |
| 295 web_contents->GetBrowserContext()); | 333 web_contents->GetBrowserContext()); |
| 296 // For UMA stats. | 334 // For UMA stats. |
| 297 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) | 335 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) |
| 298 internal_ = true; | 336 internal_ = true; |
| 299 RecordSSLBlockingPageEventStats(SHOW_ALL); | 337 RecordSSLBlockingPageEventStats(SHOW_ALL); |
| 300 if (overridable_ && !strict_enforcement_) { | 338 if (overridable_ && !strict_enforcement_) { |
| 301 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); | 339 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); |
| 302 if (internal_) | 340 if (internal_) |
| 303 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); | 341 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 334 SSLBlockingPage::~SSLBlockingPage() { | 372 SSLBlockingPage::~SSLBlockingPage() { |
| 335 if (!callback_.is_null()) { | 373 if (!callback_.is_null()) { |
| 336 RecordSSLBlockingPageDetailedStats(false, | 374 RecordSSLBlockingPageDetailedStats(false, |
| 337 cert_error_, | 375 cert_error_, |
| 338 overridable_ && !strict_enforcement_, | 376 overridable_ && !strict_enforcement_, |
| 339 internal_, | 377 internal_, |
| 340 num_visits_, | 378 num_visits_, |
| 341 captive_portal_detection_enabled_, | 379 captive_portal_detection_enabled_, |
| 342 captive_portal_probe_completed_, | 380 captive_portal_probe_completed_, |
| 343 captive_portal_no_response_, | 381 captive_portal_no_response_, |
| 344 captive_portal_detected_); | 382 captive_portal_detected_, |
| 383 expired_but_previously_allowed_); |
| 345 // The page is closed without the user having chosen what to do, default to | 384 // The page is closed without the user having chosen what to do, default to |
| 346 // deny. | 385 // deny. |
| 347 NotifyDenyCertificate(); | 386 NotifyDenyCertificate(); |
| 348 } | 387 } |
| 349 } | 388 } |
| 350 | 389 |
| 351 void SSLBlockingPage::Show() { | 390 void SSLBlockingPage::Show() { |
| 352 DCHECK(!interstitial_page_); | 391 DCHECK(!interstitial_page_); |
| 353 interstitial_page_ = InterstitialPage::Create( | 392 interstitial_page_ = InterstitialPage::Create( |
| 354 web_contents_, true, request_url_, this); | 393 web_contents_, true, request_url_, this); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 555 |
| 517 void SSLBlockingPage::OnProceed() { | 556 void SSLBlockingPage::OnProceed() { |
| 518 RecordSSLBlockingPageDetailedStats(true, | 557 RecordSSLBlockingPageDetailedStats(true, |
| 519 cert_error_, | 558 cert_error_, |
| 520 overridable_ && !strict_enforcement_, | 559 overridable_ && !strict_enforcement_, |
| 521 internal_, | 560 internal_, |
| 522 num_visits_, | 561 num_visits_, |
| 523 captive_portal_detection_enabled_, | 562 captive_portal_detection_enabled_, |
| 524 captive_portal_probe_completed_, | 563 captive_portal_probe_completed_, |
| 525 captive_portal_no_response_, | 564 captive_portal_no_response_, |
| 526 captive_portal_detected_); | 565 captive_portal_detected_, |
| 566 expired_but_previously_allowed_); |
| 527 // Accepting the certificate resumes the loading of the page. | 567 // Accepting the certificate resumes the loading of the page. |
| 528 NotifyAllowCertificate(); | 568 NotifyAllowCertificate(); |
| 529 } | 569 } |
| 530 | 570 |
| 531 void SSLBlockingPage::OnDontProceed() { | 571 void SSLBlockingPage::OnDontProceed() { |
| 532 RecordSSLBlockingPageDetailedStats(false, | 572 RecordSSLBlockingPageDetailedStats(false, |
| 533 cert_error_, | 573 cert_error_, |
| 534 overridable_ && !strict_enforcement_, | 574 overridable_ && !strict_enforcement_, |
| 535 internal_, | 575 internal_, |
| 536 num_visits_, | 576 num_visits_, |
| 537 captive_portal_detection_enabled_, | 577 captive_portal_detection_enabled_, |
| 538 captive_portal_probe_completed_, | 578 captive_portal_probe_completed_, |
| 539 captive_portal_no_response_, | 579 captive_portal_no_response_, |
| 540 captive_portal_detected_); | 580 captive_portal_detected_, |
| 581 expired_but_previously_allowed_); |
| 541 NotifyDenyCertificate(); | 582 NotifyDenyCertificate(); |
| 542 } | 583 } |
| 543 | 584 |
| 544 void SSLBlockingPage::NotifyDenyCertificate() { | 585 void SSLBlockingPage::NotifyDenyCertificate() { |
| 545 // It's possible that callback_ may not exist if the user clicks "Proceed" | 586 // 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. | 587 // followed by pressing the back button before the interstitial is hidden. |
| 547 // In that case the certificate will still be treated as allowed. | 588 // In that case the certificate will still be treated as allowed. |
| 548 if (callback_.is_null()) | 589 if (callback_.is_null()) |
| 549 return; | 590 return; |
| 550 | 591 |
| (...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 | 647 // sure we don't clear the captive portal flag, since the interstitial was |
| 607 // potentially caused by the captive portal. | 648 // potentially caused by the captive portal. |
| 608 captive_portal_detected_ = captive_portal_detected_ || | 649 captive_portal_detected_ = captive_portal_detected_ || |
| 609 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 650 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
| 610 // Also keep track of non-HTTP portals and error cases. | 651 // Also keep track of non-HTTP portals and error cases. |
| 611 captive_portal_no_response_ = captive_portal_no_response_ || | 652 captive_portal_no_response_ = captive_portal_no_response_ || |
| 612 (results->result == captive_portal::RESULT_NO_RESPONSE); | 653 (results->result == captive_portal::RESULT_NO_RESPONSE); |
| 613 } | 654 } |
| 614 #endif | 655 #endif |
| 615 } | 656 } |
| OLD | NEW |