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> |
(...skipping 2461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2472 ContentSettingsPattern::FromString("[*.]example.net"); | 2472 ContentSettingsPattern::FromString("[*.]example.net"); |
2473 | 2473 |
2474 // Patterns without wildcards. | 2474 // Patterns without wildcards. |
2475 GURL url1("https://www.google.com/"); | 2475 GURL url1("https://www.google.com/"); |
2476 GURL url2("https://www.google.com/maps"); | 2476 GURL url2("https://www.google.com/maps"); |
2477 GURL url3("http://www.google.com/maps"); | 2477 GURL url3("http://www.google.com/maps"); |
2478 GURL url3_origin_only("http://www.google.com/"); | 2478 GURL url3_origin_only("http://www.google.com/"); |
2479 | 2479 |
2480 host_content_settings_map->SetContentSettingCustomScope( | 2480 host_content_settings_map->SetContentSettingCustomScope( |
2481 pattern2, ContentSettingsPattern::Wildcard(), | 2481 pattern2, ContentSettingsPattern::Wildcard(), |
2482 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), CONTENT_SETTING_BLOCK); | 2482 CONTENT_SETTINGS_TYPE_COOKIES, std::string(), CONTENT_SETTING_BLOCK); |
2483 host_content_settings_map->SetContentSettingCustomScope( | 2483 host_content_settings_map->SetContentSettingCustomScope( |
2484 pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_IMAGES, | 2484 pattern, ContentSettingsPattern::Wildcard(), |
2485 std::string(), CONTENT_SETTING_BLOCK); | 2485 CONTENT_SETTINGS_TYPE_COOKIES, std::string(), CONTENT_SETTING_BLOCK); |
2486 host_content_settings_map->SetWebsiteSettingCustomScope( | 2486 host_content_settings_map->SetWebsiteSettingCustomScope( |
2487 pattern2, ContentSettingsPattern::Wildcard(), | 2487 pattern2, ContentSettingsPattern::Wildcard(), |
2488 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), | 2488 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), |
2489 base::WrapUnique(new base::DictionaryValue())); | 2489 base::WrapUnique(new base::DictionaryValue())); |
2490 | 2490 |
2491 // First, test that we clear only IMAGES (not APP_BANNER), and pattern2. | 2491 // First, test that we clear only COOKIES (not APP_BANNER), and pattern2. |
2492 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( | 2492 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( |
2493 host_content_settings_map, CONTENT_SETTINGS_TYPE_IMAGES, | 2493 host_content_settings_map, CONTENT_SETTINGS_TYPE_COOKIES, |
2494 base::Bind(&MatchPrimaryPattern, pattern2)); | 2494 base::Bind(&MatchPrimaryPattern, pattern2)); |
2495 host_content_settings_map->GetSettingsForOneType( | 2495 host_content_settings_map->GetSettingsForOneType( |
2496 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), &host_settings); | 2496 CONTENT_SETTINGS_TYPE_COOKIES, std::string(), &host_settings); |
2497 // |host_settings| contains default & block. | 2497 // |host_settings| contains default & block. |
2498 EXPECT_EQ(2U, host_settings.size()); | 2498 EXPECT_EQ(2U, host_settings.size()); |
2499 EXPECT_EQ(pattern, host_settings[0].primary_pattern); | 2499 EXPECT_EQ(pattern, host_settings[0].primary_pattern); |
2500 EXPECT_EQ("*", host_settings[0].secondary_pattern.ToString()); | 2500 EXPECT_EQ("*", host_settings[0].secondary_pattern.ToString()); |
2501 EXPECT_EQ("*", host_settings[1].primary_pattern.ToString()); | 2501 EXPECT_EQ("*", host_settings[1].primary_pattern.ToString()); |
2502 EXPECT_EQ("*", host_settings[1].secondary_pattern.ToString()); | 2502 EXPECT_EQ("*", host_settings[1].secondary_pattern.ToString()); |
2503 | 2503 |
2504 host_content_settings_map->GetSettingsForOneType( | 2504 host_content_settings_map->GetSettingsForOneType( |
2505 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), &host_settings); | 2505 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), &host_settings); |
2506 // |host_settings| contains block. | 2506 // |host_settings| contains block. |
(...skipping 30 matching lines...) Expand all Loading... |
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 |