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_remover.h" | 5 #include "chrome/browser/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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 browser_process_->SetSafeBrowsingService(NULL); | 189 browser_process_->SetSafeBrowsingService(NULL); |
190 } | 190 } |
191 | 191 |
192 private: | 192 private: |
193 TestingBrowserProcess* browser_process_; | 193 TestingBrowserProcess* browser_process_; |
194 | 194 |
195 DISALLOW_COPY_AND_ASSIGN(RemoveSafeBrowsingCookieTester); | 195 DISALLOW_COPY_AND_ASSIGN(RemoveSafeBrowsingCookieTester); |
196 }; | 196 }; |
197 #endif | 197 #endif |
198 | 198 |
199 class RemoveOriginBoundCertTester : public BrowsingDataRemoverTester { | 199 class RemoveOriginBoundCertTester : public BrowsingDataRemoverTester { |
Mike West
2012/03/07 10:31:47
RemoveDomainBoundCertTester
| |
200 public: | 200 public: |
201 explicit RemoveOriginBoundCertTester(TestingProfile* profile) { | 201 explicit RemoveOriginBoundCertTester(TestingProfile* profile) { |
202 profile->CreateRequestContext(); | 202 profile->CreateRequestContext(); |
203 ob_cert_service_ = profile->GetRequestContext()->GetURLRequestContext()-> | 203 ob_cert_service_ = profile->GetRequestContext()->GetURLRequestContext()-> |
204 origin_bound_cert_service(); | 204 origin_bound_cert_service(); |
Mike West
2012/03/07 10:31:47
Is this still called "origin_bound_cert_service"?
| |
205 } | 205 } |
206 | 206 |
207 int OriginBoundCertCount() { | 207 int DomainBoundCertCount() { |
208 return ob_cert_service_->cert_count(); | 208 return ob_cert_service_->cert_count(); |
Mike West
2012/03/07 10:31:47
Nit: db_cert_service
| |
209 } | 209 } |
210 | 210 |
211 // Add an origin bound cert for |origin| with specific creation and expiry | 211 // Add an domain bound cert for |origin| with specific creation and expiry |
Mike West
2012/03/07 10:31:47
Nit: fix the variable name here and in the functio
| |
212 // times. The cert and key data will be filled with dummy values. | 212 // times. The cert and key data will be filled with dummy values. |
213 void AddOriginBoundCertWithTimes(const std::string& origin, | 213 void AddDomainBoundCertWithTimes(const std::string& origin, |
214 base::Time creation_time, | 214 base::Time creation_time, |
215 base::Time expiration_time) { | 215 base::Time expiration_time) { |
216 GetCertStore()->SetOriginBoundCert(origin, net::CLIENT_CERT_RSA_SIGN, | 216 GetCertStore()->SetOriginBoundCert(origin, net::CLIENT_CERT_RSA_SIGN, |
217 creation_time, expiration_time, | 217 creation_time, expiration_time, |
218 "a", "b"); | 218 "a", "b"); |
219 } | 219 } |
220 | 220 |
221 // Add an origin bound cert for |origin|, with the current time as the | 221 // Add an origin bound cert for |origin|, with the current time as the |
Mike West
2012/03/07 10:31:47
Nit: fix the comment here, and the variable name b
| |
222 // creation time. The cert and key data will be filled with dummy values. | 222 // creation time. The cert and key data will be filled with dummy values. |
223 void AddOriginBoundCert(const std::string& origin) { | 223 void AddDomainBoundCert(const std::string& origin) { |
224 base::Time now = base::Time::Now(); | 224 base::Time now = base::Time::Now(); |
225 AddOriginBoundCertWithTimes(origin, | 225 AddDomainBoundCertWithTimes(origin, |
226 now, | 226 now, |
227 now + base::TimeDelta::FromDays(1)); | 227 now + base::TimeDelta::FromDays(1)); |
228 } | 228 } |
229 | 229 |
230 net::OriginBoundCertStore* GetCertStore() { | 230 net::OriginBoundCertStore* GetCertStore() { |
Mike West
2012/03/07 10:31:47
Same naming question.
| |
231 return ob_cert_service_->GetCertStore(); | 231 return ob_cert_service_->GetCertStore(); |
232 } | 232 } |
233 | 233 |
234 private: | 234 private: |
235 net::OriginBoundCertService* ob_cert_service_; | 235 net::OriginBoundCertService* ob_cert_service_; |
Mike West
2012/03/07 10:31:47
Same naming question.
| |
236 | 236 |
237 net::SSLClientCertType type_; | 237 net::SSLClientCertType type_; |
238 std::string key_; | 238 std::string key_; |
239 std::string cert_; | 239 std::string cert_; |
240 | 240 |
241 DISALLOW_COPY_AND_ASSIGN(RemoveOriginBoundCertTester); | 241 DISALLOW_COPY_AND_ASSIGN(RemoveOriginBoundCertTester); |
242 }; | 242 }; |
243 | 243 |
244 class RemoveHistoryTester : public BrowsingDataRemoverTester { | 244 class RemoveHistoryTester : public BrowsingDataRemoverTester { |
245 public: | 245 public: |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 504 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
505 BrowsingDataRemover::REMOVE_COOKIES, tester.get()); | 505 BrowsingDataRemover::REMOVE_COOKIES, tester.get()); |
506 | 506 |
507 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 507 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
508 // Removing with time period other than EVERYTHING should not clear safe | 508 // Removing with time period other than EVERYTHING should not clear safe |
509 // browsing cookies. | 509 // browsing cookies. |
510 EXPECT_TRUE(tester->ContainsCookie()); | 510 EXPECT_TRUE(tester->ContainsCookie()); |
511 } | 511 } |
512 #endif | 512 #endif |
513 | 513 |
514 TEST_F(BrowsingDataRemoverTest, RemoveOriginBoundCertForever) { | 514 TEST_F(BrowsingDataRemoverTest, RemoveOriginBoundCertForever) { |
Mike West
2012/03/07 10:31:47
RemoveDomainBoundCertForever
| |
515 scoped_ptr<RemoveOriginBoundCertTester> tester( | 515 scoped_ptr<RemoveOriginBoundCertTester> tester( |
516 new RemoveOriginBoundCertTester(GetProfile())); | 516 new RemoveOriginBoundCertTester(GetProfile())); |
517 | 517 |
518 tester->AddOriginBoundCert(kTestkOrigin1); | 518 tester->AddDomainBoundCert(kTestkOrigin1); |
519 EXPECT_EQ(1, tester->OriginBoundCertCount()); | 519 EXPECT_EQ(1, tester->DomainBoundCertCount()); |
520 | 520 |
521 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 521 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
522 BrowsingDataRemover::REMOVE_ORIGIN_BOUND_CERTS, tester.get()); | 522 BrowsingDataRemover::REMOVE_DOMAIN_BOUND_CERTS, tester.get()); |
523 | 523 |
524 EXPECT_EQ(BrowsingDataRemover::REMOVE_ORIGIN_BOUND_CERTS, GetRemovalMask()); | 524 EXPECT_EQ(BrowsingDataRemover::REMOVE_DOMAIN_BOUND_CERTS, GetRemovalMask()); |
525 EXPECT_EQ(0, tester->OriginBoundCertCount()); | 525 EXPECT_EQ(0, tester->DomainBoundCertCount()); |
526 } | 526 } |
527 | 527 |
528 TEST_F(BrowsingDataRemoverTest, RemoveOriginBoundCertLastHour) { | 528 TEST_F(BrowsingDataRemoverTest, RemoveOriginBoundCertLastHour) { |
Mike West
2012/03/07 10:31:47
RemoveDomainBoundCertLastHour
| |
529 scoped_ptr<RemoveOriginBoundCertTester> tester( | 529 scoped_ptr<RemoveOriginBoundCertTester> tester( |
530 new RemoveOriginBoundCertTester(GetProfile())); | 530 new RemoveOriginBoundCertTester(GetProfile())); |
531 | 531 |
532 base::Time now = base::Time::Now(); | 532 base::Time now = base::Time::Now(); |
533 tester->AddOriginBoundCert(kTestkOrigin1); | 533 tester->AddDomainBoundCert(kTestkOrigin1); |
534 tester->AddOriginBoundCertWithTimes(kTestkOrigin2, | 534 tester->AddDomainBoundCertWithTimes(kTestkOrigin2, |
535 now - base::TimeDelta::FromHours(2), | 535 now - base::TimeDelta::FromHours(2), |
536 now); | 536 now); |
537 EXPECT_EQ(2, tester->OriginBoundCertCount()); | 537 EXPECT_EQ(2, tester->DomainBoundCertCount()); |
538 | 538 |
539 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 539 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
540 BrowsingDataRemover::REMOVE_ORIGIN_BOUND_CERTS, tester.get()); | 540 BrowsingDataRemover::REMOVE_DOMAIN_BOUND_CERTS, tester.get()); |
541 | 541 |
542 EXPECT_EQ(BrowsingDataRemover::REMOVE_ORIGIN_BOUND_CERTS, GetRemovalMask()); | 542 EXPECT_EQ(BrowsingDataRemover::REMOVE_DOMAIN_BOUND_CERTS, GetRemovalMask()); |
543 EXPECT_EQ(1, tester->OriginBoundCertCount()); | 543 EXPECT_EQ(1, tester->DomainBoundCertCount()); |
544 std::vector<net::OriginBoundCertStore::OriginBoundCert> certs; | 544 std::vector<net::OriginBoundCertStore::OriginBoundCert> certs; |
545 tester->GetCertStore()->GetAllOriginBoundCerts(&certs); | 545 tester->GetCertStore()->GetAllOriginBoundCerts(&certs); |
546 EXPECT_EQ(kTestkOrigin2, certs[0].origin()); | 546 EXPECT_EQ(kTestkOrigin2, certs[0].domain()); |
547 } | 547 } |
548 | 548 |
549 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { | 549 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { |
550 scoped_ptr<RemoveHistoryTester> tester( | 550 scoped_ptr<RemoveHistoryTester> tester( |
551 new RemoveHistoryTester(GetProfile())); | 551 new RemoveHistoryTester(GetProfile())); |
552 | 552 |
553 tester->AddHistory(kOrigin1, base::Time::Now()); | 553 tester->AddHistory(kOrigin1, base::Time::Now()); |
554 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin1)); | 554 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin1)); |
555 | 555 |
556 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 556 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
880 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin1)); | 880 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin1)); |
881 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin2)); | 881 ASSERT_TRUE(tester->HistoryContainsURL(kOrigin2)); |
882 | 882 |
883 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, | 883 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
884 BrowsingDataRemover::REMOVE_HISTORY, kOrigin2, tester.get()); | 884 BrowsingDataRemover::REMOVE_HISTORY, kOrigin2, tester.get()); |
885 | 885 |
886 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 886 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
887 EXPECT_TRUE(tester->HistoryContainsURL(kOrigin1)); | 887 EXPECT_TRUE(tester->HistoryContainsURL(kOrigin1)); |
888 EXPECT_TRUE(tester->HistoryContainsURL(kOrigin2)); | 888 EXPECT_TRUE(tester->HistoryContainsURL(kOrigin2)); |
889 } | 889 } |
OLD | NEW |