blob: 3b0ec9413419c6f833f23fefaf40b69b147aaf32 [file] [log] [blame]
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/macros.h"
#include "base/sequence_checker.h"
#include "components/previews/core/bloom_filter.h"
#include "url/gurl.h"
namespace previews {
// HostFilter is a simple Host filter for keeping track of a set of strings
// that are represented by a Bloom filter.
// TODO(dougarnett): consider moving this and BloomFilter under
// components/blacklist/.
class HostFilter {
explicit HostFilter(std::unique_ptr<BloomFilter> bloom_filter);
virtual ~HostFilter();
// Returns whether this filter contains a host suffix for the host part
// of |url|. It will check at most 5 host suffixes and it may ignore simple
// top level domain matches (such as "com" or "").
// A host suffix is comprised of domain name level elements (vs. characters).
// For example, "" has the following suffixes that
// would be checked for membership:
// ""
// ""
// ""
// This method will return true if any of those suffixes are present.
// Virtual for testing.
virtual bool ContainsHostSuffix(const GURL& url) const;
std::unique_ptr<BloomFilter> bloom_filter_;
} // namespace previews