| 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> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <set> | 10 #include <set> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "base/run_loop.h" | 22 #include "base/run_loop.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 24 #include "base/task/cancelable_task_tracker.h" | 24 #include "base/task/cancelable_task_tracker.h" |
| 25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| 26 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 26 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 27 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 27 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 28 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 28 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 29 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 29 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 30 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 30 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
| 31 #include "chrome/browser/browsing_data/origin_filter_builder.h" | 31 #include "chrome/browser/browsing_data/origin_filter_builder.h" |
| 32 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 32 #include "chrome/browser/domain_reliability/service_factory.h" | 33 #include "chrome/browser/domain_reliability/service_factory.h" |
| 33 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 34 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 34 #include "chrome/browser/favicon/favicon_service_factory.h" | 35 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 35 #include "chrome/browser/history/history_service_factory.h" | 36 #include "chrome/browser/history/history_service_factory.h" |
| 36 #include "chrome/browser/password_manager/password_store_factory.h" | 37 #include "chrome/browser/password_manager/password_store_factory.h" |
| 37 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 38 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 38 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
| 39 #include "chrome/test/base/testing_browser_process.h" | 40 #include "chrome/test/base/testing_browser_process.h" |
| 40 #include "chrome/test/base/testing_profile.h" | 41 #include "chrome/test/base/testing_profile.h" |
| 41 #include "components/autofill/core/browser/autofill_profile.h" | 42 #include "components/autofill/core/browser/autofill_profile.h" |
| 42 #include "components/autofill/core/browser/autofill_test_utils.h" | 43 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 43 #include "components/autofill/core/browser/credit_card.h" | 44 #include "components/autofill/core/browser/credit_card.h" |
| 44 #include "components/autofill/core/browser/personal_data_manager.h" | 45 #include "components/autofill/core/browser/personal_data_manager.h" |
| 45 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 46 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
| 46 #include "components/bookmarks/browser/bookmark_model.h" | 47 #include "components/bookmarks/browser/bookmark_model.h" |
| 47 #include "components/bookmarks/test/bookmark_test_helpers.h" | 48 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 49 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 50 #include "components/content_settings/core/common/content_settings.h" |
| 51 #include "components/content_settings/core/common/content_settings_pattern.h" |
| 48 #include "components/domain_reliability/clear_mode.h" | 52 #include "components/domain_reliability/clear_mode.h" |
| 49 #include "components/domain_reliability/monitor.h" | 53 #include "components/domain_reliability/monitor.h" |
| 50 #include "components/domain_reliability/service.h" | 54 #include "components/domain_reliability/service.h" |
| 51 #include "components/favicon/core/favicon_service.h" | 55 #include "components/favicon/core/favicon_service.h" |
| 52 #include "components/history/core/browser/history_service.h" | 56 #include "components/history/core/browser/history_service.h" |
| 53 #include "components/omnibox/browser/omnibox_pref_names.h" | 57 #include "components/omnibox/browser/omnibox_pref_names.h" |
| 54 #include "components/password_manager/core/browser/mock_password_store.h" | 58 #include "components/password_manager/core/browser/mock_password_store.h" |
| 55 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 59 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
| 56 #include "components/password_manager/core/browser/password_store_consumer.h" | 60 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 57 #include "components/prefs/testing_pref_service.h" | 61 #include "components/prefs/testing_pref_service.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 using testing::MatcherInterface; | 112 using testing::MatcherInterface; |
| 109 using testing::MatchResultListener; | 113 using testing::MatchResultListener; |
| 110 using testing::Return; | 114 using testing::Return; |
| 111 using testing::WithArgs; | 115 using testing::WithArgs; |
| 112 | 116 |
| 113 namespace { | 117 namespace { |
| 114 | 118 |
| 115 const char kTestOrigin1[] = "http://host1:1/"; | 119 const char kTestOrigin1[] = "http://host1:1/"; |
| 116 const char kTestOrigin2[] = "http://host2:1/"; | 120 const char kTestOrigin2[] = "http://host2:1/"; |
| 117 const char kTestOrigin3[] = "http://host3:1/"; | 121 const char kTestOrigin3[] = "http://host3:1/"; |
| 122 const char kTestOrigin4[] = "https://host3:1/"; |
| 118 const char kTestOriginExt[] = "chrome-extension://abcdefghijklmnopqrstuvwxyz/"; | 123 const char kTestOriginExt[] = "chrome-extension://abcdefghijklmnopqrstuvwxyz/"; |
| 119 const char kTestOriginDevTools[] = "chrome-devtools://abcdefghijklmnopqrstuvw/"; | 124 const char kTestOriginDevTools[] = "chrome-devtools://abcdefghijklmnopqrstuvw/"; |
| 120 | 125 |
| 121 // For Autofill. | 126 // For Autofill. |
| 122 const char kChromeOrigin[] = "Chrome settings"; | 127 const char kChromeOrigin[] = "Chrome settings"; |
| 123 const char kWebOrigin[] = "https://www.example.com/"; | 128 const char kWebOrigin[] = "https://www.example.com/"; |
| 124 | 129 |
| 125 const GURL kOrigin1(kTestOrigin1); | 130 const GURL kOrigin1(kTestOrigin1); |
| 126 const GURL kOrigin2(kTestOrigin2); | 131 const GURL kOrigin2(kTestOrigin2); |
| 127 const GURL kOrigin3(kTestOrigin3); | 132 const GURL kOrigin3(kTestOrigin3); |
| 133 const GURL kOrigin4(kTestOrigin4); |
| 128 const GURL kOriginExt(kTestOriginExt); | 134 const GURL kOriginExt(kTestOriginExt); |
| 129 const GURL kOriginDevTools(kTestOriginDevTools); | 135 const GURL kOriginDevTools(kTestOriginDevTools); |
| 130 | 136 |
| 131 const base::FilePath::CharType kDomStorageOrigin1[] = | 137 const base::FilePath::CharType kDomStorageOrigin1[] = |
| 132 FILE_PATH_LITERAL("http_host1_1.localstorage"); | 138 FILE_PATH_LITERAL("http_host1_1.localstorage"); |
| 133 | 139 |
| 134 const base::FilePath::CharType kDomStorageOrigin2[] = | 140 const base::FilePath::CharType kDomStorageOrigin2[] = |
| 135 FILE_PATH_LITERAL("http_host2_1.localstorage"); | 141 FILE_PATH_LITERAL("http_host2_1.localstorage"); |
| 136 | 142 |
| 137 const base::FilePath::CharType kDomStorageOrigin3[] = | 143 const base::FilePath::CharType kDomStorageOrigin3[] = |
| 138 FILE_PATH_LITERAL("http_host3_1.localstorage"); | 144 FILE_PATH_LITERAL("http_host3_1.localstorage"); |
| 139 | 145 |
| 140 const base::FilePath::CharType kDomStorageExt[] = FILE_PATH_LITERAL( | 146 const base::FilePath::CharType kDomStorageExt[] = FILE_PATH_LITERAL( |
| 141 "chrome-extension_abcdefghijklmnopqrstuvwxyz_0.localstorage"); | 147 "chrome-extension_abcdefghijklmnopqrstuvwxyz_0.localstorage"); |
| 142 | 148 |
| 149 bool MatchPrimaryPattern(const ContentSettingsPattern& expected_primary, |
| 150 const ContentSettingsPattern& primary_pattern, |
| 151 const ContentSettingsPattern& secondary_pattern) { |
| 152 return expected_primary == primary_pattern; |
| 153 } |
| 154 |
| 143 #if defined(OS_CHROMEOS) | 155 #if defined(OS_CHROMEOS) |
| 144 void FakeDBusCall(const chromeos::BoolDBusMethodCallback& callback) { | 156 void FakeDBusCall(const chromeos::BoolDBusMethodCallback& callback) { |
| 145 base::MessageLoop::current()->PostTask( | 157 base::MessageLoop::current()->PostTask( |
| 146 FROM_HERE, | 158 FROM_HERE, |
| 147 base::Bind(callback, chromeos::DBUS_METHOD_CALL_SUCCESS, true)); | 159 base::Bind(callback, chromeos::DBUS_METHOD_CALL_SUCCESS, true)); |
| 148 } | 160 } |
| 149 #endif | 161 #endif |
| 150 | 162 |
| 151 struct StoragePartitionRemovalData { | 163 struct StoragePartitionRemovalData { |
| 152 uint32_t remove_mask = 0; | 164 uint32_t remove_mask = 0; |
| 153 uint32_t quota_storage_remove_mask = 0; | 165 uint32_t quota_storage_remove_mask = 0; |
| 154 GURL remove_origin; | |
| 155 base::Time remove_begin; | 166 base::Time remove_begin; |
| 156 base::Time remove_end; | 167 base::Time remove_end; |
| 157 StoragePartition::OriginMatcherFunction origin_matcher; | 168 StoragePartition::OriginMatcherFunction origin_matcher; |
| 158 | 169 |
| 159 StoragePartitionRemovalData() {} | 170 StoragePartitionRemovalData() {} |
| 160 }; | 171 }; |
| 161 | 172 |
| 162 class TestStoragePartition : public StoragePartition { | 173 class TestStoragePartition : public StoragePartition { |
| 163 public: | 174 public: |
| 164 TestStoragePartition() {} | 175 TestStoragePartition() {} |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 uint32_t quota_storage_remove_mask, | 236 uint32_t quota_storage_remove_mask, |
| 226 const GURL& storage_origin, | 237 const GURL& storage_origin, |
| 227 const OriginMatcherFunction& origin_matcher, | 238 const OriginMatcherFunction& origin_matcher, |
| 228 const base::Time begin, | 239 const base::Time begin, |
| 229 const base::Time end, | 240 const base::Time end, |
| 230 const base::Closure& callback) override { | 241 const base::Closure& callback) override { |
| 231 // Store stuff to verify parameters' correctness later. | 242 // Store stuff to verify parameters' correctness later. |
| 232 storage_partition_removal_data_.remove_mask = remove_mask; | 243 storage_partition_removal_data_.remove_mask = remove_mask; |
| 233 storage_partition_removal_data_.quota_storage_remove_mask = | 244 storage_partition_removal_data_.quota_storage_remove_mask = |
| 234 quota_storage_remove_mask; | 245 quota_storage_remove_mask; |
| 235 storage_partition_removal_data_.remove_origin = storage_origin; | |
| 236 storage_partition_removal_data_.remove_begin = begin; | 246 storage_partition_removal_data_.remove_begin = begin; |
| 237 storage_partition_removal_data_.remove_end = end; | 247 storage_partition_removal_data_.remove_end = end; |
| 238 storage_partition_removal_data_.origin_matcher = origin_matcher; | 248 storage_partition_removal_data_.origin_matcher = origin_matcher; |
| 239 | 249 |
| 240 BrowserThread::PostTask( | 250 BrowserThread::PostTask( |
| 241 BrowserThread::UI, | 251 BrowserThread::UI, |
| 242 FROM_HERE, | 252 FROM_HERE, |
| 243 base::Bind(&TestStoragePartition::AsyncRunCallback, | 253 base::Bind(&TestStoragePartition::AsyncRunCallback, |
| 244 base::Unretained(this), callback)); | 254 base::Unretained(this), callback)); |
| 245 } | 255 } |
| 246 | 256 |
| 257 void ClearData(uint32_t remove_mask, |
| 258 uint32_t quota_storage_remove_mask, |
| 259 const OriginMatcherFunction& origin_matcher, |
| 260 const CookieMatcherFunction& cookie_matcher, |
| 261 const base::Time begin, |
| 262 const base::Time end, |
| 263 const base::Closure& callback) override { |
| 264 // Store stuff to verify parameters' correctness later. |
| 265 storage_partition_removal_data_.remove_mask = remove_mask; |
| 266 storage_partition_removal_data_.quota_storage_remove_mask = |
| 267 quota_storage_remove_mask; |
| 268 storage_partition_removal_data_.remove_begin = begin; |
| 269 storage_partition_removal_data_.remove_end = end; |
| 270 storage_partition_removal_data_.origin_matcher = origin_matcher; |
| 271 |
| 272 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 273 base::Bind(&TestStoragePartition::AsyncRunCallback, |
| 274 base::Unretained(this), callback)); |
| 275 } |
| 276 |
| 247 void Flush() override {} | 277 void Flush() override {} |
| 248 | 278 |
| 249 StoragePartitionRemovalData GetStoragePartitionRemovalData() { | 279 StoragePartitionRemovalData GetStoragePartitionRemovalData() { |
| 250 return storage_partition_removal_data_; | 280 return storage_partition_removal_data_; |
| 251 } | 281 } |
| 252 | 282 |
| 253 private: | 283 private: |
| 254 void AsyncRunCallback(const base::Closure& callback) { | 284 void AsyncRunCallback(const base::Closure& callback) { |
| 255 callback.Run(); | 285 callback.Run(); |
| 256 } | 286 } |
| 257 | 287 |
| 258 StoragePartitionRemovalData storage_partition_removal_data_; | 288 StoragePartitionRemovalData storage_partition_removal_data_; |
| 259 | 289 |
| 260 DISALLOW_COPY_AND_ASSIGN(TestStoragePartition); | 290 DISALLOW_COPY_AND_ASSIGN(TestStoragePartition); |
| 261 }; | 291 }; |
| 262 | 292 |
| 293 |
| 263 // Custom matcher to test the equivalence of two URL filters. Since those are | 294 // Custom matcher to test the equivalence of two URL filters. Since those are |
| 264 // blackbox predicates, we can only approximate the equivalence by testing | 295 // blackbox predicates, we can only approximate the equivalence by testing |
| 265 // whether the filter give the same answer for several URLs. This is currently | 296 // whether the filter give the same answer for several URLs. This is currently |
| 266 // good enough for our testing purposes, to distinguish whitelists | 297 // good enough for our testing purposes, to distinguish whitelists |
| 267 // and blacklists, empty and non-empty filters and such. | 298 // and blacklists, empty and non-empty filters and such. |
| 268 // TODO(msramek): BrowsingDataRemover and some of its backends support URL | 299 // TODO(msramek): BrowsingDataRemover and some of its backends support URL |
| 269 // filters, but its constructor currently only takes a single URL and constructs | 300 // filters, but its constructor currently only takes a single URL and constructs |
| 270 // its own url filter. If an url filter was directly passed to | 301 // its own url filter. If an url filter was directly passed to |
| 271 // BrowsingDataRemover (what should eventually be the case), we can use the same | 302 // BrowsingDataRemover (what should eventually be the case), we can use the same |
| 272 // instance in the test as well, and thus simply test base::Callback::Equals() | 303 // instance in the test as well, and thus simply test base::Callback::Equals() |
| (...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 void BlockUntilOriginDataRemoved(BrowsingDataRemover::TimePeriod period, | 1021 void BlockUntilOriginDataRemoved(BrowsingDataRemover::TimePeriod period, |
| 991 int remove_mask, | 1022 int remove_mask, |
| 992 const GURL& remove_origin) { | 1023 const GURL& remove_origin) { |
| 993 BrowsingDataRemover* remover = | 1024 BrowsingDataRemover* remover = |
| 994 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); | 1025 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); |
| 995 TestStoragePartition storage_partition; | 1026 TestStoragePartition storage_partition; |
| 996 remover->OverrideStoragePartitionForTesting(&storage_partition); | 1027 remover->OverrideStoragePartitionForTesting(&storage_partition); |
| 997 | 1028 |
| 998 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails()); | 1029 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails()); |
| 999 | 1030 |
| 1031 OriginFilterBuilder builder(OriginFilterBuilder::WHITELIST); |
| 1032 builder.AddOrigin(url::Origin(remove_origin)); |
| 1033 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
| 1034 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, |
| 1035 builder, BrowsingDataHelper::UNPROTECTED_WEB); |
| 1036 completion_observer.BlockUntilCompletion(); |
| 1037 |
| 1038 // Save so we can verify later. |
| 1039 storage_partition_removal_data_ = |
| 1040 storage_partition.GetStoragePartitionRemovalData(); |
| 1041 } |
| 1042 |
| 1043 void BlockUntilOriginDataRemoved(BrowsingDataRemover::TimePeriod period, |
| 1044 int remove_mask, |
| 1045 const OriginFilterBuilder& filter_builder) { |
| 1046 BrowsingDataRemover* remover = |
| 1047 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); |
| 1048 TestStoragePartition storage_partition; |
| 1049 remover->OverrideStoragePartitionForTesting(&storage_partition); |
| 1050 |
| 1051 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails()); |
| 1052 |
| 1000 BrowsingDataRemoverCompletionObserver completion_observer(remover); | 1053 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
| 1001 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, | 1054 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, |
| 1002 remove_origin, BrowsingDataHelper::UNPROTECTED_WEB); | 1055 filter_builder, BrowsingDataHelper::UNPROTECTED_WEB); |
| 1003 completion_observer.BlockUntilCompletion(); | 1056 completion_observer.BlockUntilCompletion(); |
| 1004 | 1057 |
| 1005 // Save so we can verify later. | 1058 // Save so we can verify later. |
| 1006 storage_partition_removal_data_ = | 1059 storage_partition_removal_data_ = |
| 1007 storage_partition.GetStoragePartitionRemovalData(); | 1060 storage_partition.GetStoragePartitionRemovalData(); |
| 1008 } | 1061 } |
| 1009 | 1062 |
| 1010 TestingProfile* GetProfile() { | 1063 TestingProfile* GetProfile() { |
| 1011 return profile_.get(); | 1064 return profile_.get(); |
| 1012 } | 1065 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 | 1155 |
| 1103 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1156 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1104 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1157 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1105 | 1158 |
| 1106 // Verify that storage partition was instructed to remove the cookies. | 1159 // Verify that storage partition was instructed to remove the cookies. |
| 1107 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1160 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1108 EXPECT_EQ(removal_data.remove_mask, | 1161 EXPECT_EQ(removal_data.remove_mask, |
| 1109 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1162 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
| 1110 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1163 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1111 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1164 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1112 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1113 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1165 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1114 } | 1166 } |
| 1115 | 1167 |
| 1116 TEST_F(BrowsingDataRemoverTest, RemoveCookieLastHour) { | 1168 TEST_F(BrowsingDataRemoverTest, RemoveCookieLastHour) { |
| 1117 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 1169 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 1118 BrowsingDataRemover::REMOVE_COOKIES, | 1170 BrowsingDataRemover::REMOVE_COOKIES, |
| 1119 false); | 1171 false); |
| 1120 | 1172 |
| 1121 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1173 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1122 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1174 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1123 | 1175 |
| 1124 // Verify that storage partition was instructed to remove the cookies. | 1176 // Verify that storage partition was instructed to remove the cookies. |
| 1125 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1177 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1126 EXPECT_EQ(removal_data.remove_mask, | 1178 EXPECT_EQ(removal_data.remove_mask, |
| 1127 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1179 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
| 1128 // Removing with time period other than EVERYTHING should not clear | 1180 // Removing with time period other than EVERYTHING should not clear |
| 1129 // persistent storage data. | 1181 // persistent storage data. |
| 1130 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1182 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1131 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1183 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
| 1132 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1133 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1184 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1134 } | 1185 } |
| 1135 | 1186 |
| 1187 TEST_F(BrowsingDataRemoverTest, RemoveCookiesOriginBlacklist) { |
| 1188 OriginFilterBuilder filter(OriginFilterBuilder::BLACKLIST); |
| 1189 filter.AddOrigin(url::Origin(kOrigin1)); |
| 1190 filter.AddOrigin(url::Origin(kOrigin3)); |
| 1191 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 1192 BrowsingDataRemover::REMOVE_COOKIES, filter); |
| 1193 |
| 1194 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1195 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1196 |
| 1197 // Verify that storage partition was instructed to remove the cookies. |
| 1198 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1199 EXPECT_EQ(removal_data.remove_mask, |
| 1200 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
| 1201 // Removing with time period other than EVERYTHING should not clear |
| 1202 // persistent storage data. |
| 1203 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1204 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
| 1205 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1206 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1207 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1208 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1209 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); |
| 1210 } |
| 1211 |
| 1136 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { | 1212 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { |
| 1137 RemoveSafeBrowsingCookieTester tester; | 1213 RemoveSafeBrowsingCookieTester tester; |
| 1138 | 1214 |
| 1139 tester.AddCookie(); | 1215 tester.AddCookie(); |
| 1140 ASSERT_TRUE(tester.ContainsCookie()); | 1216 ASSERT_TRUE(tester.ContainsCookie()); |
| 1141 | 1217 |
| 1142 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 1218 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 1143 BrowsingDataRemover::REMOVE_COOKIES, false); | 1219 BrowsingDataRemover::REMOVE_COOKIES, false); |
| 1144 | 1220 |
| 1145 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1221 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 | 1291 |
| 1216 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1292 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
| 1217 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1293 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1218 | 1294 |
| 1219 // Verify that storage partition was instructed to remove the data correctly. | 1295 // Verify that storage partition was instructed to remove the data correctly. |
| 1220 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1296 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1221 EXPECT_EQ(removal_data.remove_mask, | 1297 EXPECT_EQ(removal_data.remove_mask, |
| 1222 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1298 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
| 1223 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1299 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1224 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1300 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1225 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1226 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1301 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1227 | 1302 |
| 1228 // Check origin matcher. | 1303 // Check origin matcher. |
| 1229 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1304 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
| 1230 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1305 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1231 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1306 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1232 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1307 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1233 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1308 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
| 1234 } | 1309 } |
| 1235 | 1310 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1247 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1322 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
| 1248 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | | 1323 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | |
| 1249 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); | 1324 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); |
| 1250 | 1325 |
| 1251 // Verify that storage partition was instructed to remove the data correctly. | 1326 // Verify that storage partition was instructed to remove the data correctly. |
| 1252 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1327 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1253 EXPECT_EQ(removal_data.remove_mask, | 1328 EXPECT_EQ(removal_data.remove_mask, |
| 1254 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1329 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
| 1255 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1330 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1256 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1331 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1257 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1258 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1332 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1259 | 1333 |
| 1260 // Check origin matcher all http origin will match since we specified | 1334 // Check origin matcher all http origin will match since we specified |
| 1261 // both protected and unprotected. | 1335 // both protected and unprotected. |
| 1262 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1336 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1263 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1337 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1264 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1338 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1265 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1339 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
| 1266 } | 1340 } |
| 1267 | 1341 |
| 1268 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { | 1342 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { |
| 1269 #if defined(ENABLE_EXTENSIONS) | 1343 #if defined(ENABLE_EXTENSIONS) |
| 1270 CreateMockPolicy(); | 1344 CreateMockPolicy(); |
| 1271 #endif | 1345 #endif |
| 1272 | 1346 |
| 1273 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, | 1347 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, |
| 1274 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, | 1348 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, |
| 1275 false); | 1349 false); |
| 1276 | 1350 |
| 1277 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1351 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
| 1278 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1352 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1279 | 1353 |
| 1280 // Verify that storage partition was instructed to remove the data correctly. | 1354 // Verify that storage partition was instructed to remove the data correctly. |
| 1281 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1355 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1282 EXPECT_EQ(removal_data.remove_mask, | 1356 EXPECT_EQ(removal_data.remove_mask, |
| 1283 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1357 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
| 1284 // Persistent storage won't be deleted. | 1358 // Persistent storage won't be deleted. |
| 1285 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1359 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1286 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1360 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
| 1287 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1288 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1361 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1289 | 1362 |
| 1290 // Check origin matcher. | 1363 // Check origin matcher. |
| 1291 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1364 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1292 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1365 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1293 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1366 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1294 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1367 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
| 1295 } | 1368 } |
| 1296 | 1369 |
| 1297 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { | 1370 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1556 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1484 EXPECT_EQ(removal_data.remove_mask, | 1557 EXPECT_EQ(removal_data.remove_mask, |
| 1485 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1558 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1486 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1559 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1487 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1560 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1488 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1561 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1489 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1562 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1490 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1563 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1491 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1564 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1492 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1565 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1493 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1494 } | 1566 } |
| 1495 | 1567 |
| 1496 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { | 1568 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { |
| 1497 #if defined(ENABLE_EXTENSIONS) | 1569 #if defined(ENABLE_EXTENSIONS) |
| 1498 CreateMockPolicy(); | 1570 CreateMockPolicy(); |
| 1499 #endif | 1571 #endif |
| 1500 | 1572 |
| 1501 BlockUntilBrowsingDataRemoved( | 1573 BlockUntilBrowsingDataRemoved( |
| 1502 BrowsingDataRemover::EVERYTHING, | 1574 BrowsingDataRemover::EVERYTHING, |
| 1503 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1575 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1522 | 1594 |
| 1523 EXPECT_EQ(removal_data.remove_mask, | 1595 EXPECT_EQ(removal_data.remove_mask, |
| 1524 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1596 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1525 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1597 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1526 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1598 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1527 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1599 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1528 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1600 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1529 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1601 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1530 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1602 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1531 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1603 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1532 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1533 | 1604 |
| 1534 // Check that all related origin data would be removed, that is, origin | 1605 // Check that all related origin data would be removed, that is, origin |
| 1535 // matcher would match these origin. | 1606 // matcher would match these origin. |
| 1536 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1607 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1537 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1608 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1538 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1609 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1539 } | 1610 } |
| 1540 | 1611 |
| 1541 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { | 1612 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { |
| 1542 #if defined(ENABLE_EXTENSIONS) | 1613 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1567 | 1638 |
| 1568 EXPECT_EQ(removal_data.remove_mask, | 1639 EXPECT_EQ(removal_data.remove_mask, |
| 1569 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1640 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1570 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1641 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1571 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1642 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1572 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1643 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1573 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1644 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1574 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1645 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1575 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1646 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1576 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1647 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1577 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1578 | 1648 |
| 1579 // Check that all related origin data would be removed, that is, origin | 1649 // Check that all related origin data would be removed, that is, origin |
| 1580 // matcher would match these origin. | 1650 // matcher would match these origin. |
| 1581 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1651 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1582 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1652 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1583 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1653 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1584 } | 1654 } |
| 1585 | 1655 |
| 1586 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { | 1656 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { |
| 1587 #if defined(ENABLE_EXTENSIONS) | 1657 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1612 | 1682 |
| 1613 EXPECT_EQ(removal_data.remove_mask, | 1683 EXPECT_EQ(removal_data.remove_mask, |
| 1614 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1684 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1615 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1685 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1616 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1686 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1617 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1687 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1618 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1688 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1619 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1689 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1620 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1690 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1621 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1691 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1622 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1623 | 1692 |
| 1624 // Check that all related origin data would be removed, that is, origin | 1693 // Check that all related origin data would be removed, that is, origin |
| 1625 // matcher would match these origin. | 1694 // matcher would match these origin. |
| 1626 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1695 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1627 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1696 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1628 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1697 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1629 } | 1698 } |
| 1630 | 1699 |
| 1631 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverSpecificOrigin) { | 1700 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverSpecificOrigin) { |
| 1632 // Remove Origin 1. | 1701 // Remove Origin 1. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1653 | 1722 |
| 1654 EXPECT_EQ(removal_data.remove_mask, | 1723 EXPECT_EQ(removal_data.remove_mask, |
| 1655 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1724 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1656 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1725 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1657 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1726 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1658 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1727 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1659 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1728 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1660 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1729 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1661 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1730 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1662 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1731 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1663 EXPECT_EQ(removal_data.remove_origin, kOrigin1); | 1732 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1733 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1734 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1735 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); |
| 1664 } | 1736 } |
| 1665 | 1737 |
| 1666 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { | 1738 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { |
| 1667 BlockUntilBrowsingDataRemoved( | 1739 BlockUntilBrowsingDataRemoved( |
| 1668 BrowsingDataRemover::LAST_HOUR, | 1740 BrowsingDataRemover::LAST_HOUR, |
| 1669 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1741 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
| 1670 BrowsingDataRemover::REMOVE_WEBSQL | | 1742 BrowsingDataRemover::REMOVE_WEBSQL | |
| 1671 BrowsingDataRemover::REMOVE_APPCACHE | | 1743 BrowsingDataRemover::REMOVE_APPCACHE | |
| 1672 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1744 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
| 1673 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1745 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1692 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1764 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1693 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1765 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1694 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1766 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1695 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1767 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1696 | 1768 |
| 1697 // Persistent data would be left out since we are not removing from | 1769 // Persistent data would be left out since we are not removing from |
| 1698 // beginning of time. | 1770 // beginning of time. |
| 1699 uint32_t expected_quota_mask = | 1771 uint32_t expected_quota_mask = |
| 1700 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 1772 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
| 1701 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); | 1773 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); |
| 1702 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1703 // Check removal begin time. | 1774 // Check removal begin time. |
| 1704 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1775 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1705 } | 1776 } |
| 1706 | 1777 |
| 1707 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { | 1778 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { |
| 1708 BlockUntilBrowsingDataRemoved( | 1779 BlockUntilBrowsingDataRemoved( |
| 1709 BrowsingDataRemover::LAST_WEEK, | 1780 BrowsingDataRemover::LAST_WEEK, |
| 1710 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1781 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
| 1711 BrowsingDataRemover::REMOVE_WEBSQL | | 1782 BrowsingDataRemover::REMOVE_WEBSQL | |
| 1712 BrowsingDataRemover::REMOVE_APPCACHE | | 1783 BrowsingDataRemover::REMOVE_APPCACHE | |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1733 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1804 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1734 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1805 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1735 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1806 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1736 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1807 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1737 | 1808 |
| 1738 // Persistent data would be left out since we are not removing from | 1809 // Persistent data would be left out since we are not removing from |
| 1739 // beginning of time. | 1810 // beginning of time. |
| 1740 uint32_t expected_quota_mask = | 1811 uint32_t expected_quota_mask = |
| 1741 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 1812 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
| 1742 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); | 1813 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); |
| 1743 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1744 // Check removal begin time. | 1814 // Check removal begin time. |
| 1745 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1815 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1746 } | 1816 } |
| 1747 | 1817 |
| 1748 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { | 1818 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { |
| 1749 #if defined(ENABLE_EXTENSIONS) | 1819 #if defined(ENABLE_EXTENSIONS) |
| 1750 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1820 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
| 1751 // Protect kOrigin1. | 1821 // Protect kOrigin1. |
| 1752 policy->AddProtected(kOrigin1.GetOrigin()); | 1822 policy->AddProtected(kOrigin1.GetOrigin()); |
| 1753 #endif | 1823 #endif |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1776 | 1846 |
| 1777 EXPECT_EQ(removal_data.remove_mask, | 1847 EXPECT_EQ(removal_data.remove_mask, |
| 1778 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1848 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1779 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1849 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1780 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1850 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1781 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1851 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1782 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1852 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1783 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1853 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1784 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1854 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1785 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1855 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1786 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1787 | 1856 |
| 1788 // Check OriginMatcherFunction. | 1857 // Check OriginMatcherFunction. |
| 1789 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1858 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
| 1790 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1859 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1791 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1860 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1792 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1861 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1793 } | 1862 } |
| 1794 | 1863 |
| 1795 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedSpecificOrigin) { | 1864 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedSpecificOrigin) { |
| 1796 #if defined(ENABLE_EXTENSIONS) | 1865 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1823 | 1892 |
| 1824 EXPECT_EQ(removal_data.remove_mask, | 1893 EXPECT_EQ(removal_data.remove_mask, |
| 1825 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1894 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1826 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1895 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1827 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1896 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1828 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1897 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1829 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1898 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1830 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1899 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1831 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1900 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1832 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1901 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1833 EXPECT_EQ(removal_data.remove_origin, kOrigin1); | |
| 1834 | 1902 |
| 1835 // Check OriginMatcherFunction. | 1903 // Check OriginMatcherFunction. |
| 1836 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1904 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
| 1837 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1905 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1838 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1906 // Since we use the matcher function to validate origins now, this should |
| 1839 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1907 // return false for the origins we're not trying to clear. |
| 1908 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1909 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1840 } | 1910 } |
| 1841 | 1911 |
| 1842 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { | 1912 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { |
| 1843 #if defined(ENABLE_EXTENSIONS) | 1913 #if defined(ENABLE_EXTENSIONS) |
| 1844 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1914 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
| 1845 // Protect kOrigin1. | 1915 // Protect kOrigin1. |
| 1846 policy->AddProtected(kOrigin1.GetOrigin()); | 1916 policy->AddProtected(kOrigin1.GetOrigin()); |
| 1847 #endif | 1917 #endif |
| 1848 | 1918 |
| 1849 // Try to remove kOrigin1. Expect success. | 1919 // Try to remove kOrigin1. Expect success. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1872 | 1942 |
| 1873 EXPECT_EQ(removal_data.remove_mask, | 1943 EXPECT_EQ(removal_data.remove_mask, |
| 1874 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1944 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1875 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1945 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1876 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1946 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1877 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1947 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1878 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1948 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1879 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1949 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1880 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1950 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1881 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1951 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1882 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1883 | 1952 |
| 1884 // Check OriginMatcherFunction, |kOrigin1| would match mask since we | 1953 // Check OriginMatcherFunction, |kOrigin1| would match mask since we |
| 1885 // would have 'protected' specified in origin_type_mask. | 1954 // would have 'protected' specified in origin_type_mask. |
| 1886 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1955 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1887 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1956 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1888 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1957 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1889 } | 1958 } |
| 1890 | 1959 |
| 1891 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { | 1960 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { |
| 1892 #if defined(ENABLE_EXTENSIONS) | 1961 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1917 | 1986 |
| 1918 EXPECT_EQ(removal_data.remove_mask, | 1987 EXPECT_EQ(removal_data.remove_mask, |
| 1919 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1988 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1920 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1989 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1921 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1990 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1922 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1991 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1923 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1992 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1924 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1993 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1925 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1994 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1926 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1995 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1927 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1928 | 1996 |
| 1929 // Check that extension and devtools data wouldn't be removed, that is, | 1997 // Check that extension and devtools data wouldn't be removed, that is, |
| 1930 // origin matcher would not match these origin. | 1998 // origin matcher would not match these origin. |
| 1931 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1999 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
| 1932 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginDevTools, mock_policy())); | 2000 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginDevTools, mock_policy())); |
| 1933 } | 2001 } |
| 1934 | 2002 |
| 1935 TEST_F(BrowsingDataRemoverTest, OriginBasedHistoryRemoval) { | 2003 TEST_F(BrowsingDataRemoverTest, TimeBasedHistoryRemoval) { |
| 1936 RemoveHistoryTester tester; | 2004 RemoveHistoryTester tester; |
| 1937 ASSERT_TRUE(tester.Init(GetProfile())); | 2005 ASSERT_TRUE(tester.Init(GetProfile())); |
| 1938 | 2006 |
| 1939 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | |
| 1940 | |
| 1941 tester.AddHistory(kOrigin1, base::Time::Now()); | |
| 1942 tester.AddHistory(kOrigin2, two_hours_ago); | |
| 1943 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | |
| 1944 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); | |
| 1945 | |
| 1946 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, | |
| 1947 BrowsingDataRemover::REMOVE_HISTORY, kOrigin2); | |
| 1948 | |
| 1949 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | |
| 1950 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | |
| 1951 | |
| 1952 // Nothing should have been deleted. | |
| 1953 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin1)); | |
| 1954 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin2)); | |
| 1955 } | |
| 1956 | |
| 1957 TEST_F(BrowsingDataRemoverTest, OriginAndTimeBasedHistoryRemoval) { | |
| 1958 RemoveHistoryTester tester; | |
| 1959 ASSERT_TRUE(tester.Init(GetProfile())); | |
| 1960 | |
| 1961 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | 2007 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
| 1962 | 2008 |
| 1963 tester.AddHistory(kOrigin1, base::Time::Now()); | 2009 tester.AddHistory(kOrigin1, base::Time::Now()); |
| 1964 tester.AddHistory(kOrigin2, two_hours_ago); | 2010 tester.AddHistory(kOrigin2, two_hours_ago); |
| 1965 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 2011 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
| 1966 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 2012 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
| 1967 | 2013 |
| 1968 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, | 2014 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 1969 BrowsingDataRemover::REMOVE_HISTORY, kOrigin2); | 2015 BrowsingDataRemover::REMOVE_HISTORY, GURL()); |
| 1970 | 2016 |
| 1971 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 2017 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
| 1972 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2018 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1973 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 2019 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); |
| 1974 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 2020 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
| 1975 } | 2021 } |
| 1976 | 2022 |
| 1977 // Verify that clearing autofill form data works. | 2023 // Verify that clearing autofill form data works. |
| 1978 TEST_F(BrowsingDataRemoverTest, AutofillRemovalLastHour) { | 2024 TEST_F(BrowsingDataRemoverTest, AutofillRemovalLastHour) { |
| 1979 GetProfile()->CreateWebDataService(); | 2025 GetProfile()->CreateWebDataService(); |
| 1980 RemoveAutofillTester tester(GetProfile()); | 2026 RemoveAutofillTester tester(GetProfile()); |
| 1981 | 2027 |
| 1982 ASSERT_FALSE(tester.HasProfile()); | 2028 ASSERT_FALSE(tester.HasProfile()); |
| 1983 tester.AddProfilesAndCards(); | 2029 tester.AddProfilesAndCards(); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2276 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) | 2322 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) |
| 2277 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2323 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
| 2278 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) | 2324 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) |
| 2279 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2325 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
| 2280 | 2326 |
| 2281 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 2327 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 2282 BrowsingDataRemover::REMOVE_COOKIES | | 2328 BrowsingDataRemover::REMOVE_COOKIES | |
| 2283 BrowsingDataRemover::REMOVE_PASSWORDS, | 2329 BrowsingDataRemover::REMOVE_PASSWORDS, |
| 2284 false); | 2330 false); |
| 2285 } | 2331 } |
| 2332 |
| 2333 TEST_F(BrowsingDataRemoverTest, RemoveContentSettingsWithBlacklist) { |
| 2334 // Add our settings. |
| 2335 HostContentSettingsMap* host_content_settings_map = |
| 2336 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 2337 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2338 kOrigin1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2339 new base::FundamentalValue(10)); |
| 2340 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2341 kOrigin2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2342 new base::FundamentalValue(11)); |
| 2343 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2344 kOrigin3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2345 new base::FundamentalValue(11)); |
| 2346 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2347 kOrigin4, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2348 new base::FundamentalValue(11)); |
| 2349 |
| 2350 // Clear all except for origin1 and origin3. |
| 2351 OriginFilterBuilder filter(OriginFilterBuilder::BLACKLIST); |
| 2352 filter.AddOrigin(url::Origin(kOrigin1)); |
| 2353 filter.AddOrigin(url::Origin(kOrigin3)); |
| 2354 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 2355 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
| 2356 filter); |
| 2357 |
| 2358 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, GetRemovalMask()); |
| 2359 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 2360 |
| 2361 // Verify we only have two, and they're origin1 and origin3. |
| 2362 ContentSettingsForOneType host_settings; |
| 2363 host_content_settings_map->GetSettingsForOneType( |
| 2364 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2365 EXPECT_EQ(2u, host_settings.size()); |
| 2366 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin1), |
| 2367 host_settings[0].primary_pattern); |
| 2368 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin3), |
| 2369 host_settings[1].primary_pattern); |
| 2370 } |
| 2371 |
| 2372 TEST_F(BrowsingDataRemoverTest, ClearWithPredicate) { |
| 2373 HostContentSettingsMap* host_content_settings_map = |
| 2374 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 2375 ContentSettingsForOneType host_settings; |
| 2376 |
| 2377 // Patterns with wildcards. |
| 2378 ContentSettingsPattern pattern = |
| 2379 ContentSettingsPattern::FromString("[*.]example.org"); |
| 2380 ContentSettingsPattern pattern2 = |
| 2381 ContentSettingsPattern::FromString("[*.]example.net"); |
| 2382 |
| 2383 // Patterns without wildcards. |
| 2384 GURL url1("https://www.google.com/"); |
| 2385 GURL url2("https://www.google.com/maps"); |
| 2386 GURL url3("http://www.google.com/maps"); |
| 2387 GURL url3_origin_only("http://www.google.com/"); |
| 2388 |
| 2389 host_content_settings_map->SetContentSetting( |
| 2390 pattern2, ContentSettingsPattern::Wildcard(), |
| 2391 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), CONTENT_SETTING_BLOCK); |
| 2392 host_content_settings_map->SetContentSetting( |
| 2393 pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_IMAGES, |
| 2394 std::string(), CONTENT_SETTING_BLOCK); |
| 2395 host_content_settings_map->SetContentSetting( |
| 2396 pattern2, ContentSettingsPattern::Wildcard(), |
| 2397 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), CONTENT_SETTING_BLOCK); |
| 2398 |
| 2399 // First, test that we clear only IMAGES (not APP_BANNER), and pattern2. |
| 2400 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( |
| 2401 host_content_settings_map, CONTENT_SETTINGS_TYPE_IMAGES, |
| 2402 base::Bind(&MatchPrimaryPattern, pattern2)); |
| 2403 host_content_settings_map->GetSettingsForOneType( |
| 2404 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), &host_settings); |
| 2405 // |host_settings| contains default & block. |
| 2406 EXPECT_EQ(2U, host_settings.size()); |
| 2407 EXPECT_EQ(pattern, host_settings[0].primary_pattern); |
| 2408 EXPECT_EQ("*", host_settings[0].secondary_pattern.ToString()); |
| 2409 EXPECT_EQ("*", host_settings[1].primary_pattern.ToString()); |
| 2410 EXPECT_EQ("*", host_settings[1].secondary_pattern.ToString()); |
| 2411 |
| 2412 host_content_settings_map->GetSettingsForOneType( |
| 2413 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), &host_settings); |
| 2414 // |host_settings| contains block. |
| 2415 EXPECT_EQ(1U, host_settings.size()); |
| 2416 EXPECT_EQ(pattern2, host_settings[0].primary_pattern); |
| 2417 EXPECT_EQ("*", host_settings[0].secondary_pattern.ToString()); |
| 2418 |
| 2419 // Next, test that we do correct pattern matching w/ an origin policy item. |
| 2420 // We verify that we have no settings stored. |
| 2421 host_content_settings_map->GetSettingsForOneType( |
| 2422 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2423 EXPECT_EQ(0u, host_settings.size()); |
| 2424 // Add settings. |
| 2425 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2426 url1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2427 new base::FundamentalValue(10)); |
| 2428 // This setting should override the one above, as it's the same origin. |
| 2429 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2430 url2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2431 new base::FundamentalValue(10)); |
| 2432 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2433 url3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2434 new base::FundamentalValue(10)); |
| 2435 // Verify we only have two. |
| 2436 host_content_settings_map->GetSettingsForOneType( |
| 2437 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2438 EXPECT_EQ(2u, host_settings.size()); |
| 2439 |
| 2440 // Clear the http one, which we should be able to do w/ the origin only, as |
| 2441 // the scope of CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT is |
| 2442 // REQUESTING_ORIGIN_ONLY_SCOPE. |
| 2443 ContentSettingsPattern http_pattern = |
| 2444 ContentSettingsPattern::FromURLNoWildcard(url3_origin_only); |
| 2445 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( |
| 2446 host_content_settings_map, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 2447 base::Bind(&MatchPrimaryPattern, http_pattern)); |
| 2448 // Verify we only have one, and it's url1. |
| 2449 host_content_settings_map->GetSettingsForOneType( |
| 2450 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2451 EXPECT_EQ(1u, host_settings.size()); |
| 2452 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1), |
| 2453 host_settings[0].primary_pattern); |
| 2454 } |
| OLD | NEW |