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 <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <set> | 10 #include <set> |
8 #include <string> | 11 #include <string> |
9 #include <vector> | 12 #include <vector> |
10 | 13 |
11 #include "base/bind.h" | 14 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
13 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
15 #include "base/guid.h" | 18 #include "base/guid.h" |
| 19 #include "base/macros.h" |
16 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
17 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
18 #include "base/prefs/testing_pref_service.h" | 22 #include "base/prefs/testing_pref_service.h" |
19 #include "base/run_loop.h" | 23 #include "base/run_loop.h" |
20 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
21 #include "base/task/cancelable_task_tracker.h" | 25 #include "base/task/cancelable_task_tracker.h" |
| 26 #include "build/build_config.h" |
22 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 27 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
23 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 28 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
24 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 29 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
25 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 30 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
26 #include "chrome/browser/domain_reliability/service_factory.h" | 31 #include "chrome/browser/domain_reliability/service_factory.h" |
27 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 32 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
28 #include "chrome/browser/favicon/favicon_service_factory.h" | 33 #include "chrome/browser/favicon/favicon_service_factory.h" |
29 #include "chrome/browser/history/history_service_factory.h" | 34 #include "chrome/browser/history/history_service_factory.h" |
30 #include "chrome/browser/password_manager/password_store_factory.h" | 35 #include "chrome/browser/password_manager/password_store_factory.h" |
31 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 36 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 140 |
136 #if defined(OS_CHROMEOS) | 141 #if defined(OS_CHROMEOS) |
137 void FakeDBusCall(const chromeos::BoolDBusMethodCallback& callback) { | 142 void FakeDBusCall(const chromeos::BoolDBusMethodCallback& callback) { |
138 base::MessageLoop::current()->PostTask( | 143 base::MessageLoop::current()->PostTask( |
139 FROM_HERE, | 144 FROM_HERE, |
140 base::Bind(callback, chromeos::DBUS_METHOD_CALL_SUCCESS, true)); | 145 base::Bind(callback, chromeos::DBUS_METHOD_CALL_SUCCESS, true)); |
141 } | 146 } |
142 #endif | 147 #endif |
143 | 148 |
144 struct StoragePartitionRemovalData { | 149 struct StoragePartitionRemovalData { |
145 uint32 remove_mask = 0; | 150 uint32_t remove_mask = 0; |
146 uint32 quota_storage_remove_mask = 0; | 151 uint32_t quota_storage_remove_mask = 0; |
147 GURL remove_origin; | 152 GURL remove_origin; |
148 base::Time remove_begin; | 153 base::Time remove_begin; |
149 base::Time remove_end; | 154 base::Time remove_end; |
150 StoragePartition::OriginMatcherFunction origin_matcher; | 155 StoragePartition::OriginMatcherFunction origin_matcher; |
151 | 156 |
152 StoragePartitionRemovalData() {} | 157 StoragePartitionRemovalData() {} |
153 }; | 158 }; |
154 | 159 |
155 class TestStoragePartition : public StoragePartition { | 160 class TestStoragePartition : public StoragePartition { |
156 public: | 161 public: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 return nullptr; | 200 return nullptr; |
196 } | 201 } |
197 content::HostZoomMap* GetHostZoomMap() override { return nullptr; } | 202 content::HostZoomMap* GetHostZoomMap() override { return nullptr; } |
198 content::HostZoomLevelContext* GetHostZoomLevelContext() override { | 203 content::HostZoomLevelContext* GetHostZoomLevelContext() override { |
199 return nullptr; | 204 return nullptr; |
200 } | 205 } |
201 content::ZoomLevelDelegate* GetZoomLevelDelegate() override { | 206 content::ZoomLevelDelegate* GetZoomLevelDelegate() override { |
202 return nullptr; | 207 return nullptr; |
203 } | 208 } |
204 | 209 |
205 void ClearDataForOrigin(uint32 remove_mask, | 210 void ClearDataForOrigin(uint32_t remove_mask, |
206 uint32 quota_storage_remove_mask, | 211 uint32_t quota_storage_remove_mask, |
207 const GURL& storage_origin, | 212 const GURL& storage_origin, |
208 net::URLRequestContextGetter* rq_context, | 213 net::URLRequestContextGetter* rq_context, |
209 const base::Closure& callback) override { | 214 const base::Closure& callback) override { |
210 BrowserThread::PostTask(BrowserThread::UI, | 215 BrowserThread::PostTask(BrowserThread::UI, |
211 FROM_HERE, | 216 FROM_HERE, |
212 base::Bind(&TestStoragePartition::AsyncRunCallback, | 217 base::Bind(&TestStoragePartition::AsyncRunCallback, |
213 base::Unretained(this), | 218 base::Unretained(this), |
214 callback)); | 219 callback)); |
215 } | 220 } |
216 | 221 |
217 void ClearData(uint32 remove_mask, | 222 void ClearData(uint32_t remove_mask, |
218 uint32 quota_storage_remove_mask, | 223 uint32_t quota_storage_remove_mask, |
219 const GURL& storage_origin, | 224 const GURL& storage_origin, |
220 const OriginMatcherFunction& origin_matcher, | 225 const OriginMatcherFunction& origin_matcher, |
221 const base::Time begin, | 226 const base::Time begin, |
222 const base::Time end, | 227 const base::Time end, |
223 const base::Closure& callback) override { | 228 const base::Closure& callback) override { |
224 // Store stuff to verify parameters' correctness later. | 229 // Store stuff to verify parameters' correctness later. |
225 storage_partition_removal_data_.remove_mask = remove_mask; | 230 storage_partition_removal_data_.remove_mask = remove_mask; |
226 storage_partition_removal_data_.quota_storage_remove_mask = | 231 storage_partition_removal_data_.quota_storage_remove_mask = |
227 quota_storage_remove_mask; | 232 quota_storage_remove_mask; |
228 storage_partition_removal_data_.remove_origin = storage_origin; | 233 storage_partition_removal_data_.remove_origin = storage_origin; |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 EXPECT_EQ(removal_data.remove_mask, | 1634 EXPECT_EQ(removal_data.remove_mask, |
1630 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1635 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
1631 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1636 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
1632 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1637 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1633 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1638 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1634 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1639 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1635 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1640 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1636 | 1641 |
1637 // Persistent data would be left out since we are not removing from | 1642 // Persistent data would be left out since we are not removing from |
1638 // beginning of time. | 1643 // beginning of time. |
1639 uint32 expected_quota_mask = | 1644 uint32_t expected_quota_mask = |
1640 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 1645 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
1641 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); | 1646 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); |
1642 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | 1647 EXPECT_TRUE(removal_data.remove_origin.is_empty()); |
1643 // Check removal begin time. | 1648 // Check removal begin time. |
1644 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1649 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1645 } | 1650 } |
1646 | 1651 |
1647 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { | 1652 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { |
1648 BlockUntilBrowsingDataRemoved( | 1653 BlockUntilBrowsingDataRemoved( |
1649 BrowsingDataRemover::LAST_WEEK, | 1654 BrowsingDataRemover::LAST_WEEK, |
(...skipping 20 matching lines...) Expand all Loading... |
1670 EXPECT_EQ(removal_data.remove_mask, | 1675 EXPECT_EQ(removal_data.remove_mask, |
1671 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1676 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
1672 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1677 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
1673 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1678 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1674 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1679 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1675 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1680 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1676 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1681 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1677 | 1682 |
1678 // Persistent data would be left out since we are not removing from | 1683 // Persistent data would be left out since we are not removing from |
1679 // beginning of time. | 1684 // beginning of time. |
1680 uint32 expected_quota_mask = | 1685 uint32_t expected_quota_mask = |
1681 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 1686 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
1682 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); | 1687 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); |
1683 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | 1688 EXPECT_TRUE(removal_data.remove_origin.is_empty()); |
1684 // Check removal begin time. | 1689 // Check removal begin time. |
1685 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1690 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1686 } | 1691 } |
1687 | 1692 |
1688 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { | 1693 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { |
1689 #if defined(ENABLE_EXTENSIONS) | 1694 #if defined(ENABLE_EXTENSIONS) |
1690 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1695 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2130 static_cast<password_manager::MockPasswordStore*>( | 2135 static_cast<password_manager::MockPasswordStore*>( |
2131 PasswordStoreFactory::GetInstance() | 2136 PasswordStoreFactory::GetInstance() |
2132 ->GetForProfile(GetProfile(), ServiceAccessType::EXPLICIT_ACCESS) | 2137 ->GetForProfile(GetProfile(), ServiceAccessType::EXPLICIT_ACCESS) |
2133 .get()); | 2138 .get()); |
2134 EXPECT_CALL(*store, RemoveStatisticsCreatedBetweenImpl(base::Time(), | 2139 EXPECT_CALL(*store, RemoveStatisticsCreatedBetweenImpl(base::Time(), |
2135 base::Time::Max())); | 2140 base::Time::Max())); |
2136 BlockUntilBrowsingDataRemoved( | 2141 BlockUntilBrowsingDataRemoved( |
2137 BrowsingDataRemover::EVERYTHING, | 2142 BrowsingDataRemover::EVERYTHING, |
2138 BrowsingDataRemover::REMOVE_HISTORY, false); | 2143 BrowsingDataRemover::REMOVE_HISTORY, false); |
2139 } | 2144 } |
OLD | NEW |