| 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/ui/website_settings/website_settings.h" | 5 #include "chrome/browser/ui/website_settings/website_settings.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // Fullscreen and mouselock settings are no longer shown (always allow). | 126 // Fullscreen and mouselock settings are no longer shown (always allow). |
| 127 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN || | 127 if (type == CONTENT_SETTINGS_TYPE_FULLSCREEN || |
| 128 type == CONTENT_SETTINGS_TYPE_MOUSELOCK) { | 128 type == CONTENT_SETTINGS_TYPE_MOUSELOCK) { |
| 129 return false; | 129 return false; |
| 130 } | 130 } |
| 131 #endif | 131 #endif |
| 132 | 132 |
| 133 return true; | 133 return true; |
| 134 } | 134 } |
| 135 | 135 |
| 136 void CheckContentStatus(SecurityStateModel::ContentStatus content_status, |
| 137 bool* displayed, |
| 138 bool* ran) { |
| 139 switch (content_status) { |
| 140 case SecurityStateModel::CONTENT_STATUS_DISPLAYED: |
| 141 *displayed = true; |
| 142 break; |
| 143 case SecurityStateModel::CONTENT_STATUS_RAN: |
| 144 *ran = true; |
| 145 break; |
| 146 case SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN: |
| 147 *displayed = true; |
| 148 *ran = true; |
| 149 break; |
| 150 case SecurityStateModel::CONTENT_STATUS_UNKNOWN: |
| 151 case SecurityStateModel::CONTENT_STATUS_NONE: |
| 152 break; |
| 153 } |
| 154 } |
| 155 |
| 156 void CheckForInsecureContent( |
| 157 const SecurityStateModel::SecurityInfo& security_info, |
| 158 bool* displayed, |
| 159 bool* ran) { |
| 160 CheckContentStatus(security_info.mixed_content_status, displayed, ran); |
| 161 // Only consider subresources with certificate errors if the main |
| 162 // resource was loaded over HTTPS without major certificate errors. If |
| 163 // the main resource had a certificate error, then it would not be |
| 164 // that useful (and would potentially be confusing) to warn about |
| 165 // subesources that had certificate errors too. |
| 166 if (net::IsCertStatusError(security_info.cert_status) && |
| 167 !net::IsCertStatusMinorError(security_info.cert_status)) { |
| 168 return; |
| 169 } |
| 170 CheckContentStatus(security_info.content_with_cert_errors_status, displayed, |
| 171 ran); |
| 172 } |
| 173 |
| 136 // Returns true if any of the given statuses match |status|. | 174 // Returns true if any of the given statuses match |status|. |
| 137 bool CertificateTransparencyStatusMatchAny( | 175 bool CertificateTransparencyStatusMatchAny( |
| 138 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses, | 176 const std::vector<net::ct::SCTVerifyStatus>& sct_verify_statuses, |
| 139 net::ct::SCTVerifyStatus status) { | 177 net::ct::SCTVerifyStatus status) { |
| 140 for (const auto& verify_status : sct_verify_statuses) { | 178 for (const auto& verify_status : sct_verify_statuses) { |
| 141 if (verify_status == status) | 179 if (verify_status == status) |
| 142 return true; | 180 return true; |
| 143 } | 181 } |
| 144 return false; | 182 return false; |
| 145 } | 183 } |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 if (security_info.is_secure_protocol_and_ciphersuite) { | 590 if (security_info.is_secure_protocol_and_ciphersuite) { |
| 553 site_connection_details_.assign(l10n_util::GetStringFUTF16( | 591 site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 554 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, | 592 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, |
| 555 subject_name)); | 593 subject_name)); |
| 556 } else { | 594 } else { |
| 557 site_connection_details_.assign(l10n_util::GetStringFUTF16( | 595 site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 558 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, | 596 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, |
| 559 subject_name)); | 597 subject_name)); |
| 560 } | 598 } |
| 561 | 599 |
| 562 if (security_info.mixed_content_status != | 600 bool ran_insecure_content = false; |
| 563 SecurityStateModel::CONTENT_STATUS_NONE) { | 601 bool displayed_insecure_content = false; |
| 564 bool ran_insecure_content = | 602 CheckForInsecureContent(security_info, &displayed_insecure_content, |
| 565 (security_info.mixed_content_status == | 603 &ran_insecure_content); |
| 566 SecurityStateModel::CONTENT_STATUS_RAN || | 604 if (ran_insecure_content || displayed_insecure_content) { |
| 567 security_info.mixed_content_status == | 605 site_connection_status_ = |
| 568 SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN); | 606 ran_insecure_content |
| 569 site_connection_status_ = ran_insecure_content | 607 ? SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE |
| 570 ? SITE_CONNECTION_STATUS_MIXED_SCRIPT | 608 : SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE; |
| 571 : SITE_CONNECTION_STATUS_MIXED_CONTENT; | |
| 572 site_connection_details_.assign(l10n_util::GetStringFUTF16( | 609 site_connection_details_.assign(l10n_util::GetStringFUTF16( |
| 573 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, | 610 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_SENTENCE_LINK, |
| 574 site_connection_details_, | 611 site_connection_details_, |
| 575 l10n_util::GetStringUTF16(ran_insecure_content ? | 612 l10n_util::GetStringUTF16( |
| 576 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR : | 613 ran_insecure_content |
| 577 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNING))); | 614 ? IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_ERROR |
| 615 : IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_INSECURE_CONTENT_WARNIN
G))); |
| 578 } | 616 } |
| 579 } | 617 } |
| 580 | 618 |
| 581 uint16_t cipher_suite = | 619 uint16_t cipher_suite = |
| 582 net::SSLConnectionStatusToCipherSuite(security_info.connection_status); | 620 net::SSLConnectionStatusToCipherSuite(security_info.connection_status); |
| 583 if (security_info.security_bits > 0 && cipher_suite) { | 621 if (security_info.security_bits > 0 && cipher_suite) { |
| 584 int ssl_version = | 622 int ssl_version = |
| 585 net::SSLConnectionStatusToVersion(security_info.connection_status); | 623 net::SSLConnectionStatusToVersion(security_info.connection_status); |
| 586 const char* ssl_version_str; | 624 const char* ssl_version_str; |
| 587 net::SSLVersionToString(&ssl_version_str, ssl_version); | 625 net::SSLVersionToString(&ssl_version_str, ssl_version); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 603 site_connection_details_ += l10n_util::GetStringFUTF16( | 641 site_connection_details_ += l10n_util::GetStringFUTF16( |
| 604 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD, | 642 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD, |
| 605 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange)); | 643 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange)); |
| 606 } else { | 644 } else { |
| 607 site_connection_details_ += l10n_util::GetStringFUTF16( | 645 site_connection_details_ += l10n_util::GetStringFUTF16( |
| 608 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, | 646 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, |
| 609 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange)); | 647 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange)); |
| 610 } | 648 } |
| 611 | 649 |
| 612 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 && | 650 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 && |
| 613 site_connection_status_ < SITE_CONNECTION_STATUS_MIXED_CONTENT) { | 651 site_connection_status_ < |
| 652 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) { |
| 614 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; | 653 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; |
| 615 } | 654 } |
| 616 | 655 |
| 617 const bool did_fallback = (security_info.connection_status & | 656 const bool did_fallback = (security_info.connection_status & |
| 618 net::SSL_CONNECTION_VERSION_FALLBACK) != 0; | 657 net::SSL_CONNECTION_VERSION_FALLBACK) != 0; |
| 619 if (did_fallback) { | 658 if (did_fallback) { |
| 620 site_connection_details_ += ASCIIToUTF16("\n\n"); | 659 site_connection_details_ += ASCIIToUTF16("\n\n"); |
| 621 site_connection_details_ += l10n_util::GetStringUTF16( | 660 site_connection_details_ += l10n_util::GetStringUTF16( |
| 622 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE); | 661 IDS_PAGE_INFO_SECURITY_TAB_FALLBACK_MESSAGE); |
| 623 } | 662 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 639 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host()); | 678 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host()); |
| 640 | 679 |
| 641 // By default select the Permissions Tab that displays all the site | 680 // By default select the Permissions Tab that displays all the site |
| 642 // permissions. In case of a connection error or an issue with the certificate | 681 // permissions. In case of a connection error or an issue with the certificate |
| 643 // presented by the website, select the Connection Tab to draw the user's | 682 // presented by the website, select the Connection Tab to draw the user's |
| 644 // attention to the issue. If the site does not provide a certificate because | 683 // attention to the issue. If the site does not provide a certificate because |
| 645 // it was loaded over an unencrypted connection, don't select the Connection | 684 // it was loaded over an unencrypted connection, don't select the Connection |
| 646 // Tab. | 685 // Tab. |
| 647 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS; | 686 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS; |
| 648 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR || | 687 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR || |
| 649 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_CONTENT || | 688 site_connection_status_ == |
| 650 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_SCRIPT || | 689 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE || |
| 690 site_connection_status_ == |
| 691 SITE_CONNECTION_STATUS_INSECURE_ACTIVE_SUBRESOURCE || |
| 651 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR || | 692 site_identity_status_ == SITE_IDENTITY_STATUS_ERROR || |
| 652 site_identity_status_ == SITE_IDENTITY_STATUS_CT_ERROR || | 693 site_identity_status_ == SITE_IDENTITY_STATUS_CT_ERROR || |
| 653 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN || | 694 site_identity_status_ == SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN || |
| 654 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT || | 695 site_identity_status_ == SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT || |
| 655 site_identity_status_ == | 696 site_identity_status_ == |
| 656 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR || | 697 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MINOR || |
| 657 site_identity_status_ == | 698 site_identity_status_ == |
| 658 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) { | 699 SITE_IDENTITY_STATUS_DEPRECATED_SIGNATURE_ALGORITHM_MAJOR) { |
| 659 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION; | 700 tab_id = WebsiteSettingsUI::TAB_ID_CONNECTION; |
| 660 RecordWebsiteSettingsAction( | 701 RecordWebsiteSettingsAction( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 info.connection_status = site_connection_status_; | 800 info.connection_status = site_connection_status_; |
| 760 info.connection_status_description = | 801 info.connection_status_description = |
| 761 UTF16ToUTF8(site_connection_details_); | 802 UTF16ToUTF8(site_connection_details_); |
| 762 info.identity_status = site_identity_status_; | 803 info.identity_status = site_identity_status_; |
| 763 info.identity_status_description = | 804 info.identity_status_description = |
| 764 UTF16ToUTF8(site_identity_details_); | 805 UTF16ToUTF8(site_identity_details_); |
| 765 info.cert_id = cert_id_; | 806 info.cert_id = cert_id_; |
| 766 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; | 807 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; |
| 767 ui_->SetIdentityInfo(info); | 808 ui_->SetIdentityInfo(info); |
| 768 } | 809 } |
| OLD | NEW |