| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 using testing::Invoke; | 109 using testing::Invoke; |
| 106 using testing::Matcher; | 110 using testing::Matcher; |
| 107 using testing::MakeMatcher; | 111 using testing::MakeMatcher; |
| 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.com:1/"; |
| 116 const char kTestOrigin2[] = "http://host2:1/"; | 120 const char kTestOrigin2[] = "http://host2.com:1/"; |
| 117 const char kTestOrigin3[] = "http://host3:1/"; | 121 const char kTestOrigin3[] = "http://host3.com:1/"; |
| 122 const char kTestOrigin4[] = "https://host3.com: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 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 1000 BrowsingDataRemoverCompletionObserver completion_observer(remover); | 1039 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
| 1040 |
| 1041 if (remove_origin.is_empty()) { |
| 1042 OriginFilterBuilder builder(OriginFilterBuilder::BLACKLIST); |
| 1043 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, |
| 1044 builder, BrowsingDataHelper::UNPROTECTED_WEB); |
| 1045 } else { |
| 1046 OriginFilterBuilder builder(OriginFilterBuilder::WHITELIST); |
| 1047 builder.AddOrigin(url::Origin(remove_origin)); |
| 1048 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, |
| 1049 builder, BrowsingDataHelper::UNPROTECTED_WEB); |
| 1050 } |
| 1051 completion_observer.BlockUntilCompletion(); |
| 1052 |
| 1053 // Save so we can verify later. |
| 1054 storage_partition_removal_data_ = |
| 1055 storage_partition.GetStoragePartitionRemovalData(); |
| 1056 } |
| 1057 |
| 1058 void BlockUntilOriginDataRemoved(BrowsingDataRemover::TimePeriod period, |
| 1059 int remove_mask, |
| 1060 const OriginFilterBuilder& filter_builder) { |
| 1061 BrowsingDataRemover* remover = |
| 1062 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); |
| 1063 TestStoragePartition storage_partition; |
| 1064 remover->OverrideStoragePartitionForTesting(&storage_partition); |
| 1065 |
| 1066 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails()); |
| 1067 |
| 1068 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
| 1001 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, | 1069 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, |
| 1002 remove_origin, BrowsingDataHelper::UNPROTECTED_WEB); | 1070 filter_builder, BrowsingDataHelper::UNPROTECTED_WEB); |
| 1003 completion_observer.BlockUntilCompletion(); | 1071 completion_observer.BlockUntilCompletion(); |
| 1004 | 1072 |
| 1005 // Save so we can verify later. | 1073 // Save so we can verify later. |
| 1006 storage_partition_removal_data_ = | 1074 storage_partition_removal_data_ = |
| 1007 storage_partition.GetStoragePartitionRemovalData(); | 1075 storage_partition.GetStoragePartitionRemovalData(); |
| 1008 } | 1076 } |
| 1009 | 1077 |
| 1010 TestingProfile* GetProfile() { | 1078 TestingProfile* GetProfile() { |
| 1011 return profile_.get(); | 1079 return profile_.get(); |
| 1012 } | 1080 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 | 1170 |
| 1103 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1171 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1104 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1172 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1105 | 1173 |
| 1106 // Verify that storage partition was instructed to remove the cookies. | 1174 // Verify that storage partition was instructed to remove the cookies. |
| 1107 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1175 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1108 EXPECT_EQ(removal_data.remove_mask, | 1176 EXPECT_EQ(removal_data.remove_mask, |
| 1109 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1177 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
| 1110 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1178 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1111 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1179 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1112 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1113 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1180 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1114 } | 1181 } |
| 1115 | 1182 |
| 1116 TEST_F(BrowsingDataRemoverTest, RemoveCookieLastHour) { | 1183 TEST_F(BrowsingDataRemoverTest, RemoveCookieLastHour) { |
| 1117 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 1184 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 1118 BrowsingDataRemover::REMOVE_COOKIES, | 1185 BrowsingDataRemover::REMOVE_COOKIES, |
| 1119 false); | 1186 false); |
| 1120 | 1187 |
| 1121 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1188 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1122 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1189 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1123 | 1190 |
| 1124 // Verify that storage partition was instructed to remove the cookies. | 1191 // Verify that storage partition was instructed to remove the cookies. |
| 1125 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1192 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1126 EXPECT_EQ(removal_data.remove_mask, | 1193 EXPECT_EQ(removal_data.remove_mask, |
| 1127 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1194 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
| 1128 // Removing with time period other than EVERYTHING should not clear | 1195 // Removing with time period other than EVERYTHING should not clear |
| 1129 // persistent storage data. | 1196 // persistent storage data. |
| 1130 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1197 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1131 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1198 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
| 1132 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1133 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1199 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1134 } | 1200 } |
| 1135 | 1201 |
| 1202 TEST_F(BrowsingDataRemoverTest, RemoveCookiesOriginBlacklist) { |
| 1203 OriginFilterBuilder filter(OriginFilterBuilder::BLACKLIST); |
| 1204 filter.AddOrigin(url::Origin(kOrigin1)); |
| 1205 filter.AddOrigin(url::Origin(kOrigin3)); |
| 1206 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 1207 BrowsingDataRemover::REMOVE_COOKIES, filter); |
| 1208 |
| 1209 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1210 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1211 |
| 1212 // Verify that storage partition was instructed to remove the cookies. |
| 1213 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1214 EXPECT_EQ(removal_data.remove_mask, |
| 1215 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
| 1216 // Removing with time period other than EVERYTHING should not clear |
| 1217 // persistent storage data. |
| 1218 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1219 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
| 1220 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1221 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1222 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1223 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1224 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); |
| 1225 |
| 1226 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin1))); |
| 1227 EXPECT_TRUE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin2))); |
| 1228 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin3))); |
| 1229 // This is false, because this is the same domain as 3, just with a different |
| 1230 // scheme. |
| 1231 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin4))); |
| 1232 } |
| 1233 |
| 1136 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { | 1234 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { |
| 1137 RemoveSafeBrowsingCookieTester tester; | 1235 RemoveSafeBrowsingCookieTester tester; |
| 1138 | 1236 |
| 1139 tester.AddCookie(); | 1237 tester.AddCookie(); |
| 1140 ASSERT_TRUE(tester.ContainsCookie()); | 1238 ASSERT_TRUE(tester.ContainsCookie()); |
| 1141 | 1239 |
| 1142 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 1240 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 1143 BrowsingDataRemover::REMOVE_COOKIES, false); | 1241 BrowsingDataRemover::REMOVE_COOKIES, false); |
| 1144 | 1242 |
| 1145 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1243 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1156 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 1254 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 1157 BrowsingDataRemover::REMOVE_COOKIES, false); | 1255 BrowsingDataRemover::REMOVE_COOKIES, false); |
| 1158 | 1256 |
| 1159 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1257 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1160 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1258 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1161 // Removing with time period other than EVERYTHING should not clear safe | 1259 // Removing with time period other than EVERYTHING should not clear safe |
| 1162 // browsing cookies. | 1260 // browsing cookies. |
| 1163 EXPECT_TRUE(tester.ContainsCookie()); | 1261 EXPECT_TRUE(tester.ContainsCookie()); |
| 1164 } | 1262 } |
| 1165 | 1263 |
| 1264 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForeverWithPredicate) { |
| 1265 RemoveSafeBrowsingCookieTester tester; |
| 1266 |
| 1267 tester.AddCookie(); |
| 1268 ASSERT_TRUE(tester.ContainsCookie()); |
| 1269 OriginFilterBuilder filter(OriginFilterBuilder::BLACKLIST); |
| 1270 filter.AddOrigin(url::Origin(kOrigin1)); |
| 1271 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 1272 BrowsingDataRemover::REMOVE_COOKIES, filter); |
| 1273 |
| 1274 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1275 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1276 EXPECT_TRUE(tester.ContainsCookie()); |
| 1277 |
| 1278 OriginFilterBuilder filter2(OriginFilterBuilder::WHITELIST); |
| 1279 filter2.AddOrigin(url::Origin(kOrigin1)); |
| 1280 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 1281 BrowsingDataRemover::REMOVE_COOKIES, filter2); |
| 1282 EXPECT_FALSE(tester.ContainsCookie()); |
| 1283 } |
| 1284 |
| 1166 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDForever) { | 1285 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDForever) { |
| 1167 RemoveChannelIDTester tester(GetProfile()); | 1286 RemoveChannelIDTester tester(GetProfile()); |
| 1168 | 1287 |
| 1169 tester.AddChannelID(kTestOrigin1); | 1288 tester.AddChannelID(kTestOrigin1); |
| 1170 EXPECT_EQ(0, tester.ssl_config_changed_count()); | 1289 EXPECT_EQ(0, tester.ssl_config_changed_count()); |
| 1171 EXPECT_EQ(1, tester.ChannelIDCount()); | 1290 EXPECT_EQ(1, tester.ChannelIDCount()); |
| 1172 | 1291 |
| 1173 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 1292 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 1174 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); | 1293 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); |
| 1175 | 1294 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 | 1334 |
| 1216 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1335 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
| 1217 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1336 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1218 | 1337 |
| 1219 // Verify that storage partition was instructed to remove the data correctly. | 1338 // Verify that storage partition was instructed to remove the data correctly. |
| 1220 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1339 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1221 EXPECT_EQ(removal_data.remove_mask, | 1340 EXPECT_EQ(removal_data.remove_mask, |
| 1222 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1341 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
| 1223 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1342 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1224 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1343 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1225 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1226 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1344 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1227 | 1345 |
| 1228 // Check origin matcher. | 1346 // Check origin matcher. |
| 1229 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1347 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
| 1230 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1348 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1231 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1349 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1232 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1350 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1233 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1351 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
| 1234 } | 1352 } |
| 1235 | 1353 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1247 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1365 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
| 1248 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | | 1366 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | |
| 1249 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); | 1367 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); |
| 1250 | 1368 |
| 1251 // Verify that storage partition was instructed to remove the data correctly. | 1369 // Verify that storage partition was instructed to remove the data correctly. |
| 1252 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1370 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1253 EXPECT_EQ(removal_data.remove_mask, | 1371 EXPECT_EQ(removal_data.remove_mask, |
| 1254 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1372 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
| 1255 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1373 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1256 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1374 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1257 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1258 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1375 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1259 | 1376 |
| 1260 // Check origin matcher all http origin will match since we specified | 1377 // Check origin matcher all http origin will match since we specified |
| 1261 // both protected and unprotected. | 1378 // both protected and unprotected. |
| 1262 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1379 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1263 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1380 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1264 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1381 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1265 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1382 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
| 1266 } | 1383 } |
| 1267 | 1384 |
| 1268 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { | 1385 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { |
| 1269 #if defined(ENABLE_EXTENSIONS) | 1386 #if defined(ENABLE_EXTENSIONS) |
| 1270 CreateMockPolicy(); | 1387 CreateMockPolicy(); |
| 1271 #endif | 1388 #endif |
| 1272 | 1389 |
| 1273 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, | 1390 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, |
| 1274 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, | 1391 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, |
| 1275 false); | 1392 false); |
| 1276 | 1393 |
| 1277 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1394 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
| 1278 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1395 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1279 | 1396 |
| 1280 // Verify that storage partition was instructed to remove the data correctly. | 1397 // Verify that storage partition was instructed to remove the data correctly. |
| 1281 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1398 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1282 EXPECT_EQ(removal_data.remove_mask, | 1399 EXPECT_EQ(removal_data.remove_mask, |
| 1283 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1400 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
| 1284 // Persistent storage won't be deleted. | 1401 // Persistent storage won't be deleted. |
| 1285 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1402 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1286 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1403 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
| 1287 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1288 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1404 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1289 | 1405 |
| 1290 // Check origin matcher. | 1406 // Check origin matcher. |
| 1291 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1407 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1292 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1408 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1293 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1409 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1294 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1410 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
| 1295 } | 1411 } |
| 1296 | 1412 |
| 1297 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { | 1413 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1599 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1484 EXPECT_EQ(removal_data.remove_mask, | 1600 EXPECT_EQ(removal_data.remove_mask, |
| 1485 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1601 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1486 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1602 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1487 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1603 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1488 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1604 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1489 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1605 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1490 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1606 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1491 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1607 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1492 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1608 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1493 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1494 } | 1609 } |
| 1495 | 1610 |
| 1496 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { | 1611 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { |
| 1497 #if defined(ENABLE_EXTENSIONS) | 1612 #if defined(ENABLE_EXTENSIONS) |
| 1498 CreateMockPolicy(); | 1613 CreateMockPolicy(); |
| 1499 #endif | 1614 #endif |
| 1500 | 1615 |
| 1501 BlockUntilBrowsingDataRemoved( | 1616 BlockUntilBrowsingDataRemoved( |
| 1502 BrowsingDataRemover::EVERYTHING, | 1617 BrowsingDataRemover::EVERYTHING, |
| 1503 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1618 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1522 | 1637 |
| 1523 EXPECT_EQ(removal_data.remove_mask, | 1638 EXPECT_EQ(removal_data.remove_mask, |
| 1524 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1639 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1525 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1640 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1526 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1641 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1527 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1642 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1528 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1643 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1529 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1644 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1530 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1645 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1531 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1646 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1532 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1533 | 1647 |
| 1534 // Check that all related origin data would be removed, that is, origin | 1648 // Check that all related origin data would be removed, that is, origin |
| 1535 // matcher would match these origin. | 1649 // matcher would match these origin. |
| 1536 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1650 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1537 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1651 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1538 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1652 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1539 } | 1653 } |
| 1540 | 1654 |
| 1541 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { | 1655 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { |
| 1542 #if defined(ENABLE_EXTENSIONS) | 1656 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1567 | 1681 |
| 1568 EXPECT_EQ(removal_data.remove_mask, | 1682 EXPECT_EQ(removal_data.remove_mask, |
| 1569 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1683 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1570 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1684 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1571 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1685 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1572 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1686 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1573 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1687 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1574 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1688 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1575 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1689 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1576 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1690 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1577 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1578 | 1691 |
| 1579 // Check that all related origin data would be removed, that is, origin | 1692 // Check that all related origin data would be removed, that is, origin |
| 1580 // matcher would match these origin. | 1693 // matcher would match these origin. |
| 1581 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1694 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1582 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1695 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1583 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1696 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1584 } | 1697 } |
| 1585 | 1698 |
| 1586 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { | 1699 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { |
| 1587 #if defined(ENABLE_EXTENSIONS) | 1700 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1612 | 1725 |
| 1613 EXPECT_EQ(removal_data.remove_mask, | 1726 EXPECT_EQ(removal_data.remove_mask, |
| 1614 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1727 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1615 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1728 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1616 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1729 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1617 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1730 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1618 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1731 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1619 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1732 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1620 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1733 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1621 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1734 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1622 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1623 | 1735 |
| 1624 // Check that all related origin data would be removed, that is, origin | 1736 // Check that all related origin data would be removed, that is, origin |
| 1625 // matcher would match these origin. | 1737 // matcher would match these origin. |
| 1626 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1738 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1627 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1739 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1628 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1740 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1629 } | 1741 } |
| 1630 | 1742 |
| 1631 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverSpecificOrigin) { | 1743 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverSpecificOrigin) { |
| 1632 // Remove Origin 1. | 1744 // Remove Origin 1. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1653 | 1765 |
| 1654 EXPECT_EQ(removal_data.remove_mask, | 1766 EXPECT_EQ(removal_data.remove_mask, |
| 1655 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1767 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1656 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1768 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1657 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1769 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1658 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1770 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1659 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1771 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1660 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1772 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1661 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1773 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1662 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1774 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1663 EXPECT_EQ(removal_data.remove_origin, kOrigin1); | 1775 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1776 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1777 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1778 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); |
| 1664 } | 1779 } |
| 1665 | 1780 |
| 1666 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { | 1781 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { |
| 1667 BlockUntilBrowsingDataRemoved( | 1782 BlockUntilBrowsingDataRemoved( |
| 1668 BrowsingDataRemover::LAST_HOUR, | 1783 BrowsingDataRemover::LAST_HOUR, |
| 1669 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1784 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
| 1670 BrowsingDataRemover::REMOVE_WEBSQL | | 1785 BrowsingDataRemover::REMOVE_WEBSQL | |
| 1671 BrowsingDataRemover::REMOVE_APPCACHE | | 1786 BrowsingDataRemover::REMOVE_APPCACHE | |
| 1672 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1787 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
| 1673 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1788 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1692 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1807 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1693 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1808 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1694 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1809 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1695 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1810 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1696 | 1811 |
| 1697 // Persistent data would be left out since we are not removing from | 1812 // Persistent data would be left out since we are not removing from |
| 1698 // beginning of time. | 1813 // beginning of time. |
| 1699 uint32_t expected_quota_mask = | 1814 uint32_t expected_quota_mask = |
| 1700 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 1815 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
| 1701 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); | 1816 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. | 1817 // Check removal begin time. |
| 1704 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1818 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1705 } | 1819 } |
| 1706 | 1820 |
| 1707 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { | 1821 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { |
| 1708 BlockUntilBrowsingDataRemoved( | 1822 BlockUntilBrowsingDataRemoved( |
| 1709 BrowsingDataRemover::LAST_WEEK, | 1823 BrowsingDataRemover::LAST_WEEK, |
| 1710 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1824 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
| 1711 BrowsingDataRemover::REMOVE_WEBSQL | | 1825 BrowsingDataRemover::REMOVE_WEBSQL | |
| 1712 BrowsingDataRemover::REMOVE_APPCACHE | | 1826 BrowsingDataRemover::REMOVE_APPCACHE | |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1733 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1847 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1734 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1848 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1735 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1849 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1736 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1850 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1737 | 1851 |
| 1738 // Persistent data would be left out since we are not removing from | 1852 // Persistent data would be left out since we are not removing from |
| 1739 // beginning of time. | 1853 // beginning of time. |
| 1740 uint32_t expected_quota_mask = | 1854 uint32_t expected_quota_mask = |
| 1741 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 1855 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
| 1742 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); | 1856 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. | 1857 // Check removal begin time. |
| 1745 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1858 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1746 } | 1859 } |
| 1747 | 1860 |
| 1748 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { | 1861 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { |
| 1749 #if defined(ENABLE_EXTENSIONS) | 1862 #if defined(ENABLE_EXTENSIONS) |
| 1750 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1863 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
| 1751 // Protect kOrigin1. | 1864 // Protect kOrigin1. |
| 1752 policy->AddProtected(kOrigin1.GetOrigin()); | 1865 policy->AddProtected(kOrigin1.GetOrigin()); |
| 1753 #endif | 1866 #endif |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1776 | 1889 |
| 1777 EXPECT_EQ(removal_data.remove_mask, | 1890 EXPECT_EQ(removal_data.remove_mask, |
| 1778 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1891 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1779 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1892 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1780 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1893 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1781 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1894 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1782 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1895 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1783 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1896 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1784 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1897 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1785 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1898 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1786 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1787 | 1899 |
| 1788 // Check OriginMatcherFunction. | 1900 // Check OriginMatcherFunction. |
| 1789 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1901 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
| 1790 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1902 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1791 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1903 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1792 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1904 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1793 } | 1905 } |
| 1794 | 1906 |
| 1795 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedSpecificOrigin) { | 1907 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedSpecificOrigin) { |
| 1796 #if defined(ENABLE_EXTENSIONS) | 1908 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1823 | 1935 |
| 1824 EXPECT_EQ(removal_data.remove_mask, | 1936 EXPECT_EQ(removal_data.remove_mask, |
| 1825 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1937 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1826 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1938 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1827 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1939 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1828 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1940 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1829 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1941 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1830 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1942 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1831 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1943 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1832 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1944 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1833 EXPECT_EQ(removal_data.remove_origin, kOrigin1); | |
| 1834 | 1945 |
| 1835 // Check OriginMatcherFunction. | 1946 // Check OriginMatcherFunction. |
| 1836 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1947 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
| 1837 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1948 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1838 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1949 // Since we use the matcher function to validate origins now, this should |
| 1839 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1950 // return false for the origins we're not trying to clear. |
| 1951 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1952 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1840 } | 1953 } |
| 1841 | 1954 |
| 1842 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { | 1955 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { |
| 1843 #if defined(ENABLE_EXTENSIONS) | 1956 #if defined(ENABLE_EXTENSIONS) |
| 1844 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1957 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
| 1845 // Protect kOrigin1. | 1958 // Protect kOrigin1. |
| 1846 policy->AddProtected(kOrigin1.GetOrigin()); | 1959 policy->AddProtected(kOrigin1.GetOrigin()); |
| 1847 #endif | 1960 #endif |
| 1848 | 1961 |
| 1849 // Try to remove kOrigin1. Expect success. | 1962 // Try to remove kOrigin1. Expect success. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1872 | 1985 |
| 1873 EXPECT_EQ(removal_data.remove_mask, | 1986 EXPECT_EQ(removal_data.remove_mask, |
| 1874 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1987 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1875 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1988 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1876 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1989 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1877 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1990 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1878 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1991 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1879 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1992 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1880 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1993 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1881 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1994 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1882 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1883 | 1995 |
| 1884 // Check OriginMatcherFunction, |kOrigin1| would match mask since we | 1996 // Check OriginMatcherFunction, |kOrigin1| would match mask since we |
| 1885 // would have 'protected' specified in origin_type_mask. | 1997 // would have 'protected' specified in origin_type_mask. |
| 1886 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1998 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1887 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1999 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1888 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 2000 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1889 } | 2001 } |
| 1890 | 2002 |
| 1891 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { | 2003 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { |
| 1892 #if defined(ENABLE_EXTENSIONS) | 2004 #if defined(ENABLE_EXTENSIONS) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1917 | 2029 |
| 1918 EXPECT_EQ(removal_data.remove_mask, | 2030 EXPECT_EQ(removal_data.remove_mask, |
| 1919 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 2031 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
| 1920 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 2032 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
| 1921 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 2033 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
| 1922 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 2034 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
| 1923 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 2035 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
| 1924 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 2036 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
| 1925 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 2037 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1926 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 2038 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
| 1927 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
| 1928 | 2039 |
| 1929 // Check that extension and devtools data wouldn't be removed, that is, | 2040 // Check that extension and devtools data wouldn't be removed, that is, |
| 1930 // origin matcher would not match these origin. | 2041 // origin matcher would not match these origin. |
| 1931 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 2042 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
| 1932 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginDevTools, mock_policy())); | 2043 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginDevTools, mock_policy())); |
| 1933 } | 2044 } |
| 1934 | 2045 |
| 1935 TEST_F(BrowsingDataRemoverTest, OriginBasedHistoryRemoval) { | 2046 TEST_F(BrowsingDataRemoverTest, TimeBasedHistoryRemoval) { |
| 1936 RemoveHistoryTester tester; | 2047 RemoveHistoryTester tester; |
| 1937 ASSERT_TRUE(tester.Init(GetProfile())); | 2048 ASSERT_TRUE(tester.Init(GetProfile())); |
| 1938 | 2049 |
| 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); | 2050 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
| 1962 | 2051 |
| 1963 tester.AddHistory(kOrigin1, base::Time::Now()); | 2052 tester.AddHistory(kOrigin1, base::Time::Now()); |
| 1964 tester.AddHistory(kOrigin2, two_hours_ago); | 2053 tester.AddHistory(kOrigin2, two_hours_ago); |
| 1965 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 2054 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
| 1966 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 2055 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
| 1967 | 2056 |
| 1968 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, | 2057 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 1969 BrowsingDataRemover::REMOVE_HISTORY, kOrigin2); | 2058 BrowsingDataRemover::REMOVE_HISTORY, GURL()); |
| 1970 | 2059 |
| 1971 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 2060 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
| 1972 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2061 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1973 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 2062 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); |
| 1974 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 2063 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
| 1975 } | 2064 } |
| 1976 | 2065 |
| 1977 // Verify that clearing autofill form data works. | 2066 // Verify that clearing autofill form data works. |
| 1978 TEST_F(BrowsingDataRemoverTest, AutofillRemovalLastHour) { | 2067 TEST_F(BrowsingDataRemoverTest, AutofillRemovalLastHour) { |
| 1979 GetProfile()->CreateWebDataService(); | 2068 GetProfile()->CreateWebDataService(); |
| 1980 RemoveAutofillTester tester(GetProfile()); | 2069 RemoveAutofillTester tester(GetProfile()); |
| 1981 | 2070 |
| 1982 ASSERT_FALSE(tester.HasProfile()); | 2071 ASSERT_FALSE(tester.HasProfile()); |
| 1983 tester.AddProfilesAndCards(); | 2072 tester.AddProfilesAndCards(); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2276 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) | 2365 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) |
| 2277 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2366 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
| 2278 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) | 2367 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) |
| 2279 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2368 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
| 2280 | 2369 |
| 2281 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 2370 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 2282 BrowsingDataRemover::REMOVE_COOKIES | | 2371 BrowsingDataRemover::REMOVE_COOKIES | |
| 2283 BrowsingDataRemover::REMOVE_PASSWORDS, | 2372 BrowsingDataRemover::REMOVE_PASSWORDS, |
| 2284 false); | 2373 false); |
| 2285 } | 2374 } |
| 2375 |
| 2376 TEST_F(BrowsingDataRemoverTest, RemoveContentSettingsWithBlacklist) { |
| 2377 // Add our settings. |
| 2378 HostContentSettingsMap* host_content_settings_map = |
| 2379 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 2380 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2381 kOrigin1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2382 new base::DictionaryValue()); |
| 2383 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2384 kOrigin2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2385 new base::DictionaryValue()); |
| 2386 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2387 kOrigin3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2388 new base::DictionaryValue()); |
| 2389 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2390 kOrigin4, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2391 new base::DictionaryValue()); |
| 2392 |
| 2393 // Clear all except for origin1 and origin3. |
| 2394 OriginFilterBuilder filter(OriginFilterBuilder::BLACKLIST); |
| 2395 filter.AddOrigin(url::Origin(kOrigin1)); |
| 2396 filter.AddOrigin(url::Origin(kOrigin3)); |
| 2397 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 2398 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
| 2399 filter); |
| 2400 |
| 2401 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, GetRemovalMask()); |
| 2402 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 2403 |
| 2404 // Verify we only have two, and they're origin1 and origin3. |
| 2405 ContentSettingsForOneType host_settings; |
| 2406 host_content_settings_map->GetSettingsForOneType( |
| 2407 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2408 EXPECT_EQ(2u, host_settings.size()); |
| 2409 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin1), |
| 2410 host_settings[0].primary_pattern); |
| 2411 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin3), |
| 2412 host_settings[1].primary_pattern); |
| 2413 } |
| 2414 |
| 2415 TEST_F(BrowsingDataRemoverTest, ClearWithPredicate) { |
| 2416 HostContentSettingsMap* host_content_settings_map = |
| 2417 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 2418 ContentSettingsForOneType host_settings; |
| 2419 |
| 2420 // Patterns with wildcards. |
| 2421 ContentSettingsPattern pattern = |
| 2422 ContentSettingsPattern::FromString("[*.]example.org"); |
| 2423 ContentSettingsPattern pattern2 = |
| 2424 ContentSettingsPattern::FromString("[*.]example.net"); |
| 2425 |
| 2426 // Patterns without wildcards. |
| 2427 GURL url1("https://www.google.com/"); |
| 2428 GURL url2("https://www.google.com/maps"); |
| 2429 GURL url3("http://www.google.com/maps"); |
| 2430 GURL url3_origin_only("http://www.google.com/"); |
| 2431 |
| 2432 host_content_settings_map->SetContentSetting( |
| 2433 pattern2, ContentSettingsPattern::Wildcard(), |
| 2434 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), CONTENT_SETTING_BLOCK); |
| 2435 host_content_settings_map->SetContentSetting( |
| 2436 pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_IMAGES, |
| 2437 std::string(), CONTENT_SETTING_BLOCK); |
| 2438 host_content_settings_map->SetWebsiteSettingCustomScope( |
| 2439 pattern2, ContentSettingsPattern::Wildcard(), |
| 2440 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), |
| 2441 make_scoped_ptr(new base::DictionaryValue())); |
| 2442 |
| 2443 // First, test that we clear only IMAGES (not APP_BANNER), and pattern2. |
| 2444 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( |
| 2445 host_content_settings_map, CONTENT_SETTINGS_TYPE_IMAGES, |
| 2446 base::Bind(&MatchPrimaryPattern, pattern2)); |
| 2447 host_content_settings_map->GetSettingsForOneType( |
| 2448 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), &host_settings); |
| 2449 // |host_settings| contains default & block. |
| 2450 EXPECT_EQ(2U, host_settings.size()); |
| 2451 EXPECT_EQ(pattern, host_settings[0].primary_pattern); |
| 2452 EXPECT_EQ("*", host_settings[0].secondary_pattern.ToString()); |
| 2453 EXPECT_EQ("*", host_settings[1].primary_pattern.ToString()); |
| 2454 EXPECT_EQ("*", host_settings[1].secondary_pattern.ToString()); |
| 2455 |
| 2456 host_content_settings_map->GetSettingsForOneType( |
| 2457 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), &host_settings); |
| 2458 // |host_settings| contains block. |
| 2459 EXPECT_EQ(1U, host_settings.size()); |
| 2460 EXPECT_EQ(pattern2, host_settings[0].primary_pattern); |
| 2461 EXPECT_EQ("*", host_settings[0].secondary_pattern.ToString()); |
| 2462 |
| 2463 // Next, test that we do correct pattern matching w/ an origin policy item. |
| 2464 // We verify that we have no settings stored. |
| 2465 host_content_settings_map->GetSettingsForOneType( |
| 2466 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2467 EXPECT_EQ(0u, host_settings.size()); |
| 2468 // Add settings. |
| 2469 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2470 url1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2471 new base::DictionaryValue()); |
| 2472 // This setting should override the one above, as it's the same origin. |
| 2473 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2474 url2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2475 new base::DictionaryValue()); |
| 2476 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2477 url3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2478 new base::DictionaryValue()); |
| 2479 // Verify we only have two. |
| 2480 host_content_settings_map->GetSettingsForOneType( |
| 2481 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2482 EXPECT_EQ(2u, host_settings.size()); |
| 2483 |
| 2484 // Clear the http one, which we should be able to do w/ the origin only, as |
| 2485 // the scope of CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT is |
| 2486 // REQUESTING_ORIGIN_ONLY_SCOPE. |
| 2487 ContentSettingsPattern http_pattern = |
| 2488 ContentSettingsPattern::FromURLNoWildcard(url3_origin_only); |
| 2489 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( |
| 2490 host_content_settings_map, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 2491 base::Bind(&MatchPrimaryPattern, http_pattern)); |
| 2492 // Verify we only have one, and it's url1. |
| 2493 host_content_settings_map->GetSettingsForOneType( |
| 2494 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2495 EXPECT_EQ(1u, host_settings.size()); |
| 2496 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1), |
| 2497 host_settings[0].primary_pattern); |
| 2498 } |
| OLD | NEW |