| 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; |
| 169 StoragePartition::CookieMatcherFunction cookie_matcher; |
| 158 | 170 |
| 159 StoragePartitionRemovalData() {} | 171 StoragePartitionRemovalData() {} |
| 160 }; | 172 }; |
| 161 | 173 |
| 174 net::CanonicalCookie CreateCookieWithHost(const GURL& source) { |
| 175 return net::CanonicalCookie(source, "A", "1", source.host(), "/", |
| 176 base::Time::Now(), base::Time::Now(), |
| 177 base::Time::Now(), false, false, false, |
| 178 net::COOKIE_PRIORITY_MEDIUM); |
| 179 } |
| 180 |
| 162 class TestStoragePartition : public StoragePartition { | 181 class TestStoragePartition : public StoragePartition { |
| 163 public: | 182 public: |
| 164 TestStoragePartition() {} | 183 TestStoragePartition() {} |
| 165 ~TestStoragePartition() override {} | 184 ~TestStoragePartition() override {} |
| 166 | 185 |
| 167 // content::StoragePartition implementation. | 186 // content::StoragePartition implementation. |
| 168 base::FilePath GetPath() override { return base::FilePath(); } | 187 base::FilePath GetPath() override { return base::FilePath(); } |
| 169 net::URLRequestContextGetter* GetURLRequestContext() override { | 188 net::URLRequestContextGetter* GetURLRequestContext() override { |
| 170 return nullptr; | 189 return nullptr; |
| 171 } | 190 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 uint32_t quota_storage_remove_mask, | 244 uint32_t quota_storage_remove_mask, |
| 226 const GURL& storage_origin, | 245 const GURL& storage_origin, |
| 227 const OriginMatcherFunction& origin_matcher, | 246 const OriginMatcherFunction& origin_matcher, |
| 228 const base::Time begin, | 247 const base::Time begin, |
| 229 const base::Time end, | 248 const base::Time end, |
| 230 const base::Closure& callback) override { | 249 const base::Closure& callback) override { |
| 231 // Store stuff to verify parameters' correctness later. | 250 // Store stuff to verify parameters' correctness later. |
| 232 storage_partition_removal_data_.remove_mask = remove_mask; | 251 storage_partition_removal_data_.remove_mask = remove_mask; |
| 233 storage_partition_removal_data_.quota_storage_remove_mask = | 252 storage_partition_removal_data_.quota_storage_remove_mask = |
| 234 quota_storage_remove_mask; | 253 quota_storage_remove_mask; |
| 235 storage_partition_removal_data_.remove_origin = storage_origin; | |
| 236 storage_partition_removal_data_.remove_begin = begin; | 254 storage_partition_removal_data_.remove_begin = begin; |
| 237 storage_partition_removal_data_.remove_end = end; | 255 storage_partition_removal_data_.remove_end = end; |
| 238 storage_partition_removal_data_.origin_matcher = origin_matcher; | 256 storage_partition_removal_data_.origin_matcher = origin_matcher; |
| 239 | 257 |
| 240 BrowserThread::PostTask( | 258 BrowserThread::PostTask( |
| 241 BrowserThread::UI, | 259 BrowserThread::UI, |
| 242 FROM_HERE, | 260 FROM_HERE, |
| 243 base::Bind(&TestStoragePartition::AsyncRunCallback, | 261 base::Bind(&TestStoragePartition::AsyncRunCallback, |
| 244 base::Unretained(this), callback)); | 262 base::Unretained(this), callback)); |
| 245 } | 263 } |
| 246 | 264 |
| 265 void ClearData(uint32_t remove_mask, |
| 266 uint32_t quota_storage_remove_mask, |
| 267 const OriginMatcherFunction& origin_matcher, |
| 268 const CookieMatcherFunction& cookie_matcher, |
| 269 const base::Time begin, |
| 270 const base::Time end, |
| 271 const base::Closure& callback) override { |
| 272 // Store stuff to verify parameters' correctness later. |
| 273 storage_partition_removal_data_.remove_mask = remove_mask; |
| 274 storage_partition_removal_data_.quota_storage_remove_mask = |
| 275 quota_storage_remove_mask; |
| 276 storage_partition_removal_data_.remove_begin = begin; |
| 277 storage_partition_removal_data_.remove_end = end; |
| 278 storage_partition_removal_data_.origin_matcher = origin_matcher; |
| 279 storage_partition_removal_data_.cookie_matcher = cookie_matcher; |
| 280 |
| 281 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 282 base::Bind(&TestStoragePartition::AsyncRunCallback, |
| 283 base::Unretained(this), callback)); |
| 284 } |
| 285 |
| 247 void Flush() override {} | 286 void Flush() override {} |
| 248 | 287 |
| 249 StoragePartitionRemovalData GetStoragePartitionRemovalData() { | 288 StoragePartitionRemovalData GetStoragePartitionRemovalData() { |
| 250 return storage_partition_removal_data_; | 289 return storage_partition_removal_data_; |
| 251 } | 290 } |
| 252 | 291 |
| 253 private: | 292 private: |
| 254 void AsyncRunCallback(const base::Closure& callback) { | 293 void AsyncRunCallback(const base::Closure& callback) { |
| 255 callback.Run(); | 294 callback.Run(); |
| 256 } | 295 } |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 void BlockUntilOriginDataRemoved(BrowsingDataRemover::TimePeriod period, | 1029 void BlockUntilOriginDataRemoved(BrowsingDataRemover::TimePeriod period, |
| 991 int remove_mask, | 1030 int remove_mask, |
| 992 const GURL& remove_origin) { | 1031 const GURL& remove_origin) { |
| 993 BrowsingDataRemover* remover = | 1032 BrowsingDataRemover* remover = |
| 994 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); | 1033 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); |
| 995 TestStoragePartition storage_partition; | 1034 TestStoragePartition storage_partition; |
| 996 remover->OverrideStoragePartitionForTesting(&storage_partition); | 1035 remover->OverrideStoragePartitionForTesting(&storage_partition); |
| 997 | 1036 |
| 998 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails()); | 1037 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails()); |
| 999 | 1038 |
| 1039 OriginFilterBuilder builder(OriginFilterBuilder::WHITELIST); |
| 1040 builder.AddOrigin(url::Origin(remove_origin)); |
| 1041 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
| 1042 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, |
| 1043 builder, BrowsingDataHelper::UNPROTECTED_WEB); |
| 1044 completion_observer.BlockUntilCompletion(); |
| 1045 |
| 1046 // Save so we can verify later. |
| 1047 storage_partition_removal_data_ = |
| 1048 storage_partition.GetStoragePartitionRemovalData(); |
| 1049 } |
| 1050 |
| 1051 void BlockUntilOriginDataRemoved(BrowsingDataRemover::TimePeriod period, |
| 1052 int remove_mask, |
| 1053 const OriginFilterBuilder& filter_builder) { |
| 1054 BrowsingDataRemover* remover = |
| 1055 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); |
| 1056 TestStoragePartition storage_partition; |
| 1057 remover->OverrideStoragePartitionForTesting(&storage_partition); |
| 1058 |
| 1059 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails()); |
| 1060 |
| 1000 BrowsingDataRemoverCompletionObserver completion_observer(remover); | 1061 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
| 1001 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, | 1062 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, |
| 1002 remove_origin, BrowsingDataHelper::UNPROTECTED_WEB); | 1063 filter_builder, BrowsingDataHelper::UNPROTECTED_WEB); |
| 1003 completion_observer.BlockUntilCompletion(); | 1064 completion_observer.BlockUntilCompletion(); |
| 1004 | 1065 |
| 1005 // Save so we can verify later. | 1066 // Save so we can verify later. |
| 1006 storage_partition_removal_data_ = | 1067 storage_partition_removal_data_ = |
| 1007 storage_partition.GetStoragePartitionRemovalData(); | 1068 storage_partition.GetStoragePartitionRemovalData(); |
| 1008 } | 1069 } |
| 1009 | 1070 |
| 1010 TestingProfile* GetProfile() { | 1071 TestingProfile* GetProfile() { |
| 1011 return profile_.get(); | 1072 return profile_.get(); |
| 1012 } | 1073 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 | 1163 |
| 1103 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1164 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1104 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1165 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1105 | 1166 |
| 1106 // Verify that storage partition was instructed to remove the cookies. | 1167 // Verify that storage partition was instructed to remove the cookies. |
| 1107 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1168 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1108 EXPECT_EQ(removal_data.remove_mask, | 1169 EXPECT_EQ(removal_data.remove_mask, |
| 1109 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1170 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
| 1110 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1171 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1111 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1172 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1112 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1113 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1173 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1114 } | 1174 } |
| 1115 | 1175 |
| 1116 TEST_F(BrowsingDataRemoverTest, RemoveCookieLastHour) { | 1176 TEST_F(BrowsingDataRemoverTest, RemoveCookieLastHour) { |
| 1117 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 1177 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 1118 BrowsingDataRemover::REMOVE_COOKIES, | 1178 BrowsingDataRemover::REMOVE_COOKIES, |
| 1119 false); | 1179 false); |
| 1120 | 1180 |
| 1121 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1181 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1122 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1182 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1123 | 1183 |
| 1124 // Verify that storage partition was instructed to remove the cookies. | 1184 // Verify that storage partition was instructed to remove the cookies. |
| 1125 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1185 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1126 EXPECT_EQ(removal_data.remove_mask, | 1186 EXPECT_EQ(removal_data.remove_mask, |
| 1127 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1187 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
| 1128 // Removing with time period other than EVERYTHING should not clear | 1188 // Removing with time period other than EVERYTHING should not clear |
| 1129 // persistent storage data. | 1189 // persistent storage data. |
| 1130 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1190 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1131 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1191 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
| 1132 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1133 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1192 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1134 } | 1193 } |
| 1135 | 1194 |
| 1195 TEST_F(BrowsingDataRemoverTest, RemoveCookiesOriginBlacklist) { |
| 1196 OriginFilterBuilder filter(OriginFilterBuilder::BLACKLIST); |
| 1197 filter.AddOrigin(url::Origin(kOrigin1)); |
| 1198 filter.AddOrigin(url::Origin(kOrigin3)); |
| 1199 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 1200 BrowsingDataRemover::REMOVE_COOKIES, filter); |
| 1201 |
| 1202 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1203 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1204 |
| 1205 // Verify that storage partition was instructed to remove the cookies. |
| 1206 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1207 EXPECT_EQ(removal_data.remove_mask, |
| 1208 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
| 1209 // Removing with time period other than EVERYTHING should not clear |
| 1210 // persistent storage data. |
| 1211 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1212 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
| 1213 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1214 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1215 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1216 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1217 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); |
| 1218 |
| 1219 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin1))); |
| 1220 EXPECT_TRUE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin2))); |
| 1221 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin3))); |
| 1222 // This is false, because this is the same domain as 3, just with a different |
| 1223 // scheme. |
| 1224 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin4))); |
| 1225 } |
| 1226 |
| 1136 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { | 1227 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { |
| 1137 RemoveSafeBrowsingCookieTester tester; | 1228 RemoveSafeBrowsingCookieTester tester; |
| 1138 | 1229 |
| 1139 tester.AddCookie(); | 1230 tester.AddCookie(); |
| 1140 ASSERT_TRUE(tester.ContainsCookie()); | 1231 ASSERT_TRUE(tester.ContainsCookie()); |
| 1141 | 1232 |
| 1142 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 1233 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 1143 BrowsingDataRemover::REMOVE_COOKIES, false); | 1234 BrowsingDataRemover::REMOVE_COOKIES, false); |
| 1144 | 1235 |
| 1145 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1236 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1156 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 1247 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 1157 BrowsingDataRemover::REMOVE_COOKIES, false); | 1248 BrowsingDataRemover::REMOVE_COOKIES, false); |
| 1158 | 1249 |
| 1159 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1250 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1160 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1251 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1161 // Removing with time period other than EVERYTHING should not clear safe | 1252 // Removing with time period other than EVERYTHING should not clear safe |
| 1162 // browsing cookies. | 1253 // browsing cookies. |
| 1163 EXPECT_TRUE(tester.ContainsCookie()); | 1254 EXPECT_TRUE(tester.ContainsCookie()); |
| 1164 } | 1255 } |
| 1165 | 1256 |
| 1257 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForeverWithPredicate) { |
| 1258 RemoveSafeBrowsingCookieTester tester; |
| 1259 |
| 1260 tester.AddCookie(); |
| 1261 ASSERT_TRUE(tester.ContainsCookie()); |
| 1262 OriginFilterBuilder filter(OriginFilterBuilder::BLACKLIST); |
| 1263 filter.AddOrigin(url::Origin(kOrigin1)); |
| 1264 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 1265 BrowsingDataRemover::REMOVE_COOKIES, filter); |
| 1266 |
| 1267 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1268 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1269 EXPECT_TRUE(tester.ContainsCookie()); |
| 1270 |
| 1271 OriginFilterBuilder filter2(OriginFilterBuilder::WHITELIST); |
| 1272 filter2.AddOrigin(url::Origin(kOrigin1)); |
| 1273 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 1274 BrowsingDataRemover::REMOVE_COOKIES, filter2); |
| 1275 EXPECT_FALSE(tester.ContainsCookie()); |
| 1276 } |
| 1277 |
| 1166 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDForever) { | 1278 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDForever) { |
| 1167 RemoveChannelIDTester tester(GetProfile()); | 1279 RemoveChannelIDTester tester(GetProfile()); |
| 1168 | 1280 |
| 1169 tester.AddChannelID(kTestOrigin1); | 1281 tester.AddChannelID(kTestOrigin1); |
| 1170 EXPECT_EQ(0, tester.ssl_config_changed_count()); | 1282 EXPECT_EQ(0, tester.ssl_config_changed_count()); |
| 1171 EXPECT_EQ(1, tester.ChannelIDCount()); | 1283 EXPECT_EQ(1, tester.ChannelIDCount()); |
| 1172 | 1284 |
| 1173 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 1285 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 1174 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); | 1286 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); |
| 1175 | 1287 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 | 1327 |
| 1216 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1328 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
| 1217 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1329 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1218 | 1330 |
| 1219 // Verify that storage partition was instructed to remove the data correctly. | 1331 // Verify that storage partition was instructed to remove the data correctly. |
| 1220 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1332 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1221 EXPECT_EQ(removal_data.remove_mask, | 1333 EXPECT_EQ(removal_data.remove_mask, |
| 1222 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1334 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
| 1223 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1335 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1224 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1336 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1225 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1226 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1337 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1227 | 1338 |
| 1228 // Check origin matcher. | 1339 // Check origin matcher. |
| 1229 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1340 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
| 1230 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1341 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1231 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1342 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1232 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1343 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1233 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1344 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
| 1234 } | 1345 } |
| 1235 | 1346 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1247 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1358 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
| 1248 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | | 1359 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | |
| 1249 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); | 1360 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); |
| 1250 | 1361 |
| 1251 // Verify that storage partition was instructed to remove the data correctly. | 1362 // Verify that storage partition was instructed to remove the data correctly. |
| 1252 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1363 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1253 EXPECT_EQ(removal_data.remove_mask, | 1364 EXPECT_EQ(removal_data.remove_mask, |
| 1254 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1365 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
| 1255 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1366 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1256 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1367 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1257 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1258 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1368 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1259 | 1369 |
| 1260 // Check origin matcher all http origin will match since we specified | 1370 // Check origin matcher all http origin will match since we specified |
| 1261 // both protected and unprotected. | 1371 // both protected and unprotected. |
| 1262 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1372 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1263 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1373 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1264 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1374 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1265 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1375 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
| 1266 } | 1376 } |
| 1267 | 1377 |
| 1268 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { | 1378 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { |
| 1269 #if defined(ENABLE_EXTENSIONS) | 1379 #if defined(ENABLE_EXTENSIONS) |
| 1270 CreateMockPolicy(); | 1380 CreateMockPolicy(); |
| 1271 #endif | 1381 #endif |
| 1272 | 1382 |
| 1273 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, | 1383 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, |
| 1274 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, | 1384 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, |
| 1275 false); | 1385 false); |
| 1276 | 1386 |
| 1277 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1387 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
| 1278 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1388 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1279 | 1389 |
| 1280 // Verify that storage partition was instructed to remove the data correctly. | 1390 // Verify that storage partition was instructed to remove the data correctly. |
| 1281 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1391 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1282 EXPECT_EQ(removal_data.remove_mask, | 1392 EXPECT_EQ(removal_data.remove_mask, |
| 1283 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1393 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
| 1284 // Persistent storage won't be deleted. | 1394 // Persistent storage won't be deleted. |
| 1285 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1395 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1286 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1396 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
| 1287 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1288 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1397 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1289 | 1398 |
| 1290 // Check origin matcher. | 1399 // Check origin matcher. |
| 1291 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1400 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1292 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1401 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1293 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1402 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1294 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1403 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
| 1295 } | 1404 } |
| 1296 | 1405 |
| 1297 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { | 1406 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1592 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1484 EXPECT_EQ(removal_data.remove_mask, | 1593 EXPECT_EQ(removal_data.remove_mask, |
| 1485 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1594 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1486 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1595 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1487 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1596 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1488 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1597 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1489 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1598 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1490 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1599 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1491 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1600 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1492 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1601 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1493 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1494 } | 1602 } |
| 1495 | 1603 |
| 1496 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { | 1604 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { |
| 1497 #if defined(ENABLE_EXTENSIONS) | 1605 #if defined(ENABLE_EXTENSIONS) |
| 1498 CreateMockPolicy(); | 1606 CreateMockPolicy(); |
| 1499 #endif | 1607 #endif |
| 1500 | 1608 |
| 1501 BlockUntilBrowsingDataRemoved( | 1609 BlockUntilBrowsingDataRemoved( |
| 1502 BrowsingDataRemover::EVERYTHING, | 1610 BrowsingDataRemover::EVERYTHING, |
| 1503 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1611 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1522 | 1630 |
| 1523 EXPECT_EQ(removal_data.remove_mask, | 1631 EXPECT_EQ(removal_data.remove_mask, |
| 1524 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1632 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1525 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1633 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1526 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1634 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1527 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1635 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1528 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1636 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1529 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1637 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1530 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1638 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1531 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1639 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1532 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1533 | 1640 |
| 1534 // Check that all related origin data would be removed, that is, origin | 1641 // Check that all related origin data would be removed, that is, origin |
| 1535 // matcher would match these origin. | 1642 // matcher would match these origin. |
| 1536 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1643 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1537 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1644 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1538 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1645 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1539 } | 1646 } |
| 1540 | 1647 |
| 1541 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { | 1648 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { |
| 1542 #if defined(ENABLE_EXTENSIONS) | 1649 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1567 | 1674 |
| 1568 EXPECT_EQ(removal_data.remove_mask, | 1675 EXPECT_EQ(removal_data.remove_mask, |
| 1569 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1676 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1570 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1677 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1571 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1678 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1572 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1679 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1573 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1680 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1574 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1681 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1575 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1682 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1576 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1683 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1577 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1578 | 1684 |
| 1579 // Check that all related origin data would be removed, that is, origin | 1685 // Check that all related origin data would be removed, that is, origin |
| 1580 // matcher would match these origin. | 1686 // matcher would match these origin. |
| 1581 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1687 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1582 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1688 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1583 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1689 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1584 } | 1690 } |
| 1585 | 1691 |
| 1586 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { | 1692 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { |
| 1587 #if defined(ENABLE_EXTENSIONS) | 1693 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1612 | 1718 |
| 1613 EXPECT_EQ(removal_data.remove_mask, | 1719 EXPECT_EQ(removal_data.remove_mask, |
| 1614 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1720 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1615 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1721 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1616 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1722 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1617 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1723 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1618 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1724 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1619 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1725 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1620 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1726 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1621 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1727 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1622 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1623 | 1728 |
| 1624 // Check that all related origin data would be removed, that is, origin | 1729 // Check that all related origin data would be removed, that is, origin |
| 1625 // matcher would match these origin. | 1730 // matcher would match these origin. |
| 1626 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1731 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1627 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1732 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1628 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1733 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1629 } | 1734 } |
| 1630 | 1735 |
| 1631 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverSpecificOrigin) { | 1736 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverSpecificOrigin) { |
| 1632 // Remove Origin 1. | 1737 // Remove Origin 1. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1653 | 1758 |
| 1654 EXPECT_EQ(removal_data.remove_mask, | 1759 EXPECT_EQ(removal_data.remove_mask, |
| 1655 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1760 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1656 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1761 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1657 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1762 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1658 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1763 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1659 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1764 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1660 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1765 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1661 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1766 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1662 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1767 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1663 EXPECT_EQ(removal_data.remove_origin, kOrigin1); | 1768 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1769 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1770 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1771 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); |
| 1664 } | 1772 } |
| 1665 | 1773 |
| 1666 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { | 1774 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { |
| 1667 BlockUntilBrowsingDataRemoved( | 1775 BlockUntilBrowsingDataRemoved( |
| 1668 BrowsingDataRemover::LAST_HOUR, | 1776 BrowsingDataRemover::LAST_HOUR, |
| 1669 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1777 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
| 1670 BrowsingDataRemover::REMOVE_WEBSQL | | 1778 BrowsingDataRemover::REMOVE_WEBSQL | |
| 1671 BrowsingDataRemover::REMOVE_APPCACHE | | 1779 BrowsingDataRemover::REMOVE_APPCACHE | |
| 1672 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1780 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
| 1673 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1781 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1692 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1800 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1693 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1801 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1694 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1802 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1695 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1803 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1696 | 1804 |
| 1697 // Persistent data would be left out since we are not removing from | 1805 // Persistent data would be left out since we are not removing from |
| 1698 // beginning of time. | 1806 // beginning of time. |
| 1699 uint32_t expected_quota_mask = | 1807 uint32_t expected_quota_mask = |
| 1700 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 1808 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
| 1701 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); | 1809 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. | 1810 // Check removal begin time. |
| 1704 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1811 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1705 } | 1812 } |
| 1706 | 1813 |
| 1707 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { | 1814 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { |
| 1708 BlockUntilBrowsingDataRemoved( | 1815 BlockUntilBrowsingDataRemoved( |
| 1709 BrowsingDataRemover::LAST_WEEK, | 1816 BrowsingDataRemover::LAST_WEEK, |
| 1710 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1817 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
| 1711 BrowsingDataRemover::REMOVE_WEBSQL | | 1818 BrowsingDataRemover::REMOVE_WEBSQL | |
| 1712 BrowsingDataRemover::REMOVE_APPCACHE | | 1819 BrowsingDataRemover::REMOVE_APPCACHE | |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1733 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1840 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1734 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1841 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1735 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1842 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1736 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1843 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1737 | 1844 |
| 1738 // Persistent data would be left out since we are not removing from | 1845 // Persistent data would be left out since we are not removing from |
| 1739 // beginning of time. | 1846 // beginning of time. |
| 1740 uint32_t expected_quota_mask = | 1847 uint32_t expected_quota_mask = |
| 1741 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 1848 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
| 1742 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); | 1849 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. | 1850 // Check removal begin time. |
| 1745 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1851 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1746 } | 1852 } |
| 1747 | 1853 |
| 1748 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { | 1854 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { |
| 1749 #if defined(ENABLE_EXTENSIONS) | 1855 #if defined(ENABLE_EXTENSIONS) |
| 1750 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1856 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
| 1751 // Protect kOrigin1. | 1857 // Protect kOrigin1. |
| 1752 policy->AddProtected(kOrigin1.GetOrigin()); | 1858 policy->AddProtected(kOrigin1.GetOrigin()); |
| 1753 #endif | 1859 #endif |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1776 | 1882 |
| 1777 EXPECT_EQ(removal_data.remove_mask, | 1883 EXPECT_EQ(removal_data.remove_mask, |
| 1778 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1884 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1779 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1885 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1780 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1886 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1781 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1887 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1782 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1888 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1783 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1889 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1784 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1890 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1785 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1891 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1786 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1787 | 1892 |
| 1788 // Check OriginMatcherFunction. | 1893 // Check OriginMatcherFunction. |
| 1789 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1894 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
| 1790 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1895 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1791 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1896 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1792 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1897 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1793 } | 1898 } |
| 1794 | 1899 |
| 1795 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedSpecificOrigin) { | 1900 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedSpecificOrigin) { |
| 1796 #if defined(ENABLE_EXTENSIONS) | 1901 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1823 | 1928 |
| 1824 EXPECT_EQ(removal_data.remove_mask, | 1929 EXPECT_EQ(removal_data.remove_mask, |
| 1825 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1930 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1826 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1931 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1827 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1932 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1828 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1933 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1829 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1934 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1830 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1935 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1831 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1936 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1832 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1937 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1833 EXPECT_EQ(removal_data.remove_origin, kOrigin1); | |
| 1834 | 1938 |
| 1835 // Check OriginMatcherFunction. | 1939 // Check OriginMatcherFunction. |
| 1836 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1940 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
| 1837 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1941 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1838 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1942 // Since we use the matcher function to validate origins now, this should |
| 1839 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1943 // return false for the origins we're not trying to clear. |
| 1944 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1945 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1840 } | 1946 } |
| 1841 | 1947 |
| 1842 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { | 1948 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { |
| 1843 #if defined(ENABLE_EXTENSIONS) | 1949 #if defined(ENABLE_EXTENSIONS) |
| 1844 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1950 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
| 1845 // Protect kOrigin1. | 1951 // Protect kOrigin1. |
| 1846 policy->AddProtected(kOrigin1.GetOrigin()); | 1952 policy->AddProtected(kOrigin1.GetOrigin()); |
| 1847 #endif | 1953 #endif |
| 1848 | 1954 |
| 1849 // Try to remove kOrigin1. Expect success. | 1955 // Try to remove kOrigin1. Expect success. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1872 | 1978 |
| 1873 EXPECT_EQ(removal_data.remove_mask, | 1979 EXPECT_EQ(removal_data.remove_mask, |
| 1874 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1980 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1875 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1981 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1876 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1982 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1877 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1983 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1878 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1984 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1879 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1985 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1880 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1986 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1881 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1987 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1882 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1883 | 1988 |
| 1884 // Check OriginMatcherFunction, |kOrigin1| would match mask since we | 1989 // Check OriginMatcherFunction, |kOrigin1| would match mask since we |
| 1885 // would have 'protected' specified in origin_type_mask. | 1990 // would have 'protected' specified in origin_type_mask. |
| 1886 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1991 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1887 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1992 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1888 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1993 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1889 } | 1994 } |
| 1890 | 1995 |
| 1891 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { | 1996 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { |
| 1892 #if defined(ENABLE_EXTENSIONS) | 1997 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1917 | 2022 |
| 1918 EXPECT_EQ(removal_data.remove_mask, | 2023 EXPECT_EQ(removal_data.remove_mask, |
| 1919 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 2024 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1920 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 2025 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1921 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 2026 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1922 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 2027 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1923 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 2028 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1924 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 2029 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1925 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 2030 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1926 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 2031 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1927 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1928 | 2032 |
| 1929 // Check that extension and devtools data wouldn't be removed, that is, | 2033 // Check that extension and devtools data wouldn't be removed, that is, |
| 1930 // origin matcher would not match these origin. | 2034 // origin matcher would not match these origin. |
| 1931 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 2035 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
| 1932 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginDevTools, mock_policy())); | 2036 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginDevTools, mock_policy())); |
| 1933 } | 2037 } |
| 1934 | 2038 |
| 1935 TEST_F(BrowsingDataRemoverTest, OriginBasedHistoryRemoval) { | 2039 TEST_F(BrowsingDataRemoverTest, TimeBasedHistoryRemoval) { |
| 1936 RemoveHistoryTester tester; | 2040 RemoveHistoryTester tester; |
| 1937 ASSERT_TRUE(tester.Init(GetProfile())); | 2041 ASSERT_TRUE(tester.Init(GetProfile())); |
| 1938 | 2042 |
| 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); | 2043 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
| 1962 | 2044 |
| 1963 tester.AddHistory(kOrigin1, base::Time::Now()); | 2045 tester.AddHistory(kOrigin1, base::Time::Now()); |
| 1964 tester.AddHistory(kOrigin2, two_hours_ago); | 2046 tester.AddHistory(kOrigin2, two_hours_ago); |
| 1965 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 2047 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
| 1966 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 2048 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
| 1967 | 2049 |
| 1968 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, | 2050 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 1969 BrowsingDataRemover::REMOVE_HISTORY, kOrigin2); | 2051 BrowsingDataRemover::REMOVE_HISTORY, GURL()); |
| 1970 | 2052 |
| 1971 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 2053 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
| 1972 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2054 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1973 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 2055 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); |
| 1974 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 2056 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
| 1975 } | 2057 } |
| 1976 | 2058 |
| 1977 // Verify that clearing autofill form data works. | 2059 // Verify that clearing autofill form data works. |
| 1978 TEST_F(BrowsingDataRemoverTest, AutofillRemovalLastHour) { | 2060 TEST_F(BrowsingDataRemoverTest, AutofillRemovalLastHour) { |
| 1979 GetProfile()->CreateWebDataService(); | 2061 GetProfile()->CreateWebDataService(); |
| 1980 RemoveAutofillTester tester(GetProfile()); | 2062 RemoveAutofillTester tester(GetProfile()); |
| 1981 | 2063 |
| 1982 ASSERT_FALSE(tester.HasProfile()); | 2064 ASSERT_FALSE(tester.HasProfile()); |
| 1983 tester.AddProfilesAndCards(); | 2065 tester.AddProfilesAndCards(); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2276 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) | 2358 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) |
| 2277 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2359 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
| 2278 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) | 2360 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) |
| 2279 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2361 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
| 2280 | 2362 |
| 2281 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 2363 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 2282 BrowsingDataRemover::REMOVE_COOKIES | | 2364 BrowsingDataRemover::REMOVE_COOKIES | |
| 2283 BrowsingDataRemover::REMOVE_PASSWORDS, | 2365 BrowsingDataRemover::REMOVE_PASSWORDS, |
| 2284 false); | 2366 false); |
| 2285 } | 2367 } |
| 2368 |
| 2369 TEST_F(BrowsingDataRemoverTest, RemoveContentSettingsWithBlacklist) { |
| 2370 // Add our settings. |
| 2371 HostContentSettingsMap* host_content_settings_map = |
| 2372 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 2373 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2374 kOrigin1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2375 new base::FundamentalValue(10)); |
| 2376 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2377 kOrigin2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2378 new base::FundamentalValue(11)); |
| 2379 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2380 kOrigin3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2381 new base::FundamentalValue(11)); |
| 2382 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2383 kOrigin4, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2384 new base::FundamentalValue(11)); |
| 2385 |
| 2386 // Clear all except for origin1 and origin3. |
| 2387 OriginFilterBuilder filter(OriginFilterBuilder::BLACKLIST); |
| 2388 filter.AddOrigin(url::Origin(kOrigin1)); |
| 2389 filter.AddOrigin(url::Origin(kOrigin3)); |
| 2390 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 2391 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
| 2392 filter); |
| 2393 |
| 2394 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, GetRemovalMask()); |
| 2395 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 2396 |
| 2397 // Verify we only have two, and they're origin1 and origin3. |
| 2398 ContentSettingsForOneType host_settings; |
| 2399 host_content_settings_map->GetSettingsForOneType( |
| 2400 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2401 EXPECT_EQ(2u, host_settings.size()); |
| 2402 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin1), |
| 2403 host_settings[0].primary_pattern); |
| 2404 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin3), |
| 2405 host_settings[1].primary_pattern); |
| 2406 } |
| 2407 |
| 2408 TEST_F(BrowsingDataRemoverTest, ClearWithPredicate) { |
| 2409 HostContentSettingsMap* host_content_settings_map = |
| 2410 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 2411 ContentSettingsForOneType host_settings; |
| 2412 |
| 2413 // Patterns with wildcards. |
| 2414 ContentSettingsPattern pattern = |
| 2415 ContentSettingsPattern::FromString("[*.]example.org"); |
| 2416 ContentSettingsPattern pattern2 = |
| 2417 ContentSettingsPattern::FromString("[*.]example.net"); |
| 2418 |
| 2419 // Patterns without wildcards. |
| 2420 GURL url1("https://www.google.com/"); |
| 2421 GURL url2("https://www.google.com/maps"); |
| 2422 GURL url3("http://www.google.com/maps"); |
| 2423 GURL url3_origin_only("http://www.google.com/"); |
| 2424 |
| 2425 host_content_settings_map->SetContentSetting( |
| 2426 pattern2, ContentSettingsPattern::Wildcard(), |
| 2427 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), CONTENT_SETTING_BLOCK); |
| 2428 host_content_settings_map->SetContentSetting( |
| 2429 pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_IMAGES, |
| 2430 std::string(), CONTENT_SETTING_BLOCK); |
| 2431 host_content_settings_map->SetContentSetting( |
| 2432 pattern2, ContentSettingsPattern::Wildcard(), |
| 2433 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), CONTENT_SETTING_BLOCK); |
| 2434 |
| 2435 // First, test that we clear only IMAGES (not APP_BANNER), and pattern2. |
| 2436 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( |
| 2437 host_content_settings_map, CONTENT_SETTINGS_TYPE_IMAGES, |
| 2438 base::Bind(&MatchPrimaryPattern, pattern2)); |
| 2439 host_content_settings_map->GetSettingsForOneType( |
| 2440 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), &host_settings); |
| 2441 // |host_settings| contains default & block. |
| 2442 EXPECT_EQ(2U, host_settings.size()); |
| 2443 EXPECT_EQ(pattern, host_settings[0].primary_pattern); |
| 2444 EXPECT_EQ("*", host_settings[0].secondary_pattern.ToString()); |
| 2445 EXPECT_EQ("*", host_settings[1].primary_pattern.ToString()); |
| 2446 EXPECT_EQ("*", host_settings[1].secondary_pattern.ToString()); |
| 2447 |
| 2448 host_content_settings_map->GetSettingsForOneType( |
| 2449 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), &host_settings); |
| 2450 // |host_settings| contains block. |
| 2451 EXPECT_EQ(1U, host_settings.size()); |
| 2452 EXPECT_EQ(pattern2, host_settings[0].primary_pattern); |
| 2453 EXPECT_EQ("*", host_settings[0].secondary_pattern.ToString()); |
| 2454 |
| 2455 // Next, test that we do correct pattern matching w/ an origin policy item. |
| 2456 // We verify that we have no settings stored. |
| 2457 host_content_settings_map->GetSettingsForOneType( |
| 2458 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2459 EXPECT_EQ(0u, host_settings.size()); |
| 2460 // Add settings. |
| 2461 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2462 url1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2463 new base::FundamentalValue(10)); |
| 2464 // This setting should override the one above, as it's the same origin. |
| 2465 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2466 url2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2467 new base::FundamentalValue(10)); |
| 2468 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2469 url3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2470 new base::FundamentalValue(10)); |
| 2471 // Verify we only have two. |
| 2472 host_content_settings_map->GetSettingsForOneType( |
| 2473 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2474 EXPECT_EQ(2u, host_settings.size()); |
| 2475 |
| 2476 // Clear the http one, which we should be able to do w/ the origin only, as |
| 2477 // the scope of CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT is |
| 2478 // REQUESTING_ORIGIN_ONLY_SCOPE. |
| 2479 ContentSettingsPattern http_pattern = |
| 2480 ContentSettingsPattern::FromURLNoWildcard(url3_origin_only); |
| 2481 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( |
| 2482 host_content_settings_map, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 2483 base::Bind(&MatchPrimaryPattern, http_pattern)); |
| 2484 // Verify we only have one, and it's url1. |
| 2485 host_content_settings_map->GetSettingsForOneType( |
| 2486 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2487 EXPECT_EQ(1u, host_settings.size()); |
| 2488 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1), |
| 2489 host_settings[0].primary_pattern); |
| 2490 } |
| OLD | NEW |