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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE, | 110 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE, |
111 CAPTIVE_PORTAL_PROBE_COMPLETED, | 111 CAPTIVE_PORTAL_PROBE_COMPLETED, |
112 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE, | 112 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE, |
113 CAPTIVE_PORTAL_NO_RESPONSE, | 113 CAPTIVE_PORTAL_NO_RESPONSE, |
114 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE, | 114 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE, |
115 CAPTIVE_PORTAL_DETECTED, | 115 CAPTIVE_PORTAL_DETECTED, |
116 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE, | 116 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE, |
117 UNUSED_BLOCKING_PAGE_EVENT, | 117 UNUSED_BLOCKING_PAGE_EVENT, |
118 }; | 118 }; |
119 | 119 |
| 120 // Events for UMA. Do not reorder or change! |
| 121 enum SSLExpirationAndDecision { |
| 122 EXPIRED_AND_PROCEED, |
| 123 EXPIRED_AND_DO_NOT_PROCEED, |
| 124 NOT_EXPIRED_AND_PROCEED, |
| 125 NOT_EXPIRED_AND_DO_NOT_PROCEED, |
| 126 END_OF_SSL_EXPIRATION_AND_DECISION, |
| 127 }; |
| 128 |
120 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { | 129 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { |
121 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", | 130 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", |
122 event, | 131 event, |
123 UNUSED_BLOCKING_PAGE_EVENT); | 132 UNUSED_BLOCKING_PAGE_EVENT); |
124 } | 133 } |
125 | 134 |
126 void RecordSSLBlockingPageDetailedStats( | 135 void RecordSSLExpirationPageEventState(bool expired_but_previously_allowed, |
127 bool proceed, | 136 bool proceed, |
128 int cert_error, | 137 bool overridable) { |
129 bool overridable, | 138 SSLExpirationAndDecision event; |
130 bool internal, | 139 if (expired_but_previously_allowed && proceed) |
131 int num_visits, | 140 event = EXPIRED_AND_PROCEED; |
132 bool captive_portal_detection_enabled, | 141 else if (expired_but_previously_allowed && !proceed) |
133 bool captive_portal_probe_completed, | 142 event = EXPIRED_AND_DO_NOT_PROCEED; |
134 bool captive_portal_no_response, | 143 else if (!expired_but_previously_allowed && proceed) |
135 bool captive_portal_detected) { | 144 event = NOT_EXPIRED_AND_PROCEED; |
| 145 else |
| 146 event = NOT_EXPIRED_AND_DO_NOT_PROCEED; |
| 147 |
| 148 if (overridable) { |
| 149 UMA_HISTOGRAM_ENUMERATION( |
| 150 "interstitial.ssl.expiration_and_decision.overridable", |
| 151 event, |
| 152 END_OF_SSL_EXPIRATION_AND_DECISION); |
| 153 } else { |
| 154 UMA_HISTOGRAM_ENUMERATION( |
| 155 "interstitial.ssl.expiration_and_decision.nonoverridable", |
| 156 event, |
| 157 END_OF_SSL_EXPIRATION_AND_DECISION); |
| 158 } |
| 159 } |
| 160 |
| 161 void RecordSSLBlockingPageDetailedStats(bool proceed, |
| 162 int cert_error, |
| 163 bool overridable, |
| 164 bool internal, |
| 165 int num_visits, |
| 166 bool captive_portal_detection_enabled, |
| 167 bool captive_portal_probe_completed, |
| 168 bool captive_portal_no_response, |
| 169 bool captive_portal_detected, |
| 170 bool expired_but_previously_allowed) { |
136 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", | 171 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", |
137 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); | 172 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); |
| 173 RecordSSLExpirationPageEventState( |
| 174 expired_but_previously_allowed, proceed, overridable); |
138 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 175 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
139 if (captive_portal_detection_enabled) | 176 if (captive_portal_detection_enabled) |
140 RecordSSLBlockingPageEventStats( | 177 RecordSSLBlockingPageEventStats( |
141 overridable ? | 178 overridable ? |
142 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE : | 179 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE : |
143 CAPTIVE_PORTAL_DETECTION_ENABLED); | 180 CAPTIVE_PORTAL_DETECTION_ENABLED); |
144 if (captive_portal_probe_completed) | 181 if (captive_portal_probe_completed) |
145 RecordSSLBlockingPageEventStats( | 182 RecordSSLBlockingPageEventStats( |
146 overridable ? | 183 overridable ? |
147 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE : | 184 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE : |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 options.allow_new_privs = true; | 314 options.allow_new_privs = true; |
278 #endif | 315 #endif |
279 base::LaunchProcess(command, options, NULL); | 316 base::LaunchProcess(command, options, NULL); |
280 #endif | 317 #endif |
281 } | 318 } |
282 | 319 |
283 } // namespace | 320 } // namespace |
284 | 321 |
285 // Note that we always create a navigation entry with SSL errors. | 322 // Note that we always create a navigation entry with SSL errors. |
286 // No error happening loading a sub-resource triggers an interstitial so far. | 323 // No error happening loading a sub-resource triggers an interstitial so far. |
287 SSLBlockingPage::SSLBlockingPage( | 324 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, |
288 content::WebContents* web_contents, | 325 int cert_error, |
289 int cert_error, | 326 const net::SSLInfo& ssl_info, |
290 const net::SSLInfo& ssl_info, | 327 const GURL& request_url, |
291 const GURL& request_url, | 328 int options_mask, |
292 bool overridable, | 329 const base::Callback<void(bool)>& callback) |
293 bool strict_enforcement, | |
294 const base::Callback<void(bool)>& callback) | |
295 : callback_(callback), | 330 : callback_(callback), |
296 web_contents_(web_contents), | 331 web_contents_(web_contents), |
297 cert_error_(cert_error), | 332 cert_error_(cert_error), |
298 ssl_info_(ssl_info), | 333 ssl_info_(ssl_info), |
299 request_url_(request_url), | 334 request_url_(request_url), |
300 overridable_(overridable), | 335 overridable_(options_mask & OVERRIDABLE && |
301 strict_enforcement_(strict_enforcement), | 336 !(options_mask & STRICT_ENFORCEMENT)), |
| 337 strict_enforcement_((options_mask & STRICT_ENFORCEMENT) != 0), |
302 interstitial_page_(NULL), | 338 interstitial_page_(NULL), |
303 internal_(false), | 339 internal_(false), |
304 num_visits_(-1), | 340 num_visits_(-1), |
305 captive_portal_detection_enabled_(false), | 341 captive_portal_detection_enabled_(false), |
306 captive_portal_probe_completed_(false), | 342 captive_portal_probe_completed_(false), |
307 captive_portal_no_response_(false), | 343 captive_portal_no_response_(false), |
308 captive_portal_detected_(false) { | 344 captive_portal_detected_(false), |
| 345 expired_but_previously_allowed_( |
| 346 (options_mask & EXPIRED_BUT_PREVIOUSLY_ALLOWED) != 0) { |
309 Profile* profile = Profile::FromBrowserContext( | 347 Profile* profile = Profile::FromBrowserContext( |
310 web_contents->GetBrowserContext()); | 348 web_contents->GetBrowserContext()); |
311 if (strict_enforcement_) overridable_ = false; | |
312 // For UMA stats. | 349 // For UMA stats. |
313 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) | 350 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) |
314 internal_ = true; | 351 internal_ = true; |
315 RecordSSLBlockingPageEventStats(SHOW_ALL); | 352 RecordSSLBlockingPageEventStats(SHOW_ALL); |
316 if (overridable_) { | 353 if (overridable_) { |
317 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); | 354 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); |
318 if (internal_) | 355 if (internal_) |
319 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); | 356 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); |
320 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 357 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
321 profile, Profile::EXPLICIT_ACCESS); | 358 profile, Profile::EXPLICIT_ACCESS); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 SSLBlockingPage::~SSLBlockingPage() { | 403 SSLBlockingPage::~SSLBlockingPage() { |
367 if (!callback_.is_null()) { | 404 if (!callback_.is_null()) { |
368 RecordSSLBlockingPageDetailedStats(false, | 405 RecordSSLBlockingPageDetailedStats(false, |
369 cert_error_, | 406 cert_error_, |
370 overridable_, | 407 overridable_, |
371 internal_, | 408 internal_, |
372 num_visits_, | 409 num_visits_, |
373 captive_portal_detection_enabled_, | 410 captive_portal_detection_enabled_, |
374 captive_portal_probe_completed_, | 411 captive_portal_probe_completed_, |
375 captive_portal_no_response_, | 412 captive_portal_no_response_, |
376 captive_portal_detected_); | 413 captive_portal_detected_, |
| 414 expired_but_previously_allowed_); |
377 // The page is closed without the user having chosen what to do, default to | 415 // The page is closed without the user having chosen what to do, default to |
378 // deny. | 416 // deny. |
379 NotifyDenyCertificate(); | 417 NotifyDenyCertificate(); |
380 } | 418 } |
381 } | 419 } |
382 | 420 |
383 void SSLBlockingPage::Show() { | 421 void SSLBlockingPage::Show() { |
384 DCHECK(!interstitial_page_); | 422 DCHECK(!interstitial_page_); |
385 interstitial_page_ = InterstitialPage::Create( | 423 interstitial_page_ = InterstitialPage::Create( |
386 web_contents_, true, request_url_, this); | 424 web_contents_, true, request_url_, this); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 | 593 |
556 void SSLBlockingPage::OnProceed() { | 594 void SSLBlockingPage::OnProceed() { |
557 RecordSSLBlockingPageDetailedStats(true, | 595 RecordSSLBlockingPageDetailedStats(true, |
558 cert_error_, | 596 cert_error_, |
559 overridable_, | 597 overridable_, |
560 internal_, | 598 internal_, |
561 num_visits_, | 599 num_visits_, |
562 captive_portal_detection_enabled_, | 600 captive_portal_detection_enabled_, |
563 captive_portal_probe_completed_, | 601 captive_portal_probe_completed_, |
564 captive_portal_no_response_, | 602 captive_portal_no_response_, |
565 captive_portal_detected_); | 603 captive_portal_detected_, |
| 604 expired_but_previously_allowed_); |
566 #if defined(ENABLE_EXTENSIONS) | 605 #if defined(ENABLE_EXTENSIONS) |
567 // ExperienceSampling: Notify that user decided to proceed. | 606 // ExperienceSampling: Notify that user decided to proceed. |
568 if (sampling_event_.get()) | 607 if (sampling_event_.get()) |
569 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed); | 608 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kProceed); |
570 #endif | 609 #endif |
571 // Accepting the certificate resumes the loading of the page. | 610 // Accepting the certificate resumes the loading of the page. |
572 NotifyAllowCertificate(); | 611 NotifyAllowCertificate(); |
573 } | 612 } |
574 | 613 |
575 void SSLBlockingPage::OnDontProceed() { | 614 void SSLBlockingPage::OnDontProceed() { |
576 RecordSSLBlockingPageDetailedStats(false, | 615 RecordSSLBlockingPageDetailedStats(false, |
577 cert_error_, | 616 cert_error_, |
578 overridable_, | 617 overridable_, |
579 internal_, | 618 internal_, |
580 num_visits_, | 619 num_visits_, |
581 captive_portal_detection_enabled_, | 620 captive_portal_detection_enabled_, |
582 captive_portal_probe_completed_, | 621 captive_portal_probe_completed_, |
583 captive_portal_no_response_, | 622 captive_portal_no_response_, |
584 captive_portal_detected_); | 623 captive_portal_detected_, |
| 624 expired_but_previously_allowed_); |
585 #if defined(ENABLE_EXTENSIONS) | 625 #if defined(ENABLE_EXTENSIONS) |
586 // ExperienceSampling: Notify that user decided to not proceed. | 626 // ExperienceSampling: Notify that user decided to not proceed. |
587 // This also occurs if the user navigates away or closes the tab. | 627 // This also occurs if the user navigates away or closes the tab. |
588 if (sampling_event_.get()) | 628 if (sampling_event_.get()) |
589 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny); | 629 sampling_event_->CreateUserDecisionEvent(ExperienceSamplingEvent::kDeny); |
590 #endif | 630 #endif |
591 NotifyDenyCertificate(); | 631 NotifyDenyCertificate(); |
592 } | 632 } |
593 | 633 |
594 void SSLBlockingPage::NotifyDenyCertificate() { | 634 void SSLBlockingPage::NotifyDenyCertificate() { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 // sure we don't clear the captive portal flag, since the interstitial was | 696 // sure we don't clear the captive portal flag, since the interstitial was |
657 // potentially caused by the captive portal. | 697 // potentially caused by the captive portal. |
658 captive_portal_detected_ = captive_portal_detected_ || | 698 captive_portal_detected_ = captive_portal_detected_ || |
659 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 699 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
660 // Also keep track of non-HTTP portals and error cases. | 700 // Also keep track of non-HTTP portals and error cases. |
661 captive_portal_no_response_ = captive_portal_no_response_ || | 701 captive_portal_no_response_ = captive_portal_no_response_ || |
662 (results->result == captive_portal::RESULT_NO_RESPONSE); | 702 (results->result == captive_portal::RESULT_NO_RESPONSE); |
663 } | 703 } |
664 #endif | 704 #endif |
665 } | 705 } |
OLD | NEW |