Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Unified Diff: net/base/transport_security_state.cc

Issue 460135: STS: add chrome.google.com to the built in STS list. (Closed)
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/transport_security_state.h ('k') | net/base/transport_security_state_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/transport_security_state.cc
diff --git a/net/base/transport_security_state.cc b/net/base/transport_security_state.cc
index 35b930ce5365b4e02b46c0b49960d735b0126f87..ccce6a093857bc5e6726775b43a7e300e4f19a1c 100644
--- a/net/base/transport_security_state.cc
+++ b/net/base/transport_security_state.cc
@@ -24,6 +24,11 @@ TransportSecurityState::TransportSecurityState()
void TransportSecurityState::EnableHost(const std::string& host,
const DomainState& state) {
+ if (GetBuiltin(NULL, host)) {
+ // You cannot override the settings of a builtin record.
+ return;
+ }
+
const std::string canonicalised_host = CanonicaliseHost(host);
if (canonicalised_host.empty())
return;
@@ -52,23 +57,27 @@ bool TransportSecurityState::IsEnabledForHost(DomainState* result,
sizeof(hashed_domain));
std::map<std::string, DomainState>::iterator j =
enabled_hosts_.find(std::string(hashed_domain, sizeof(hashed_domain)));
- if (j == enabled_hosts_.end())
- continue;
+ if (j != enabled_hosts_.end()) {
+ if (current_time > j->second.expiry) {
+ enabled_hosts_.erase(j);
+ DirtyNotify();
+ continue;
+ }
+ *result = j->second;
- if (current_time > j->second.expiry) {
- enabled_hosts_.erase(j);
- DirtyNotify();
+ } else if (GetBuiltin(result, host)) {
+ // The host has a builtin record. We don't check the expiry on these.
+ } else {
+ // no record for this host. Try the next least specific domain.
continue;
}
- *result = j->second;
-
// If we matched the domain exactly, it doesn't matter what the value of
// include_subdomains is.
if (i == 0)
return true;
- return j->second.include_subdomains;
+ return result->include_subdomains;
}
return false;
@@ -334,4 +343,22 @@ std::string TransportSecurityState::CanonicaliseHost(const std::string& host) {
return new_host;
}
+bool TransportSecurityState::GetBuiltin(DomainState* result,
+ const std::string& host) {
+ // This time is somewhere around the year 2970.
+ static const double kNoExpiry = 31557600000;
+
+ // For the moment this list is just compiled into the browser.
+ if (host == "chrome.google.com") {
abarth-chromium 2009/12/08 03:09:42 They rolled back this change because they're hosti
+ if (result) {
+ result->mode = DomainState::MODE_STRICT;
+ result->include_subdomains = true;
abarth-chromium 2009/12/08 03:09:42 This should be false.
+ result->expiry = base::Time::FromDoubleT(kNoExpiry);
+ }
+ return true;
+ }
+
+ return false;
+}
+
} // namespace
« no previous file with comments | « net/base/transport_security_state.h ('k') | net/base/transport_security_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698