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

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

Issue 57183002: Fix the SSL interstitial UMA stats (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comment Created 7 years, 1 month 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 | Annotate | Revision Log
« 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/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
10 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
12 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 13 #include "base/values.h"
15 #include "chrome/browser/history/history_service_factory.h" 14 #include "chrome/browser/history/history_service_factory.h"
16 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/renderer_preferences_util.h" 16 #include "chrome/browser/renderer_preferences_util.h"
18 #include "chrome/browser/ssl/ssl_error_info.h" 17 #include "chrome/browser/ssl/ssl_error_info.h"
(...skipping 27 matching lines...) Expand all
46 using content::InterstitialPage; 45 using content::InterstitialPage;
47 using content::NavigationController; 46 using content::NavigationController;
48 using content::NavigationEntry; 47 using content::NavigationEntry;
49 48
50 namespace { 49 namespace {
51 50
52 // These represent the commands sent by ssl_roadblock.html. 51 // These represent the commands sent by ssl_roadblock.html.
53 enum SSLBlockingPageCommands { 52 enum SSLBlockingPageCommands {
54 CMD_DONT_PROCEED, 53 CMD_DONT_PROCEED,
55 CMD_PROCEED, 54 CMD_PROCEED,
56 CMD_FOCUS,
57 CMD_MORE, 55 CMD_MORE,
58 CMD_RELOAD, 56 CMD_RELOAD,
59 }; 57 };
60 58
61 // Events for UMA. 59 // Events for UMA.
62 enum SSLBlockingPageEvent { 60 enum SSLBlockingPageEvent {
63 SHOW_ALL, 61 SHOW_ALL,
64 SHOW_OVERRIDABLE, 62 SHOW_OVERRIDABLE,
65 PROCEED_OVERRIDABLE, 63 PROCEED_OVERRIDABLE,
66 PROCEED_NAME, 64 PROCEED_NAME,
(...skipping 16 matching lines...) Expand all
83 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", 81 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl",
84 event, 82 event,
85 UNUSED_BLOCKING_PAGE_EVENT); 83 UNUSED_BLOCKING_PAGE_EVENT);
86 } 84 }
87 85
88 void RecordSSLBlockingPageDetailedStats( 86 void RecordSSLBlockingPageDetailedStats(
89 bool proceed, 87 bool proceed,
90 int cert_error, 88 int cert_error,
91 bool overridable, 89 bool overridable,
92 bool internal, 90 bool internal,
93 const base::TimeTicks& start_time,
94 int num_visits) { 91 int num_visits) {
95 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", 92 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type",
96 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); 93 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM);
97 if (start_time.is_null() || !overridable) { 94 if (!overridable) {
98 // A null start time will occur if the page never came into focus.
99 // Overridable is false if the user didn't have any option except to turn 95 // Overridable is false if the user didn't have any option except to turn
100 // back. In either case, we don't want to record some of our metrics. 96 // back. If that's the case, don't record some of the metrics.
101 return; 97 return;
102 } 98 }
103 if (num_visits == 0) 99 if (num_visits == 0)
104 RecordSSLBlockingPageEventStats(SHOW_NEW_SITE); 100 RecordSSLBlockingPageEventStats(SHOW_NEW_SITE);
105 if (proceed) { 101 if (proceed) {
106 RecordSSLBlockingPageEventStats(PROCEED_OVERRIDABLE); 102 RecordSSLBlockingPageEventStats(PROCEED_OVERRIDABLE);
107 if (internal) 103 if (internal)
108 RecordSSLBlockingPageEventStats(PROCEED_INTERNAL_HOSTNAME); 104 RecordSSLBlockingPageEventStats(PROCEED_INTERNAL_HOSTNAME);
109 if (num_visits == 0) 105 if (num_visits == 0)
110 RecordSSLBlockingPageEventStats(PROCEED_NEW_SITE); 106 RecordSSLBlockingPageEventStats(PROCEED_NEW_SITE);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 history_service->GetVisibleVisitCountToHost( 172 history_service->GetVisibleVisitCountToHost(
177 request_url_, 173 request_url_,
178 &request_consumer_, 174 &request_consumer_,
179 base::Bind(&SSLBlockingPage::OnGotHistoryCount, 175 base::Bind(&SSLBlockingPage::OnGotHistoryCount,
180 base::Unretained(this))); 176 base::Unretained(this)));
181 } 177 }
182 } 178 }
183 179
184 interstitial_page_ = InterstitialPage::Create( 180 interstitial_page_ = InterstitialPage::Create(
185 web_contents_, true, request_url, this); 181 web_contents_, true, request_url, this);
186 display_start_time_ = TimeTicks();
187 interstitial_page_->Show(); 182 interstitial_page_->Show();
188 } 183 }
189 184
190 SSLBlockingPage::~SSLBlockingPage() { 185 SSLBlockingPage::~SSLBlockingPage() {
191 if (!callback_.is_null()) { 186 if (!callback_.is_null()) {
192 RecordSSLBlockingPageDetailedStats(false, 187 RecordSSLBlockingPageDetailedStats(false,
193 cert_error_, 188 cert_error_,
194 overridable_ && !strict_enforcement_, 189 overridable_ && !strict_enforcement_,
195 internal_, 190 internal_,
196 display_start_time_,
197 num_visits_); 191 num_visits_);
198 // The page is closed without the user having chosen what to do, default to 192 // The page is closed without the user having chosen what to do, default to
199 // deny. 193 // deny.
200 NotifyDenyCertificate(); 194 NotifyDenyCertificate();
201 } 195 }
202 } 196 }
203 197
204 std::string SSLBlockingPage::GetHTMLContents() { 198 std::string SSLBlockingPage::GetHTMLContents() {
205 DictionaryValue strings; 199 DictionaryValue strings;
206 int resource_id; 200 int resource_id;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 #endif // !defined(OS_ANDROID) 352 #endif // !defined(OS_ANDROID)
359 } 353 }
360 354
361 // Matches events defined in ssl_error.html and ssl_roadblock.html. 355 // Matches events defined in ssl_error.html and ssl_roadblock.html.
362 void SSLBlockingPage::CommandReceived(const std::string& command) { 356 void SSLBlockingPage::CommandReceived(const std::string& command) {
363 int cmd = atoi(command.c_str()); 357 int cmd = atoi(command.c_str());
364 if (cmd == CMD_DONT_PROCEED) { 358 if (cmd == CMD_DONT_PROCEED) {
365 interstitial_page_->DontProceed(); 359 interstitial_page_->DontProceed();
366 } else if (cmd == CMD_PROCEED) { 360 } else if (cmd == CMD_PROCEED) {
367 interstitial_page_->Proceed(); 361 interstitial_page_->Proceed();
368 } else if (cmd == CMD_FOCUS) {
369 // Start recording the time when the page is first in focus
370 display_start_time_ = base::TimeTicks::Now();
371 } else if (cmd == CMD_MORE) { 362 } else if (cmd == CMD_MORE) {
372 RecordSSLBlockingPageEventStats(MORE); 363 RecordSSLBlockingPageEventStats(MORE);
373 } else if (cmd == CMD_RELOAD) { 364 } else if (cmd == CMD_RELOAD) {
374 // The interstitial can't refresh itself. 365 // The interstitial can't refresh itself.
375 content::NavigationController* controller = &web_contents_->GetController(); 366 content::NavigationController* controller = &web_contents_->GetController();
376 controller->Reload(true); 367 controller->Reload(true);
377 } 368 }
378 } 369 }
379 370
380 void SSLBlockingPage::OverrideRendererPrefs( 371 void SSLBlockingPage::OverrideRendererPrefs(
381 content::RendererPreferences* prefs) { 372 content::RendererPreferences* prefs) {
382 Profile* profile = Profile::FromBrowserContext( 373 Profile* profile = Profile::FromBrowserContext(
383 web_contents_->GetBrowserContext()); 374 web_contents_->GetBrowserContext());
384 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); 375 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile);
385 } 376 }
386 377
387 void SSLBlockingPage::OnProceed() { 378 void SSLBlockingPage::OnProceed() {
388 RecordSSLBlockingPageDetailedStats(true, 379 RecordSSLBlockingPageDetailedStats(true,
389 cert_error_, 380 cert_error_,
390 overridable_ && !strict_enforcement_, 381 overridable_ && !strict_enforcement_,
391 internal_, 382 internal_,
392 display_start_time_,
393 num_visits_); 383 num_visits_);
394 // Accepting the certificate resumes the loading of the page. 384 // Accepting the certificate resumes the loading of the page.
395 NotifyAllowCertificate(); 385 NotifyAllowCertificate();
396 } 386 }
397 387
398 void SSLBlockingPage::OnDontProceed() { 388 void SSLBlockingPage::OnDontProceed() {
399 RecordSSLBlockingPageDetailedStats(false, 389 RecordSSLBlockingPageDetailedStats(false,
400 cert_error_, 390 cert_error_,
401 overridable_ && !strict_enforcement_, 391 overridable_ && !strict_enforcement_,
402 internal_, 392 internal_,
403 display_start_time_,
404 num_visits_); 393 num_visits_);
405 NotifyDenyCertificate(); 394 NotifyDenyCertificate();
406 } 395 }
407 396
408 void SSLBlockingPage::NotifyDenyCertificate() { 397 void SSLBlockingPage::NotifyDenyCertificate() {
409 // It's possible that callback_ may not exist if the user clicks "Proceed" 398 // It's possible that callback_ may not exist if the user clicks "Proceed"
410 // followed by pressing the back button before the interstitial is hidden. 399 // followed by pressing the back button before the interstitial is hidden.
411 // In that case the certificate will still be treated as allowed. 400 // In that case the certificate will still be treated as allowed.
412 if (callback_.is_null()) 401 if (callback_.is_null())
413 return; 402 return;
(...skipping 25 matching lines...) Expand all
439 strings->SetString(keys[i], std::string()); 428 strings->SetString(keys[i], std::string());
440 } 429 }
441 } 430 }
442 431
443 void SSLBlockingPage::OnGotHistoryCount(HistoryService::Handle handle, 432 void SSLBlockingPage::OnGotHistoryCount(HistoryService::Handle handle,
444 bool success, 433 bool success,
445 int num_visits, 434 int num_visits,
446 base::Time first_visit) { 435 base::Time first_visit) {
447 num_visits_ = num_visits; 436 num_visits_ = num_visits;
448 } 437 }
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