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