Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(381)

Side by Side Diff: chrome/browser/ssl/ssl_blocking_page.cc

Issue 399773002: Experience sampling insturmentation for SSL and Safe Browsing interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sampling-api
Patch Set: rebase-update Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/process/launch.h" 13 #include "base/process/launch.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_piece.h" 15 #include "base/strings/string_piece.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "base/values.h" 19 #include "base/values.h"
20 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h"
21 #include "chrome/browser/history/history_service_factory.h" 22 #include "chrome/browser/history/history_service_factory.h"
22 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/renderer_preferences_util.h" 24 #include "chrome/browser/renderer_preferences_util.h"
24 #include "chrome/browser/ssl/ssl_error_classification.h" 25 #include "chrome/browser/ssl/ssl_error_classification.h"
25 #include "chrome/browser/ssl/ssl_error_info.h" 26 #include "chrome/browser/ssl/ssl_error_info.h"
26 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
27 #include "content/public/browser/cert_store.h" 28 #include "content/public/browser/cert_store.h"
28 #include "content/public/browser/interstitial_page.h" 29 #include "content/public/browser/interstitial_page.h"
29 #include "content/public/browser/navigation_controller.h" 30 #include "content/public/browser/navigation_controller.h"
30 #include "content/public/browser/navigation_entry.h" 31 #include "content/public/browser/navigation_entry.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 #include "chrome/browser/profiles/profile_manager.h" 63 #include "chrome/browser/profiles/profile_manager.h"
63 #include "chrome/browser/ui/chrome_pages.h" 64 #include "chrome/browser/ui/chrome_pages.h"
64 #include "chrome/common/url_constants.h" 65 #include "chrome/common/url_constants.h"
65 #endif 66 #endif
66 67
67 using base::ASCIIToUTF16; 68 using base::ASCIIToUTF16;
68 using base::TimeTicks; 69 using base::TimeTicks;
69 using content::InterstitialPage; 70 using content::InterstitialPage;
70 using content::NavigationController; 71 using content::NavigationController;
71 using content::NavigationEntry; 72 using content::NavigationEntry;
73 using extensions::SamplingEvent;
72 74
73 namespace { 75 namespace {
74 76
75 // Constants for the M37 Finch trial. 77 // Constants for the M37 Finch trial.
76 const char kInterstitialTrialName[] = "SSLInterstitialVersion"; 78 const char kInterstitialTrialName[] = "SSLInterstitialVersion";
77 const char kCondV1[] = "V1"; 79 const char kCondV1[] = "V1";
78 const char kCondV1LayoutV2Text[] = "V1LayoutV2Text"; 80 const char kCondV1LayoutV2Text[] = "V1LayoutV2Text";
79 const char kCondV2[] = "V2"; // Also the default. 81 const char kCondV2[] = "V2"; // Also the default.
80 const char kCondV2Guard[] = "V2WithGuard"; 82 const char kCondV2Guard[] = "V2WithGuard";
81 const char kCondV2Yellow[] = "V2Yellow"; 83 const char kCondV2Yellow[] = "V2Yellow";
(...skipping 18 matching lines...) Expand all
100 return kCondV2; 102 return kCondV2;
101 if (name == kCondV1LayoutV2Text) 103 if (name == kCondV1LayoutV2Text)
102 return kCondV1LayoutV2Text; 104 return kCondV1LayoutV2Text;
103 if (name == kCondV2Guard) 105 if (name == kCondV2Guard)
104 return kCondV2Guard; 106 return kCondV2Guard;
105 if (name == kCondV2Yellow) 107 if (name == kCondV2Yellow)
106 return kCondV2Yellow; 108 return kCondV2Yellow;
107 return kCondV2; 109 return kCondV2;
108 } 110 }
109 111
112 // Constants for the Experience Sampling instrumentation.
113 const char kEventNameBase[] = "ssl_interstitial_";
114 const char kEventNotOverridable[] = "notoverridable_";
115 const char kEventOverridable[] = "overridable_";
116
110 // Events for UMA. Do not reorder or change! 117 // Events for UMA. Do not reorder or change!
111 enum SSLBlockingPageEvent { 118 enum SSLBlockingPageEvent {
112 SHOW_ALL, 119 SHOW_ALL,
113 SHOW_OVERRIDABLE, 120 SHOW_OVERRIDABLE,
114 PROCEED_OVERRIDABLE, 121 PROCEED_OVERRIDABLE,
115 PROCEED_NAME, 122 PROCEED_NAME,
116 PROCEED_DATE, 123 PROCEED_DATE,
117 PROCEED_AUTHORITY, 124 PROCEED_AUTHORITY,
118 DONT_PROCEED_OVERRIDABLE, 125 DONT_PROCEED_OVERRIDABLE,
119 DONT_PROCEED_NAME, 126 DONT_PROCEED_NAME,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 362 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
356 CaptivePortalService* captive_portal_service = 363 CaptivePortalService* captive_portal_service =
357 CaptivePortalServiceFactory::GetForProfile(profile); 364 CaptivePortalServiceFactory::GetForProfile(profile);
358 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); 365 captive_portal_detection_enabled_ = captive_portal_service ->enabled();
359 captive_portal_service ->DetectCaptivePortal(); 366 captive_portal_service ->DetectCaptivePortal();
360 registrar_.Add(this, 367 registrar_.Add(this,
361 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, 368 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT,
362 content::Source<Profile>(profile)); 369 content::Source<Profile>(profile));
363 #endif 370 #endif
364 371
372 // ExperienceSampling: Set up new sampling event for this interstitial.
373 std::string event_name(kEventNameBase);
374 if (overridable_ && !strict_enforcement_)
375 event_name.append(kEventOverridable);
376 else
377 event_name.append(kEventNotOverridable);
378 event_name.append(net::ErrorToString(cert_error_));
379 sampling_event_.reset(new SamplingEvent(
380 event_name,
381 request_url_,
382 web_contents_->GetLastCommittedURL(),
383 web_contents_->GetBrowserContext()));
384
365 interstitial_page_ = InterstitialPage::Create( 385 interstitial_page_ = InterstitialPage::Create(
366 web_contents_, true, request_url, this); 386 web_contents_, true, request_url, this);
367 interstitial_page_->Show(); 387 interstitial_page_->Show();
368 } 388 }
369 389
370 SSLBlockingPage::~SSLBlockingPage() { 390 SSLBlockingPage::~SSLBlockingPage() {
371 if (!callback_.is_null()) { 391 if (!callback_.is_null()) {
372 RecordSSLBlockingPageDetailedStats(false, 392 RecordSSLBlockingPageDetailedStats(false,
373 cert_error_, 393 cert_error_,
374 overridable_ && !strict_enforcement_, 394 overridable_ && !strict_enforcement_,
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 case CMD_DONT_PROCEED: { 694 case CMD_DONT_PROCEED: {
675 interstitial_page_->DontProceed(); 695 interstitial_page_->DontProceed();
676 break; 696 break;
677 } 697 }
678 case CMD_PROCEED: { 698 case CMD_PROCEED: {
679 interstitial_page_->Proceed(); 699 interstitial_page_->Proceed();
680 break; 700 break;
681 } 701 }
682 case CMD_MORE: { 702 case CMD_MORE: {
683 RecordSSLBlockingPageEventStats(MORE); 703 RecordSSLBlockingPageEventStats(MORE);
704 sampling_event_->has_viewed_details = true;
684 break; 705 break;
685 } 706 }
686 case CMD_RELOAD: { 707 case CMD_RELOAD: {
687 // The interstitial can't refresh itself. 708 // The interstitial can't refresh itself.
688 web_contents_->GetController().Reload(true); 709 web_contents_->GetController().Reload(true);
689 break; 710 break;
690 } 711 }
691 case CMD_HELP: { 712 case CMD_HELP: {
692 content::NavigationController::LoadURLParams help_page_params(GURL( 713 content::NavigationController::LoadURLParams help_page_params(GURL(
693 "https://support.google.com/chrome/answer/4454607")); 714 "https://support.google.com/chrome/answer/4454607"));
715 sampling_event_->has_viewed_learn_more = true;
694 web_contents_->GetController().LoadURLWithParams(help_page_params); 716 web_contents_->GetController().LoadURLWithParams(help_page_params);
695 break; 717 break;
696 } 718 }
697 case CMD_CLOCK: { 719 case CMD_CLOCK: {
698 LaunchDateAndTimeSettings(); 720 LaunchDateAndTimeSettings();
699 break; 721 break;
700 } 722 }
701 default: { 723 default: {
702 NOTREACHED(); 724 NOTREACHED();
703 } 725 }
(...skipping 10 matching lines...) Expand all
714 void SSLBlockingPage::OnProceed() { 736 void SSLBlockingPage::OnProceed() {
715 RecordSSLBlockingPageDetailedStats(true, 737 RecordSSLBlockingPageDetailedStats(true,
716 cert_error_, 738 cert_error_,
717 overridable_ && !strict_enforcement_, 739 overridable_ && !strict_enforcement_,
718 internal_, 740 internal_,
719 num_visits_, 741 num_visits_,
720 captive_portal_detection_enabled_, 742 captive_portal_detection_enabled_,
721 captive_portal_probe_completed_, 743 captive_portal_probe_completed_,
722 captive_portal_no_response_, 744 captive_portal_no_response_,
723 captive_portal_detected_); 745 captive_portal_detected_);
746 // ExperienceSampling: Notify that user decided to proceed.
747 sampling_event_->CreateUserDecisionEvent(SamplingEvent::kProceed);
724 // Accepting the certificate resumes the loading of the page. 748 // Accepting the certificate resumes the loading of the page.
725 NotifyAllowCertificate(); 749 NotifyAllowCertificate();
726 } 750 }
727 751
728 void SSLBlockingPage::OnDontProceed() { 752 void SSLBlockingPage::OnDontProceed() {
729 RecordSSLBlockingPageDetailedStats(false, 753 RecordSSLBlockingPageDetailedStats(false,
730 cert_error_, 754 cert_error_,
731 overridable_ && !strict_enforcement_, 755 overridable_ && !strict_enforcement_,
732 internal_, 756 internal_,
733 num_visits_, 757 num_visits_,
734 captive_portal_detection_enabled_, 758 captive_portal_detection_enabled_,
735 captive_portal_probe_completed_, 759 captive_portal_probe_completed_,
736 captive_portal_no_response_, 760 captive_portal_no_response_,
737 captive_portal_detected_); 761 captive_portal_detected_);
762 // ExperienceSampling: Notify that user decided to not proceed.
763 // This also occurs if the user navigates away or closes the tab.
764 sampling_event_->CreateUserDecisionEvent(SamplingEvent::kDeny);
765
felt 2014/07/25 01:05:51 nit: don't need this empty line
Chris Thompson 2014/07/25 01:21:59 Done.
738 NotifyDenyCertificate(); 766 NotifyDenyCertificate();
739 } 767 }
740 768
741 void SSLBlockingPage::NotifyDenyCertificate() { 769 void SSLBlockingPage::NotifyDenyCertificate() {
742 // It's possible that callback_ may not exist if the user clicks "Proceed" 770 // It's possible that callback_ may not exist if the user clicks "Proceed"
743 // followed by pressing the back button before the interstitial is hidden. 771 // followed by pressing the back button before the interstitial is hidden.
744 // In that case the certificate will still be treated as allowed. 772 // In that case the certificate will still be treated as allowed.
745 if (callback_.is_null()) 773 if (callback_.is_null())
746 return; 774 return;
747 775
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 // sure we don't clear the captive portal flag, since the interstitial was 831 // sure we don't clear the captive portal flag, since the interstitial was
804 // potentially caused by the captive portal. 832 // potentially caused by the captive portal.
805 captive_portal_detected_ = captive_portal_detected_ || 833 captive_portal_detected_ = captive_portal_detected_ ||
806 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); 834 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL);
807 // Also keep track of non-HTTP portals and error cases. 835 // Also keep track of non-HTTP portals and error cases.
808 captive_portal_no_response_ = captive_portal_no_response_ || 836 captive_portal_no_response_ = captive_portal_no_response_ ||
809 (results->result == captive_portal::RESULT_NO_RESPONSE); 837 (results->result == captive_portal::RESULT_NO_RESPONSE);
810 } 838 }
811 #endif 839 #endif
812 } 840 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_blocking_page.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698