| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/interstitials/chrome_controller_client.h" | 17 #include "chrome/browser/interstitials/chrome_controller_client.h" |
| 18 #include "chrome/browser/interstitials/chrome_metrics_helper.h" | 18 #include "chrome/browser/interstitials/chrome_metrics_helper.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/renderer_preferences_util.h" | 20 #include "chrome/browser/renderer_preferences_util.h" |
| 21 #include "chrome/browser/ssl/cert_report_helper.h" | 21 #include "chrome/browser/ssl/cert_report_helper.h" |
| 22 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 22 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
| 23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 25 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
| 26 #include "components/security_interstitials/core/controller_client.h" | 26 #include "components/security_interstitials/core/controller_client.h" |
| 27 #include "components/security_interstitials/core/metrics_helper.h" | 27 #include "components/security_interstitials/core/metrics_helper.h" |
| 28 #include "components/security_interstitials/core/ssl_error_ui.h" | 28 #include "components/security_interstitials/core/ssl_error_ui.h" |
| 29 #include "content/public/browser/cert_store.h" | |
| 30 #include "content/public/browser/interstitial_page.h" | 29 #include "content/public/browser/interstitial_page.h" |
| 31 #include "content/public/browser/interstitial_page_delegate.h" | 30 #include "content/public/browser/interstitial_page_delegate.h" |
| 32 #include "content/public/browser/navigation_entry.h" | 31 #include "content/public/browser/navigation_entry.h" |
| 33 #include "content/public/browser/render_process_host.h" | 32 #include "content/public/browser/render_process_host.h" |
| 34 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| 35 #include "content/public/common/renderer_preferences.h" | 34 #include "content/public/common/renderer_preferences.h" |
| 36 #include "content/public/common/ssl_status.h" | 35 #include "content/public/common/ssl_status.h" |
| 37 #include "net/base/net_errors.h" | 36 #include "net/base/net_errors.h" |
| 38 | 37 |
| 39 using base::TimeTicks; | 38 using base::TimeTicks; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 controller_->set_interstitial_page(interstitial_page()); | 185 controller_->set_interstitial_page(interstitial_page()); |
| 187 } | 186 } |
| 188 | 187 |
| 189 void SSLBlockingPage::PopulateInterstitialStrings( | 188 void SSLBlockingPage::PopulateInterstitialStrings( |
| 190 base::DictionaryValue* load_time_data) { | 189 base::DictionaryValue* load_time_data) { |
| 191 ssl_error_ui_->PopulateStringsForHTML(load_time_data); | 190 ssl_error_ui_->PopulateStringsForHTML(load_time_data); |
| 192 cert_report_helper_->PopulateExtendedReportingOption(load_time_data); | 191 cert_report_helper_->PopulateExtendedReportingOption(load_time_data); |
| 193 } | 192 } |
| 194 | 193 |
| 195 void SSLBlockingPage::OverrideEntry(NavigationEntry* entry) { | 194 void SSLBlockingPage::OverrideEntry(NavigationEntry* entry) { |
| 196 const int process_id = web_contents()->GetRenderProcessHost()->GetID(); | |
| 197 const int cert_id = content::CertStore::GetInstance()->StoreCert( | |
| 198 ssl_info_.cert.get(), process_id); | |
| 199 DCHECK(cert_id); | |
| 200 | |
| 201 entry->GetSSL() = content::SSLStatus( | 195 entry->GetSSL() = content::SSLStatus( |
| 202 content::SECURITY_STYLE_AUTHENTICATION_BROKEN, cert_id, ssl_info_); | 196 content::SECURITY_STYLE_AUTHENTICATION_BROKEN, ssl_info_.cert, ssl_info_); |
| 203 } | 197 } |
| 204 | 198 |
| 205 void SSLBlockingPage::SetSSLCertReporterForTesting( | 199 void SSLBlockingPage::SetSSLCertReporterForTesting( |
| 206 std::unique_ptr<SSLCertReporter> ssl_cert_reporter) { | 200 std::unique_ptr<SSLCertReporter> ssl_cert_reporter) { |
| 207 cert_report_helper_->SetSSLCertReporterForTesting( | 201 cert_report_helper_->SetSSLCertReporterForTesting( |
| 208 std::move(ssl_cert_reporter)); | 202 std::move(ssl_cert_reporter)); |
| 209 } | 203 } |
| 210 | 204 |
| 211 // This handles the commands sent from the interstitial JavaScript. | 205 // This handles the commands sent from the interstitial JavaScript. |
| 212 void SSLBlockingPage::CommandReceived(const std::string& command) { | 206 void SSLBlockingPage::CommandReceived(const std::string& command) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 261 |
| 268 // static | 262 // static |
| 269 bool SSLBlockingPage::IsOverridable(int options_mask, | 263 bool SSLBlockingPage::IsOverridable(int options_mask, |
| 270 const Profile* const profile) { | 264 const Profile* const profile) { |
| 271 const bool is_overridable = | 265 const bool is_overridable = |
| 272 (options_mask & SSLErrorUI::SOFT_OVERRIDE_ENABLED) && | 266 (options_mask & SSLErrorUI::SOFT_OVERRIDE_ENABLED) && |
| 273 !(options_mask & SSLErrorUI::STRICT_ENFORCEMENT) && | 267 !(options_mask & SSLErrorUI::STRICT_ENFORCEMENT) && |
| 274 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); | 268 profile->GetPrefs()->GetBoolean(prefs::kSSLErrorOverrideAllowed); |
| 275 return is_overridable; | 269 return is_overridable; |
| 276 } | 270 } |
| OLD | NEW |