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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 StoragePartitionRemovalData() : remove_mask(0), | 129 StoragePartitionRemovalData() : remove_mask(0), |
130 quota_storage_remove_mask(0) {} | 130 quota_storage_remove_mask(0) {} |
131 }; | 131 }; |
132 | 132 |
133 class TestStoragePartition : public StoragePartition { | 133 class TestStoragePartition : public StoragePartition { |
134 public: | 134 public: |
135 TestStoragePartition() {} | 135 TestStoragePartition() {} |
136 virtual ~TestStoragePartition() {} | 136 virtual ~TestStoragePartition() {} |
137 | 137 |
138 // content::StoragePartition implementation. | 138 // content::StoragePartition implementation. |
139 virtual base::FilePath GetPath() OVERRIDE { return base::FilePath(); } | 139 virtual base::FilePath GetPath() override { return base::FilePath(); } |
140 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE { | 140 virtual net::URLRequestContextGetter* GetURLRequestContext() override { |
141 return NULL; | 141 return NULL; |
142 } | 142 } |
143 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() OVERRIDE { | 143 virtual net::URLRequestContextGetter* GetMediaURLRequestContext() override { |
144 return NULL; | 144 return NULL; |
145 } | 145 } |
146 virtual storage::QuotaManager* GetQuotaManager() OVERRIDE { return NULL; } | 146 virtual storage::QuotaManager* GetQuotaManager() override { return NULL; } |
147 virtual content::AppCacheService* GetAppCacheService() OVERRIDE { | 147 virtual content::AppCacheService* GetAppCacheService() override { |
148 return NULL; | 148 return NULL; |
149 } | 149 } |
150 virtual storage::FileSystemContext* GetFileSystemContext() OVERRIDE { | 150 virtual storage::FileSystemContext* GetFileSystemContext() override { |
151 return NULL; | 151 return NULL; |
152 } | 152 } |
153 virtual storage::DatabaseTracker* GetDatabaseTracker() OVERRIDE { | 153 virtual storage::DatabaseTracker* GetDatabaseTracker() override { |
154 return NULL; | 154 return NULL; |
155 } | 155 } |
156 virtual content::DOMStorageContext* GetDOMStorageContext() OVERRIDE { | 156 virtual content::DOMStorageContext* GetDOMStorageContext() override { |
157 return NULL; | 157 return NULL; |
158 } | 158 } |
159 virtual content::IndexedDBContext* GetIndexedDBContext() OVERRIDE { | 159 virtual content::IndexedDBContext* GetIndexedDBContext() override { |
160 return NULL; | 160 return NULL; |
161 } | 161 } |
162 virtual content::ServiceWorkerContext* GetServiceWorkerContext() OVERRIDE { | 162 virtual content::ServiceWorkerContext* GetServiceWorkerContext() override { |
163 return NULL; | 163 return NULL; |
164 } | 164 } |
165 | 165 |
166 virtual void ClearDataForOrigin(uint32 remove_mask, | 166 virtual void ClearDataForOrigin(uint32 remove_mask, |
167 uint32 quota_storage_remove_mask, | 167 uint32 quota_storage_remove_mask, |
168 const GURL& storage_origin, | 168 const GURL& storage_origin, |
169 net::URLRequestContextGetter* rq_context, | 169 net::URLRequestContextGetter* rq_context, |
170 const base::Closure& callback) OVERRIDE { | 170 const base::Closure& callback) override { |
171 BrowserThread::PostTask(BrowserThread::UI, | 171 BrowserThread::PostTask(BrowserThread::UI, |
172 FROM_HERE, | 172 FROM_HERE, |
173 base::Bind(&TestStoragePartition::AsyncRunCallback, | 173 base::Bind(&TestStoragePartition::AsyncRunCallback, |
174 base::Unretained(this), | 174 base::Unretained(this), |
175 callback)); | 175 callback)); |
176 } | 176 } |
177 | 177 |
178 virtual void ClearData(uint32 remove_mask, | 178 virtual void ClearData(uint32 remove_mask, |
179 uint32 quota_storage_remove_mask, | 179 uint32 quota_storage_remove_mask, |
180 const GURL& storage_origin, | 180 const GURL& storage_origin, |
181 const OriginMatcherFunction& origin_matcher, | 181 const OriginMatcherFunction& origin_matcher, |
182 const base::Time begin, | 182 const base::Time begin, |
183 const base::Time end, | 183 const base::Time end, |
184 const base::Closure& callback) OVERRIDE { | 184 const base::Closure& callback) override { |
185 // Store stuff to verify parameters' correctness later. | 185 // Store stuff to verify parameters' correctness later. |
186 storage_partition_removal_data_.remove_mask = remove_mask; | 186 storage_partition_removal_data_.remove_mask = remove_mask; |
187 storage_partition_removal_data_.quota_storage_remove_mask = | 187 storage_partition_removal_data_.quota_storage_remove_mask = |
188 quota_storage_remove_mask; | 188 quota_storage_remove_mask; |
189 storage_partition_removal_data_.remove_origin = storage_origin; | 189 storage_partition_removal_data_.remove_origin = storage_origin; |
190 storage_partition_removal_data_.remove_begin = begin; | 190 storage_partition_removal_data_.remove_begin = begin; |
191 storage_partition_removal_data_.remove_end = end; | 191 storage_partition_removal_data_.remove_end = end; |
192 storage_partition_removal_data_.origin_matcher = origin_matcher; | 192 storage_partition_removal_data_.origin_matcher = origin_matcher; |
193 | 193 |
194 BrowserThread::PostTask( | 194 BrowserThread::PostTask( |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 | 354 |
355 net::ChannelIDStore* GetChannelIDStore() { | 355 net::ChannelIDStore* GetChannelIDStore() { |
356 return channel_id_service_->GetChannelIDStore(); | 356 return channel_id_service_->GetChannelIDStore(); |
357 } | 357 } |
358 | 358 |
359 int ssl_config_changed_count() const { | 359 int ssl_config_changed_count() const { |
360 return ssl_config_changed_count_; | 360 return ssl_config_changed_count_; |
361 } | 361 } |
362 | 362 |
363 // net::SSLConfigService::Observer implementation: | 363 // net::SSLConfigService::Observer implementation: |
364 virtual void OnSSLConfigChanged() OVERRIDE { | 364 virtual void OnSSLConfigChanged() override { |
365 ssl_config_changed_count_++; | 365 ssl_config_changed_count_++; |
366 } | 366 } |
367 | 367 |
368 private: | 368 private: |
369 static void GetAllChannelIDsCallback( | 369 static void GetAllChannelIDsCallback( |
370 net::ChannelIDStore::ChannelIDList* dest, | 370 net::ChannelIDStore::ChannelIDList* dest, |
371 const net::ChannelIDStore::ChannelIDList& result) { | 371 const net::ChannelIDStore::ChannelIDList& result) { |
372 *dest = result; | 372 *dest = result; |
373 } | 373 } |
374 | 374 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 | 505 |
506 card.set_guid(base::GenerateGUID()); | 506 card.set_guid(base::GenerateGUID()); |
507 card.set_origin(kChromeOrigin); | 507 card.set_origin(kChromeOrigin); |
508 cards.push_back(card); | 508 cards.push_back(card); |
509 | 509 |
510 personal_data_manager_->SetCreditCards(&cards); | 510 personal_data_manager_->SetCreditCards(&cards); |
511 base::MessageLoop::current()->Run(); | 511 base::MessageLoop::current()->Run(); |
512 } | 512 } |
513 | 513 |
514 private: | 514 private: |
515 virtual void OnPersonalDataChanged() OVERRIDE { | 515 virtual void OnPersonalDataChanged() override { |
516 base::MessageLoop::current()->Quit(); | 516 base::MessageLoop::current()->Quit(); |
517 } | 517 } |
518 | 518 |
519 autofill::PersonalDataManager* personal_data_manager_; | 519 autofill::PersonalDataManager* personal_data_manager_; |
520 DISALLOW_COPY_AND_ASSIGN(RemoveAutofillTester); | 520 DISALLOW_COPY_AND_ASSIGN(RemoveAutofillTester); |
521 }; | 521 }; |
522 | 522 |
523 class RemoveLocalStorageTester { | 523 class RemoveLocalStorageTester { |
524 public: | 524 public: |
525 explicit RemoveLocalStorageTester(TestingProfile* profile) | 525 explicit RemoveLocalStorageTester(TestingProfile* profile) |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 }; | 594 }; |
595 | 595 |
596 class MockDomainReliabilityService : public DomainReliabilityService { | 596 class MockDomainReliabilityService : public DomainReliabilityService { |
597 public: | 597 public: |
598 MockDomainReliabilityService() : clear_count_(0) {} | 598 MockDomainReliabilityService() : clear_count_(0) {} |
599 | 599 |
600 virtual ~MockDomainReliabilityService() {} | 600 virtual ~MockDomainReliabilityService() {} |
601 | 601 |
602 virtual scoped_ptr<DomainReliabilityMonitor> CreateMonitor( | 602 virtual scoped_ptr<DomainReliabilityMonitor> CreateMonitor( |
603 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) | 603 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner) |
604 OVERRIDE { | 604 override { |
605 NOTREACHED(); | 605 NOTREACHED(); |
606 return scoped_ptr<DomainReliabilityMonitor>(); | 606 return scoped_ptr<DomainReliabilityMonitor>(); |
607 } | 607 } |
608 | 608 |
609 virtual void ClearBrowsingData(DomainReliabilityClearMode clear_mode, | 609 virtual void ClearBrowsingData(DomainReliabilityClearMode clear_mode, |
610 const base::Closure& callback) OVERRIDE { | 610 const base::Closure& callback) override { |
611 clear_count_++; | 611 clear_count_++; |
612 last_clear_mode_ = clear_mode; | 612 last_clear_mode_ = clear_mode; |
613 callback.Run(); | 613 callback.Run(); |
614 } | 614 } |
615 | 615 |
616 virtual void GetWebUIData( | 616 virtual void GetWebUIData( |
617 const base::Callback<void(scoped_ptr<base::Value>)>& callback) | 617 const base::Callback<void(scoped_ptr<base::Value>)>& callback) |
618 const OVERRIDE { | 618 const override { |
619 NOTREACHED(); | 619 NOTREACHED(); |
620 } | 620 } |
621 | 621 |
622 int clear_count() const { return clear_count_; } | 622 int clear_count() const { return clear_count_; } |
623 | 623 |
624 DomainReliabilityClearMode last_clear_mode() const { | 624 DomainReliabilityClearMode last_clear_mode() const { |
625 return last_clear_mode_; | 625 return last_clear_mode_; |
626 } | 626 } |
627 | 627 |
628 private: | 628 private: |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 return called_with_details_->origin_set_mask; | 796 return called_with_details_->origin_set_mask; |
797 } | 797 } |
798 | 798 |
799 StoragePartitionRemovalData GetStoragePartitionRemovalData() { | 799 StoragePartitionRemovalData GetStoragePartitionRemovalData() { |
800 return storage_partition_removal_data_; | 800 return storage_partition_removal_data_; |
801 } | 801 } |
802 | 802 |
803 // content::NotificationObserver implementation. | 803 // content::NotificationObserver implementation. |
804 virtual void Observe(int type, | 804 virtual void Observe(int type, |
805 const content::NotificationSource& source, | 805 const content::NotificationSource& source, |
806 const content::NotificationDetails& details) OVERRIDE { | 806 const content::NotificationDetails& details) override { |
807 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSING_DATA_REMOVED); | 807 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSING_DATA_REMOVED); |
808 | 808 |
809 // We're not taking ownership of the details object, but storing a copy of | 809 // We're not taking ownership of the details object, but storing a copy of |
810 // it locally. | 810 // it locally. |
811 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails( | 811 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails( |
812 *content::Details<BrowsingDataRemover::NotificationDetails>( | 812 *content::Details<BrowsingDataRemover::NotificationDetails>( |
813 details).ptr())); | 813 details).ptr())); |
814 | 814 |
815 registrar_.RemoveAll(); | 815 registrar_.RemoveAll(); |
816 } | 816 } |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 EXPECT_EQ(1u, tester.clear_count()); | 1829 EXPECT_EQ(1u, tester.clear_count()); |
1830 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); | 1830 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); |
1831 } | 1831 } |
1832 | 1832 |
1833 TEST_F(BrowsingDataRemoverTest, DomainReliability_NoMonitor) { | 1833 TEST_F(BrowsingDataRemoverTest, DomainReliability_NoMonitor) { |
1834 BlockUntilBrowsingDataRemoved( | 1834 BlockUntilBrowsingDataRemoved( |
1835 BrowsingDataRemover::EVERYTHING, | 1835 BrowsingDataRemover::EVERYTHING, |
1836 BrowsingDataRemover::REMOVE_HISTORY | | 1836 BrowsingDataRemover::REMOVE_HISTORY | |
1837 BrowsingDataRemover::REMOVE_COOKIES, false); | 1837 BrowsingDataRemover::REMOVE_COOKIES, false); |
1838 } | 1838 } |
OLD | NEW |