Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/bad_clock_blocking_page.h" | 5 #include "chrome/browser/ssl/bad_clock_blocking_page.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/build_time.h" | 9 #include "base/build_time.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
| 13 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
| 14 #include "base/process/launch.h" | 14 #include "base/process/launch.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_piece.h" | 16 #include "base/strings/string_piece.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "base/values.h" | 21 #include "base/values.h" |
| 22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/interstitials/chrome_metrics_helper.h" | |
| 23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/renderer_preferences_util.h" | 25 #include "chrome/browser/renderer_preferences_util.h" |
| 25 #include "chrome/browser/ssl/ssl_error_classification.h" | 26 #include "chrome/browser/ssl/ssl_error_classification.h" |
| 26 #include "chrome/browser/ssl/ssl_error_info.h" | 27 #include "chrome/browser/ssl/ssl_error_info.h" |
| 27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/grit/chromium_strings.h" | 29 #include "chrome/grit/chromium_strings.h" |
| 29 #include "chrome/grit/generated_resources.h" | 30 #include "chrome/grit/generated_resources.h" |
| 30 #include "components/google/core/browser/google_util.h" | 31 #include "components/google/core/browser/google_util.h" |
| 31 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
| 32 #include "content/public/browser/cert_store.h" | 33 #include "content/public/browser/cert_store.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 63 | 64 |
| 64 using base::ASCIIToUTF16; | 65 using base::ASCIIToUTF16; |
| 65 using base::TimeTicks; | 66 using base::TimeTicks; |
| 66 using content::InterstitialPage; | 67 using content::InterstitialPage; |
| 67 using content::InterstitialPageDelegate; | 68 using content::InterstitialPageDelegate; |
| 68 using content::NavigationController; | 69 using content::NavigationController; |
| 69 using content::NavigationEntry; | 70 using content::NavigationEntry; |
| 70 | 71 |
| 71 namespace { | 72 namespace { |
| 72 | 73 |
| 74 const char kMetricsName[] = "bad_clock"; | |
| 75 | |
| 73 void LaunchDateAndTimeSettings() { | 76 void LaunchDateAndTimeSettings() { |
| 74 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 77 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| 75 // The code for each OS is completely separate, in order to avoid bugs like | 78 // The code for each OS is completely separate, in order to avoid bugs like |
| 76 // https://crbug.com/430877 . | 79 // https://crbug.com/430877 . |
| 77 #if defined(OS_ANDROID) | 80 #if defined(OS_ANDROID) |
| 78 chrome::android::OpenDateAndTimeSettings(); | 81 chrome::android::OpenDateAndTimeSettings(); |
| 79 | 82 |
| 80 #elif defined(OS_CHROMEOS) | 83 #elif defined(OS_CHROMEOS) |
| 81 std::string sub_page = | 84 std::string sub_page = |
| 82 std::string(chrome::kSearchSubPage) + "#" + | 85 std::string(chrome::kSearchSubPage) + "#" + |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 content::WebContents* web_contents, | 173 content::WebContents* web_contents, |
| 171 int cert_error, | 174 int cert_error, |
| 172 const net::SSLInfo& ssl_info, | 175 const net::SSLInfo& ssl_info, |
| 173 const GURL& request_url, | 176 const GURL& request_url, |
| 174 const base::Time& time_triggered, | 177 const base::Time& time_triggered, |
| 175 const base::Callback<void(bool)>& callback) | 178 const base::Callback<void(bool)>& callback) |
| 176 : SecurityInterstitialPage(web_contents, request_url), | 179 : SecurityInterstitialPage(web_contents, request_url), |
| 177 callback_(callback), | 180 callback_(callback), |
| 178 cert_error_(cert_error), | 181 cert_error_(cert_error), |
| 179 ssl_info_(ssl_info), | 182 ssl_info_(ssl_info), |
| 180 time_triggered_(time_triggered) {} | 183 time_triggered_(time_triggered) { |
| 184 security_interstitials::MetricsHelper::ReportDetails reporting_info; | |
| 185 reporting_info.metric_prefix = kMetricsName; | |
| 186 set_metrics_helper(new ChromeMetricsHelper(web_contents, request_url, | |
| 187 reporting_info, kMetricsName)); | |
| 188 metrics_helper()->RecordUserInteraction( | |
| 189 security_interstitials::MetricsHelper::TOTAL_VISITS); | |
| 190 | |
| 191 // TODO(felt): Separate the clock statistics from the main ssl statistics. | |
| 192 (new SSLErrorClassification(web_contents, time_triggered_, request_url, | |
|
estark
2015/09/01 16:41:48
memory leak... put it in a scoped_ptr or just do
felt
2015/09/01 19:13:15
Done.
| |
| 193 cert_error_, *ssl_info_.cert.get())) | |
| 194 ->RecordUMAStatistics(false); | |
| 195 } | |
| 181 | 196 |
| 182 bool BadClockBlockingPage::ShouldCreateNewNavigation() const { | 197 bool BadClockBlockingPage::ShouldCreateNewNavigation() const { |
| 183 return true; | 198 return true; |
| 184 } | 199 } |
| 185 | 200 |
| 186 InterstitialPageDelegate::TypeID BadClockBlockingPage::GetTypeForTesting() | 201 InterstitialPageDelegate::TypeID BadClockBlockingPage::GetTypeForTesting() |
| 187 const { | 202 const { |
| 188 return BadClockBlockingPage::kTypeForTesting; | 203 return BadClockBlockingPage::kTypeForTesting; |
| 189 } | 204 } |
| 190 | 205 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 case CMD_DONT_PROCEED: | 302 case CMD_DONT_PROCEED: |
| 288 interstitial_page()->DontProceed(); | 303 interstitial_page()->DontProceed(); |
| 289 break; | 304 break; |
| 290 case CMD_DO_REPORT: | 305 case CMD_DO_REPORT: |
| 291 SetReportingPreference(true); | 306 SetReportingPreference(true); |
| 292 break; | 307 break; |
| 293 case CMD_DONT_REPORT: | 308 case CMD_DONT_REPORT: |
| 294 SetReportingPreference(false); | 309 SetReportingPreference(false); |
| 295 break; | 310 break; |
| 296 case CMD_SHOW_MORE_SECTION: | 311 case CMD_SHOW_MORE_SECTION: |
| 312 metrics_helper()->RecordUserInteraction( | |
| 313 security_interstitials::MetricsHelper::SHOW_ADVANCED); | |
| 297 break; | 314 break; |
| 298 case CMD_OPEN_DATE_SETTINGS: | 315 case CMD_OPEN_DATE_SETTINGS: |
| 316 metrics_helper()->RecordUserInteraction( | |
| 317 security_interstitials::MetricsHelper::OPEN_TIME_SETTINGS); | |
| 299 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 318 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
| 300 base::Bind(&LaunchDateAndTimeSettings)); | 319 base::Bind(&LaunchDateAndTimeSettings)); |
| 301 break; | 320 break; |
| 302 case CMD_OPEN_REPORTING_PRIVACY: | 321 case CMD_OPEN_REPORTING_PRIVACY: |
| 303 OpenExtendedReportingPrivacyPolicy(); | 322 OpenExtendedReportingPrivacyPolicy(); |
| 304 break; | 323 break; |
| 305 case CMD_PROCEED: | 324 case CMD_PROCEED: |
| 306 case CMD_OPEN_HELP_CENTER: | 325 case CMD_OPEN_HELP_CENTER: |
| 307 case CMD_RELOAD: | 326 case CMD_RELOAD: |
| 308 case CMD_OPEN_DIAGNOSTIC: | 327 case CMD_OPEN_DIAGNOSTIC: |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 325 | 344 |
| 326 void BadClockBlockingPage::NotifyDenyCertificate() { | 345 void BadClockBlockingPage::NotifyDenyCertificate() { |
| 327 // It's possible that callback_ may not exist if the user clicks "Proceed" | 346 // It's possible that callback_ may not exist if the user clicks "Proceed" |
| 328 // followed by pressing the back button before the interstitial is hidden. | 347 // followed by pressing the back button before the interstitial is hidden. |
| 329 // In that case the certificate will still be treated as allowed. | 348 // In that case the certificate will still be treated as allowed. |
| 330 if (callback_.is_null()) | 349 if (callback_.is_null()) |
| 331 return; | 350 return; |
| 332 | 351 |
| 333 base::ResetAndReturn(&callback_).Run(false); | 352 base::ResetAndReturn(&callback_).Run(false); |
| 334 } | 353 } |
| OLD | NEW |