| OLD | NEW | 
|   1 // Copyright 2015 The Chromium Authors. All rights reserved. |   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 |   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/chrome_security_state_model_client.h" |   5 #include "chrome/browser/ssl/chrome_security_state_model_client.h" | 
|   6  |   6  | 
|   7 #include "base/command_line.h" |   7 #include "base/command_line.h" | 
|   8 #include "base/metrics/field_trial.h" |   8 #include "base/metrics/field_trial.h" | 
|   9 #include "base/metrics/histogram_macros.h" |   9 #include "base/metrics/histogram_macros.h" | 
|  10 #include "chrome/browser/chromeos/policy/policy_cert_service.h" |  10 #include "chrome/browser/chromeos/policy/policy_cert_service.h" | 
|  11 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" |  11 #include "chrome/browser/chromeos/policy/policy_cert_service_factory.h" | 
|  12 #include "chrome/browser/profiles/profile.h" |  12 #include "chrome/browser/profiles/profile.h" | 
|  13 #include "content/public/browser/cert_store.h" |  13 #include "content/public/browser/cert_store.h" | 
|  14 #include "content/public/browser/navigation_entry.h" |  14 #include "content/public/browser/navigation_entry.h" | 
|  15 #include "content/public/browser/web_contents.h" |  15 #include "content/public/browser/web_contents.h" | 
|  16 #include "content/public/common/ssl_status.h" |  16 #include "content/public/common/ssl_status.h" | 
|  17 #include "net/cert/x509_certificate.h" |  17 #include "net/cert/x509_certificate.h" | 
|  18  |  18  | 
 |  19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromeSecurityStateModelClient); | 
 |  20  | 
|  19 ChromeSecurityStateModelClient::ChromeSecurityStateModelClient( |  21 ChromeSecurityStateModelClient::ChromeSecurityStateModelClient( | 
|  20     content::WebContents* web_contents) |  22     content::WebContents* web_contents) | 
|  21     : web_contents_(web_contents) {} |  23     : web_contents_(web_contents), | 
 |  24       security_state_model_(new SecurityStateModel(web_contents)) { | 
 |  25   security_state_model_->SetClient(this); | 
 |  26 } | 
|  22  |  27  | 
|  23 ChromeSecurityStateModelClient::~ChromeSecurityStateModelClient() {} |  28 ChromeSecurityStateModelClient::~ChromeSecurityStateModelClient() {} | 
|  24  |  29  | 
 |  30 const SecurityStateModel::SecurityInfo& | 
 |  31 ChromeSecurityStateModelClient::GetSecurityInfo() const { | 
 |  32   return security_state_model_->GetSecurityInfo(); | 
 |  33 } | 
 |  34  | 
|  25 bool ChromeSecurityStateModelClient::RetrieveCert( |  35 bool ChromeSecurityStateModelClient::RetrieveCert( | 
|  26     scoped_refptr<net::X509Certificate>* cert) { |  36     scoped_refptr<net::X509Certificate>* cert) { | 
|  27   content::NavigationEntry* entry = |  37   content::NavigationEntry* entry = | 
|  28       web_contents_->GetController().GetVisibleEntry(); |  38       web_contents_->GetController().GetVisibleEntry(); | 
|  29   if (!entry) |  39   if (!entry) | 
|  30     return false; |  40     return false; | 
|  31   return content::CertStore::GetInstance()->RetrieveCert( |  41   return content::CertStore::GetInstance()->RetrieveCert( | 
|  32       entry->GetSSL().cert_id, cert); |  42       entry->GetSSL().cert_id, cert); | 
|  33 } |  43 } | 
|  34  |  44  | 
|  35 bool ChromeSecurityStateModelClient::UsedPolicyInstalledCertificate() { |  45 bool ChromeSecurityStateModelClient::UsedPolicyInstalledCertificate() { | 
|  36 #if defined(OS_CHROMEOS) |  46 #if defined(OS_CHROMEOS) | 
|  37   policy::PolicyCertService* service = |  47   policy::PolicyCertService* service = | 
|  38       policy::PolicyCertServiceFactory::GetForProfile( |  48       policy::PolicyCertServiceFactory::GetForProfile( | 
|  39           Profile::FromBrowserContext(web_contents_->GetBrowserContext())); |  49           Profile::FromBrowserContext(web_contents_->GetBrowserContext())); | 
|  40   if (service && service->UsedPolicyCertificates()) |  50   if (service && service->UsedPolicyCertificates()) | 
|  41     return true; |  51     return true; | 
|  42 #endif |  52 #endif | 
|  43   return false; |  53   return false; | 
|  44 } |  54 } | 
| OLD | NEW |