| 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 scoped_ptr<SSLErrorClassification> classifier( |
| 193 new SSLErrorClassification(web_contents, time_triggered_, request_url, |
| 194 cert_error_, *ssl_info_.cert.get())); |
| 195 classifier->RecordUMAStatistics(false); |
| 196 } |
| 181 | 197 |
| 182 bool BadClockBlockingPage::ShouldCreateNewNavigation() const { | 198 bool BadClockBlockingPage::ShouldCreateNewNavigation() const { |
| 183 return true; | 199 return true; |
| 184 } | 200 } |
| 185 | 201 |
| 186 InterstitialPageDelegate::TypeID BadClockBlockingPage::GetTypeForTesting() | 202 InterstitialPageDelegate::TypeID BadClockBlockingPage::GetTypeForTesting() |
| 187 const { | 203 const { |
| 188 return BadClockBlockingPage::kTypeForTesting; | 204 return BadClockBlockingPage::kTypeForTesting; |
| 189 } | 205 } |
| 190 | 206 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 case CMD_DONT_PROCEED: | 303 case CMD_DONT_PROCEED: |
| 288 interstitial_page()->DontProceed(); | 304 interstitial_page()->DontProceed(); |
| 289 break; | 305 break; |
| 290 case CMD_DO_REPORT: | 306 case CMD_DO_REPORT: |
| 291 SetReportingPreference(true); | 307 SetReportingPreference(true); |
| 292 break; | 308 break; |
| 293 case CMD_DONT_REPORT: | 309 case CMD_DONT_REPORT: |
| 294 SetReportingPreference(false); | 310 SetReportingPreference(false); |
| 295 break; | 311 break; |
| 296 case CMD_SHOW_MORE_SECTION: | 312 case CMD_SHOW_MORE_SECTION: |
| 313 metrics_helper()->RecordUserInteraction( |
| 314 security_interstitials::MetricsHelper::SHOW_ADVANCED); |
| 297 break; | 315 break; |
| 298 case CMD_OPEN_DATE_SETTINGS: | 316 case CMD_OPEN_DATE_SETTINGS: |
| 317 metrics_helper()->RecordUserInteraction( |
| 318 security_interstitials::MetricsHelper::OPEN_TIME_SETTINGS); |
| 299 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 319 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
| 300 base::Bind(&LaunchDateAndTimeSettings)); | 320 base::Bind(&LaunchDateAndTimeSettings)); |
| 301 break; | 321 break; |
| 302 case CMD_OPEN_REPORTING_PRIVACY: | 322 case CMD_OPEN_REPORTING_PRIVACY: |
| 303 OpenExtendedReportingPrivacyPolicy(); | 323 OpenExtendedReportingPrivacyPolicy(); |
| 304 break; | 324 break; |
| 305 case CMD_PROCEED: | 325 case CMD_PROCEED: |
| 306 case CMD_OPEN_HELP_CENTER: | 326 case CMD_OPEN_HELP_CENTER: |
| 307 case CMD_RELOAD: | 327 case CMD_RELOAD: |
| 308 case CMD_OPEN_DIAGNOSTIC: | 328 case CMD_OPEN_DIAGNOSTIC: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 325 | 345 |
| 326 void BadClockBlockingPage::NotifyDenyCertificate() { | 346 void BadClockBlockingPage::NotifyDenyCertificate() { |
| 327 // It's possible that callback_ may not exist if the user clicks "Proceed" | 347 // 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. | 348 // followed by pressing the back button before the interstitial is hidden. |
| 329 // In that case the certificate will still be treated as allowed. | 349 // In that case the certificate will still be treated as allowed. |
| 330 if (callback_.is_null()) | 350 if (callback_.is_null()) |
| 331 return; | 351 return; |
| 332 | 352 |
| 333 base::ResetAndReturn(&callback_).Run(false); | 353 base::ResetAndReturn(&callback_).Run(false); |
| 334 } | 354 } |
| OLD | NEW |