summaryrefslogtreecommitdiffstats
path: root/content/browser/ssl/ssl_policy.cc
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser/ssl/ssl_policy.cc')
-rw-r--r--content/browser/ssl/ssl_policy.cc48
1 files changed, 22 insertions, 26 deletions
diff --git a/content/browser/ssl/ssl_policy.cc b/content/browser/ssl/ssl_policy.cc
index 8804409..f038444 100644
--- a/content/browser/ssl/ssl_policy.cc
+++ b/content/browser/ssl/ssl_policy.cc
@@ -19,12 +19,11 @@
#include "content/browser/ssl/ssl_request_info.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/content_browser_client.h"
-#include "content/public/browser/web_contents.h"
#include "content/public/common/resource_type.h"
#include "content/public/common/ssl_status.h"
#include "content/public/common/url_constants.h"
#include "net/ssl/ssl_info.h"
-#include "url/gurl.h"
+
namespace content {
@@ -139,22 +138,37 @@ void SSLPolicy::OnRequestStarted(SSLRequestInfo* info) {
}
void SSLPolicy::UpdateEntry(NavigationEntryImpl* entry,
- WebContents* web_contents) {
+ WebContentsImpl* web_contents) {
DCHECK(entry);
InitializeEntryIfNeeded(entry);
- if (entry->GetSSL().security_style == SECURITY_STYLE_UNAUTHENTICATED)
+ if (!entry->GetURL().SchemeIsCryptographic())
return;
if (!web_contents->DisplayedInsecureContent())
entry->GetSSL().content_status &= ~SSLStatus::DISPLAYED_INSECURE_CONTENT;
+ // 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 (!entry->GetSSL().cert_id) {
+ entry->GetSSL().security_style = SECURITY_STYLE_UNAUTHENTICATED;
+ return;
+ }
+
if (web_contents->DisplayedInsecureContent())
entry->GetSSL().content_status |= SSLStatus::DISPLAYED_INSECURE_CONTENT;
- if (entry->GetSSL().security_style == SECURITY_STYLE_AUTHENTICATION_BROKEN)
+ if (net::IsCertStatusError(entry->GetSSL().cert_status)) {
+ // Minor errors don't lower the security style to
+ // SECURITY_STYLE_AUTHENTICATION_BROKEN.
+ if (!net::IsCertStatusMinorError(entry->GetSSL().cert_status)) {
+ entry->GetSSL().security_style =
+ SECURITY_STYLE_AUTHENTICATION_BROKEN;
+ }
return;
+ }
SiteInstance* site_instance = entry->site_instance();
// Note that |site_instance| can be NULL here because NavigationEntries don't
@@ -170,25 +184,6 @@ void SSLPolicy::UpdateEntry(NavigationEntryImpl* entry,
}
}
-// Static
-SecurityStyle SSLPolicy::GetSecurityStyleForResource(const GURL& url,
- const SSLStatus& ssl) {
- // 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() || !ssl.cert_id)
- return SECURITY_STYLE_UNAUTHENTICATED;
-
- // Minor errors don't lower the security style to
- // SECURITY_STYLE_AUTHENTICATION_BROKEN.
- if (net::IsCertStatusError(ssl.cert_status) &&
- !net::IsCertStatusMinorError(ssl.cert_status)) {
- return SECURITY_STYLE_AUTHENTICATION_BROKEN;
- }
-
- return SECURITY_STYLE_AUTHENTICATED;
-}
-
void SSLPolicy::OnAllowCertificate(scoped_refptr<SSLCertErrorHandler> handler,
bool allow) {
DCHECK(handler->ssl_info().is_valid());
@@ -256,8 +251,9 @@ void SSLPolicy::InitializeEntryIfNeeded(NavigationEntryImpl* entry) {
if (entry->GetSSL().security_style != SECURITY_STYLE_UNKNOWN)
return;
- entry->GetSSL().security_style =
- GetSecurityStyleForResource(entry->GetURL(), entry->GetSSL());
+ entry->GetSSL().security_style = entry->GetURL().SchemeIsCryptographic()
+ ? SECURITY_STYLE_AUTHENTICATED
+ : SECURITY_STYLE_UNAUTHENTICATED;
}
void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) {