Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: chrome/browser/ui/page_info/website_settings.cc

Issue 2741303002: Run `git cl format` on all desktop page_info code. (Closed)
Patch Set: Rebase. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/page_info/website_settings.h" 5 #include "chrome/browser/ui/page_info/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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN: 137 case security_state::CONTENT_STATUS_DISPLAYED_AND_RAN:
138 *displayed = true; 138 *displayed = true;
139 *ran = true; 139 *ran = true;
140 break; 140 break;
141 case security_state::CONTENT_STATUS_UNKNOWN: 141 case security_state::CONTENT_STATUS_UNKNOWN:
142 case security_state::CONTENT_STATUS_NONE: 142 case security_state::CONTENT_STATUS_NONE:
143 break; 143 break;
144 } 144 }
145 } 145 }
146 146
147 void CheckForInsecureContent( 147 void CheckForInsecureContent(const security_state::SecurityInfo& security_info,
148 const security_state::SecurityInfo& security_info, 148 bool* displayed,
149 bool* displayed, 149 bool* ran) {
150 bool* ran) {
151 CheckContentStatus(security_info.mixed_content_status, displayed, ran); 150 CheckContentStatus(security_info.mixed_content_status, displayed, ran);
152 // Only consider subresources with certificate errors if the main 151 // Only consider subresources with certificate errors if the main
153 // resource was loaded over HTTPS without major certificate errors. If 152 // resource was loaded over HTTPS without major certificate errors. If
154 // the main resource had a certificate error, then it would not be 153 // the main resource had a certificate error, then it would not be
155 // that useful (and would potentially be confusing) to warn about 154 // that useful (and would potentially be confusing) to warn about
156 // subesources that had certificate errors too. 155 // subesources that had certificate errors too.
157 if (net::IsCertStatusError(security_info.cert_status) && 156 if (net::IsCertStatusError(security_info.cert_status) &&
158 !net::IsCertStatusMinorError(security_info.cert_status)) { 157 !net::IsCertStatusMinorError(security_info.cert_status)) {
159 return; 158 return;
160 } 159 }
161 CheckContentStatus(security_info.content_with_cert_errors_status, displayed, 160 CheckContentStatus(security_info.content_with_cert_errors_status, displayed,
162 ran); 161 ran);
163 } 162 }
164 163
165 void GetSiteIdentityByMaliciousContentStatus( 164 void GetSiteIdentityByMaliciousContentStatus(
166 security_state::MaliciousContentStatus malicious_content_status, 165 security_state::MaliciousContentStatus malicious_content_status,
167 WebsiteSettings::SiteIdentityStatus* status, 166 WebsiteSettings::SiteIdentityStatus* status,
168 base::string16* details) { 167 base::string16* details) {
169 switch (malicious_content_status) { 168 switch (malicious_content_status) {
170 case security_state::MALICIOUS_CONTENT_STATUS_NONE: 169 case security_state::MALICIOUS_CONTENT_STATUS_NONE:
171 NOTREACHED(); 170 NOTREACHED();
172 break; 171 break;
173 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE: 172 case security_state::MALICIOUS_CONTENT_STATUS_MALWARE:
174 *status = WebsiteSettings::SITE_IDENTITY_STATUS_MALWARE; 173 *status = WebsiteSettings::SITE_IDENTITY_STATUS_MALWARE;
175 *details = 174 *details = l10n_util::GetStringUTF16(IDS_PAGEINFO_MALWARE_DETAILS);
176 l10n_util::GetStringUTF16(IDS_PAGEINFO_MALWARE_DETAILS);
177 break; 175 break;
178 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING: 176 case security_state::MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING:
179 *status = WebsiteSettings::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING; 177 *status = WebsiteSettings::SITE_IDENTITY_STATUS_SOCIAL_ENGINEERING;
180 *details = l10n_util::GetStringUTF16( 178 *details =
181 IDS_PAGEINFO_SOCIAL_ENGINEERING_DETAILS); 179 l10n_util::GetStringUTF16(IDS_PAGEINFO_SOCIAL_ENGINEERING_DETAILS);
182 break; 180 break;
183 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE: 181 case security_state::MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE:
184 *status = WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE; 182 *status = WebsiteSettings::SITE_IDENTITY_STATUS_UNWANTED_SOFTWARE;
185 *details = l10n_util::GetStringUTF16( 183 *details =
186 IDS_PAGEINFO_UNWANTED_SOFTWARE_DETAILS); 184 l10n_util::GetStringUTF16(IDS_PAGEINFO_UNWANTED_SOFTWARE_DETAILS);
187 break; 185 break;
188 } 186 }
189 } 187 }
190 188
191 base::string16 GetSimpleSiteName(const GURL& url) { 189 base::string16 GetSimpleSiteName(const GURL& url) {
192 return url_formatter::FormatUrlForSecurityDisplay( 190 return url_formatter::FormatUrlForSecurityDisplay(
193 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS); 191 url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
194 } 192 }
195 193
196 ChooserContextBase* GetUsbChooserContext(Profile* profile) { 194 ChooserContextBase* GetUsbChooserContext(Profile* profile) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 232
235 PresentSitePermissions(); 233 PresentSitePermissions();
236 PresentSiteData(); 234 PresentSiteData();
237 PresentSiteIdentity(); 235 PresentSiteIdentity();
238 236
239 // Every time the Website Settings UI is opened a |WebsiteSettings| object is 237 // Every time the Website Settings UI is opened a |WebsiteSettings| object is
240 // created. So this counts how ofter the Website Settings UI is opened. 238 // created. So this counts how ofter the Website Settings UI is opened.
241 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED); 239 RecordWebsiteSettingsAction(WEBSITE_SETTINGS_OPENED);
242 } 240 }
243 241
244 WebsiteSettings::~WebsiteSettings() { 242 WebsiteSettings::~WebsiteSettings() {}
245 }
246 243
247 void WebsiteSettings::RecordWebsiteSettingsAction( 244 void WebsiteSettings::RecordWebsiteSettingsAction(
248 WebsiteSettingsAction action) { 245 WebsiteSettingsAction action) {
249 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", 246 UMA_HISTOGRAM_ENUMERATION("WebsiteSettings.Action", action,
250 action,
251 WEBSITE_SETTINGS_COUNT); 247 WEBSITE_SETTINGS_COUNT);
252 248
253 std::string histogram_name; 249 std::string histogram_name;
254 250
255 if (site_url_.SchemeIsCryptographic()) { 251 if (site_url_.SchemeIsCryptographic()) {
256 if (security_level_ == security_state::SECURE || 252 if (security_level_ == security_state::SECURE ||
257 security_level_ == security_state::EV_SECURE) { 253 security_level_ == security_state::EV_SECURE) {
258 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid", 254 UMA_HISTOGRAM_ENUMERATION("Security.PageInfo.Action.HttpsUrl.Valid",
259 action, WEBSITE_SETTINGS_COUNT); 255 action, WEBSITE_SETTINGS_COUNT);
260 } else if (security_level_ == security_state::NONE) { 256 } else if (security_level_ == security_state::NONE) {
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 std::vector<ssl_errors::ErrorInfo> errors; 510 std::vector<ssl_errors::ErrorInfo> errors;
515 ssl_errors::ErrorInfo::GetErrorsForCertStatus( 511 ssl_errors::ErrorInfo::GetErrorsForCertStatus(
516 certificate_, security_info.cert_status, url, &errors); 512 certificate_, security_info.cert_status, url, &errors);
517 for (size_t i = 0; i < errors.size(); ++i) { 513 for (size_t i = 0; i < errors.size(); ++i) {
518 site_identity_details_ += bullet; 514 site_identity_details_ += bullet;
519 site_identity_details_ += errors[i].short_description(); 515 site_identity_details_ += errors[i].short_description();
520 } 516 }
521 517
522 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) { 518 if (security_info.cert_status & net::CERT_STATUS_NON_UNIQUE_NAME) {
523 site_identity_details_ += ASCIIToUTF16("\n\n"); 519 site_identity_details_ += ASCIIToUTF16("\n\n");
524 site_identity_details_ += l10n_util::GetStringUTF16( 520 site_identity_details_ +=
525 IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME); 521 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SECURITY_TAB_NON_UNIQUE_NAME);
526 } 522 }
527 } 523 }
528 524
529 // Site Connection 525 // Site Connection
530 // We consider anything less than 80 bits encryption to be weak encryption. 526 // We consider anything less than 80 bits encryption to be weak encryption.
531 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and 527 // TODO(wtc): Bug 1198735: report mixed/unsafe content for unencrypted and
532 // weakly encrypted connections. 528 // weakly encrypted connections.
533 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN; 529 site_connection_status_ = SITE_CONNECTION_STATUS_UNKNOWN;
534 530
535 base::string16 subject_name(GetSimpleSiteName(url)); 531 base::string16 subject_name(GetSimpleSiteName(url));
(...skipping 17 matching lines...) Expand all
553 DCHECK_NE(security_info.security_level, security_state::NONE); 549 DCHECK_NE(security_info.security_level, security_state::NONE);
554 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; 550 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
555 site_connection_details_.assign(l10n_util::GetStringFUTF16( 551 site_connection_details_.assign(l10n_util::GetStringFUTF16(
556 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT, 552 IDS_PAGE_INFO_SECURITY_TAB_NOT_ENCRYPTED_CONNECTION_TEXT,
557 subject_name)); 553 subject_name));
558 } else { 554 } else {
559 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED; 555 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED;
560 556
561 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) { 557 if (security_info.obsolete_ssl_status == net::OBSOLETE_SSL_NONE) {
562 site_connection_details_.assign(l10n_util::GetStringFUTF16( 558 site_connection_details_.assign(l10n_util::GetStringFUTF16(
563 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, 559 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTED_CONNECTION_TEXT, subject_name));
564 subject_name));
565 } else { 560 } else {
566 site_connection_details_.assign(l10n_util::GetStringFUTF16( 561 site_connection_details_.assign(l10n_util::GetStringFUTF16(
567 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT, 562 IDS_PAGE_INFO_SECURITY_TAB_WEAK_ENCRYPTION_CONNECTION_TEXT,
568 subject_name)); 563 subject_name));
569 } 564 }
570 565
571 bool ran_insecure_content = false; 566 bool ran_insecure_content = false;
572 bool displayed_insecure_content = false; 567 bool displayed_insecure_content = false;
573 CheckForInsecureContent(security_info, &displayed_insecure_content, 568 CheckForInsecureContent(security_info, &displayed_insecure_content,
574 &ran_insecure_content); 569 &ran_insecure_content);
(...skipping 14 matching lines...) Expand all
589 584
590 uint16_t cipher_suite = 585 uint16_t cipher_suite =
591 net::SSLConnectionStatusToCipherSuite(security_info.connection_status); 586 net::SSLConnectionStatusToCipherSuite(security_info.connection_status);
592 if (security_info.security_bits > 0 && cipher_suite) { 587 if (security_info.security_bits > 0 && cipher_suite) {
593 int ssl_version = 588 int ssl_version =
594 net::SSLConnectionStatusToVersion(security_info.connection_status); 589 net::SSLConnectionStatusToVersion(security_info.connection_status);
595 const char* ssl_version_str; 590 const char* ssl_version_str;
596 net::SSLVersionToString(&ssl_version_str, ssl_version); 591 net::SSLVersionToString(&ssl_version_str, ssl_version);
597 site_connection_details_ += ASCIIToUTF16("\n\n"); 592 site_connection_details_ += ASCIIToUTF16("\n\n");
598 site_connection_details_ += l10n_util::GetStringFUTF16( 593 site_connection_details_ += l10n_util::GetStringFUTF16(
599 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, 594 IDS_PAGE_INFO_SECURITY_TAB_SSL_VERSION, ASCIIToUTF16(ssl_version_str));
600 ASCIIToUTF16(ssl_version_str));
601 595
602 const char *key_exchange, *cipher, *mac; 596 const char *key_exchange, *cipher, *mac;
603 bool is_aead, is_tls13; 597 bool is_aead, is_tls13;
604 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, 598 net::SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead,
605 &is_tls13, cipher_suite); 599 &is_tls13, cipher_suite);
606 600
607 site_connection_details_ += ASCIIToUTF16("\n\n"); 601 site_connection_details_ += ASCIIToUTF16("\n\n");
608 if (is_aead) { 602 if (is_aead) {
609 if (is_tls13) { 603 if (is_tls13) {
610 // For TLS 1.3 ciphers, report the group (historically, curve) as the 604 // For TLS 1.3 ciphers, report the group (historically, curve) as the
611 // key exchange. 605 // key exchange.
612 key_exchange = SSL_get_curve_name(security_info.key_exchange_group); 606 key_exchange = SSL_get_curve_name(security_info.key_exchange_group);
613 if (!key_exchange) { 607 if (!key_exchange) {
614 NOTREACHED(); 608 NOTREACHED();
615 key_exchange = ""; 609 key_exchange = "";
616 } 610 }
617 } 611 }
618 site_connection_details_ += l10n_util::GetStringFUTF16( 612 site_connection_details_ += l10n_util::GetStringFUTF16(
619 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD, 613 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS_AEAD,
620 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange)); 614 ASCIIToUTF16(cipher), ASCIIToUTF16(key_exchange));
621 } else { 615 } else {
622 site_connection_details_ += l10n_util::GetStringFUTF16( 616 site_connection_details_ += l10n_util::GetStringFUTF16(
623 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, 617 IDS_PAGE_INFO_SECURITY_TAB_ENCRYPTION_DETAILS, ASCIIToUTF16(cipher),
624 ASCIIToUTF16(cipher), ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange)); 618 ASCIIToUTF16(mac), ASCIIToUTF16(key_exchange));
625 } 619 }
626 620
627 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 && 621 if (ssl_version == net::SSL_CONNECTION_VERSION_SSL3 &&
628 site_connection_status_ < 622 site_connection_status_ <
629 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) { 623 SITE_CONNECTION_STATUS_INSECURE_PASSIVE_SUBRESOURCE) {
630 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR; 624 site_connection_status_ = SITE_CONNECTION_STATUS_ENCRYPTED_ERROR;
631 } 625 }
632 } 626 }
633 627
634 // Check if a user decision has been made to allow or deny certificates with 628 // Check if a user decision has been made to allow or deny certificates with
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 // identity must be available. 738 // identity must be available.
745 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN); 739 DCHECK_NE(site_identity_status_, SITE_IDENTITY_STATUS_UNKNOWN);
746 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN); 740 DCHECK_NE(site_connection_status_, SITE_CONNECTION_STATUS_UNKNOWN);
747 WebsiteSettingsUI::IdentityInfo info; 741 WebsiteSettingsUI::IdentityInfo info;
748 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT) 742 if (site_identity_status_ == SITE_IDENTITY_STATUS_EV_CERT)
749 info.site_identity = UTF16ToUTF8(organization_name()); 743 info.site_identity = UTF16ToUTF8(organization_name());
750 else 744 else
751 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_)); 745 info.site_identity = UTF16ToUTF8(GetSimpleSiteName(site_url_));
752 746
753 info.connection_status = site_connection_status_; 747 info.connection_status = site_connection_status_;
754 info.connection_status_description = 748 info.connection_status_description = UTF16ToUTF8(site_connection_details_);
755 UTF16ToUTF8(site_connection_details_);
756 info.identity_status = site_identity_status_; 749 info.identity_status = site_identity_status_;
757 info.identity_status_description = 750 info.identity_status_description = UTF16ToUTF8(site_identity_details_);
758 UTF16ToUTF8(site_identity_details_);
759 info.certificate = certificate_; 751 info.certificate = certificate_;
760 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_; 752 info.show_ssl_decision_revoke_button = show_ssl_decision_revoke_button_;
761 ui_->SetIdentityInfo(info); 753 ui_->SetIdentityInfo(info);
762 } 754 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698