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" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/values.h" | 22 #include "base/values.h" |
23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/interstitials/chrome_metrics_helper.h" | 24 #include "chrome/browser/interstitials/chrome_metrics_helper.h" |
25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/browser/renderer_preferences_util.h" | 26 #include "chrome/browser/renderer_preferences_util.h" |
27 #include "chrome/browser/ssl/cert_report_helper.h" | 27 #include "chrome/browser/ssl/cert_report_helper.h" |
28 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 28 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
30 #include "chrome/grit/generated_resources.h" | 30 #include "chrome/grit/generated_resources.h" |
31 #include "components/google/core/browser/google_util.h" | 31 #include "components/google/core/browser/google_util.h" |
| 32 #include "components/security_interstitials/core/controller_client.h" |
32 #include "components/ssl_errors/error_classification.h" | 33 #include "components/ssl_errors/error_classification.h" |
33 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
34 #include "content/public/browser/cert_store.h" | 35 #include "content/public/browser/cert_store.h" |
35 #include "content/public/browser/interstitial_page.h" | 36 #include "content/public/browser/interstitial_page.h" |
36 #include "content/public/browser/interstitial_page_delegate.h" | 37 #include "content/public/browser/interstitial_page_delegate.h" |
37 #include "content/public/browser/navigation_controller.h" | 38 #include "content/public/browser/navigation_controller.h" |
38 #include "content/public/browser/navigation_entry.h" | 39 #include "content/public/browser/navigation_entry.h" |
39 #include "content/public/browser/render_process_host.h" | 40 #include "content/public/browser/render_process_host.h" |
40 #include "content/public/browser/render_view_host.h" | 41 #include "content/public/browser/render_view_host.h" |
41 #include "content/public/browser/signed_certificate_timestamp_store.h" | 42 #include "content/public/browser/signed_certificate_timestamp_store.h" |
(...skipping 23 matching lines...) Expand all Loading... |
65 #include "base/strings/string16.h" | 66 #include "base/strings/string16.h" |
66 #include "base/win/windows_version.h" | 67 #include "base/win/windows_version.h" |
67 #endif | 68 #endif |
68 | 69 |
69 using base::ASCIIToUTF16; | 70 using base::ASCIIToUTF16; |
70 using base::TimeTicks; | 71 using base::TimeTicks; |
71 using content::InterstitialPage; | 72 using content::InterstitialPage; |
72 using content::InterstitialPageDelegate; | 73 using content::InterstitialPageDelegate; |
73 using content::NavigationController; | 74 using content::NavigationController; |
74 using content::NavigationEntry; | 75 using content::NavigationEntry; |
| 76 using security_interstitials::ControllerClient; |
75 | 77 |
76 namespace { | 78 namespace { |
77 | 79 |
78 const char kMetricsName[] = "bad_clock"; | 80 const char kMetricsName[] = "bad_clock"; |
79 | 81 |
80 void LaunchDateAndTimeSettings() { | 82 void LaunchDateAndTimeSettings() { |
81 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); | 83 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
82 // The code for each OS is completely separate, in order to avoid bugs like | 84 // The code for each OS is completely separate, in order to avoid bugs like |
83 // https://crbug.com/430877 . | 85 // https://crbug.com/430877 . |
84 #if defined(OS_ANDROID) | 86 #if defined(OS_ANDROID) |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if (command == "\"pageLoadComplete\"") { | 321 if (command == "\"pageLoadComplete\"") { |
320 // content::WaitForRenderFrameReady sends this message when the page | 322 // content::WaitForRenderFrameReady sends this message when the page |
321 // load completes. Ignore it. | 323 // load completes. Ignore it. |
322 return; | 324 return; |
323 } | 325 } |
324 | 326 |
325 int cmd = 0; | 327 int cmd = 0; |
326 bool retval = base::StringToInt(command, &cmd); | 328 bool retval = base::StringToInt(command, &cmd); |
327 DCHECK(retval); | 329 DCHECK(retval); |
328 switch (cmd) { | 330 switch (cmd) { |
329 case CMD_DONT_PROCEED: | 331 case ControllerClient::CMD_DONT_PROCEED: |
330 interstitial_page()->DontProceed(); | 332 interstitial_page()->DontProceed(); |
331 break; | 333 break; |
332 case CMD_DO_REPORT: | 334 case ControllerClient::CMD_DO_REPORT: |
333 SetReportingPreference(true); | 335 SetReportingPreference(true); |
334 break; | 336 break; |
335 case CMD_DONT_REPORT: | 337 case ControllerClient::CMD_DONT_REPORT: |
336 SetReportingPreference(false); | 338 SetReportingPreference(false); |
337 break; | 339 break; |
338 case CMD_SHOW_MORE_SECTION: | 340 case ControllerClient::CMD_SHOW_MORE_SECTION: |
339 metrics_helper()->RecordUserInteraction( | 341 metrics_helper()->RecordUserInteraction( |
340 security_interstitials::MetricsHelper::SHOW_ADVANCED); | 342 security_interstitials::MetricsHelper::SHOW_ADVANCED); |
341 break; | 343 break; |
342 case CMD_OPEN_DATE_SETTINGS: | 344 case ControllerClient::CMD_OPEN_DATE_SETTINGS: |
343 metrics_helper()->RecordUserInteraction( | 345 metrics_helper()->RecordUserInteraction( |
344 security_interstitials::MetricsHelper::OPEN_TIME_SETTINGS); | 346 security_interstitials::MetricsHelper::OPEN_TIME_SETTINGS); |
345 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, | 347 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, |
346 base::Bind(&LaunchDateAndTimeSettings)); | 348 base::Bind(&LaunchDateAndTimeSettings)); |
347 break; | 349 break; |
348 case CMD_OPEN_REPORTING_PRIVACY: | 350 case ControllerClient::CMD_OPEN_REPORTING_PRIVACY: |
349 OpenExtendedReportingPrivacyPolicy(); | 351 OpenExtendedReportingPrivacyPolicy(); |
350 break; | 352 break; |
351 case CMD_PROCEED: | 353 case ControllerClient::CMD_PROCEED: |
352 case CMD_OPEN_HELP_CENTER: | 354 case ControllerClient::CMD_OPEN_HELP_CENTER: |
353 case CMD_RELOAD: | 355 case ControllerClient::CMD_RELOAD: |
354 case CMD_OPEN_DIAGNOSTIC: | 356 case ControllerClient::CMD_OPEN_DIAGNOSTIC: |
355 // Not supported for the bad clock interstitial. | 357 // Not supported for the bad clock interstitial. |
356 NOTREACHED() << "Unexpected command: " << command; | 358 NOTREACHED() << "Unexpected command: " << command; |
357 } | 359 } |
358 } | 360 } |
359 | 361 |
360 void BadClockBlockingPage::OverrideRendererPrefs( | 362 void BadClockBlockingPage::OverrideRendererPrefs( |
361 content::RendererPreferences* prefs) { | 363 content::RendererPreferences* prefs) { |
362 Profile* profile = | 364 Profile* profile = |
363 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 365 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
364 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile, | 366 renderer_preferences_util::UpdateFromSystemSettings(prefs, profile, |
365 web_contents()); | 367 web_contents()); |
366 } | 368 } |
367 | 369 |
368 void BadClockBlockingPage::OnDontProceed() { | 370 void BadClockBlockingPage::OnDontProceed() { |
369 cert_report_helper_->FinishCertCollection( | 371 cert_report_helper_->FinishCertCollection( |
370 certificate_reporting::ErrorReport::USER_DID_NOT_PROCEED); | 372 certificate_reporting::ErrorReport::USER_DID_NOT_PROCEED); |
371 NotifyDenyCertificate(); | 373 NotifyDenyCertificate(); |
372 } | 374 } |
373 | 375 |
374 void BadClockBlockingPage::NotifyDenyCertificate() { | 376 void BadClockBlockingPage::NotifyDenyCertificate() { |
375 // It's possible that callback_ may not exist if the user clicks "Proceed" | 377 // It's possible that callback_ may not exist if the user clicks "Proceed" |
376 // followed by pressing the back button before the interstitial is hidden. | 378 // followed by pressing the back button before the interstitial is hidden. |
377 // In that case the certificate will still be treated as allowed. | 379 // In that case the certificate will still be treated as allowed. |
378 if (callback_.is_null()) | 380 if (callback_.is_null()) |
379 return; | 381 return; |
380 | 382 |
381 base::ResetAndReturn(&callback_).Run(false); | 383 base::ResetAndReturn(&callback_).Run(false); |
382 } | 384 } |
OLD | NEW |