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

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

Issue 400323002: Refactor the captive portal code to move from the ssl_blocking_page class to the ssl_error_classific (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comments 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
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"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 DONT_PROCEED_NAME, 109 DONT_PROCEED_NAME,
110 DONT_PROCEED_DATE, 110 DONT_PROCEED_DATE,
111 DONT_PROCEED_AUTHORITY, 111 DONT_PROCEED_AUTHORITY,
112 MORE, 112 MORE,
113 SHOW_UNDERSTAND, // Used by the summer 2013 Finch trial. Deprecated. 113 SHOW_UNDERSTAND, // Used by the summer 2013 Finch trial. Deprecated.
114 SHOW_INTERNAL_HOSTNAME, 114 SHOW_INTERNAL_HOSTNAME,
115 PROCEED_INTERNAL_HOSTNAME, 115 PROCEED_INTERNAL_HOSTNAME,
116 SHOW_NEW_SITE, 116 SHOW_NEW_SITE,
117 PROCEED_NEW_SITE, 117 PROCEED_NEW_SITE,
118 PROCEED_MANUAL_NONOVERRIDABLE, 118 PROCEED_MANUAL_NONOVERRIDABLE,
119 CAPTIVE_PORTAL_DETECTION_ENABLED, 119 CAPTIVE_PORTAL_DETECTION_ENABLED, // Captive Portal errors moved to
felt 2014/07/18 23:53:42 Can you rename them like: DEPRECATED_CAPTIVE_PORT
meacer 2014/07/19 00:06:45 I think it makes sense to put captive portal stuff
radhikabhar 2014/07/21 16:05:11 I have already created a new enum in the ssl_error
radhikabhar 2014/07/21 16:05:11 Done.
felt 2014/07/21 18:14:45 I think you have done it the correct way now. Msut
120 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE, 120 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE, // ssl_error_classification.
121 CAPTIVE_PORTAL_PROBE_COMPLETED, 121 CAPTIVE_PORTAL_PROBE_COMPLETED,
122 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE, 122 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE,
123 CAPTIVE_PORTAL_NO_RESPONSE, 123 CAPTIVE_PORTAL_NO_RESPONSE,
124 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE, 124 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE,
125 CAPTIVE_PORTAL_DETECTED, 125 CAPTIVE_PORTAL_DETECTED,
126 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE, 126 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE,
127 UNUSED_BLOCKING_PAGE_EVENT, 127 UNUSED_BLOCKING_PAGE_EVENT,
128 }; 128 };
129 129
130 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { 130 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) {
131 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", 131 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl",
132 event, 132 event,
133 UNUSED_BLOCKING_PAGE_EVENT); 133 UNUSED_BLOCKING_PAGE_EVENT);
134 } 134 }
135 135
136 void RecordSSLBlockingPageDetailedStats( 136 void RecordSSLBlockingPageDetailedStats(
137 bool proceed, 137 bool proceed,
138 int cert_error, 138 int cert_error,
139 bool overridable, 139 bool overridable,
140 bool internal, 140 bool internal,
141 int num_visits, 141 int num_visits) {
142 bool captive_portal_detection_enabled,
143 bool captive_portal_probe_completed,
144 bool captive_portal_no_response,
145 bool captive_portal_detected) {
146 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", 142 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type",
147 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); 143 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM);
148 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
149 if (captive_portal_detection_enabled)
150 RecordSSLBlockingPageEventStats(
151 overridable ?
152 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE :
153 CAPTIVE_PORTAL_DETECTION_ENABLED);
154 if (captive_portal_probe_completed)
155 RecordSSLBlockingPageEventStats(
156 overridable ?
157 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE :
158 CAPTIVE_PORTAL_PROBE_COMPLETED);
159 // Log only one of portal detected and no response results.
160 if (captive_portal_detected)
161 RecordSSLBlockingPageEventStats(
162 overridable ?
163 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE :
164 CAPTIVE_PORTAL_DETECTED);
165 else if (captive_portal_no_response)
166 RecordSSLBlockingPageEventStats(
167 overridable ?
168 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE :
169 CAPTIVE_PORTAL_NO_RESPONSE);
170 #endif
171 if (!overridable) { 144 if (!overridable) {
172 if (proceed) { 145 if (proceed) {
173 RecordSSLBlockingPageEventStats(PROCEED_MANUAL_NONOVERRIDABLE); 146 RecordSSLBlockingPageEventStats(PROCEED_MANUAL_NONOVERRIDABLE);
174 } 147 }
175 // Overridable is false if the user didn't have any option except to turn 148 // Overridable is false if the user didn't have any option except to turn
176 // back. If that's the case, don't record some of the metrics. 149 // back. If that's the case, don't record some of the metrics.
177 return; 150 return;
178 } 151 }
179 if (num_visits == 0) 152 if (num_visits == 0)
180 RecordSSLBlockingPageEventStats(SHOW_NEW_SITE); 153 RecordSSLBlockingPageEventStats(SHOW_NEW_SITE);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 HistoryService* history_service = HistoryServiceFactory::GetForProfile( 228 HistoryService* history_service = HistoryServiceFactory::GetForProfile(
256 profile, Profile::EXPLICIT_ACCESS); 229 profile, Profile::EXPLICIT_ACCESS);
257 if (history_service) { 230 if (history_service) {
258 history_service->GetVisibleVisitCountToHost( 231 history_service->GetVisibleVisitCountToHost(
259 request_url_, 232 request_url_,
260 base::Bind(&SSLBlockingPage::OnGotHistoryCount, 233 base::Bind(&SSLBlockingPage::OnGotHistoryCount,
261 base::Unretained(this)), 234 base::Unretained(this)),
262 &request_tracker_); 235 &request_tracker_);
263 } 236 }
264 } 237 }
238
239 SSLErrorClassification ssl_error_classification(
240 *web_contents_,
241 base::Time::NowFromSystemTime(),
242 *ssl_info_.cert.get());
265 if (SSLErrorInfo::NetErrorToErrorType(cert_error_) == 243 if (SSLErrorInfo::NetErrorToErrorType(cert_error_) ==
266 SSLErrorInfo::CERT_DATE_INVALID) { 244 SSLErrorInfo::CERT_DATE_INVALID)
felt 2014/07/18 23:53:42 not a single line, so it needs { } (if i missed th
radhikabhar 2014/07/21 16:05:11 Done.
267 SSLErrorClassification::RecordUMAStatistics(overridable_ && 245 ssl_error_classification.RecordUMAStatistics(
268 !strict_enforcement_); 246 overridable_ && !strict_enforcement_);
269 }
270 247
271 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 248 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
272 CaptivePortalService* captive_portal_service = 249 CaptivePortalService* captive_portal_service =
273 CaptivePortalServiceFactory::GetForProfile(profile); 250 CaptivePortalServiceFactory::GetForProfile(profile);
274 captive_portal_detection_enabled_ = captive_portal_service ->enabled(); 251 captive_portal_detection_enabled_ = captive_portal_service ->enabled();
275 captive_portal_service ->DetectCaptivePortal(); 252 captive_portal_service ->DetectCaptivePortal();
276 registrar_.Add(this, 253 registrar_.Add(this,
277 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT, 254 chrome::NOTIFICATION_CAPTIVE_PORTAL_CHECK_RESULT,
278 content::Source<Profile>(profile)); 255 content::Source<Profile>(profile));
256 ssl_error_classification.RecordUMAStatisticsCaptivePortals(
257 overridable_ && !strict_enforcement_);
279 #endif 258 #endif
280 259
281 interstitial_page_ = InterstitialPage::Create( 260 interstitial_page_ = InterstitialPage::Create(
282 web_contents_, true, request_url, this); 261 web_contents_, true, request_url, this);
283 interstitial_page_->Show(); 262 interstitial_page_->Show();
284 } 263 }
285 264
286 SSLBlockingPage::~SSLBlockingPage() { 265 SSLBlockingPage::~SSLBlockingPage() {
287 if (!callback_.is_null()) { 266 if (!callback_.is_null()) {
288 RecordSSLBlockingPageDetailedStats(false, 267 RecordSSLBlockingPageDetailedStats(false,
289 cert_error_, 268 cert_error_,
290 overridable_ && !strict_enforcement_, 269 overridable_ && !strict_enforcement_,
291 internal_, 270 internal_,
292 num_visits_, 271 num_visits_);
293 captive_portal_detection_enabled_,
294 captive_portal_probe_completed_,
295 captive_portal_no_response_,
296 captive_portal_detected_);
297 // The page is closed without the user having chosen what to do, default to 272 // The page is closed without the user having chosen what to do, default to
298 // deny. 273 // deny.
299 NotifyDenyCertificate(); 274 NotifyDenyCertificate();
300 } 275 }
301 } 276 }
302 277
303 std::string SSLBlockingPage::GetHTMLContents() { 278 std::string SSLBlockingPage::GetHTMLContents() {
304 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text) 279 if (trial_condition_ == kCondV1 || trial_condition_ == kCondV1LayoutV2Text)
305 return GetHTMLContentsV1(); 280 return GetHTMLContentsV1();
306 return GetHTMLContentsV2(); 281 return GetHTMLContentsV2();
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 Profile* profile = Profile::FromBrowserContext( 602 Profile* profile = Profile::FromBrowserContext(
628 web_contents_->GetBrowserContext()); 603 web_contents_->GetBrowserContext());
629 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); 604 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile);
630 } 605 }
631 606
632 void SSLBlockingPage::OnProceed() { 607 void SSLBlockingPage::OnProceed() {
633 RecordSSLBlockingPageDetailedStats(true, 608 RecordSSLBlockingPageDetailedStats(true,
634 cert_error_, 609 cert_error_,
635 overridable_ && !strict_enforcement_, 610 overridable_ && !strict_enforcement_,
636 internal_, 611 internal_,
637 num_visits_, 612 num_visits_);
638 captive_portal_detection_enabled_,
639 captive_portal_probe_completed_,
640 captive_portal_no_response_,
641 captive_portal_detected_);
642 // Accepting the certificate resumes the loading of the page. 613 // Accepting the certificate resumes the loading of the page.
643 NotifyAllowCertificate(); 614 NotifyAllowCertificate();
644 } 615 }
645 616
646 void SSLBlockingPage::OnDontProceed() { 617 void SSLBlockingPage::OnDontProceed() {
647 RecordSSLBlockingPageDetailedStats(false, 618 RecordSSLBlockingPageDetailedStats(false,
648 cert_error_, 619 cert_error_,
649 overridable_ && !strict_enforcement_, 620 overridable_ && !strict_enforcement_,
650 internal_, 621 internal_,
651 num_visits_, 622 num_visits_);
652 captive_portal_detection_enabled_,
653 captive_portal_probe_completed_,
654 captive_portal_no_response_,
655 captive_portal_detected_);
656 NotifyDenyCertificate(); 623 NotifyDenyCertificate();
657 } 624 }
658 625
659 void SSLBlockingPage::NotifyDenyCertificate() { 626 void SSLBlockingPage::NotifyDenyCertificate() {
660 // It's possible that callback_ may not exist if the user clicks "Proceed" 627 // 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. 628 // followed by pressing the back button before the interstitial is hidden.
662 // In that case the certificate will still be treated as allowed. 629 // In that case the certificate will still be treated as allowed.
663 if (callback_.is_null()) 630 if (callback_.is_null())
664 return; 631 return;
665 632
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 // sure we don't clear the captive portal flag, since the interstitial was 688 // sure we don't clear the captive portal flag, since the interstitial was
722 // potentially caused by the captive portal. 689 // potentially caused by the captive portal.
723 captive_portal_detected_ = captive_portal_detected_ || 690 captive_portal_detected_ = captive_portal_detected_ ||
724 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); 691 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL);
725 // Also keep track of non-HTTP portals and error cases. 692 // Also keep track of non-HTTP portals and error cases.
726 captive_portal_no_response_ = captive_portal_no_response_ || 693 captive_portal_no_response_ = captive_portal_no_response_ ||
727 (results->result == captive_portal::RESULT_NO_RESPONSE); 694 (results->result == captive_portal::RESULT_NO_RESPONSE);
728 } 695 }
729 #endif 696 #endif
730 } 697 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ssl/ssl_error_classification.h » ('j') | chrome/browser/ssl/ssl_error_classification.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698