| 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 "ios/chrome/browser/ui/omnibox/page_info_model.h" | 5 #include "ios/chrome/browser/ui/omnibox/page_info_model.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 base::string16 summary; | 62 base::string16 summary; |
| 63 base::string16 details; | 63 base::string16 details; |
| 64 base::string16 certificate_details; | 64 base::string16 certificate_details; |
| 65 | 65 |
| 66 // Summary and details. | 66 // Summary and details. |
| 67 SectionStateIcon icon_id = ICON_NONE; | 67 SectionStateIcon icon_id = ICON_NONE; |
| 68 if (!ssl.certificate) { | 68 if (!ssl.certificate) { |
| 69 // Not HTTPS. | 69 // Not HTTPS. |
| 70 icon_id = ICON_STATE_INFO; | 70 icon_id = ICON_STATE_INFO; |
| 71 summary.assign(l10n_util::GetStringUTF16(IDS_PAGEINFO_NOT_SECURE_SUMMARY)); | 71 summary.assign(l10n_util::GetStringUTF16(IDS_PAGE_INFO_NOT_SECURE_SUMMARY)); |
| 72 details.assign(l10n_util::GetStringUTF16(IDS_PAGEINFO_NOT_SECURE_DETAILS)); | 72 details.assign(l10n_util::GetStringUTF16(IDS_PAGE_INFO_NOT_SECURE_DETAILS)); |
| 73 } else { | 73 } else { |
| 74 // It is possible to have |SECURITY_STYLE_AUTHENTICATION_BROKEN| and | 74 // It is possible to have |SECURITY_STYLE_AUTHENTICATION_BROKEN| and |
| 75 // non-error | 75 // non-error |
| 76 // |cert_status| for WKWebView because |security_style| and |cert_status| | 76 // |cert_status| for WKWebView because |security_style| and |cert_status| |
| 77 // are | 77 // are |
| 78 // calculated using different API, which may lead to different cert | 78 // calculated using different API, which may lead to different cert |
| 79 // verification results. | 79 // verification results. |
| 80 if (net::IsCertStatusError(ssl.cert_status) || | 80 if (net::IsCertStatusError(ssl.cert_status) || |
| 81 ssl.security_style == web::SECURITY_STYLE_AUTHENTICATION_BROKEN) { | 81 ssl.security_style == web::SECURITY_STYLE_AUTHENTICATION_BROKEN) { |
| 82 // HTTPS with major errors | 82 // HTTPS with major errors |
| 83 icon_id = ICON_STATE_ERROR; | 83 icon_id = ICON_STATE_ERROR; |
| 84 DCHECK(!net::IsCertStatusMinorError(ssl.cert_status)); | 84 DCHECK(!net::IsCertStatusMinorError(ssl.cert_status)); |
| 85 summary.assign( | 85 summary.assign( |
| 86 l10n_util::GetStringUTF16(IDS_PAGEINFO_NOT_SECURE_SUMMARY)); | 86 l10n_util::GetStringUTF16(IDS_PAGE_INFO_NOT_SECURE_SUMMARY)); |
| 87 details.assign( | 87 details.assign( |
| 88 l10n_util::GetStringUTF16(IDS_PAGEINFO_NOT_SECURE_DETAILS)); | 88 l10n_util::GetStringUTF16(IDS_PAGE_INFO_NOT_SECURE_DETAILS)); |
| 89 | 89 |
| 90 certificate_details.assign(l10n_util::GetStringUTF16( | 90 certificate_details.assign(l10n_util::GetStringUTF16( |
| 91 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); | 91 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); |
| 92 const base::string16 bullet = base::UTF8ToUTF16("\n • "); | 92 const base::string16 bullet = base::UTF8ToUTF16("\n • "); |
| 93 std::vector<ssl_errors::ErrorInfo> errors; | 93 std::vector<ssl_errors::ErrorInfo> errors; |
| 94 ssl_errors::ErrorInfo::GetErrorsForCertStatus( | 94 ssl_errors::ErrorInfo::GetErrorsForCertStatus( |
| 95 ssl.certificate, ssl.cert_status, url, &errors); | 95 ssl.certificate, ssl.cert_status, url, &errors); |
| 96 for (size_t i = 0; i < errors.size(); ++i) { | 96 for (size_t i = 0; i < errors.size(); ++i) { |
| 97 certificate_details += bullet; | 97 certificate_details += bullet; |
| 98 certificate_details += errors[i].short_description(); | 98 certificate_details += errors[i].short_description(); |
| 99 } | 99 } |
| 100 } else { | 100 } else { |
| 101 // Valid HTTPS or HTTPS with minor errors. | 101 // Valid HTTPS or HTTPS with minor errors. |
| 102 base::string16 issuer_name( | 102 base::string16 issuer_name( |
| 103 base::UTF8ToUTF16(ssl.certificate->issuer().GetDisplayName())); | 103 base::UTF8ToUTF16(ssl.certificate->issuer().GetDisplayName())); |
| 104 if (!issuer_name.empty()) { | 104 if (!issuer_name.empty()) { |
| 105 // Show the issuer name if it's available. | 105 // Show the issuer name if it's available. |
| 106 // TODO(crbug.com/502470): Implement a certificate viewer instead. | 106 // TODO(crbug.com/502470): Implement a certificate viewer instead. |
| 107 certificate_details.assign(l10n_util::GetStringFUTF16( | 107 certificate_details.assign(l10n_util::GetStringFUTF16( |
| 108 IDS_IOS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name)); | 108 IDS_IOS_PAGE_INFO_SECURITY_TAB_SECURE_IDENTITY, issuer_name)); |
| 109 } | 109 } |
| 110 if (ssl.content_status == web::SSLStatus::DISPLAYED_INSECURE_CONTENT) { | 110 if (ssl.content_status == web::SSLStatus::DISPLAYED_INSECURE_CONTENT) { |
| 111 // HTTPS with mixed content. | 111 // HTTPS with mixed content. |
| 112 icon_id = ICON_STATE_INFO; | 112 icon_id = ICON_STATE_INFO; |
| 113 summary.assign( | 113 summary.assign( |
| 114 l10n_util::GetStringUTF16(IDS_PAGEINFO_MIXED_CONTENT_SUMMARY)); | 114 l10n_util::GetStringUTF16(IDS_PAGE_INFO_MIXED_CONTENT_SUMMARY)); |
| 115 details.assign( | 115 details.assign( |
| 116 l10n_util::GetStringUTF16(IDS_PAGEINFO_MIXED_CONTENT_DETAILS)); | 116 l10n_util::GetStringUTF16(IDS_PAGE_INFO_MIXED_CONTENT_DETAILS)); |
| 117 } else { | 117 } else { |
| 118 // Valid HTTPS | 118 // Valid HTTPS |
| 119 icon_id = ICON_STATE_OK; | 119 icon_id = ICON_STATE_OK; |
| 120 summary.assign(l10n_util::GetStringUTF16(IDS_PAGEINFO_SECURE_SUMMARY)); | 120 summary.assign(l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURE_SUMMARY)); |
| 121 details.assign(l10n_util::GetStringUTF16(IDS_PAGEINFO_SECURE_DETAILS)); | 121 details.assign(l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURE_DETAILS)); |
| 122 | 122 |
| 123 DCHECK(!(ssl.cert_status & net::CERT_STATUS_IS_EV)) | 123 DCHECK(!(ssl.cert_status & net::CERT_STATUS_IS_EV)) |
| 124 << "Extended Validation should be disabled"; | 124 << "Extended Validation should be disabled"; |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 base::string16 description; | 129 base::string16 description; |
| 130 base::string16 spacer = base::UTF8ToUTF16("\n\n"); | 130 base::string16 spacer = base::UTF8ToUTF16("\n\n"); |
| 131 | 131 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 case ICON_STATE_OFFLINE_PAGE: | 169 case ICON_STATE_OFFLINE_PAGE: |
| 170 return &rb.GetNativeImageNamed(IDR_IOS_OMNIBOX_OFFLINE); | 170 return &rb.GetNativeImageNamed(IDR_IOS_OMNIBOX_OFFLINE); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 base::string16 PageInfoModel::GetCertificateLabel() const { | 174 base::string16 PageInfoModel::GetCertificateLabel() const { |
| 175 return certificate_label_; | 175 return certificate_label_; |
| 176 } | 176 } |
| 177 | 177 |
| 178 PageInfoModel::PageInfoModel() : observer_(NULL) {} | 178 PageInfoModel::PageInfoModel() : observer_(NULL) {} |
| OLD | NEW |