| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/browser/ssl/ios_chrome_security_state_model_client.h" | 5 #include "ios/chrome/browser/ssl/ios_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 "ios/web/public/cert_store.h" | |
| 11 #include "ios/web/public/navigation_item.h" | 10 #include "ios/web/public/navigation_item.h" |
| 12 #import "ios/web/public/navigation_manager.h" | 11 #import "ios/web/public/navigation_manager.h" |
| 13 #import "ios/web/public/origin_util.h" | 12 #import "ios/web/public/origin_util.h" |
| 14 #include "ios/web/public/security_style.h" | 13 #include "ios/web/public/security_style.h" |
| 15 #include "ios/web/public/ssl_status.h" | 14 #include "ios/web/public/ssl_status.h" |
| 16 #include "ios/web/public/web_state/web_state.h" | 15 #include "ios/web/public/web_state/web_state.h" |
| 17 #include "net/cert/x509_certificate.h" | 16 #include "net/cert/x509_certificate.h" |
| 18 | 17 |
| 19 DEFINE_WEB_STATE_USER_DATA_KEY(IOSChromeSecurityStateModelClient); | 18 DEFINE_WEB_STATE_USER_DATA_KEY(IOSChromeSecurityStateModelClient); |
| 20 | 19 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 57 |
| 59 const security_state::SecurityStateModel::SecurityInfo& | 58 const security_state::SecurityStateModel::SecurityInfo& |
| 60 IOSChromeSecurityStateModelClient::GetSecurityInfo() const { | 59 IOSChromeSecurityStateModelClient::GetSecurityInfo() const { |
| 61 return security_state_model_->GetSecurityInfo(); | 60 return security_state_model_->GetSecurityInfo(); |
| 62 } | 61 } |
| 63 | 62 |
| 64 bool IOSChromeSecurityStateModelClient::RetrieveCert( | 63 bool IOSChromeSecurityStateModelClient::RetrieveCert( |
| 65 scoped_refptr<net::X509Certificate>* cert) { | 64 scoped_refptr<net::X509Certificate>* cert) { |
| 66 web::NavigationItem* item = | 65 web::NavigationItem* item = |
| 67 web_state_->GetNavigationManager()->GetVisibleItem(); | 66 web_state_->GetNavigationManager()->GetVisibleItem(); |
| 68 if (!item) | 67 if (!item || !item->GetSSL().certificate) |
| 69 return false; | 68 return false; |
| 70 | 69 |
| 71 int cert_id = item->GetSSL().cert_id; | 70 *cert = item->GetSSL().certificate; |
| 72 return web::CertStore::GetInstance()->RetrieveCert(cert_id, cert); | 71 return true; |
| 73 } | 72 } |
| 74 | 73 |
| 75 bool IOSChromeSecurityStateModelClient::UsedPolicyInstalledCertificate() { | 74 bool IOSChromeSecurityStateModelClient::UsedPolicyInstalledCertificate() { |
| 76 return false; | 75 return false; |
| 77 } | 76 } |
| 78 | 77 |
| 79 bool IOSChromeSecurityStateModelClient::IsOriginSecure(const GURL& url) { | 78 bool IOSChromeSecurityStateModelClient::IsOriginSecure(const GURL& url) { |
| 80 return web::IsOriginSecure(url); | 79 return web::IsOriginSecure(url); |
| 81 } | 80 } |
| 82 | 81 |
| 83 void IOSChromeSecurityStateModelClient::GetVisibleSecurityState( | 82 void IOSChromeSecurityStateModelClient::GetVisibleSecurityState( |
| 84 security_state::SecurityStateModel::VisibleSecurityState* state) { | 83 security_state::SecurityStateModel::VisibleSecurityState* state) { |
| 85 web::NavigationItem* item = | 84 web::NavigationItem* item = |
| 86 web_state_->GetNavigationManager()->GetVisibleItem(); | 85 web_state_->GetNavigationManager()->GetVisibleItem(); |
| 87 if (!item || item->GetSSL().security_style == web::SECURITY_STYLE_UNKNOWN) { | 86 if (!item || item->GetSSL().security_style == web::SECURITY_STYLE_UNKNOWN) { |
| 88 *state = security_state::SecurityStateModel::VisibleSecurityState(); | 87 *state = security_state::SecurityStateModel::VisibleSecurityState(); |
| 89 return; | 88 return; |
| 90 } | 89 } |
| 91 | 90 |
| 92 state->connection_info_initialized = true; | 91 state->connection_info_initialized = true; |
| 93 state->url = item->GetURL(); | 92 state->url = item->GetURL(); |
| 94 const web::SSLStatus& ssl = item->GetSSL(); | 93 const web::SSLStatus& ssl = item->GetSSL(); |
| 95 state->initial_security_level = | 94 state->initial_security_level = |
| 96 GetSecurityLevelForSecurityStyle(ssl.security_style); | 95 GetSecurityLevelForSecurityStyle(ssl.security_style); |
| 97 state->cert_id = ssl.cert_id; | 96 state->certificate = ssl.certificate; |
| 98 state->cert_status = ssl.cert_status; | 97 state->cert_status = ssl.cert_status; |
| 99 state->connection_status = ssl.connection_status; | 98 state->connection_status = ssl.connection_status; |
| 100 state->security_bits = ssl.security_bits; | 99 state->security_bits = ssl.security_bits; |
| 101 state->displayed_mixed_content = | 100 state->displayed_mixed_content = |
| 102 (ssl.content_status & web::SSLStatus::DISPLAYED_INSECURE_CONTENT) ? true | 101 (ssl.content_status & web::SSLStatus::DISPLAYED_INSECURE_CONTENT) ? true |
| 103 : false; | 102 : false; |
| 104 } | 103 } |
| OLD | NEW |