| 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 "content/browser/ssl/ssl_policy.h" | 5 #include "content/browser/ssl/ssl_policy.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 backend_->DidHostRunInsecureContent( | 169 backend_->DidHostRunInsecureContent( |
| 170 entry->GetURL().host(), site_instance->GetProcess()->GetID())) { | 170 entry->GetURL().host(), site_instance->GetProcess()->GetID())) { |
| 171 entry->GetSSL().security_style = | 171 entry->GetSSL().security_style = |
| 172 SECURITY_STYLE_AUTHENTICATION_BROKEN; | 172 SECURITY_STYLE_AUTHENTICATION_BROKEN; |
| 173 entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT; | 173 entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT; |
| 174 return; | 174 return; |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 | 177 |
| 178 // Static | 178 // Static |
| 179 SecurityStyle SSLPolicy::GetSecurityStyleForResource(const GURL& url, | 179 SecurityStyle SSLPolicy::GetSecurityStyleForResource( |
| 180 const SSLStatus& ssl) { | 180 const GURL& url, |
| 181 int cert_id, |
| 182 net::CertStatus cert_status) { |
| 181 // An HTTPS response may not have a certificate for some reason. When that | 183 // An HTTPS response may not have a certificate for some reason. When that |
| 182 // happens, use the unauthenticated (HTTP) rather than the authentication | 184 // happens, use the unauthenticated (HTTP) rather than the authentication |
| 183 // broken security style so that we can detect this error condition. | 185 // broken security style so that we can detect this error condition. |
| 184 if (!url.SchemeIsCryptographic() || !ssl.cert_id) | 186 if (!url.SchemeIsCryptographic() || !cert_id) |
| 185 return SECURITY_STYLE_UNAUTHENTICATED; | 187 return SECURITY_STYLE_UNAUTHENTICATED; |
| 186 | 188 |
| 187 // Minor errors don't lower the security style to | 189 // Minor errors don't lower the security style to |
| 188 // SECURITY_STYLE_AUTHENTICATION_BROKEN. | 190 // SECURITY_STYLE_AUTHENTICATION_BROKEN. |
| 189 if (net::IsCertStatusError(ssl.cert_status) && | 191 if (net::IsCertStatusError(cert_status) && |
| 190 !net::IsCertStatusMinorError(ssl.cert_status)) { | 192 !net::IsCertStatusMinorError(cert_status)) { |
| 191 return SECURITY_STYLE_AUTHENTICATION_BROKEN; | 193 return SECURITY_STYLE_AUTHENTICATION_BROKEN; |
| 192 } | 194 } |
| 193 | 195 |
| 194 return SECURITY_STYLE_AUTHENTICATED; | 196 return SECURITY_STYLE_AUTHENTICATED; |
| 195 } | 197 } |
| 196 | 198 |
| 197 void SSLPolicy::OnAllowCertificate(scoped_refptr<SSLCertErrorHandler> handler, | 199 void SSLPolicy::OnAllowCertificate(scoped_refptr<SSLCertErrorHandler> handler, |
| 198 bool allow) { | 200 bool allow) { |
| 199 DCHECK(handler->ssl_info().is_valid()); | 201 DCHECK(handler->ssl_info().is_valid()); |
| 200 if (allow) { | 202 if (allow) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 break; | 256 break; |
| 255 default: | 257 default: |
| 256 NOTREACHED(); | 258 NOTREACHED(); |
| 257 } | 259 } |
| 258 } | 260 } |
| 259 | 261 |
| 260 void SSLPolicy::InitializeEntryIfNeeded(NavigationEntryImpl* entry) { | 262 void SSLPolicy::InitializeEntryIfNeeded(NavigationEntryImpl* entry) { |
| 261 if (entry->GetSSL().security_style != SECURITY_STYLE_UNKNOWN) | 263 if (entry->GetSSL().security_style != SECURITY_STYLE_UNKNOWN) |
| 262 return; | 264 return; |
| 263 | 265 |
| 264 entry->GetSSL().security_style = | 266 entry->GetSSL().security_style = GetSecurityStyleForResource( |
| 265 GetSecurityStyleForResource(entry->GetURL(), entry->GetSSL()); | 267 entry->GetURL(), entry->GetSSL().cert_id, entry->GetSSL().cert_status); |
| 266 } | 268 } |
| 267 | 269 |
| 268 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) { | 270 void SSLPolicy::OriginRanInsecureContent(const std::string& origin, int pid) { |
| 269 GURL parsed_origin(origin); | 271 GURL parsed_origin(origin); |
| 270 if (parsed_origin.SchemeIsCryptographic()) | 272 if (parsed_origin.SchemeIsCryptographic()) |
| 271 backend_->HostRanInsecureContent(parsed_origin.host(), pid); | 273 backend_->HostRanInsecureContent(parsed_origin.host(), pid); |
| 272 } | 274 } |
| 273 | 275 |
| 274 } // namespace content | 276 } // namespace content |
| OLD | NEW |