| Index: chrome/browser/ssl/chrome_security_state_model_delegate.cc
|
| diff --git a/chrome/browser/ssl/chrome_security_state_model_delegate.cc b/chrome/browser/ssl/chrome_security_state_model_delegate.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..28f6bba22c551add66dd784aacefb964acec5e33
|
| --- /dev/null
|
| +++ b/chrome/browser/ssl/chrome_security_state_model_delegate.cc
|
| @@ -0,0 +1,49 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/ssl/chrome_security_state_model_delegate.h"
|
| +
|
| +#include "base/command_line.h"
|
| +#include "base/metrics/field_trial.h"
|
| +#include "base/metrics/histogram_macros.h"
|
| +#include "chrome/browser/chromeos/policy/policy_cert_service.h"
|
| +#include "chrome/browser/chromeos/policy/policy_cert_service_factory.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "content/public/browser/cert_store.h"
|
| +#include "content/public/browser/navigation_entry.h"
|
| +#include "content/public/browser/web_contents.h"
|
| +#include "content/public/common/ssl_status.h"
|
| +#include "net/cert/x509_certificate.h"
|
| +
|
| +ChromeSecurityStateModelDelegate::ChromeSecurityStateModelDelegate(
|
| + content::WebContents* web_contents)
|
| + : web_contents_(web_contents) {}
|
| +
|
| +ChromeSecurityStateModelDelegate::~ChromeSecurityStateModelDelegate() {}
|
| +
|
| +bool ChromeSecurityStateModelDelegate::RetrieveCert(
|
| + scoped_refptr<net::X509Certificate>* cert) {
|
| + content::NavigationEntry* entry =
|
| + web_contents_->GetController().GetVisibleEntry();
|
| + if (!entry)
|
| + return false;
|
| + return content::CertStore::GetInstance()->RetrieveCert(
|
| + entry->GetSSL().cert_id, cert);
|
| +}
|
| +
|
| +bool ChromeSecurityStateModelDelegate::UsedKnownMITMCertificate() {
|
| +#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::FromBrowserContext(web_contents_->GetBrowserContext()));
|
| + if (service && service->UsedPolicyCertificates())
|
| + return true;
|
| +#endif
|
| + return false;
|
| +}
|
|
|