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" |
11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "base/values.h" | 18 #include "base/values.h" |
19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h" | |
20 #include "chrome/browser/history/history_service_factory.h" | 21 #include "chrome/browser/history/history_service_factory.h" |
21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/renderer_preferences_util.h" | 23 #include "chrome/browser/renderer_preferences_util.h" |
23 #include "chrome/browser/ssl/ssl_error_classification.h" | 24 #include "chrome/browser/ssl/ssl_error_classification.h" |
24 #include "chrome/browser/ssl/ssl_error_info.h" | 25 #include "chrome/browser/ssl/ssl_error_info.h" |
25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
26 #include "content/public/browser/cert_store.h" | 27 #include "content/public/browser/cert_store.h" |
27 #include "content/public/browser/interstitial_page.h" | 28 #include "content/public/browser/interstitial_page.h" |
28 #include "content/public/browser/navigation_controller.h" | 29 #include "content/public/browser/navigation_controller.h" |
29 #include "content/public/browser/navigation_entry.h" | 30 #include "content/public/browser/navigation_entry.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
52 | 53 |
53 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
54 #include "base/win/windows_version.h" | 55 #include "base/win/windows_version.h" |
55 #endif | 56 #endif |
56 | 57 |
57 using base::ASCIIToUTF16; | 58 using base::ASCIIToUTF16; |
58 using base::TimeTicks; | 59 using base::TimeTicks; |
59 using content::InterstitialPage; | 60 using content::InterstitialPage; |
60 using content::NavigationController; | 61 using content::NavigationController; |
61 using content::NavigationEntry; | 62 using content::NavigationEntry; |
63 using extensions::SamplingEvent; | |
62 | 64 |
63 namespace { | 65 namespace { |
64 | 66 |
65 // Constants for the M37 Finch trial. | 67 // Constants for the M37 Finch trial. |
66 const char kInterstitialTrialName[] = "SSLInterstitialVersion"; | 68 const char kInterstitialTrialName[] = "SSLInterstitialVersion"; |
67 const char kCondV1[] = "V1"; | 69 const char kCondV1[] = "V1"; |
68 const char kCondV1LayoutV2Text[] = "V1LayoutV2Text"; | 70 const char kCondV1LayoutV2Text[] = "V1LayoutV2Text"; |
69 const char kCondV2[] = "V2"; // Also the default. | 71 const char kCondV2[] = "V2"; // Also the default. |
70 const char kCondV2Guard[] = "V2WithGuard"; | 72 const char kCondV2Guard[] = "V2WithGuard"; |
71 const char kCondV2Yellow[] = "V2Yellow"; | 73 const char kCondV2Yellow[] = "V2Yellow"; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 273 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
272 CaptivePortalService* captive_portal_service = | 274 CaptivePortalService* captive_portal_service = |
273 CaptivePortalServiceFactory::GetForProfile(profile); | 275 CaptivePortalServiceFactory::GetForProfile(profile); |
274 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); | 276 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); |
275 captive_portal_service ->DetectCaptivePortal(); | 277 captive_portal_service ->DetectCaptivePortal(); |
276 registrar_.Add(this, | 278 registrar_.Add(this, |
277 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, | 279 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, |
278 content::Source<Profile>(profile)); | 280 content::Source<Profile>(profile)); |
279 #endif | 281 #endif |
280 | 282 |
283 // ExperienceSampling: Set up new sampling event for this interstitial. | |
284 std::string event_name("ssl_interstitial_"); | |
felt
2014/07/18 21:13:59
these should be constants too
you might even want
Chris Thompson
2014/07/23 22:45:38
Done. I've put the context-specific strings at the
| |
285 if (overridable_) | |
286 event_name.append("nonblocking_"); | |
felt
2014/07/18 21:13:59
use "overridable" here to match the boolean; also,
Chris Thompson
2014/07/23 22:45:38
Done.
| |
287 else | |
288 event_name.append("blocking_"); | |
289 event_name.append(net::ErrorToString(cert_error_)); | |
290 sampling_event_ = make_scoped_ptr(new SamplingEvent( | |
291 event_name, | |
292 request_url_.possibly_invalid_spec(), | |
293 web_contents_->GetLastCommittedURL().possibly_invalid_spec(), | |
294 web_contents_->GetBrowserContext())); | |
295 | |
281 interstitial_page_ = InterstitialPage::Create( | 296 interstitial_page_ = InterstitialPage::Create( |
282 web_contents_, true, request_url, this); | 297 web_contents_, true, request_url, this); |
283 interstitial_page_->Show(); | 298 interstitial_page_->Show(); |
284 } | 299 } |
285 | 300 |
286 SSLBlockingPage::~SSLBlockingPage() { | 301 SSLBlockingPage::~SSLBlockingPage() { |
287 if (!callback_.is_null()) { | 302 if (!callback_.is_null()) { |
288 RecordSSLBlockingPageDetailedStats(false, | 303 RecordSSLBlockingPageDetailedStats(false, |
289 cert_error_, | 304 cert_error_, |
290 overridable_ && !strict_enforcement_, | 305 overridable_ && !strict_enforcement_, |
291 internal_, | 306 internal_, |
292 num_visits_, | 307 num_visits_, |
293 captive_portal_detection_enabled_, | 308 captive_portal_detection_enabled_, |
294 captive_portal_probe_completed_, | 309 captive_portal_probe_completed_, |
295 captive_portal_no_response_, | 310 captive_portal_no_response_, |
296 captive_portal_detected_); | 311 captive_portal_detected_); |
312 | |
felt
2014/07/18 21:13:59
don't add spurious blank lines please
Chris Thompson
2014/07/23 22:45:38
Done. Accidentally left this in from previous vers
| |
297 // The page is closed without the user having chosen what to do, default to | 313 // The page is closed without the user having chosen what to do, default to |
298 // deny. | 314 // deny. |
299 NotifyDenyCertificate(); | 315 NotifyDenyCertificate(); |
300 } | 316 } |
301 } | 317 } |
302 | 318 |
303 std::string SSLBlockingPage::GetHTMLContents() { | 319 std::string SSLBlockingPage::GetHTMLContents() { |
304 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text) | 320 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text) |
305 return GetHTMLContentsV1(); | 321 return GetHTMLContentsV1(); |
306 return GetHTMLContentsV2(); | 322 return GetHTMLContentsV2(); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
632 void SSLBlockingPage::OnProceed() { | 648 void SSLBlockingPage::OnProceed() { |
633 RecordSSLBlockingPageDetailedStats(true, | 649 RecordSSLBlockingPageDetailedStats(true, |
634 cert_error_, | 650 cert_error_, |
635 overridable_ && !strict_enforcement_, | 651 overridable_ && !strict_enforcement_, |
636 internal_, | 652 internal_, |
637 num_visits_, | 653 num_visits_, |
638 captive_portal_detection_enabled_, | 654 captive_portal_detection_enabled_, |
639 captive_portal_probe_completed_, | 655 captive_portal_probe_completed_, |
640 captive_portal_no_response_, | 656 captive_portal_no_response_, |
641 captive_portal_detected_); | 657 captive_portal_detected_); |
658 // ExperienceSampling: Notify that user decided to proceed. | |
659 sampling_event_->CreateUserDecisionEvent("proceed"); | |
642 // Accepting the certificate resumes the loading of the page. | 660 // Accepting the certificate resumes the loading of the page. |
643 NotifyAllowCertificate(); | 661 NotifyAllowCertificate(); |
644 } | 662 } |
645 | 663 |
646 void SSLBlockingPage::OnDontProceed() { | 664 void SSLBlockingPage::OnDontProceed() { |
647 RecordSSLBlockingPageDetailedStats(false, | 665 RecordSSLBlockingPageDetailedStats(false, |
648 cert_error_, | 666 cert_error_, |
649 overridable_ && !strict_enforcement_, | 667 overridable_ && !strict_enforcement_, |
650 internal_, | 668 internal_, |
651 num_visits_, | 669 num_visits_, |
652 captive_portal_detection_enabled_, | 670 captive_portal_detection_enabled_, |
653 captive_portal_probe_completed_, | 671 captive_portal_probe_completed_, |
654 captive_portal_no_response_, | 672 captive_portal_no_response_, |
655 captive_portal_detected_); | 673 captive_portal_detected_); |
674 // ExperienceSampling: Notify that user decided to not proceed. | |
675 // This also occurs if the user navigates away or closes the tab. | |
676 sampling_event_->CreateUserDecisionEvent("deny"); | |
677 | |
656 NotifyDenyCertificate(); | 678 NotifyDenyCertificate(); |
657 } | 679 } |
658 | 680 |
659 void SSLBlockingPage::NotifyDenyCertificate() { | 681 void SSLBlockingPage::NotifyDenyCertificate() { |
660 // It's possible that callback_ may not exist if the user clicks "Proceed" | 682 // It's possible that callback_ may not exist if the user clicks "Proceed" |
661 // followed by pressing the back button before the interstitial is hidden. | 683 // followed by pressing the back button before the interstitial is hidden. |
662 // In that case the certificate will still be treated as allowed. | 684 // In that case the certificate will still be treated as allowed. |
663 if (callback_.is_null()) | 685 if (callback_.is_null()) |
664 return; | 686 return; |
665 | 687 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
721 // sure we don't clear the captive portal flag, since the interstitial was | 743 // sure we don't clear the captive portal flag, since the interstitial was |
722 // potentially caused by the captive portal. | 744 // potentially caused by the captive portal. |
723 captive_portal_detected_ = captive_portal_detected_ || | 745 captive_portal_detected_ = captive_portal_detected_ || |
724 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 746 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
725 // Also keep track of non-HTTP portals and error cases. | 747 // Also keep track of non-HTTP portals and error cases. |
726 captive_portal_no_response_ = captive_portal_no_response_ || | 748 captive_portal_no_response_ = captive_portal_no_response_ || |
727 (results->result == captive_portal::RESULT_NO_RESPONSE); | 749 (results->result == captive_portal::RESULT_NO_RESPONSE); |
728 } | 750 } |
729 #endif | 751 #endif |
730 } | 752 } |
OLD | NEW |