Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover_unittest.cc

Issue 2054623002: Refactor HostContentSettingsMap::SetWebsiteSettingDefaultScope to take a std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing reviewer comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2403 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698