| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browsing_data/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 | 291 |
| 292 // Add a server bound cert for |server|, with the current time as the | 292 // Add a server bound cert for |server|, with the current time as the |
| 293 // creation time. The cert and key data will be filled with dummy values. | 293 // creation time. The cert and key data will be filled with dummy values. |
| 294 void AddServerBoundCert(const std::string& server_identifier) { | 294 void AddServerBoundCert(const std::string& server_identifier) { |
| 295 base::Time now = base::Time::Now(); | 295 base::Time now = base::Time::Now(); |
| 296 AddServerBoundCertWithTimes(server_identifier, | 296 AddServerBoundCertWithTimes(server_identifier, |
| 297 now, | 297 now, |
| 298 now + base::TimeDelta::FromDays(1)); | 298 now + base::TimeDelta::FromDays(1)); |
| 299 } | 299 } |
| 300 | 300 |
| 301 void GetCertList(net::ServerBoundCertStore::ServerBoundCertList* certs) { |
| 302 GetCertStore()->GetAllServerBoundCerts( |
| 303 base::Bind(&RemoveServerBoundCertTester::GetAllCertsCallback, certs)); |
| 304 } |
| 305 |
| 301 net::ServerBoundCertStore* GetCertStore() { | 306 net::ServerBoundCertStore* GetCertStore() { |
| 302 return server_bound_cert_service_->GetCertStore(); | 307 return server_bound_cert_service_->GetCertStore(); |
| 303 } | 308 } |
| 304 | 309 |
| 305 int ssl_config_changed_count() const { | 310 int ssl_config_changed_count() const { |
| 306 return ssl_config_changed_count_; | 311 return ssl_config_changed_count_; |
| 307 } | 312 } |
| 308 | 313 |
| 309 // net::SSLConfigService::Observer implementation: | 314 // net::SSLConfigService::Observer implementation: |
| 310 virtual void OnSSLConfigChanged() OVERRIDE { | 315 virtual void OnSSLConfigChanged() OVERRIDE { |
| 311 ssl_config_changed_count_++; | 316 ssl_config_changed_count_++; |
| 312 } | 317 } |
| 313 | 318 |
| 314 private: | 319 private: |
| 320 static void GetAllCertsCallback( |
| 321 net::ServerBoundCertStore::ServerBoundCertList* dest, |
| 322 const net::ServerBoundCertStore::ServerBoundCertList& result) { |
| 323 *dest = result; |
| 324 } |
| 325 |
| 315 net::ServerBoundCertService* server_bound_cert_service_; | 326 net::ServerBoundCertService* server_bound_cert_service_; |
| 316 scoped_refptr<net::SSLConfigService> ssl_config_service_; | 327 scoped_refptr<net::SSLConfigService> ssl_config_service_; |
| 317 int ssl_config_changed_count_; | 328 int ssl_config_changed_count_; |
| 318 | 329 |
| 319 DISALLOW_COPY_AND_ASSIGN(RemoveServerBoundCertTester); | 330 DISALLOW_COPY_AND_ASSIGN(RemoveServerBoundCertTester); |
| 320 }; | 331 }; |
| 321 | 332 |
| 322 class RemoveHistoryTester { | 333 class RemoveHistoryTester { |
| 323 public: | 334 public: |
| 324 explicit RemoveHistoryTester(TestingProfile* profile) | 335 explicit RemoveHistoryTester(TestingProfile* profile) |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 EXPECT_EQ(2, tester.ServerBoundCertCount()); | 716 EXPECT_EQ(2, tester.ServerBoundCertCount()); |
| 706 | 717 |
| 707 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 718 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 708 BrowsingDataRemover::REMOVE_SERVER_BOUND_CERTS, false); | 719 BrowsingDataRemover::REMOVE_SERVER_BOUND_CERTS, false); |
| 709 | 720 |
| 710 EXPECT_EQ(BrowsingDataRemover::REMOVE_SERVER_BOUND_CERTS, GetRemovalMask()); | 721 EXPECT_EQ(BrowsingDataRemover::REMOVE_SERVER_BOUND_CERTS, GetRemovalMask()); |
| 711 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); | 722 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); |
| 712 EXPECT_EQ(1, tester.ssl_config_changed_count()); | 723 EXPECT_EQ(1, tester.ssl_config_changed_count()); |
| 713 ASSERT_EQ(1, tester.ServerBoundCertCount()); | 724 ASSERT_EQ(1, tester.ServerBoundCertCount()); |
| 714 net::ServerBoundCertStore::ServerBoundCertList certs; | 725 net::ServerBoundCertStore::ServerBoundCertList certs; |
| 715 tester.GetCertStore()->GetAllServerBoundCerts(&certs); | 726 tester.GetCertList(&certs); |
| 727 ASSERT_EQ(1U, certs.size()); |
| 716 EXPECT_EQ(kTestOrigin2, certs.front().server_identifier()); | 728 EXPECT_EQ(kTestOrigin2, certs.front().server_identifier()); |
| 717 } | 729 } |
| 718 | 730 |
| 719 TEST_F(BrowsingDataRemoverTest, RemoveUnprotectedLocalStorageForever) { | 731 TEST_F(BrowsingDataRemoverTest, RemoveUnprotectedLocalStorageForever) { |
| 720 // Protect kOrigin1. | 732 // Protect kOrigin1. |
| 721 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy = | 733 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy = |
| 722 new MockExtensionSpecialStoragePolicy; | 734 new MockExtensionSpecialStoragePolicy; |
| 723 mock_policy->AddProtected(kOrigin1.GetOrigin()); | 735 mock_policy->AddProtected(kOrigin1.GetOrigin()); |
| 724 GetProfile()->SetExtensionSpecialStoragePolicy(mock_policy); | 736 GetProfile()->SetExtensionSpecialStoragePolicy(mock_policy); |
| 725 | 737 |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 ASSERT_TRUE(tester.HasProfile()); | 1247 ASSERT_TRUE(tester.HasProfile()); |
| 1236 | 1248 |
| 1237 BlockUntilBrowsingDataRemoved( | 1249 BlockUntilBrowsingDataRemoved( |
| 1238 BrowsingDataRemover::EVERYTHING, | 1250 BrowsingDataRemover::EVERYTHING, |
| 1239 BrowsingDataRemover::REMOVE_FORM_DATA, false); | 1251 BrowsingDataRemover::REMOVE_FORM_DATA, false); |
| 1240 | 1252 |
| 1241 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); | 1253 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); |
| 1242 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); | 1254 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginSetMask()); |
| 1243 ASSERT_FALSE(tester.HasProfile()); | 1255 ASSERT_FALSE(tester.HasProfile()); |
| 1244 } | 1256 } |
| OLD | NEW |