| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/common/security_style_util.h" | |
| 6 | |
| 7 #include "url/gurl.h" | |
| 8 | |
| 9 namespace content { | |
| 10 | |
| 11 SecurityStyle GetSecurityStyleForResource( | |
| 12 const GURL& url, | |
| 13 bool has_certificate, | |
| 14 net::CertStatus cert_status) { | |
| 15 // An HTTPS response may not have a certificate for some reason. When that | |
| 16 // happens, use the unauthenticated (HTTP) rather than the authentication | |
| 17 // broken security style so that we can detect this error condition. | |
| 18 if (!url.SchemeIsCryptographic() || !has_certificate) | |
| 19 return SECURITY_STYLE_UNAUTHENTICATED; | |
| 20 | |
| 21 // Minor errors don't lower the security style to | |
| 22 // SECURITY_STYLE_AUTHENTICATION_BROKEN. | |
| 23 if (net::IsCertStatusError(cert_status) && | |
| 24 !net::IsCertStatusMinorError(cert_status)) { | |
| 25 return SECURITY_STYLE_AUTHENTICATION_BROKEN; | |
| 26 } | |
| 27 | |
| 28 return SECURITY_STYLE_AUTHENTICATED; | |
| 29 } | |
| 30 | |
| 31 } // namespace content | |
| OLD | NEW |