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 <stddef.h> | 5 #include <stddef.h> |
6 #include <memory> | 6 #include <memory> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" |
13 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 14 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
14 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 15 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
15 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 16 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
16 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 17 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
17 #include "chrome/browser/browsing_data/cache_counter.h" | 18 #include "chrome/browser/browsing_data/cache_counter.h" |
18 #include "chrome/browser/browsing_data/origin_filter_builder.h" | |
19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
23 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
24 #include "chrome/test/base/in_process_browser_test.h" | 24 #include "chrome/test/base/in_process_browser_test.h" |
25 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
26 #include "components/browsing_data/core/browsing_data_utils.h" | 26 #include "components/browsing_data/core/browsing_data_utils.h" |
27 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
28 #include "content/public/browser/browser_context.h" | 28 #include "content/public/browser/browser_context.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 ASSERT_FALSE(url::IsSameOriginWith(url1, url2)); | 241 ASSERT_FALSE(url::IsSameOriginWith(url1, url2)); |
242 ui_test_utils::NavigateToURL(browser(), url1); | 242 ui_test_utils::NavigateToURL(browser(), url1); |
243 ui_test_utils::NavigateToURL(browser(), url2); | 243 ui_test_utils::NavigateToURL(browser(), url2); |
244 | 244 |
245 // The cache is nonempty, because we created entries by visiting websites. | 245 // The cache is nonempty, because we created entries by visiting websites. |
246 browsing_data::BrowsingDataCounter::ResultInt original_size = GetCacheSize(); | 246 browsing_data::BrowsingDataCounter::ResultInt original_size = GetCacheSize(); |
247 EXPECT_GT(original_size, 0); | 247 EXPECT_GT(original_size, 0); |
248 | 248 |
249 // Partially delete cache data. Delete data for localhost, which is the origin | 249 // Partially delete cache data. Delete data for localhost, which is the origin |
250 // of |url1|, but not for |kExampleHost|, which is the origin of |url2|. | 250 // of |url1|, but not for |kExampleHost|, which is the origin of |url2|. |
251 std::unique_ptr<OriginFilterBuilder> filter_builder( | 251 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder = |
252 new OriginFilterBuilder(OriginFilterBuilder::WHITELIST)); | 252 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::WHITELIST); |
253 filter_builder->AddOrigin(url::Origin(url1)); | 253 filter_builder->AddOrigin(url::Origin(url1)); |
254 RemoveWithFilterAndWait(BrowsingDataRemover::REMOVE_CACHE, | 254 RemoveWithFilterAndWait(BrowsingDataRemover::REMOVE_CACHE, |
255 std::move(filter_builder)); | 255 std::move(filter_builder)); |
256 | 256 |
257 // After the partial deletion, the cache should be smaller but still nonempty. | 257 // After the partial deletion, the cache should be smaller but still nonempty. |
258 browsing_data::BrowsingDataCounter::ResultInt new_size = GetCacheSize(); | 258 browsing_data::BrowsingDataCounter::ResultInt new_size = GetCacheSize(); |
259 EXPECT_LT(new_size, original_size); | 259 EXPECT_LT(new_size, original_size); |
260 | 260 |
261 // Another partial deletion with the same filter should have no effect. | 261 // Another partial deletion with the same filter should have no effect. |
262 filter_builder.reset(new OriginFilterBuilder(OriginFilterBuilder::WHITELIST)); | 262 filter_builder = |
| 263 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::WHITELIST); |
263 filter_builder->AddOrigin(url::Origin(url1)); | 264 filter_builder->AddOrigin(url::Origin(url1)); |
264 RemoveWithFilterAndWait(BrowsingDataRemover::REMOVE_CACHE, | 265 RemoveWithFilterAndWait(BrowsingDataRemover::REMOVE_CACHE, |
265 std::move(filter_builder)); | 266 std::move(filter_builder)); |
266 EXPECT_EQ(new_size, GetCacheSize()); | 267 EXPECT_EQ(new_size, GetCacheSize()); |
267 | 268 |
268 // Delete the remaining data. | 269 // Delete the remaining data. |
269 RemoveAndWait(BrowsingDataRemover::REMOVE_CACHE); | 270 RemoveAndWait(BrowsingDataRemover::REMOVE_CACHE); |
270 | 271 |
271 // The cache is empty. | 272 // The cache is empty. |
272 EXPECT_EQ(0, GetCacheSize()); | 273 EXPECT_EQ(0, GetCacheSize()); |
(...skipping 22 matching lines...) Expand all Loading... |
295 base::RunLoop run_loop; | 296 base::RunLoop run_loop; |
296 BrowserThread::PostTaskAndReply( | 297 BrowserThread::PostTaskAndReply( |
297 BrowserThread::IO, FROM_HERE, | 298 BrowserThread::IO, FROM_HERE, |
298 base::Bind(&BrowsingDataRemoverTransportSecurityStateBrowserTest:: | 299 base::Bind(&BrowsingDataRemoverTransportSecurityStateBrowserTest:: |
299 CheckTransportSecurityState, | 300 CheckTransportSecurityState, |
300 base::Unretained(this), | 301 base::Unretained(this), |
301 base::RetainedRef(browser()->profile()->GetRequestContext()), | 302 base::RetainedRef(browser()->profile()->GetRequestContext()), |
302 false /* should not be cleared */), | 303 false /* should not be cleared */), |
303 run_loop.QuitClosure()); | 304 run_loop.QuitClosure()); |
304 } | 305 } |
OLD | NEW |