| 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::TimeTicks; | 41 using base::TimeTicks; |
| 41 using content::InterstitialPage; | 42 using content::InterstitialPage; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 60 PROCEED_OVERRIDABLE, | 61 PROCEED_OVERRIDABLE, |
| 61 PROCEED_NAME, | 62 PROCEED_NAME, |
| 62 PROCEED_DATE, | 63 PROCEED_DATE, |
| 63 PROCEED_AUTHORITY, | 64 PROCEED_AUTHORITY, |
| 64 DONT_PROCEED_OVERRIDABLE, | 65 DONT_PROCEED_OVERRIDABLE, |
| 65 DONT_PROCEED_NAME, | 66 DONT_PROCEED_NAME, |
| 66 DONT_PROCEED_DATE, | 67 DONT_PROCEED_DATE, |
| 67 DONT_PROCEED_AUTHORITY, | 68 DONT_PROCEED_AUTHORITY, |
| 68 MORE, | 69 MORE, |
| 69 SHOW_UNDERSTAND, | 70 SHOW_UNDERSTAND, |
| 71 SHOW_INTERNAL_HOSTNAME, |
| 72 PROCEED_INTERNAL_HOSTNAME, |
| 70 UNUSED_BLOCKING_PAGE_EVENT, | 73 UNUSED_BLOCKING_PAGE_EVENT, |
| 71 }; | 74 }; |
| 72 | 75 |
| 73 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { | 76 void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { |
| 74 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", | 77 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl", |
| 75 event, | 78 event, |
| 76 UNUSED_BLOCKING_PAGE_EVENT); | 79 UNUSED_BLOCKING_PAGE_EVENT); |
| 77 } | 80 } |
| 78 | 81 |
| 79 void RecordSSLBlockingPageDetailedStats( | 82 void RecordSSLBlockingPageDetailedStats( |
| 80 bool proceed, | 83 bool proceed, |
| 81 int cert_error, | 84 int cert_error, |
| 82 bool overridable, | 85 bool overridable, |
| 86 bool internal, |
| 83 const base::TimeTicks& start_time) { | 87 const base::TimeTicks& start_time) { |
| 84 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", | 88 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl_error_type", |
| 85 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); | 89 SSLErrorInfo::NetErrorToErrorType(cert_error), SSLErrorInfo::END_OF_ENUM); |
| 86 if (start_time.is_null() || !overridable) { | 90 if (start_time.is_null() || !overridable) { |
| 87 // A null start time will occur if the page never came into focus. | 91 // A null start time will occur if the page never came into focus. |
| 88 // Overridable is false if the user didn't have any option except to turn | 92 // Overridable is false if the user didn't have any option except to turn |
| 89 // back. In either case, we don't want to record some of our metrics. | 93 // back. In either case, we don't want to record some of our metrics. |
| 90 return; | 94 return; |
| 91 } | 95 } |
| 92 if (proceed) | 96 if (proceed) { |
| 93 RecordSSLBlockingPageEventStats(PROCEED_OVERRIDABLE); | 97 RecordSSLBlockingPageEventStats(PROCEED_OVERRIDABLE); |
| 94 else if (!proceed) | 98 if (internal) |
| 99 RecordSSLBlockingPageEventStats(PROCEED_INTERNAL_HOSTNAME); |
| 100 } else if (!proceed) { |
| 95 RecordSSLBlockingPageEventStats(DONT_PROCEED_OVERRIDABLE); | 101 RecordSSLBlockingPageEventStats(DONT_PROCEED_OVERRIDABLE); |
| 102 } |
| 96 SSLErrorInfo::ErrorType type = SSLErrorInfo::NetErrorToErrorType(cert_error); | 103 SSLErrorInfo::ErrorType type = SSLErrorInfo::NetErrorToErrorType(cert_error); |
| 97 switch (type) { | 104 switch (type) { |
| 98 case SSLErrorInfo::CERT_COMMON_NAME_INVALID: { | 105 case SSLErrorInfo::CERT_COMMON_NAME_INVALID: { |
| 99 if (proceed) | 106 if (proceed) |
| 100 RecordSSLBlockingPageEventStats(PROCEED_NAME); | 107 RecordSSLBlockingPageEventStats(PROCEED_NAME); |
| 101 else | 108 else |
| 102 RecordSSLBlockingPageEventStats(DONT_PROCEED_NAME); | 109 RecordSSLBlockingPageEventStats(DONT_PROCEED_NAME); |
| 103 break; | 110 break; |
| 104 } | 111 } |
| 105 case SSLErrorInfo::CERT_DATE_INVALID: { | 112 case SSLErrorInfo::CERT_DATE_INVALID: { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 const GURL& request_url, | 150 const GURL& request_url, |
| 144 bool overridable, | 151 bool overridable, |
| 145 bool strict_enforcement, | 152 bool strict_enforcement, |
| 146 const base::Callback<void(bool)>& callback) | 153 const base::Callback<void(bool)>& callback) |
| 147 : callback_(callback), | 154 : callback_(callback), |
| 148 web_contents_(web_contents), | 155 web_contents_(web_contents), |
| 149 cert_error_(cert_error), | 156 cert_error_(cert_error), |
| 150 ssl_info_(ssl_info), | 157 ssl_info_(ssl_info), |
| 151 request_url_(request_url), | 158 request_url_(request_url), |
| 152 overridable_(overridable), | 159 overridable_(overridable), |
| 153 strict_enforcement_(strict_enforcement) { | 160 strict_enforcement_(strict_enforcement), |
| 161 internal_(false) { |
| 154 trialCondition_ = base::FieldTrialList::FindFullName(kStudyName); | 162 trialCondition_ = base::FieldTrialList::FindFullName(kStudyName); |
| 155 | 163 |
| 164 if (net::IsHostnameNonUnique(request_url_.HostNoBrackets())) |
| 165 internal_ = true; |
| 166 |
| 156 RecordSSLBlockingPageEventStats(SHOW_ALL); | 167 RecordSSLBlockingPageEventStats(SHOW_ALL); |
| 157 if (overridable_ && !strict_enforcement_) | 168 if (overridable_ && !strict_enforcement_) { |
| 158 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); | 169 RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); |
| 170 if (internal_) |
| 171 RecordSSLBlockingPageEventStats(SHOW_INTERNAL_HOSTNAME); |
| 172 } |
| 159 | 173 |
| 160 interstitial_page_ = InterstitialPage::Create( | 174 interstitial_page_ = InterstitialPage::Create( |
| 161 web_contents_, true, request_url, this); | 175 web_contents_, true, request_url, this); |
| 162 display_start_time_ = TimeTicks(); | 176 display_start_time_ = TimeTicks(); |
| 163 interstitial_page_->Show(); | 177 interstitial_page_->Show(); |
| 164 } | 178 } |
| 165 | 179 |
| 166 SSLBlockingPage::~SSLBlockingPage() { | 180 SSLBlockingPage::~SSLBlockingPage() { |
| 167 if (!callback_.is_null()) { | 181 if (!callback_.is_null()) { |
| 168 RecordSSLBlockingPageDetailedStats( | 182 RecordSSLBlockingPageDetailedStats(false, |
| 169 false, cert_error_, | 183 cert_error_, |
| 170 overridable_ && !strict_enforcement_, display_start_time_); | 184 overridable_ && !strict_enforcement_, |
| 185 internal_, |
| 186 display_start_time_); |
| 171 // The page is closed without the user having chosen what to do, default to | 187 // The page is closed without the user having chosen what to do, default to |
| 172 // deny. | 188 // deny. |
| 173 NotifyDenyCertificate(); | 189 NotifyDenyCertificate(); |
| 174 } | 190 } |
| 175 } | 191 } |
| 176 | 192 |
| 177 std::string SSLBlockingPage::GetHTMLContents() { | 193 std::string SSLBlockingPage::GetHTMLContents() { |
| 178 // Let's build the html error page. | 194 // Let's build the html error page. |
| 179 DictionaryValue strings; | 195 DictionaryValue strings; |
| 180 SSLErrorInfo error_info = | 196 SSLErrorInfo error_info = |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 } | 299 } |
| 284 | 300 |
| 285 void SSLBlockingPage::OverrideRendererPrefs( | 301 void SSLBlockingPage::OverrideRendererPrefs( |
| 286 content::RendererPreferences* prefs) { | 302 content::RendererPreferences* prefs) { |
| 287 Profile* profile = Profile::FromBrowserContext( | 303 Profile* profile = Profile::FromBrowserContext( |
| 288 web_contents_->GetBrowserContext()); | 304 web_contents_->GetBrowserContext()); |
| 289 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); | 305 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile); |
| 290 } | 306 } |
| 291 | 307 |
| 292 void SSLBlockingPage::OnProceed() { | 308 void SSLBlockingPage::OnProceed() { |
| 293 RecordSSLBlockingPageDetailedStats(true, cert_error_, | 309 RecordSSLBlockingPageDetailedStats(true, |
| 294 overridable_ && !strict_enforcement_, display_start_time_); | 310 cert_error_, |
| 295 | 311 overridable_ && !strict_enforcement_, |
| 312 internal_, |
| 313 display_start_time_); |
| 296 // Accepting the certificate resumes the loading of the page. | 314 // Accepting the certificate resumes the loading of the page. |
| 297 NotifyAllowCertificate(); | 315 NotifyAllowCertificate(); |
| 298 } | 316 } |
| 299 | 317 |
| 300 void SSLBlockingPage::OnDontProceed() { | 318 void SSLBlockingPage::OnDontProceed() { |
| 301 RecordSSLBlockingPageDetailedStats(false, cert_error_, | 319 RecordSSLBlockingPageDetailedStats(false, |
| 302 overridable_ && !strict_enforcement_, display_start_time_); | 320 cert_error_, |
| 303 | 321 overridable_ && !strict_enforcement_, |
| 322 internal_, |
| 323 display_start_time_); |
| 304 NotifyDenyCertificate(); | 324 NotifyDenyCertificate(); |
| 305 } | 325 } |
| 306 | 326 |
| 307 void SSLBlockingPage::NotifyDenyCertificate() { | 327 void SSLBlockingPage::NotifyDenyCertificate() { |
| 308 // It's possible that callback_ may not exist if the user clicks "Proceed" | 328 // It's possible that callback_ may not exist if the user clicks "Proceed" |
| 309 // followed by pressing the back button before the interstitial is hidden. | 329 // followed by pressing the back button before the interstitial is hidden. |
| 310 // In that case the certificate will still be treated as allowed. | 330 // In that case the certificate will still be treated as allowed. |
| 311 if (callback_.is_null()) | 331 if (callback_.is_null()) |
| 312 return; | 332 return; |
| 313 | 333 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 331 "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5" | 351 "moreInfo1", "moreInfo2", "moreInfo3", "moreInfo4", "moreInfo5" |
| 332 }; | 352 }; |
| 333 int i; | 353 int i; |
| 334 for (i = 0; i < static_cast<int>(extra_info.size()); i++) { | 354 for (i = 0; i < static_cast<int>(extra_info.size()); i++) { |
| 335 strings->SetString(keys[i], extra_info[i]); | 355 strings->SetString(keys[i], extra_info[i]); |
| 336 } | 356 } |
| 337 for (; i < 5; i++) { | 357 for (; i < 5; i++) { |
| 338 strings->SetString(keys[i], std::string()); | 358 strings->SetString(keys[i], std::string()); |
| 339 } | 359 } |
| 340 } | 360 } |
| OLD | NEW |