Chromium Code Reviews| Index: net/base/transport_security_state.cc |
| diff --git a/net/base/transport_security_state.cc b/net/base/transport_security_state.cc |
| index aed714caafb8f10880947802fef863bb0b2daba6..b7ac9f0a7a50bfff5d59927eccd0def3d00fc09c 100644 |
| --- a/net/base/transport_security_state.cc |
| +++ b/net/base/transport_security_state.cc |
| @@ -45,10 +45,32 @@ void TransportSecurityState::EnableHost(const std::string& host, |
| if (IsEnabledForHost(&existing_state, host)) |
| state_copy.created = existing_state.created; |
| + // We don't store these values. |
| + state_copy.preloaded = false; |
| + state_copy.domain.clear(); |
| + |
| enabled_hosts_[std::string(hashed, sizeof(hashed))] = state_copy; |
| DirtyNotify(); |
| } |
| +bool TransportSecurityState::DeleteHost(const std::string& host) { |
| + const std::string canonicalised_host = CanonicaliseHost(host); |
| + if (canonicalised_host.empty()) |
| + return false; |
| + |
| + char hashed[base::SHA256_LENGTH]; |
| + base::SHA256HashString(canonicalised_host, hashed, sizeof(hashed)); |
|
willchan no longer on Chromium
2011/02/11 21:16:27
arraysize
|
| + |
| + std::map<std::string, DomainState>::iterator i = enabled_hosts_.find( |
| + std::string(hashed, sizeof(hashed))); |
| + if (i != enabled_hosts_.end()) { |
| + enabled_hosts_.erase(i); |
| + DirtyNotify(); |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| // IncludeNUL converts a char* to a std::string and includes the terminating |
| // NUL in the result. |
| static std::string IncludeNUL(const char* in) { |
| @@ -66,9 +88,11 @@ bool TransportSecurityState::IsEnabledForHost(DomainState* result, |
| result->created = result->expiry = base::Time::FromTimeT(0); |
| result->mode = DomainState::MODE_STRICT; |
| result->include_subdomains = include_subdomains; |
| + result->preloaded = true; |
| return true; |
| } |
| + result->preloaded = false; |
| base::Time current_time(base::Time::Now()); |
| for (size_t i = 0; canonicalised_host[i]; i += canonicalised_host[i] + 1) { |
| @@ -88,6 +112,7 @@ bool TransportSecurityState::IsEnabledForHost(DomainState* result, |
| } |
| *result = j->second; |
| + result->domain = DNSDomainToString(&canonicalised_host[i]); |
| // If we matched the domain exactly, it doesn't matter what the value of |
| // include_subdomains is. |