| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/ssl/ssl_policy.h" | 5 #include "chrome/browser/ssl/ssl_policy.h" |
| 6 | 6 |
| 7 #include "base/singleton.h" | 7 #include "base/singleton.h" |
| 8 #include "base/string_piece.h" | 8 #include "base/string_piece.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/browser/cert_store.h" | 10 #include "chrome/browser/cert_store.h" |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 // if (IsIntranetHost(url.host())) | 435 // if (IsIntranetHost(url.host())) |
| 436 // return SECURITY_STYLE_AUTHENTICATION_BROKEN; | 436 // return SECURITY_STYLE_AUTHENTICATION_BROKEN; |
| 437 | 437 |
| 438 return SECURITY_STYLE_AUTHENTICATED; | 438 return SECURITY_STYLE_AUTHENTICATED; |
| 439 } | 439 } |
| 440 | 440 |
| 441 // Otherwise, show the unauthenticated style. | 441 // Otherwise, show the unauthenticated style. |
| 442 return SECURITY_STYLE_UNAUTHENTICATED; | 442 return SECURITY_STYLE_UNAUTHENTICATED; |
| 443 } | 443 } |
| 444 | 444 |
| 445 // static |
| 446 bool SSLPolicy::IsMixedContent(const GURL& url, |
| 447 ResourceType::Type resource_type, |
| 448 const std::string& main_frame_origin) { |
| 449 //////////////////////////////////////////////////////////////////////////// |
| 450 // WARNING: This function is called from both the IO and UI threads. Do // |
| 451 // not touch any non-thread-safe objects! You have been warned. // |
| 452 //////////////////////////////////////////////////////////////////////////// |
| 453 |
| 454 // We can't possibly have mixed content when loading the main frame. |
| 455 if (resource_type == ResourceType::MAIN_FRAME) |
| 456 return false; |
| 457 |
| 458 // TODO(abarth): This is wrong, but it matches our current behavior. |
| 459 // I'll fix this in a subsequent step. |
| 460 return GURL(main_frame_origin).SchemeIsSecure() && !url.SchemeIsSecure(); |
| 461 } |
| 462 |
| 445 SSLErrorInfo SSLPolicy::GetSSLErrorInfo(SSLManager::CertError* error) { | 463 SSLErrorInfo SSLPolicy::GetSSLErrorInfo(SSLManager::CertError* error) { |
| 446 return SSLErrorInfo::CreateError( | 464 return SSLErrorInfo::CreateError( |
| 447 SSLErrorInfo::NetErrorToErrorType(error->cert_error()), | 465 SSLErrorInfo::NetErrorToErrorType(error->cert_error()), |
| 448 error->ssl_info().cert, error->request_url()); | 466 error->ssl_info().cert, error->request_url()); |
| 449 } | 467 } |
| 450 | 468 |
| 451 void SSLPolicy::OnDenyCertificate(SSLManager::CertError* error) { | 469 void SSLPolicy::OnDenyCertificate(SSLManager::CertError* error) { |
| 452 // Default behavior for rejecting a certificate. | 470 // Default behavior for rejecting a certificate. |
| 453 error->CancelRequest(); | 471 error->CancelRequest(); |
| 454 error->manager()->DenyCertForHost(error->ssl_info().cert, | 472 error->manager()->DenyCertForHost(error->ssl_info().cert, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 484 void SSLPolicy::OnFatalCertError(const GURL& main_frame_url, | 502 void SSLPolicy::OnFatalCertError(const GURL& main_frame_url, |
| 485 SSLManager::CertError* error) { | 503 SSLManager::CertError* error) { |
| 486 if (error->resource_type() != ResourceType::MAIN_FRAME) { | 504 if (error->resource_type() != ResourceType::MAIN_FRAME) { |
| 487 error->DenyRequest(); | 505 error->DenyRequest(); |
| 488 return; | 506 return; |
| 489 } | 507 } |
| 490 error->CancelRequest(); | 508 error->CancelRequest(); |
| 491 ShowErrorPage(this, error); | 509 ShowErrorPage(this, error); |
| 492 // No need to degrade our security indicators because we didn't continue. | 510 // No need to degrade our security indicators because we didn't continue. |
| 493 } | 511 } |
| OLD | NEW |