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