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