| 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/navigation_item.h" | 10 #include "ios/web/public/navigation_item.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 security_state_model_->SetClient(this); | 53 security_state_model_->SetClient(this); |
| 54 } | 54 } |
| 55 | 55 |
| 56 IOSChromeSecurityStateModelClient::~IOSChromeSecurityStateModelClient() {} | 56 IOSChromeSecurityStateModelClient::~IOSChromeSecurityStateModelClient() {} |
| 57 | 57 |
| 58 void IOSChromeSecurityStateModelClient::GetSecurityInfo( | 58 void IOSChromeSecurityStateModelClient::GetSecurityInfo( |
| 59 security_state::SecurityStateModel::SecurityInfo* result) const { | 59 security_state::SecurityStateModel::SecurityInfo* result) const { |
| 60 return security_state_model_->GetSecurityInfo(result); | 60 return security_state_model_->GetSecurityInfo(result); |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool IOSChromeSecurityStateModelClient::RetrieveCert( | |
| 64 scoped_refptr<net::X509Certificate>* cert) { | |
| 65 web::NavigationItem* item = | |
| 66 web_state_->GetNavigationManager()->GetVisibleItem(); | |
| 67 if (!item || !item->GetSSL().certificate) | |
| 68 return false; | |
| 69 | |
| 70 *cert = item->GetSSL().certificate; | |
| 71 return true; | |
| 72 } | |
| 73 | |
| 74 bool IOSChromeSecurityStateModelClient::UsedPolicyInstalledCertificate() { | 63 bool IOSChromeSecurityStateModelClient::UsedPolicyInstalledCertificate() { |
| 75 return false; | 64 return false; |
| 76 } | 65 } |
| 77 | 66 |
| 78 bool IOSChromeSecurityStateModelClient::IsOriginSecure(const GURL& url) { | 67 bool IOSChromeSecurityStateModelClient::IsOriginSecure(const GURL& url) { |
| 79 return web::IsOriginSecure(url); | 68 return web::IsOriginSecure(url); |
| 80 } | 69 } |
| 81 | 70 |
| 82 void IOSChromeSecurityStateModelClient::GetVisibleSecurityState( | 71 void IOSChromeSecurityStateModelClient::GetVisibleSecurityState( |
| 83 security_state::SecurityStateModel::VisibleSecurityState* state) { | 72 security_state::SecurityStateModel::VisibleSecurityState* state) { |
| 84 web::NavigationItem* item = | 73 web::NavigationItem* item = |
| 85 web_state_->GetNavigationManager()->GetVisibleItem(); | 74 web_state_->GetNavigationManager()->GetVisibleItem(); |
| 86 if (!item || item->GetSSL().security_style == web::SECURITY_STYLE_UNKNOWN) { | 75 if (!item || item->GetSSL().security_style == web::SECURITY_STYLE_UNKNOWN) { |
| 87 *state = security_state::SecurityStateModel::VisibleSecurityState(); | 76 *state = security_state::SecurityStateModel::VisibleSecurityState(); |
| 88 return; | 77 return; |
| 89 } | 78 } |
| 90 | 79 |
| 91 state->connection_info_initialized = true; | 80 state->connection_info_initialized = true; |
| 92 state->url = item->GetURL(); | 81 state->url = item->GetURL(); |
| 93 const web::SSLStatus& ssl = item->GetSSL(); | 82 const web::SSLStatus& ssl = item->GetSSL(); |
| 94 state->initial_security_level = | |
| 95 GetSecurityLevelForSecurityStyle(ssl.security_style); | |
| 96 state->certificate = ssl.certificate; | 83 state->certificate = ssl.certificate; |
| 97 state->cert_status = ssl.cert_status; | 84 state->cert_status = ssl.cert_status; |
| 98 state->connection_status = ssl.connection_status; | 85 state->connection_status = ssl.connection_status; |
| 99 state->security_bits = ssl.security_bits; | 86 state->security_bits = ssl.security_bits; |
| 100 state->displayed_mixed_content = | 87 state->displayed_mixed_content = |
| 101 (ssl.content_status & web::SSLStatus::DISPLAYED_INSECURE_CONTENT) ? true | 88 (ssl.content_status & web::SSLStatus::DISPLAYED_INSECURE_CONTENT) ? true |
| 102 : false; | 89 : false; |
| 103 } | 90 } |
| OLD | NEW |