Index: content/common/security_style_util.cc |
diff --git a/content/common/security_style_util.cc b/content/common/security_style_util.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..dcb9eb84fcacaf32fee9c7c0b113f32f65a4fab8 |
--- /dev/null |
+++ b/content/common/security_style_util.cc |
@@ -0,0 +1,31 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "content/common/security_style_util.h" |
+ |
+#include "url/gurl.h" |
+ |
+namespace content { |
+ |
+SecurityStyle GetSecurityStyleForResource( |
+ const GURL& url, |
+ bool has_certificate, |
+ net::CertStatus cert_status) { |
+ // An HTTPS response may not have a certificate for some reason. When that |
+ // happens, use the unauthenticated (HTTP) rather than the authentication |
+ // broken security style so that we can detect this error condition. |
+ if (!url.SchemeIsCryptographic() || !has_certificate) |
+ return SECURITY_STYLE_UNAUTHENTICATED; |
+ |
+ // Minor errors don't lower the security style to |
+ // SECURITY_STYLE_AUTHENTICATION_BROKEN. |
+ if (net::IsCertStatusError(cert_status) && |
+ !net::IsCertStatusMinorError(cert_status)) { |
+ return SECURITY_STYLE_AUTHENTICATION_BROKEN; |
+ } |
+ |
+ return SECURITY_STYLE_AUTHENTICATED; |
+} |
+ |
+} // namespace content |