summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-11 00:17:44 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-11 00:17:44 +0000
commitb7dbbec00aa43f94a078f2e5852601fb725d4b4b (patch)
tree12405dbbd5de879c940cc2b86a02ce0cb5ae8ef7 /net
parent32ba74abd684923faaa26a1e717765af07d7a7bb (diff)
downloadchromium_src-b7dbbec00aa43f94a078f2e5852601fb725d4b4b.zip
chromium_src-b7dbbec00aa43f94a078f2e5852601fb725d4b4b.tar.gz
chromium_src-b7dbbec00aa43f94a078f2e5852601fb725d4b4b.tar.bz2
Strict transport security: add checkbox to clear state.
This patches add a checkbox to the "Clear Browsing Data" dialog which clears the STS state when checked. Since we don't timestamp our entries (for now at least, should we?), the duration selected has no effect: we always clear everything. Mac doesn't appear to have a dialog for this yet, so no Mac specific changes. http://codereview.chromium.org/196070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25955 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/strict_transport_security_state.cc7
-rw-r--r--net/base/strict_transport_security_state.h3
-rw-r--r--net/base/strict_transport_security_state_unittest.cc14
3 files changed, 24 insertions, 0 deletions
diff --git a/net/base/strict_transport_security_state.cc b/net/base/strict_transport_security_state.cc
index fc267c5..cc812d9 100644
--- a/net/base/strict_transport_security_state.cc
+++ b/net/base/strict_transport_security_state.cc
@@ -187,6 +187,13 @@ bool StrictTransportSecurityState::ParseHeader(const std::string& value,
}
}
+void StrictTransportSecurityState::Clear() {
+ AutoLock lock(lock_);
+
+ enabled_hosts_.clear();
+ DirtyNotify();
+}
+
void StrictTransportSecurityState::SetDelegate(
StrictTransportSecurityState::Delegate* delegate) {
AutoLock lock(lock_);
diff --git a/net/base/strict_transport_security_state.h b/net/base/strict_transport_security_state.h
index 463382c..5739001 100644
--- a/net/base/strict_transport_security_state.h
+++ b/net/base/strict_transport_security_state.h
@@ -48,6 +48,9 @@ class StrictTransportSecurityState :
int* max_age,
bool* include_subdomains);
+ // Deletes all the state and notifies the delegate that the state is dirty.
+ void Clear();
+
struct State {
base::Time expiry; // the absolute time (UTC) when this record expires
bool include_subdomains; // subdomains included?
diff --git a/net/base/strict_transport_security_state_unittest.cc b/net/base/strict_transport_security_state_unittest.cc
index 5ebd358..2b769d7 100644
--- a/net/base/strict_transport_security_state_unittest.cc
+++ b/net/base/strict_transport_security_state_unittest.cc
@@ -204,3 +204,17 @@ TEST_F(StrictTransportSecurityStateTest, Serialise2) {
EXPECT_TRUE(state->IsEnabledForHost("foo.bar.baz.google.com"));
EXPECT_FALSE(state->IsEnabledForHost("com"));
}
+
+TEST_F(StrictTransportSecurityStateTest, Clear) {
+ scoped_refptr<net::StrictTransportSecurityState> state(
+ new net::StrictTransportSecurityState);
+
+ const base::Time current_time(base::Time::Now());
+ const base::Time expiry = current_time + base::TimeDelta::FromSeconds(1000);
+
+ EXPECT_FALSE(state->IsEnabledForHost("google.com"));
+ state->EnableHost("google.com", expiry, true);
+ EXPECT_TRUE(state->IsEnabledForHost("google.com"));
+ state->Clear();
+ EXPECT_FALSE(state->IsEnabledForHost("google.com"));
+}