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 "components/security_state/security_state_model.h" | 5 #include "components/security_state/security_state_model.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 key_exchange_group(0), | 286 key_exchange_group(0), |
287 obsolete_ssl_status(net::OBSOLETE_SSL_NONE), | 287 obsolete_ssl_status(net::OBSOLETE_SSL_NONE), |
288 pkp_bypassed(false) {} | 288 pkp_bypassed(false) {} |
289 | 289 |
290 SecurityStateModel::SecurityInfo::~SecurityInfo() {} | 290 SecurityStateModel::SecurityInfo::~SecurityInfo() {} |
291 | 291 |
292 SecurityStateModel::SecurityStateModel() {} | 292 SecurityStateModel::SecurityStateModel() {} |
293 | 293 |
294 SecurityStateModel::~SecurityStateModel() {} | 294 SecurityStateModel::~SecurityStateModel() {} |
295 | 295 |
296 const SecurityStateModel::SecurityInfo& SecurityStateModel::GetSecurityInfo() | 296 void SecurityStateModel::GetSecurityInfo( |
297 const { | 297 SecurityStateModel::SecurityInfo* result) const { |
298 scoped_refptr<net::X509Certificate> cert = nullptr; | 298 scoped_refptr<net::X509Certificate> cert = nullptr; |
299 client_->RetrieveCert(&cert); | 299 client_->RetrieveCert(&cert); |
300 | 300 |
301 // Check if the cached |security_info_| must be recomputed. | |
302 VisibleSecurityState new_visible_state; | 301 VisibleSecurityState new_visible_state; |
303 client_->GetVisibleSecurityState(&new_visible_state); | 302 client_->GetVisibleSecurityState(&new_visible_state); |
304 bool visible_security_state_changed = | 303 SecurityInfoForRequest(client_, new_visible_state, cert, result); |
305 !(visible_security_state_ == new_visible_state); | |
306 if (!visible_security_state_changed) { | |
307 // A cert must be present in order for the site to be considered | |
308 // EV_SECURE, and the cert might have been removed since the | |
309 // security level was last computed. | |
310 if (security_info_.security_level == EV_SECURE && !cert) { | |
311 security_info_.security_level = SECURE; | |
312 } | |
313 return security_info_; | |
314 } | |
315 | |
316 visible_security_state_ = new_visible_state; | |
317 SecurityInfoForRequest(client_, visible_security_state_, cert, | |
318 &security_info_); | |
319 return security_info_; | |
320 } | 304 } |
321 | 305 |
322 void SecurityStateModel::SetClient(SecurityStateModelClient* client) { | 306 void SecurityStateModel::SetClient(SecurityStateModelClient* client) { |
323 client_ = client; | 307 client_ = client; |
324 } | 308 } |
325 | 309 |
326 SecurityStateModel::VisibleSecurityState::VisibleSecurityState() | 310 SecurityStateModel::VisibleSecurityState::VisibleSecurityState() |
327 : initial_security_level(SecurityStateModel::NONE), | 311 : initial_security_level(SecurityStateModel::NONE), |
328 fails_malware_check(false), | 312 fails_malware_check(false), |
329 connection_info_initialized(false), | 313 connection_info_initialized(false), |
(...skipping 28 matching lines...) Expand all Loading... |
358 other.displayed_content_with_cert_errors && | 342 other.displayed_content_with_cert_errors && |
359 ran_content_with_cert_errors == other.ran_content_with_cert_errors && | 343 ran_content_with_cert_errors == other.ran_content_with_cert_errors && |
360 pkp_bypassed == other.pkp_bypassed && | 344 pkp_bypassed == other.pkp_bypassed && |
361 displayed_password_field_on_http == | 345 displayed_password_field_on_http == |
362 other.displayed_password_field_on_http && | 346 other.displayed_password_field_on_http && |
363 displayed_credit_card_field_on_http == | 347 displayed_credit_card_field_on_http == |
364 other.displayed_credit_card_field_on_http); | 348 other.displayed_credit_card_field_on_http); |
365 } | 349 } |
366 | 350 |
367 } // namespace security_state | 351 } // namespace security_state |
OLD | NEW |