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 <memory> | 10 #include <memory> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
18 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
19 #include "base/guid.h" | 19 #include "base/guid.h" |
20 #include "base/location.h" | 20 #include "base/location.h" |
21 #include "base/macros.h" | 21 #include "base/macros.h" |
22 #include "base/memory/ptr_util.h" | 22 #include "base/memory/ptr_util.h" |
23 #include "base/message_loop/message_loop.h" | 23 #include "base/message_loop/message_loop.h" |
24 #include "base/run_loop.h" | 24 #include "base/run_loop.h" |
25 #include "base/single_thread_task_runner.h" | 25 #include "base/single_thread_task_runner.h" |
26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
27 #include "base/task/cancelable_task_tracker.h" | 27 #include "base/task/cancelable_task_tracker.h" |
28 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
29 #include "build/build_config.h" | 29 #include "build/build_config.h" |
raymes
2016/06/09 05:59:21
Should probably include ptr_util.h here too
dominickn
2016/06/09 06:09:44
It's already there (line 22 :))
| |
30 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 30 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
31 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 31 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
32 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" | 32 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" |
33 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 33 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
34 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 34 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
35 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 35 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
36 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" | 36 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" |
37 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 37 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
38 #include "chrome/browser/domain_reliability/service_factory.h" | 38 #include "chrome/browser/domain_reliability/service_factory.h" |
39 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 39 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
(...skipping 2374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2414 BrowsingDataRemover::REMOVE_PASSWORDS, | 2414 BrowsingDataRemover::REMOVE_PASSWORDS, |
2415 false); | 2415 false); |
2416 } | 2416 } |
2417 | 2417 |
2418 TEST_F(BrowsingDataRemoverTest, RemoveContentSettingsWithBlacklist) { | 2418 TEST_F(BrowsingDataRemoverTest, RemoveContentSettingsWithBlacklist) { |
2419 // Add our settings. | 2419 // Add our settings. |
2420 HostContentSettingsMap* host_content_settings_map = | 2420 HostContentSettingsMap* host_content_settings_map = |
2421 HostContentSettingsMapFactory::GetForProfile(GetProfile()); | 2421 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
2422 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2422 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2423 kOrigin1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2423 kOrigin1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2424 new base::DictionaryValue()); | 2424 base::WrapUnique(new base::DictionaryValue())); |
2425 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2425 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2426 kOrigin2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2426 kOrigin2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2427 new base::DictionaryValue()); | 2427 base::WrapUnique(new base::DictionaryValue())); |
2428 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2428 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2429 kOrigin3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2429 kOrigin3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2430 new base::DictionaryValue()); | 2430 base::WrapUnique(new base::DictionaryValue())); |
2431 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2431 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2432 kOrigin4, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2432 kOrigin4, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2433 new base::DictionaryValue()); | 2433 base::WrapUnique(new base::DictionaryValue())); |
2434 | 2434 |
2435 // Clear all except for origin1 and origin3. | 2435 // Clear all except for origin1 and origin3. |
2436 RegistrableDomainFilterBuilder filter( | 2436 RegistrableDomainFilterBuilder filter( |
2437 RegistrableDomainFilterBuilder::BLACKLIST); | 2437 RegistrableDomainFilterBuilder::BLACKLIST); |
2438 filter.AddRegisterableDomain(kTestRegisterableDomain1); | 2438 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
2439 filter.AddRegisterableDomain(kTestRegisterableDomain3); | 2439 filter.AddRegisterableDomain(kTestRegisterableDomain3); |
2440 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, | 2440 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
2441 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, | 2441 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
2442 filter); | 2442 filter); |
2443 | 2443 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2509 EXPECT_EQ("*", host_settings[0].secondary_pattern.ToString()); | 2509 EXPECT_EQ("*", host_settings[0].secondary_pattern.ToString()); |
2510 | 2510 |
2511 // Next, test that we do correct pattern matching w/ an origin policy item. | 2511 // Next, test that we do correct pattern matching w/ an origin policy item. |
2512 // We verify that we have no settings stored. | 2512 // We verify that we have no settings stored. |
2513 host_content_settings_map->GetSettingsForOneType( | 2513 host_content_settings_map->GetSettingsForOneType( |
2514 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); | 2514 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
2515 EXPECT_EQ(0u, host_settings.size()); | 2515 EXPECT_EQ(0u, host_settings.size()); |
2516 // Add settings. | 2516 // Add settings. |
2517 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2517 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2518 url1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2518 url1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2519 new base::DictionaryValue()); | 2519 base::WrapUnique(new base::DictionaryValue())); |
2520 // This setting should override the one above, as it's the same origin. | 2520 // This setting should override the one above, as it's the same origin. |
2521 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2521 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2522 url2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2522 url2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2523 new base::DictionaryValue()); | 2523 base::WrapUnique(new base::DictionaryValue())); |
2524 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2524 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2525 url3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2525 url3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2526 new base::DictionaryValue()); | 2526 base::WrapUnique(new base::DictionaryValue())); |
2527 // Verify we only have two. | 2527 // Verify we only have two. |
2528 host_content_settings_map->GetSettingsForOneType( | 2528 host_content_settings_map->GetSettingsForOneType( |
2529 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); | 2529 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
2530 EXPECT_EQ(2u, host_settings.size()); | 2530 EXPECT_EQ(2u, host_settings.size()); |
2531 | 2531 |
2532 // Clear the http one, which we should be able to do w/ the origin only, as | 2532 // Clear the http one, which we should be able to do w/ the origin only, as |
2533 // the scope of CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT is | 2533 // the scope of CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT is |
2534 // REQUESTING_ORIGIN_ONLY_SCOPE. | 2534 // REQUESTING_ORIGIN_ONLY_SCOPE. |
2535 ContentSettingsPattern http_pattern = | 2535 ContentSettingsPattern http_pattern = |
2536 ContentSettingsPattern::FromURLNoWildcard(url3_origin_only); | 2536 ContentSettingsPattern::FromURLNoWildcard(url3_origin_only); |
2537 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( | 2537 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( |
2538 host_content_settings_map, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, | 2538 host_content_settings_map, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
2539 base::Bind(&MatchPrimaryPattern, http_pattern)); | 2539 base::Bind(&MatchPrimaryPattern, http_pattern)); |
2540 // Verify we only have one, and it's url1. | 2540 // Verify we only have one, and it's url1. |
2541 host_content_settings_map->GetSettingsForOneType( | 2541 host_content_settings_map->GetSettingsForOneType( |
2542 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); | 2542 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
2543 EXPECT_EQ(1u, host_settings.size()); | 2543 EXPECT_EQ(1u, host_settings.size()); |
2544 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1), | 2544 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1), |
2545 host_settings[0].primary_pattern); | 2545 host_settings[0].primary_pattern); |
2546 } | 2546 } |
OLD | NEW |