| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/browser/ssl/ios_ssl_blocking_page.h" | 5 #include "ios/chrome/browser/ssl/ios_ssl_blocking_page.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "components/security_interstitials/core/metrics_helper.h" | 13 #include "components/security_interstitials/core/metrics_helper.h" |
| 14 #include "components/security_interstitials/core/ssl_error_ui.h" | 14 #include "components/security_interstitials/core/ssl_error_ui.h" |
| 15 #include "grit/components_strings.h" | 15 #include "grit/components_strings.h" |
| 16 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 16 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 17 #include "ios/chrome/browser/interstitials/ios_chrome_controller_client.h" | 17 #include "ios/chrome/browser/interstitials/ios_chrome_controller_client.h" |
| 18 #include "ios/chrome/browser/interstitials/ios_chrome_metrics_helper.h" | 18 #include "ios/chrome/browser/interstitials/ios_chrome_metrics_helper.h" |
| 19 #include "ios/chrome/grit/ios_strings.h" | 19 #include "ios/chrome/grit/ios_strings.h" |
| 20 #include "ios/public/provider/chrome/browser/browser_constants.h" | 20 #include "ios/public/provider/chrome/browser/browser_constants.h" |
| 21 #include "ios/web/public/cert_store.h" | |
| 22 #import "ios/web/public/navigation_item.h" | 21 #import "ios/web/public/navigation_item.h" |
| 23 #include "ios/web/public/ssl_status.h" | 22 #include "ios/web/public/ssl_status.h" |
| 24 #include "ios/web/public/web_state/web_state.h" | 23 #include "ios/web/public/web_state/web_state.h" |
| 25 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 28 | 27 |
| 29 using security_interstitials::SSLErrorUI; | 28 using security_interstitials::SSLErrorUI; |
| 30 | 29 |
| 31 namespace { | 30 namespace { |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 187 } |
| 189 | 188 |
| 190 void IOSSSLBlockingPage::OverrideItem(web::NavigationItem* item) { | 189 void IOSSSLBlockingPage::OverrideItem(web::NavigationItem* item) { |
| 191 item->SetTitle(l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); | 190 item->SetTitle(l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); |
| 192 | 191 |
| 193 item->GetSSL().security_style = web::SECURITY_STYLE_AUTHENTICATION_BROKEN; | 192 item->GetSSL().security_style = web::SECURITY_STYLE_AUTHENTICATION_BROKEN; |
| 194 item->GetSSL().cert_status = ssl_info_.cert_status; | 193 item->GetSSL().cert_status = ssl_info_.cert_status; |
| 195 // On iOS cert may be null when it is not provided by API callback or can not | 194 // On iOS cert may be null when it is not provided by API callback or can not |
| 196 // be parsed. | 195 // be parsed. |
| 197 if (ssl_info_.cert) { | 196 if (ssl_info_.cert) { |
| 198 item->GetSSL().cert_id = web::CertStore::GetInstance()->StoreCert( | 197 item->GetSSL().certificate = ssl_info_.cert; |
| 199 ssl_info_.cert.get(), web_state()->GetCertGroupId()); | |
| 200 } | 198 } |
| 201 } | 199 } |
| 202 | 200 |
| 203 void IOSSSLBlockingPage::NotifyDenyCertificate() { | 201 void IOSSSLBlockingPage::NotifyDenyCertificate() { |
| 204 // It's possible that callback_ may not exist if the user clicks "Proceed" | 202 // It's possible that callback_ may not exist if the user clicks "Proceed" |
| 205 // followed by pressing the back button before the interstitial is hidden. | 203 // followed by pressing the back button before the interstitial is hidden. |
| 206 // In that case the certificate will still be treated as allowed. | 204 // In that case the certificate will still be treated as allowed. |
| 207 if (callback_.is_null()) | 205 if (callback_.is_null()) |
| 208 return; | 206 return; |
| 209 | 207 |
| 210 callback_.Run(false); | 208 callback_.Run(false); |
| 211 callback_.Reset(); | 209 callback_.Reset(); |
| 212 } | 210 } |
| 213 | 211 |
| 214 // static | 212 // static |
| 215 bool IOSSSLBlockingPage::IsOverridable(int options_mask) { | 213 bool IOSSSLBlockingPage::IsOverridable(int options_mask) { |
| 216 const bool is_overridable = | 214 const bool is_overridable = |
| 217 (options_mask & SSLErrorUI::SOFT_OVERRIDE_ENABLED) && | 215 (options_mask & SSLErrorUI::SOFT_OVERRIDE_ENABLED) && |
| 218 !(options_mask & SSLErrorUI::STRICT_ENFORCEMENT); | 216 !(options_mask & SSLErrorUI::STRICT_ENFORCEMENT); |
| 219 return is_overridable; | 217 return is_overridable; |
| 220 } | 218 } |
| OLD | NEW |