Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3114)

Unified Diff: chrome/browser/ssl/security_state_model.cc

Issue 1470813002: Add SecurityStateModelClient interface and implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: blundell comments Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ssl/security_state_model.cc
diff --git a/chrome/browser/ssl/security_state_model.cc b/chrome/browser/ssl/security_state_model.cc
index ace1743eac733172c50365b7f95d418bf44ced38..b66225dd6f109a7012f68a0cbd0b3a8a56262eb0 100644
--- a/chrome/browser/ssl/security_state_model.cc
+++ b/chrome/browser/ssl/security_state_model.cc
@@ -9,6 +9,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ssl/chrome_security_state_model_delegate.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -115,7 +116,8 @@ SecurityStateModel::SecurityLevel GetSecurityLevelForRequest(
Profile* profile,
scoped_refptr<net::X509Certificate> cert,
SecurityStateModel::SHA1DeprecationStatus sha1_status,
- SecurityStateModel::MixedContentStatus mixed_content_status) {
+ SecurityStateModel::MixedContentStatus mixed_content_status,
+ bool used_known_mitm_certificate) {
switch (ssl.security_style) {
case content::SECURITY_STYLE_UNKNOWN:
return SecurityStateModel::NONE;
@@ -134,17 +136,8 @@ SecurityStateModel::SecurityLevel GetSecurityLevelForRequest(
return SecurityStateModel::SECURITY_WARNING;
case content::SECURITY_STYLE_AUTHENTICATED: {
-#if defined(OS_CHROMEOS)
- // Report if there is a policy cert first, before reporting any other
- // authenticated-but-with-errors cases. A policy cert is a strong
- // indicator of a MITM being present (the enterprise), while the
- // other authenticated-but-with-errors indicate something may
- // be wrong, or may be wrong in the future, but is unclear now.
- policy::PolicyCertService* service =
- policy::PolicyCertServiceFactory::GetForProfile(profile);
- if (service && service->UsedPolicyCertificates())
+ if (used_known_mitm_certificate)
return SecurityStateModel::SECURITY_POLICY_WARNING;
-#endif
if (sha1_status == SecurityStateModel::DEPRECATED_SHA1_MAJOR)
return SecurityStateModel::SECURITY_ERROR;
@@ -222,8 +215,9 @@ const SecurityStateModel::SecurityInfo& SecurityStateModel::GetSecurityInfo()
// A cert must be present in the CertStore in order for the site to
// be considered EV_SECURE, and the cert might have been removed
// since the security level was last computed.
+ scoped_refptr<net::X509Certificate> cert;
if (security_info_.security_level == EV_SECURE &&
- !GetCertForSSLStatus(visible_ssl_status_)) {
+ !delegate_->RetrieveCert(&cert)) {
security_info_.security_level = SECURE;
}
return security_info_;
@@ -232,17 +226,19 @@ const SecurityStateModel::SecurityInfo& SecurityStateModel::GetSecurityInfo()
SecurityInfoForRequest(
entry->GetURL(), entry->GetSSL(),
Profile::FromBrowserContext(web_contents_->GetBrowserContext()),
- &security_info_);
+ delegate_->UsedKnownMITMCertificate(), &security_info_);
visible_url_ = entry->GetURL();
visible_ssl_status_ = entry->GetSSL();
return security_info_;
}
// static
-void SecurityStateModel::SecurityInfoForRequest(const GURL& url,
- const content::SSLStatus& ssl,
- Profile* profile,
- SecurityInfo* security_info) {
+void SecurityStateModel::SecurityInfoForRequest(
+ const GURL& url,
+ const content::SSLStatus& ssl,
+ Profile* profile,
+ bool used_known_mitm_certificate,
+ SecurityInfo* security_info) {
scoped_refptr<net::X509Certificate> cert = GetCertForSSLStatus(ssl);
felt 2015/11/23 23:21:00 Will this also need to be replaced with either Ret
estark 2015/11/24 00:07:23 Oh, I guess I could just add it an arg and then de
security_info->cert_id = ssl.cert_id;
security_info->sha1_deprecation_status = GetSHA1DeprecationStatus(cert, ssl);
@@ -264,8 +260,9 @@ void SecurityStateModel::SecurityInfoForRequest(const GURL& url,
security_info->security_level = GetSecurityLevelForRequest(
url, ssl, profile, cert, security_info->sha1_deprecation_status,
- security_info->mixed_content_status);
+ security_info->mixed_content_status, used_known_mitm_certificate);
}
SecurityStateModel::SecurityStateModel(content::WebContents* web_contents)
- : web_contents_(web_contents) {}
+ : web_contents_(web_contents),
+ delegate_(new ChromeSecurityStateModelDelegate(web_contents)) {}

Powered by Google App Engine
This is Rietveld 408576698