| 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/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
| 24 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
| 25 #include "content/public/browser/render_view_host.h" | 25 #include "content/public/browser/render_view_host.h" |
| 26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/common/ssl_status.h" | 27 #include "content/public/common/ssl_status.h" |
| 28 #include "grit/app_locale_settings.h" | 28 #include "grit/app_locale_settings.h" |
| 29 #include "grit/browser_resources.h" | 29 #include "grit/browser_resources.h" |
| 30 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
| 31 #include "net/base/net_errors.h" | 31 #include "net/base/net_errors.h" |
| 32 #include "net/base/net_util.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
| 34 #include "ui/webui/jstemplate_builder.h" | 35 #include "ui/webui/jstemplate_builder.h" |
| 35 | 36 |
| 36 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 37 #include "base/win/windows_version.h" | 38 #include "base/win/windows_version.h" |
| 38 #endif | 39 #endif |
| 39 | 40 |
| 40 using base::TimeDelta; | 41 using base::TimeDelta; |
| 41 using base::TimeTicks; | 42 using base::TimeTicks; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 PROCEED_OVERRIDABLE, | 76 PROCEED_OVERRIDABLE, |
| 76 PROCEED_NAME, | 77 PROCEED_NAME, |
| 77 PROCEED_DATE, | 78 PROCEED_DATE, |
| 78 PROCEED_AUTHORITY, | 79 PROCEED_AUTHORITY, |
| 79 DONT_PROCEED_OVERRIDABLE, | 80 DONT_PROCEED_OVERRIDABLE, |
| 80 DONT_PROCEED_NAME, | 81 DONT_PROCEED_NAME, |
| 81 DONT_PROCEED_DATE, | 82 DONT_PROCEED_DATE, |
| 82 DONT_PROCEED_AUTHORITY, | 83 DONT_PROCEED_AUTHORITY, |
| 83 MORE, | 84 MORE, |
| 84 SHOW_UNDERSTAND, | 85 SHOW_UNDERSTAND, |
| 86 SHOW_INTERNAL_HOSTNAME, |
| 87 PROCEED_INTERNAL_HOSTNAME, |
| 85 UNUSED_BLOCKING_PAGE_EVENT, | 88 UNUSED_BLOCKING_PAGE_EVENT, |
| 86 }; | 89 }; |
| 87 | 90 |
| 88 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { | 91 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { |
| 89 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", | 92 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", |
| 90 event, | 93 event, |
| 91 UNUSED_BLOCKING_PAGE_EVENT); | 94 UNUSED_BLOCKING_PAGE_EVENT); |
| 92 } | 95 } |
| 93 | 96 |
| 94 void RecordSSLBlockingPageTimeStats( | 97 void RecordSSLBlockingPageTimeStats( |
| 95 bool proceed, | 98 bool proceed, |
| 96 int cert_error, | 99 int cert_error, |
| 97 bool overridable, | 100 bool overridable, |
| 101 bool internal, |
| 98 const base::TimeTicks& start_time, | 102 const base::TimeTicks& start_time, |
| 99 const base::TimeTicks& end_time) { | 103 const base::TimeTicks& end_time) { |
| 100 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", | 104 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", |
| 101 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); | 105 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); |
| 102 if (start_time.is_null() || !overridable) { | 106 if (start_time.is_null() || !overridable) { |
| 103 // A null start time will occur if the page never came into focus and the | 107 // A null start time will occur if the page never came into focus and the |
| 104 // user quit without seeing it. If so, we don't record the time. | 108 // user quit without seeing it. If so, we don't record the time. |
| 105 // The user might not have an option except to turn back; that happens | 109 // The user might not have an option except to turn back; that happens |
| 106 // if overridable is true. If so, the time/outcome isn't meaningful. | 110 // if overridable is true. If so, the time/outcome isn't meaningful. |
| 107 return; | 111 return; |
| 108 } | 112 } |
| 109 base::TimeDelta delta = end_time - start_time; | 113 base::TimeDelta delta = end_time - start_time; |
| 110 if (proceed) { | 114 if (proceed) { |
| 111 RecordSSLBlockingPageEventStats(PROCEED_OVERRIDABLE); | 115 RecordSSLBlockingPageEventStats(PROCEED_OVERRIDABLE); |
| 112 HISTOGRAM_INTERSTITIAL_LARGE_TIME("interstitial.ssl_accept_time", delta); | 116 HISTOGRAM_INTERSTITIAL_LARGE_TIME("interstitial.ssl_accept_time", delta); |
| 117 if (internal) |
| 118 RecordSSLBlockingPageEventStats(PROCEED_INTERNAL_HOSTNAME); |
| 113 } else if (!proceed) { | 119 } else if (!proceed) { |
| 114 RecordSSLBlockingPageEventStats(DONT_PROCEED_OVERRIDABLE); | 120 RecordSSLBlockingPageEventStats(DONT_PROCEED_OVERRIDABLE); |
| 115 HISTOGRAM_INTERSTITIAL_LARGE_TIME("interstitial.ssl_reject_time", delta); | 121 HISTOGRAM_INTERSTITIAL_LARGE_TIME("interstitial.ssl_reject_time", delta); |
| 116 } | 122 } |
| 117 SSLErrorInfo::ErrorType type = SSLErrorInfo::NetErrorToErrorType(cert_error); | 123 SSLErrorInfo::ErrorType type = SSLErrorInfo::NetErrorToErrorType(cert_error); |
| 118 switch (type) { | 124 switch (type) { |
| 119 case SSLErrorInfo::CERT_COMMON_NAME_INVALID: { | 125 case SSLErrorInfo::CERT_COMMON_NAME_INVALID: { |
| 120 HISTOGRAM_INTERSTITIAL_SMALL_TIME( | 126 HISTOGRAM_INTERSTITIAL_SMALL_TIME( |
| 121 "interstitial.common_name_invalid_time", | 127 "interstitial.common_name_invalid_time", |
| 122 delta); | 128 delta); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 const GURL& request_url, | 179 const GURL& request_url, |
| 174 bool overridable, | 180 bool overridable, |
| 175 bool strict_enforcement, | 181 bool strict_enforcement, |
| 176 const base::Callback<void(bool)>& callback) | 182 const base::Callback<void(bool)>& callback) |
| 177 : callback_(callback), | 183 : callback_(callback), |
| 178 web_contents_(web_contents), | 184 web_contents_(web_contents), |
| 179 cert_error_(cert_error), | 185 cert_error_(cert_error), |
| 180 ssl_info_(ssl_info), | 186 ssl_info_(ssl_info), |
| 181 request_url_(request_url), | 187 request_url_(request_url), |
| 182 overridable_(overridable), | 188 overridable_(overridable), |
| 183 strict_enforcement_(strict_enforcement) { | 189 strict_enforcement_(strict_enforcement), |
| 190 internal_(false) { |
| 184 trialCondition_ = base::FieldTrialList::FindFullName(kStudyName); | 191 trialCondition_ = base::FieldTrialList::FindFullName(kStudyName); |
| 185 | 192 |
| 193 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) |
| 194 internal_ = true; |
| 195 |
| 186 RecordSSLBlockingPageEventStats(SHOW_ALL); | 196 RecordSSLBlockingPageEventStats(SHOW_ALL); |
| 187 if (overridable_ && !strict_enforcement_) | 197 if (overridable_ && !strict_enforcement_) { |
| 188 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); | 198 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); |
| 199 if (internal_) |
| 200 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); |
| 201 } |
| 189 | 202 |
| 190 interstitial_page_ = InterstitialPage::Create( | 203 interstitial_page_ = InterstitialPage::Create( |
| 191 web_contents_, true, request_url, this); | 204 web_contents_, true, request_url, this); |
| 192 display_start_time_ = TimeTicks(); | 205 display_start_time_ = TimeTicks(); |
| 193 interstitial_page_->Show(); | 206 interstitial_page_->Show(); |
| 194 } | 207 } |
| 195 | 208 |
| 196 SSLBlockingPage::~SSLBlockingPage() { | 209 SSLBlockingPage::~SSLBlockingPage() { |
| 197 if (!callback_.is_null()) { | 210 if (!callback_.is_null()) { |
| 198 RecordSSLBlockingPageTimeStats( | 211 RecordSSLBlockingPageTimeStats(false, |
| 199 false, cert_error_, | 212 cert_error_, |
| 200 overridable_ && !strict_enforcement_, display_start_time_, | 213 overridable_ && !strict_enforcement_, |
| 201 base::TimeTicks::Now()); | 214 internal_, |
| 215 display_start_time_, |
| 216 base::TimeTicks::Now()); |
| 202 // The page is closed without the user having chosen what to do, default to | 217 // The page is closed without the user having chosen what to do, default to |
| 203 // deny. | 218 // deny. |
| 204 NotifyDenyCertificate(); | 219 NotifyDenyCertificate(); |
| 205 } | 220 } |
| 206 } | 221 } |
| 207 | 222 |
| 208 std::string SSLBlockingPage::GetHTMLContents() { | 223 std::string SSLBlockingPage::GetHTMLContents() { |
| 209 // Let's build the html error page. | 224 // Let's build the html error page. |
| 210 DictionaryValue strings; | 225 DictionaryValue strings; |
| 211 SSLErrorInfo error_info = | 226 SSLErrorInfo error_info = |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 } | 329 } |
| 315 | 330 |
| 316 void SSLBlockingPage::OverrideRendererPrefs( | 331 void SSLBlockingPage::OverrideRendererPrefs( |
| 317 content::RendererPreferences* prefs) { | 332 content::RendererPreferences* prefs) { |
| 318 Profile* profile = Profile::FromBrowserContext( | 333 Profile* profile = Profile::FromBrowserContext( |
| 319 web_contents_->GetBrowserContext()); | 334 web_contents_->GetBrowserContext()); |
| 320 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); | 335 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); |
| 321 } | 336 } |
| 322 | 337 |
| 323 void SSLBlockingPage::OnProceed() { | 338 void SSLBlockingPage::OnProceed() { |
| 324 RecordSSLBlockingPageTimeStats(true, cert_error_, | 339 RecordSSLBlockingPageTimeStats(true, |
| 325 overridable_ && !strict_enforcement_, display_start_time_, | 340 cert_error_, |
| 326 base::TimeTicks::Now()); | 341 overridable_ && !strict_enforcement_, |
| 327 | 342 internal_, |
| 343 display_start_time_, |
| 344 base::TimeTicks::Now()); |
| 328 // Accepting the certificate resumes the loading of the page. | 345 // Accepting the certificate resumes the loading of the page. |
| 329 NotifyAllowCertificate(); | 346 NotifyAllowCertificate(); |
| 330 } | 347 } |
| 331 | 348 |
| 332 void SSLBlockingPage::OnDontProceed() { | 349 void SSLBlockingPage::OnDontProceed() { |
| 333 RecordSSLBlockingPageTimeStats(false, cert_error_, | 350 RecordSSLBlockingPageTimeStats(false, |
| 334 overridable_ && !strict_enforcement_, display_start_time_, | 351 cert_error_, |
| 335 base::TimeTicks::Now()); | 352 overridable_ && !strict_enforcement_, |
| 336 | 353 internal_, |
| 354 display_start_time_, |
| 355 base::TimeTicks::Now()); |
| 337 NotifyDenyCertificate(); | 356 NotifyDenyCertificate(); |
| 338 } | 357 } |
| 339 | 358 |
| 340 void SSLBlockingPage::NotifyDenyCertificate() { | 359 void SSLBlockingPage::NotifyDenyCertificate() { |
| 341 // It's possible that callback_ may not exist if the user clicks "Proceed" | 360 // It's possible that callback_ may not exist if the user clicks "Proceed" |
| 342 // followed by pressing the back button before the interstitial is hidden. | 361 // followed by pressing the back button before the interstitial is hidden. |
| 343 // In that case the certificate will still be treated as allowed. | 362 // In that case the certificate will still be treated as allowed. |
| 344 if (callback_.is_null()) | 363 if (callback_.is_null()) |
| 345 return; | 364 return; |
| 346 | 365 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 364 "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5" | 383 "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5" |
| 365 }; | 384 }; |
| 366 int i; | 385 int i; |
| 367 for (i = 0; i < static_cast<int>(extra_info.size()); i++) { | 386 for (i = 0; i < static_cast<int>(extra_info.size()); i++) { |
| 368 strings->SetString(keys[i], extra_info[i]); | 387 strings->SetString(keys[i], extra_info[i]); |
| 369 } | 388 } |
| 370 for (; i < 5; i++) { | 389 for (; i < 5; i++) { |
| 371 strings->SetString(keys[i], std::string()); | 390 strings->SetString(keys[i], std::string()); |
| 372 } | 391 } |
| 373 } | 392 } |
| OLD | NEW |