| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/grit/chromium_strings.h" | 31 #include "chrome/grit/chromium_strings.h" |
| 32 #include "chrome/grit/generated_resources.h" | 32 #include "chrome/grit/generated_resources.h" |
| 33 #include "components/google/core/browser/google_util.h" | 33 #include "components/google/core/browser/google_util.h" |
| 34 #include "components/security_interstitials/core/controller_client.h" |
| 34 #include "components/ssl_errors/error_classification.h" | 35 #include "components/ssl_errors/error_classification.h" |
| 35 #include "components/ssl_errors/error_info.h" | 36 #include "components/ssl_errors/error_info.h" |
| 36 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
| 37 #include "content/public/browser/cert_store.h" | 38 #include "content/public/browser/cert_store.h" |
| 38 #include "content/public/browser/interstitial_page.h" | 39 #include "content/public/browser/interstitial_page.h" |
| 39 #include "content/public/browser/interstitial_page_delegate.h" | 40 #include "content/public/browser/interstitial_page_delegate.h" |
| 40 #include "content/public/browser/navigation_controller.h" | 41 #include "content/public/browser/navigation_controller.h" |
| 41 #include "content/public/browser/navigation_entry.h" | 42 #include "content/public/browser/navigation_entry.h" |
| 42 #include "content/public/browser/notification_service.h" | 43 #include "content/public/browser/notification_service.h" |
| 43 #include "content/public/browser/notification_types.h" | 44 #include "content/public/browser/notification_types.h" |
| 44 #include "content/public/browser/render_process_host.h" | 45 #include "content/public/browser/render_process_host.h" |
| 45 #include "content/public/browser/render_view_host.h" | 46 #include "content/public/browser/render_view_host.h" |
| 46 #include "content/public/browser/signed_certificate_timestamp_store.h" | 47 #include "content/public/browser/signed_certificate_timestamp_store.h" |
| 47 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
| 48 #include "content/public/common/renderer_preferences.h" | 49 #include "content/public/common/renderer_preferences.h" |
| 49 #include "content/public/common/ssl_status.h" | 50 #include "content/public/common/ssl_status.h" |
| 50 #include "grit/browser_resources.h" | 51 #include "grit/browser_resources.h" |
| 51 #include "grit/components_strings.h" | 52 #include "grit/components_strings.h" |
| 52 #include "net/base/hash_value.h" | 53 #include "net/base/hash_value.h" |
| 53 #include "net/base/net_errors.h" | 54 #include "net/base/net_errors.h" |
| 54 #include "net/base/net_util.h" | 55 #include "net/base/net_util.h" |
| 55 #include "ui/base/l10n/l10n_util.h" | 56 #include "ui/base/l10n/l10n_util.h" |
| 56 | 57 |
| 57 using base::ASCIIToUTF16; | 58 using base::ASCIIToUTF16; |
| 58 using base::TimeTicks; | 59 using base::TimeTicks; |
| 59 using content::InterstitialPage; | 60 using content::InterstitialPage; |
| 60 using content::InterstitialPageDelegate; | 61 using content::InterstitialPageDelegate; |
| 61 using content::NavigationController; | 62 using content::NavigationController; |
| 62 using content::NavigationEntry; | 63 using content::NavigationEntry; |
| 64 using security_interstitials::ControllerClient; |
| 63 | 65 |
| 64 namespace { | 66 namespace { |
| 65 | 67 |
| 66 // URL for help page. | 68 // URL for help page. |
| 67 const char kHelpURL[] = "https://support.google.com/chrome/answer/4454607"; | 69 const char kHelpURL[] = "https://support.google.com/chrome/answer/4454607"; |
| 68 | 70 |
| 69 // Constants for the Experience Sampling instrumentation. | 71 // Constants for the Experience Sampling instrumentation. |
| 70 const char kEventNameBase[] = "ssl_interstitial_"; | 72 const char kEventNameBase[] = "ssl_interstitial_"; |
| 71 const char kEventNotOverridable[] = "notoverridable_"; | 73 const char kEventNotOverridable[] = "notoverridable_"; |
| 72 const char kEventOverridable[] = "overridable_"; | 74 const char kEventOverridable[] = "overridable_"; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 if (command == "\"pageLoadComplete\"") { | 309 if (command == "\"pageLoadComplete\"") { |
| 308 // content::WaitForRenderFrameReady sends this message when the page | 310 // content::WaitForRenderFrameReady sends this message when the page |
| 309 // load completes. Ignore it. | 311 // load completes. Ignore it. |
| 310 return; | 312 return; |
| 311 } | 313 } |
| 312 | 314 |
| 313 int cmd = 0; | 315 int cmd = 0; |
| 314 bool retval = base::StringToInt(command, &cmd); | 316 bool retval = base::StringToInt(command, &cmd); |
| 315 DCHECK(retval); | 317 DCHECK(retval); |
| 316 switch (cmd) { | 318 switch (cmd) { |
| 317 case CMD_DONT_PROCEED: { | 319 case ControllerClient::CMD_DONT_PROCEED: { |
| 318 interstitial_page()->DontProceed(); | 320 interstitial_page()->DontProceed(); |
| 319 break; | 321 break; |
| 320 } | 322 } |
| 321 case CMD_PROCEED: { | 323 case ControllerClient::CMD_PROCEED: { |
| 322 if (danger_overridable_) { | 324 if (danger_overridable_) { |
| 323 interstitial_page()->Proceed(); | 325 interstitial_page()->Proceed(); |
| 324 } | 326 } |
| 325 break; | 327 break; |
| 326 } | 328 } |
| 327 case CMD_DO_REPORT: { | 329 case ControllerClient::CMD_DO_REPORT: { |
| 328 SetReportingPreference(true); | 330 SetReportingPreference(true); |
| 329 break; | 331 break; |
| 330 } | 332 } |
| 331 case CMD_DONT_REPORT: { | 333 case ControllerClient::CMD_DONT_REPORT: { |
| 332 SetReportingPreference(false); | 334 SetReportingPreference(false); |
| 333 break; | 335 break; |
| 334 } | 336 } |
| 335 case CMD_SHOW_MORE_SECTION: { | 337 case ControllerClient::CMD_SHOW_MORE_SECTION: { |
| 336 metrics_helper()->RecordUserInteraction( | 338 metrics_helper()->RecordUserInteraction( |
| 337 security_interstitials::MetricsHelper::SHOW_ADVANCED); | 339 security_interstitials::MetricsHelper::SHOW_ADVANCED); |
| 338 break; | 340 break; |
| 339 } | 341 } |
| 340 case CMD_OPEN_HELP_CENTER: { | 342 case ControllerClient::CMD_OPEN_HELP_CENTER: { |
| 341 metrics_helper()->RecordUserInteraction( | 343 metrics_helper()->RecordUserInteraction( |
| 342 security_interstitials::MetricsHelper::SHOW_LEARN_MORE); | 344 security_interstitials::MetricsHelper::SHOW_LEARN_MORE); |
| 343 content::NavigationController::LoadURLParams help_page_params( | 345 content::NavigationController::LoadURLParams help_page_params( |
| 344 google_util::AppendGoogleLocaleParam( | 346 google_util::AppendGoogleLocaleParam( |
| 345 GURL(kHelpURL), g_browser_process->GetApplicationLocale())); | 347 GURL(kHelpURL), g_browser_process->GetApplicationLocale())); |
| 346 web_contents()->GetController().LoadURLWithParams(help_page_params); | 348 web_contents()->GetController().LoadURLWithParams(help_page_params); |
| 347 break; | 349 break; |
| 348 } | 350 } |
| 349 case CMD_RELOAD: { | 351 case ControllerClient::CMD_RELOAD: { |
| 350 metrics_helper()->RecordUserInteraction( | 352 metrics_helper()->RecordUserInteraction( |
| 351 security_interstitials::MetricsHelper::RELOAD); | 353 security_interstitials::MetricsHelper::RELOAD); |
| 352 // The interstitial can't refresh itself. | 354 // The interstitial can't refresh itself. |
| 353 web_contents()->GetController().Reload(true); | 355 web_contents()->GetController().Reload(true); |
| 354 break; | 356 break; |
| 355 } | 357 } |
| 356 case CMD_OPEN_REPORTING_PRIVACY: | 358 case ControllerClient::CMD_OPEN_REPORTING_PRIVACY: |
| 357 OpenExtendedReportingPrivacyPolicy(); | 359 OpenExtendedReportingPrivacyPolicy(); |
| 358 break; | 360 break; |
| 359 case CMD_OPEN_DATE_SETTINGS: | 361 case ControllerClient::CMD_OPEN_DATE_SETTINGS: |
| 360 case CMD_OPEN_DIAGNOSTIC: | 362 case ControllerClient::CMD_OPEN_DIAGNOSTIC: |
| 361 // Commands not supported by the SSL interstitial. | 363 // Commands not supported by the SSL interstitial. |
| 362 NOTREACHED() << "Unexpected command: " << command; | 364 NOTREACHED() << "Unexpected command: " << command; |
| 363 } | 365 } |
| 364 } | 366 } |
| 365 | 367 |
| 366 void SSLBlockingPage::OverrideRendererPrefs( | 368 void SSLBlockingPage::OverrideRendererPrefs( |
| 367 content::RendererPreferences* prefs) { | 369 content::RendererPreferences* prefs) { |
| 368 Profile* profile = Profile::FromBrowserContext( | 370 Profile* profile = Profile::FromBrowserContext( |
| 369 web_contents()->GetBrowserContext()); | 371 web_contents()->GetBrowserContext()); |
| 370 renderer_preferences_util::UpdateFromSystemSettings( | 372 renderer_preferences_util::UpdateFromSystemSettings( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT) && | 442 !(options_mask & SSLBlockingPage::STRICT_ENFORCEMENT) && |
| 441 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); | 443 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); |
| 442 return is_overridable; | 444 return is_overridable; |
| 443 } | 445 } |
| 444 | 446 |
| 445 // static | 447 // static |
| 446 bool SSLBlockingPage::DoesPolicyAllowDangerOverride( | 448 bool SSLBlockingPage::DoesPolicyAllowDangerOverride( |
| 447 const Profile* const profile) { | 449 const Profile* const profile) { |
| 448 return profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); | 450 return profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); |
| 449 } | 451 } |
| OLD | NEW |