OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ssl/chrome_security_state_model_delegate.h" |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |
| 11 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |
| 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "content/public/browser/cert_store.h" |
| 14 #include "content/public/browser/navigation_entry.h" |
| 15 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/common/ssl_status.h" |
| 17 #include "net/cert/x509_certificate.h" |
| 18 |
| 19 ChromeSecurityStateModelDelegate::ChromeSecurityStateModelDelegate( |
| 20 content::WebContents* web_contents) |
| 21 : web_contents_(web_contents) {} |
| 22 |
| 23 ChromeSecurityStateModelDelegate::~ChromeSecurityStateModelDelegate() {} |
| 24 |
| 25 bool ChromeSecurityStateModelDelegate::RetrieveCert( |
| 26 scoped_refptr<net::X509Certificate>* cert) { |
| 27 content::NavigationEntry* entry = |
| 28 web_contents_->GetController().GetVisibleEntry(); |
| 29 if (!entry) |
| 30 return false; |
| 31 return content::CertStore::GetInstance()->RetrieveCert( |
| 32 entry->GetSSL().cert_id, cert); |
| 33 } |
| 34 |
| 35 bool ChromeSecurityStateModelDelegate::UsedKnownMITMCertificate() { |
| 36 #if defined(OS_CHROMEOS) |
| 37 // Report if there is a policy cert first, before reporting any other |
| 38 // authenticated-but-with-errors cases. A policy cert is a strong |
| 39 // indicator of a MITM being present (the enterprise), while the |
| 40 // other authenticated-but-with-errors indicate something may |
| 41 // be wrong, or may be wrong in the future, but is unclear now. |
| 42 policy::PolicyCertService* service = |
| 43 policy::PolicyCertServiceFactory::GetForProfile( |
| 44 Profile::FromBrowserContext(web_contents_->GetBrowserContext())); |
| 45 if (service && service->UsedPolicyCertificates()) |
| 46 return true; |
| 47 #endif |
| 48 return false; |
| 49 } |
OLD | NEW |