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 enum SSLIsExpiredAndDecision { | |
felt
2014/08/08 00:17:06
sort of a weird name for an enum, the "Is" makes i
felt
2014/08/08 00:17:06
Add a note warning people that this is a UMA histo
jww
2014/08/08 15:55:45
Done.
jww
2014/08/08 15:55:45
Done.
| |
106 EXPIRED_AND_PROCEED, | |
107 EXPIRED_AND_DO_NOT_PROCEED, | |
108 NOT_EXPIRED_AND_PROCEED, | |
109 NOT_EXPIRED_AND_DO_NOT_PROCEED, | |
110 END_OF_SSL_IS_EXPIRED_AND_DECISION, | |
111 }; | |
112 | |
105 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { | 113 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { |
106 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", | 114 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", |
107 event, | 115 event, |
108 UNUSED_BLOCKING_PAGE_EVENT); | 116 UNUSED_BLOCKING_PAGE_EVENT); |
109 } | 117 } |
110 | 118 |
111 void RecordSSLBlockingPageDetailedStats( | 119 void RecordSSLIsExpiredPageEventState(bool expired_but_previously_allowed, |
felt
2014/08/08 00:17:06
it seems like this will count all non-overridable
jww
2014/08/08 15:55:45
Good call. I'll split them into "interstitial.ssl.
| |
112 bool proceed, | 120 bool proceed) { |
113 int cert_error, | 121 SSLIsExpiredAndDecision event; |
114 bool overridable, | 122 if (expired_but_previously_allowed && proceed) |
115 bool internal, | 123 event = EXPIRED_AND_PROCEED; |
116 int num_visits, | 124 else if (expired_but_previously_allowed && !proceed) |
117 bool captive_portal_detection_enabled, | 125 event = EXPIRED_AND_DO_NOT_PROCEED; |
118 bool captive_portal_probe_completed, | 126 else if (!expired_but_previously_allowed && proceed) |
119 bool captive_portal_no_response, | 127 event = NOT_EXPIRED_AND_PROCEED; |
120 bool captive_portal_detected) { | 128 else |
129 event = NOT_EXPIRED_AND_DO_NOT_PROCEED; | |
130 | |
131 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.is_expired_and_decision", | |
132 event, | |
133 END_OF_SSL_IS_EXPIRED_AND_DECISION); | |
134 } | |
135 | |
136 void RecordSSLBlockingPageDetailedStats(bool proceed, | |
137 int cert_error, | |
138 bool overridable, | |
139 bool internal, | |
140 int num_visits, | |
141 bool captive_portal_detection_enabled, | |
142 bool captive_portal_probe_completed, | |
143 bool captive_portal_no_response, | |
144 bool captive_portal_detected, | |
145 bool expired_but_previously_allowed) { | |
121 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", | 146 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", |
122 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); | 147 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); |
148 RecordSSLIsExpiredPageEventState(expired_but_previously_allowed, proceed); | |
123 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 149 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
124 if (captive_portal_detection_enabled) | 150 if (captive_portal_detection_enabled) |
125 RecordSSLBlockingPageEventStats( | 151 RecordSSLBlockingPageEventStats( |
126 overridable ? | 152 overridable ? |
127 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE : | 153 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE : |
128 CAPTIVE_PORTAL_DETECTION_ENABLED); | 154 CAPTIVE_PORTAL_DETECTION_ENABLED); |
129 if (captive_portal_probe_completed) | 155 if (captive_portal_probe_completed) |
130 RecordSSLBlockingPageEventStats( | 156 RecordSSLBlockingPageEventStats( |
131 overridable ? | 157 overridable ? |
132 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE : | 158 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE : |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 options.allow_new_privs = true; | 288 options.allow_new_privs = true; |
263 #endif | 289 #endif |
264 base::LaunchProcess(command, options, NULL); | 290 base::LaunchProcess(command, options, NULL); |
265 #endif | 291 #endif |
266 } | 292 } |
267 | 293 |
268 } // namespace | 294 } // namespace |
269 | 295 |
270 // Note that we always create a navigation entry with SSL errors. | 296 // Note that we always create a navigation entry with SSL errors. |
271 // No error happening loading a sub-resource triggers an interstitial so far. | 297 // No error happening loading a sub-resource triggers an interstitial so far. |
272 SSLBlockingPage::SSLBlockingPage( | 298 SSLBlockingPage::SSLBlockingPage(content::WebContents* web_contents, |
273 content::WebContents* web_contents, | 299 int cert_error, |
274 int cert_error, | 300 const net::SSLInfo& ssl_info, |
275 const net::SSLInfo& ssl_info, | 301 const GURL& request_url, |
276 const GURL& request_url, | 302 bool overridable, |
277 bool overridable, | 303 bool strict_enforcement, |
278 bool strict_enforcement, | 304 bool expired_but_previously_allowed, |
279 const base::Callback<void(bool)>& callback) | 305 const base::Callback<void(bool)>& callback) |
280 : callback_(callback), | 306 : callback_(callback), |
281 web_contents_(web_contents), | 307 web_contents_(web_contents), |
282 cert_error_(cert_error), | 308 cert_error_(cert_error), |
283 ssl_info_(ssl_info), | 309 ssl_info_(ssl_info), |
284 request_url_(request_url), | 310 request_url_(request_url), |
285 overridable_(overridable), | 311 overridable_(overridable), |
286 strict_enforcement_(strict_enforcement), | 312 strict_enforcement_(strict_enforcement), |
287 interstitial_page_(NULL), | 313 interstitial_page_(NULL), |
288 internal_(false), | 314 internal_(false), |
289 num_visits_(-1), | 315 num_visits_(-1), |
290 captive_portal_detection_enabled_(false), | 316 captive_portal_detection_enabled_(false), |
291 captive_portal_probe_completed_(false), | 317 captive_portal_probe_completed_(false), |
292 captive_portal_no_response_(false), | 318 captive_portal_no_response_(false), |
293 captive_portal_detected_(false) { | 319 captive_portal_detected_(false), |
320 expired_but_previously_allowed_(expired_but_previously_allowed) { | |
294 Profile* profile = Profile::FromBrowserContext( | 321 Profile* profile = Profile::FromBrowserContext( |
295 web_contents->GetBrowserContext()); | 322 web_contents->GetBrowserContext()); |
296 // For UMA stats. | 323 // For UMA stats. |
297 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) | 324 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) |
298 internal_ = true; | 325 internal_ = true; |
299 RecordSSLBlockingPageEventStats(SHOW_ALL); | 326 RecordSSLBlockingPageEventStats(SHOW_ALL); |
300 if (overridable_ && !strict_enforcement_) { | 327 if (overridable_ && !strict_enforcement_) { |
301 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); | 328 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); |
302 if (internal_) | 329 if (internal_) |
303 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); | 330 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); |
(...skipping 30 matching lines...) Expand all Loading... | |
334 SSLBlockingPage::~SSLBlockingPage() { | 361 SSLBlockingPage::~SSLBlockingPage() { |
335 if (!callback_.is_null()) { | 362 if (!callback_.is_null()) { |
336 RecordSSLBlockingPageDetailedStats(false, | 363 RecordSSLBlockingPageDetailedStats(false, |
337 cert_error_, | 364 cert_error_, |
338 overridable_ && !strict_enforcement_, | 365 overridable_ && !strict_enforcement_, |
339 internal_, | 366 internal_, |
340 num_visits_, | 367 num_visits_, |
341 captive_portal_detection_enabled_, | 368 captive_portal_detection_enabled_, |
342 captive_portal_probe_completed_, | 369 captive_portal_probe_completed_, |
343 captive_portal_no_response_, | 370 captive_portal_no_response_, |
344 captive_portal_detected_); | 371 captive_portal_detected_, |
372 expired_but_previously_allowed_); | |
345 // The page is closed without the user having chosen what to do, default to | 373 // The page is closed without the user having chosen what to do, default to |
346 // deny. | 374 // deny. |
347 NotifyDenyCertificate(); | 375 NotifyDenyCertificate(); |
348 } | 376 } |
349 } | 377 } |
350 | 378 |
351 void SSLBlockingPage::Show() { | 379 void SSLBlockingPage::Show() { |
352 DCHECK(!interstitial_page_); | 380 DCHECK(!interstitial_page_); |
353 interstitial_page_ = InterstitialPage::Create( | 381 interstitial_page_ = InterstitialPage::Create( |
354 web_contents_, true, request_url_, this); | 382 web_contents_, true, request_url_, this); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
516 | 544 |
517 void SSLBlockingPage::OnProceed() { | 545 void SSLBlockingPage::OnProceed() { |
518 RecordSSLBlockingPageDetailedStats(true, | 546 RecordSSLBlockingPageDetailedStats(true, |
519 cert_error_, | 547 cert_error_, |
520 overridable_ && !strict_enforcement_, | 548 overridable_ && !strict_enforcement_, |
521 internal_, | 549 internal_, |
522 num_visits_, | 550 num_visits_, |
523 captive_portal_detection_enabled_, | 551 captive_portal_detection_enabled_, |
524 captive_portal_probe_completed_, | 552 captive_portal_probe_completed_, |
525 captive_portal_no_response_, | 553 captive_portal_no_response_, |
526 captive_portal_detected_); | 554 captive_portal_detected_, |
555 expired_but_previously_allowed_); | |
527 // Accepting the certificate resumes the loading of the page. | 556 // Accepting the certificate resumes the loading of the page. |
528 NotifyAllowCertificate(); | 557 NotifyAllowCertificate(); |
529 } | 558 } |
530 | 559 |
531 void SSLBlockingPage::OnDontProceed() { | 560 void SSLBlockingPage::OnDontProceed() { |
532 RecordSSLBlockingPageDetailedStats(false, | 561 RecordSSLBlockingPageDetailedStats(false, |
533 cert_error_, | 562 cert_error_, |
534 overridable_ && !strict_enforcement_, | 563 overridable_ && !strict_enforcement_, |
535 internal_, | 564 internal_, |
536 num_visits_, | 565 num_visits_, |
537 captive_portal_detection_enabled_, | 566 captive_portal_detection_enabled_, |
538 captive_portal_probe_completed_, | 567 captive_portal_probe_completed_, |
539 captive_portal_no_response_, | 568 captive_portal_no_response_, |
540 captive_portal_detected_); | 569 captive_portal_detected_, |
570 expired_but_previously_allowed_); | |
541 NotifyDenyCertificate(); | 571 NotifyDenyCertificate(); |
542 } | 572 } |
543 | 573 |
544 void SSLBlockingPage::NotifyDenyCertificate() { | 574 void SSLBlockingPage::NotifyDenyCertificate() { |
545 // It's possible that callback_ may not exist if the user clicks "Proceed" | 575 // 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. | 576 // followed by pressing the back button before the interstitial is hidden. |
547 // In that case the certificate will still be treated as allowed. | 577 // In that case the certificate will still be treated as allowed. |
548 if (callback_.is_null()) | 578 if (callback_.is_null()) |
549 return; | 579 return; |
550 | 580 |
(...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 | 636 // sure we don't clear the captive portal flag, since the interstitial was |
607 // potentially caused by the captive portal. | 637 // potentially caused by the captive portal. |
608 captive_portal_detected_ = captive_portal_detected_ || | 638 captive_portal_detected_ = captive_portal_detected_ || |
609 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 639 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
610 // Also keep track of non-HTTP portals and error cases. | 640 // Also keep track of non-HTTP portals and error cases. |
611 captive_portal_no_response_ = captive_portal_no_response_ || | 641 captive_portal_no_response_ = captive_portal_no_response_ || |
612 (results->result == captive_portal::RESULT_NO_RESPONSE); | 642 (results->result == captive_portal::RESULT_NO_RESPONSE); |
613 } | 643 } |
614 #endif | 644 #endif |
615 } | 645 } |
OLD | NEW |