| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_ssl_host_state_delegate.h" | 5 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 294 |
| 295 void ChromeSSLHostStateDelegate::AllowCert(const std::string& host, | 295 void ChromeSSLHostStateDelegate::AllowCert(const std::string& host, |
| 296 const net::X509Certificate& cert, | 296 const net::X509Certificate& cert, |
| 297 net::CertStatus error) { | 297 net::CertStatus error) { |
| 298 GURL url = GetSecureGURLForHost(host); | 298 GURL url = GetSecureGURLForHost(host); |
| 299 HostContentSettingsMap* map = | 299 HostContentSettingsMap* map = |
| 300 HostContentSettingsMapFactory::GetForProfile(profile_); | 300 HostContentSettingsMapFactory::GetForProfile(profile_); |
| 301 std::unique_ptr<base::Value> value(map->GetWebsiteSetting( | 301 std::unique_ptr<base::Value> value(map->GetWebsiteSetting( |
| 302 url, url, CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, std::string(), NULL)); | 302 url, url, CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, std::string(), NULL)); |
| 303 | 303 |
| 304 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) | 304 if (!value.get() || !value->IsType(base::Value::Type::DICTIONARY)) |
| 305 value.reset(new base::DictionaryValue()); | 305 value.reset(new base::DictionaryValue()); |
| 306 | 306 |
| 307 base::DictionaryValue* dict; | 307 base::DictionaryValue* dict; |
| 308 bool success = value->GetAsDictionary(&dict); | 308 bool success = value->GetAsDictionary(&dict); |
| 309 DCHECK(success); | 309 DCHECK(success); |
| 310 | 310 |
| 311 bool expired_previous_decision; // unused value in this function | 311 bool expired_previous_decision; // unused value in this function |
| 312 base::DictionaryValue* cert_dict = GetValidCertDecisionsDict( | 312 base::DictionaryValue* cert_dict = GetValidCertDecisionsDict( |
| 313 dict, CREATE_DICTIONARY_ENTRIES, &expired_previous_decision); | 313 dict, CREATE_DICTIONARY_ENTRIES, &expired_previous_decision); |
| 314 // If a a valid certificate dictionary cannot be extracted from the content | 314 // If a a valid certificate dictionary cannot be extracted from the content |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 *expired_previous_decision = false; | 362 *expired_previous_decision = false; |
| 363 | 363 |
| 364 // If the appropriate flag is set, let requests on localhost go | 364 // If the appropriate flag is set, let requests on localhost go |
| 365 // through even if there are certificate errors. Errors on localhost | 365 // through even if there are certificate errors. Errors on localhost |
| 366 // are unlikely to indicate actual security problems. | 366 // are unlikely to indicate actual security problems. |
| 367 bool allow_localhost = base::CommandLine::ForCurrentProcess()->HasSwitch( | 367 bool allow_localhost = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 368 switches::kAllowInsecureLocalhost); | 368 switches::kAllowInsecureLocalhost); |
| 369 if (allow_localhost && net::IsLocalhost(url.host())) | 369 if (allow_localhost && net::IsLocalhost(url.host())) |
| 370 return ALLOWED; | 370 return ALLOWED; |
| 371 | 371 |
| 372 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) | 372 if (!value.get() || !value->IsType(base::Value::Type::DICTIONARY)) |
| 373 return DENIED; | 373 return DENIED; |
| 374 | 374 |
| 375 base::DictionaryValue* dict; // Owned by value | 375 base::DictionaryValue* dict; // Owned by value |
| 376 int policy_decision; | 376 int policy_decision; |
| 377 bool success = value->GetAsDictionary(&dict); | 377 bool success = value->GetAsDictionary(&dict); |
| 378 DCHECK(success); | 378 DCHECK(success); |
| 379 | 379 |
| 380 base::DictionaryValue* cert_error_dict; // Owned by value | 380 base::DictionaryValue* cert_error_dict; // Owned by value |
| 381 cert_error_dict = GetValidCertDecisionsDict( | 381 cert_error_dict = GetValidCertDecisionsDict( |
| 382 dict, DO_NOT_CREATE_DICTIONARY_ENTRIES, expired_previous_decision); | 382 dict, DO_NOT_CREATE_DICTIONARY_ENTRIES, expired_previous_decision); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 const std::string& host) const { | 438 const std::string& host) const { |
| 439 GURL url = GetSecureGURLForHost(host); | 439 GURL url = GetSecureGURLForHost(host); |
| 440 const ContentSettingsPattern pattern = | 440 const ContentSettingsPattern pattern = |
| 441 ContentSettingsPattern::FromURLNoWildcard(url); | 441 ContentSettingsPattern::FromURLNoWildcard(url); |
| 442 HostContentSettingsMap* map = | 442 HostContentSettingsMap* map = |
| 443 HostContentSettingsMapFactory::GetForProfile(profile_); | 443 HostContentSettingsMapFactory::GetForProfile(profile_); |
| 444 | 444 |
| 445 std::unique_ptr<base::Value> value(map->GetWebsiteSetting( | 445 std::unique_ptr<base::Value> value(map->GetWebsiteSetting( |
| 446 url, url, CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, std::string(), NULL)); | 446 url, url, CONTENT_SETTINGS_TYPE_SSL_CERT_DECISIONS, std::string(), NULL)); |
| 447 | 447 |
| 448 if (!value.get() || !value->IsType(base::Value::TYPE_DICTIONARY)) | 448 if (!value.get() || !value->IsType(base::Value::Type::DICTIONARY)) |
| 449 return false; | 449 return false; |
| 450 | 450 |
| 451 base::DictionaryValue* dict; // Owned by value | 451 base::DictionaryValue* dict; // Owned by value |
| 452 bool success = value->GetAsDictionary(&dict); | 452 bool success = value->GetAsDictionary(&dict); |
| 453 DCHECK(success); | 453 DCHECK(success); |
| 454 | 454 |
| 455 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 455 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
| 456 int policy_decision; // Owned by dict | 456 int policy_decision; // Owned by dict |
| 457 success = it.value().GetAsInteger(&policy_decision); | 457 success = it.value().GetAsInteger(&policy_decision); |
| 458 if (success && (static_cast<CertJudgment>(policy_decision) == ALLOWED)) | 458 if (success && (static_cast<CertJudgment>(policy_decision) == ALLOWED)) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 487 case CERT_ERRORS_CONTENT: | 487 case CERT_ERRORS_CONTENT: |
| 488 return !!ran_content_with_cert_errors_hosts_.count( | 488 return !!ran_content_with_cert_errors_hosts_.count( |
| 489 BrokenHostEntry(host, child_id)); | 489 BrokenHostEntry(host, child_id)); |
| 490 } | 490 } |
| 491 NOTREACHED(); | 491 NOTREACHED(); |
| 492 return false; | 492 return false; |
| 493 } | 493 } |
| 494 void ChromeSSLHostStateDelegate::SetClock(std::unique_ptr<base::Clock> clock) { | 494 void ChromeSSLHostStateDelegate::SetClock(std::unique_ptr<base::Clock> clock) { |
| 495 clock_ = std::move(clock); | 495 clock_ = std::move(clock); |
| 496 } | 496 } |
| OLD | NEW |