Chromium Code Reviews| Index: chrome/browser/browsing_data/registrable_domain_filter_builder.cc |
| diff --git a/chrome/browser/browsing_data/registrable_domain_filter_builder.cc b/chrome/browser/browsing_data/registrable_domain_filter_builder.cc |
| index 139b046f7983f020dc8bceddcb5d071c3f61baf0..2fe4b83f356503b10cff17e06b7e5fd1bdfc3c91 100644 |
| --- a/chrome/browser/browsing_data/registrable_domain_filter_builder.cc |
| +++ b/chrome/browser/browsing_data/registrable_domain_filter_builder.cc |
| @@ -107,6 +107,16 @@ RegistrableDomainFilterBuilder::BuildChannelIDFilter() const { |
| base::Owned(domains_and_ips), mode()); |
| } |
| +base::Callback<bool(const std::string& site)> |
| +RegistrableDomainFilterBuilder::BuildPluginFilter() const { |
|
Bernhard Bauer
2016/08/18 18:36:00
Actually, you could move this to an anonymous name
msramek
2016/08/19 11:16:47
Yes, but then I should also move all the others. G
Bernhard Bauer
2016/08/19 16:29:39
OK, thanks!
|
| + std::set<std::string>* domains_and_ips = |
|
Bernhard Bauer
2016/08/18 18:36:00
Use a unique_ptr? Or maybe even just a plain std::
msramek
2016/08/19 11:16:47
Yes, that's a good idea. It actually makes the cod
|
| + new std::set<std::string>(domain_list_); |
| + return base::Bind( |
| + &RegistrableDomainFilterBuilder |
| + ::MatchesPluginSiteForRegisterableDomainsAndIPs, |
| + base::Owned(domains_and_ips), mode()); |
| +} |
| + |
| bool RegistrableDomainFilterBuilder::operator==( |
| const RegistrableDomainFilterBuilder& other) const { |
| return domain_list_ == other.domain_list_ && mode() == other.mode(); |
| @@ -172,3 +182,19 @@ RegistrableDomainFilterBuilder::MatchesChannelIDForRegisterableDomainsAndIPs( |
| return ((mode == WHITELIST) == (domains_and_ips->find(channel_id_server_id) != |
| domains_and_ips->end())); |
| } |
| + |
| +// static |
| +bool |
| +RegistrableDomainFilterBuilder::MatchesPluginSiteForRegisterableDomainsAndIPs( |
| + std::set<std::string>* domains_and_ips, |
| + Mode mode, |
| + const std::string& site) { |
| + // If |site| is a third- or lower-level domain, find the corresponding eTLD+1. |
| + std::string domain_or_ip = |
| + GetDomainAndRegistry(site, INCLUDE_PRIVATE_REGISTRIES); |
| + if (domain_or_ip.empty()) |
| + domain_or_ip = site; |
| + |
| + return ((mode == WHITELIST) == (domains_and_ips->find(domain_or_ip) != |
| + domains_and_ips->end())); |
| +} |