| 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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 const GURL& url, | 356 const GURL& url, |
| 357 const SecurityStateModel::SecurityInfo& security_info) { | 357 const SecurityStateModel::SecurityInfo& security_info) { |
| 358 bool isChromeUINativeScheme = false; | 358 bool isChromeUINativeScheme = false; |
| 359 #if BUILDFLAG(ANDROID_JAVA_UI) | 359 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 360 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme); | 360 isChromeUINativeScheme = url.SchemeIs(chrome::kChromeUINativeScheme); |
| 361 #endif | 361 #endif |
| 362 | 362 |
| 363 if (url.SchemeIs(url::kAboutScheme)) { | 363 if (url.SchemeIs(url::kAboutScheme)) { |
| 364 // All about: URLs except about:blank are redirected. | 364 // All about: URLs except about:blank are redirected. |
| 365 DCHECK_EQ(url::kAboutBlankURL, url.spec()); | 365 DCHECK_EQ(url::kAboutBlankURL, url.spec()); |
| 366 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT; | |
| 367 site_identity_details_ = | |
| 368 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY); | |
| 369 site_connection_status_ = SITE_CONNECTION_STATUS_UNENCRYPTED; | |
| 370 site_connection_details_ = l10n_util::GetStringFUTF16( | |
| 371 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, | |
| 372 UTF8ToUTF16(url.spec())); | |
| 373 return; | |
| 374 } | 366 } |
| 375 | 367 |
| 376 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) { | 368 if (url.SchemeIs(content::kChromeUIScheme) || isChromeUINativeScheme) { |
| 377 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE; | 369 site_identity_status_ = SITE_IDENTITY_STATUS_INTERNAL_PAGE; |
| 378 site_identity_details_ = | 370 site_identity_details_ = |
| 379 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); | 371 l10n_util::GetStringUTF16(IDS_PAGE_INFO_INTERNAL_PAGE); |
| 380 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE; | 372 site_connection_status_ = SITE_CONNECTION_STATUS_INTERNAL_PAGE; |
| 381 return; | 373 return; |
| 382 } | 374 } |
| 383 | 375 |
| 384 // Identity section. | 376 // Identity section. |
| 385 scoped_refptr<net::X509Certificate> cert; | 377 scoped_refptr<net::X509Certificate> cert; |
| 386 cert_id_ = security_info.cert_id; | 378 cert_id_ = security_info.cert_id; |
| 387 | 379 |
| 388 // HTTPS with no or minor errors. | 380 // HTTPS with no or minor errors. |
| 389 if (security_info.cert_id && | 381 if (security_info.cert_id && |
| 390 cert_store_->RetrieveCert(security_info.cert_id, &cert) && | 382 cert_store_->RetrieveCert(security_info.cert_id, &cert) && |
| 391 (!net::IsCertStatusError(security_info.cert_status) || | 383 (!net::IsCertStatusError(security_info.cert_status) || |
| 392 net::IsCertStatusMinorError(security_info.cert_status))) { | 384 net::IsCertStatusMinorError(security_info.cert_status))) { |
| 393 // There are no major errors. Check for minor errors. | 385 // There are no major errors. Check for minor errors. |
| 394 if (security_info.security_level == | 386 if (security_info.security_level == |
| 395 SecurityStateModel::SECURITY_POLICY_WARNING) { | 387 SecurityStateModel::SECURITY_POLICY_WARNING) { |
| 396 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT; | 388 site_identity_status_ = SITE_IDENTITY_STATUS_ADMIN_PROVIDED_CERT; |
| 397 site_identity_details_ = l10n_util::GetStringFUTF16( | 389 site_identity_details_ = l10n_util::GetStringFUTF16( |
| 398 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(url.host())); | 390 IDS_CERT_POLICY_PROVIDED_CERT_MESSAGE, UTF8ToUTF16(site_url_.host())); |
| 399 } else if (net::IsCertStatusMinorError(security_info.cert_status)) { | 391 } else if (net::IsCertStatusMinorError(security_info.cert_status)) { |
| 400 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN; | 392 site_identity_status_ = SITE_IDENTITY_STATUS_CERT_REVOCATION_UNKNOWN; |
| 401 base::string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName())); | 393 base::string16 issuer_name(UTF8ToUTF16(cert->issuer().GetDisplayName())); |
| 402 if (issuer_name.empty()) { | 394 if (issuer_name.empty()) { |
| 403 issuer_name.assign(l10n_util::GetStringUTF16( | 395 issuer_name.assign(l10n_util::GetStringUTF16( |
| 404 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); | 396 IDS_PAGE_INFO_SECURITY_TAB_UNKNOWN_PARTY)); |
| 405 } | 397 } |
| 406 | 398 |
| 407 site_identity_details_.assign(l10n_util::GetStringFUTF16( | 399 site_identity_details_.assign(l10n_util::GetStringFUTF16( |
| 408 GetSiteIdentityDetailsMessageByCTInfo( | 400 GetSiteIdentityDetailsMessageByCTInfo( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 site_identity_details_.assign(l10n_util::GetStringUTF16( | 486 site_identity_details_.assign(l10n_util::GetStringUTF16( |
| 495 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); | 487 IDS_PAGE_INFO_SECURITY_TAB_INSECURE_IDENTITY)); |
| 496 if (!security_info.scheme_is_cryptographic || !security_info.cert_id) | 488 if (!security_info.scheme_is_cryptographic || !security_info.cert_id) |
| 497 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT; | 489 site_identity_status_ = SITE_IDENTITY_STATUS_NO_CERT; |
| 498 else | 490 else |
| 499 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR; | 491 site_identity_status_ = SITE_IDENTITY_STATUS_ERROR; |
| 500 | 492 |
| 501 const base::string16 bullet = UTF8ToUTF16("\n • "); | 493 const base::string16 bullet = UTF8ToUTF16("\n • "); |
| 502 std::vector<ssl_errors::ErrorInfo> errors; | 494 std::vector<ssl_errors::ErrorInfo> errors; |
| 503 ssl_errors::ErrorInfo::GetErrorsForCertStatus( | 495 ssl_errors::ErrorInfo::GetErrorsForCertStatus( |
| 504 cert, security_info.cert_status, url, &errors); | 496 cert, security_info.cert_status, site_url_, &errors); |
| 505 for (size_t i = 0; i < errors.size(); ++i) { | 497 for (size_t i = 0; i < errors.size(); ++i) { |
| 506 site_identity_details_ += bullet; | 498 site_identity_details_ += bullet; |
| 507 site_identity_details_ += errors[i].short_description(); | 499 site_identity_details_ += errors[i].short_description(); |
| 508 } | 500 } |
| 509 | 501 |
| 510 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) { | 502 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) { |
| 511 site_identity_details_ += ASCIIToUTF16("\n\n"); | 503 site_identity_details_ += ASCIIToUTF16("\n\n"); |
| 512 site_identity_details_ += l10n_util::GetStringUTF16( | 504 site_identity_details_ += l10n_util::GetStringUTF16( |
| 513 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME); | 505 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME); |
| 514 } | 506 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 } | 618 } |
| 627 } | 619 } |
| 628 | 620 |
| 629 // Check if a user decision has been made to allow or deny certificates with | 621 // Check if a user decision has been made to allow or deny certificates with |
| 630 // errors on this site. | 622 // errors on this site. |
| 631 ChromeSSLHostStateDelegate* delegate = | 623 ChromeSSLHostStateDelegate* delegate = |
| 632 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_); | 624 ChromeSSLHostStateDelegateFactory::GetForProfile(profile_); |
| 633 DCHECK(delegate); | 625 DCHECK(delegate); |
| 634 // Only show an SSL decision revoke button if the user has chosen to bypass | 626 // Only show an SSL decision revoke button if the user has chosen to bypass |
| 635 // SSL host errors for this host in the past. | 627 // SSL host errors for this host in the past. |
| 636 show_ssl_decision_revoke_button_ = delegate->HasAllowException(url.host()); | 628 show_ssl_decision_revoke_button_ = |
| 629 delegate->HasAllowException(site_url_.host()); |
| 637 | 630 |
| 638 // By default select the Permissions Tab that displays all the site | 631 // By default select the Permissions Tab that displays all the site |
| 639 // permissions. In case of a connection error or an issue with the certificate | 632 // permissions. In case of a connection error or an issue with the certificate |
| 640 // presented by the website, select the Connection Tab to draw the user's | 633 // presented by the website, select the Connection Tab to draw the user's |
| 641 // attention to the issue. If the site does not provide a certificate because | 634 // attention to the issue. If the site does not provide a certificate because |
| 642 // it was loaded over an unencrypted connection, don't select the Connection | 635 // it was loaded over an unencrypted connection, don't select the Connection |
| 643 // Tab. | 636 // Tab. |
| 644 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS; | 637 WebsiteSettingsUI::TabId tab_id = WebsiteSettingsUI::TAB_ID_PERMISSIONS; |
| 645 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR || | 638 if (site_connection_status_ == SITE_CONNECTION_STATUS_ENCRYPTED_ERROR || |
| 646 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_CONTENT || | 639 site_connection_status_ == SITE_CONNECTION_STATUS_MIXED_CONTENT || |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 info.connection_status = site_connection_status_; | 753 info.connection_status = site_connection_status_; |
| 761 info.connection_status_description = | 754 info.connection_status_description = |
| 762 UTF16ToUTF8(site_connection_details_); | 755 UTF16ToUTF8(site_connection_details_); |
| 763 info.identity_status = site_identity_status_; | 756 info.identity_status = site_identity_status_; |
| 764 info.identity_status_description = | 757 info.identity_status_description = |
| 765 UTF16ToUTF8(site_identity_details_); | 758 UTF16ToUTF8(site_identity_details_); |
| 766 info.cert_id = cert_id_; | 759 info.cert_id = cert_id_; |
| 767 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; | 760 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; |
| 768 ui_->SetIdentityInfo(info); | 761 ui_->SetIdentityInfo(info); |
| 769 } | 762 } |
| OLD | NEW |