chromium/components/offline_pages/core/page_criteria.h

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_OFFLINE_PAGES_CORE_PAGE_CRITERIA_H_
#define COMPONENTS_OFFLINE_PAGES_CORE_PAGE_CRITERIA_H_

#include <cstdint>
#include <optional>
#include <string>
#include <vector>

#include "base/functional/callback.h"
#include "components/offline_pages/core/client_id.h"
#include "components/offline_pages/core/offline_page_client_policy.h"
#include "url/gurl.h"

namespace offline_pages {
struct OfflinePageItem;

// Criteria for matching an offline page. The default |PageCriteria| matches
// all pages.
struct PageCriteria {};

// Returns true if an offline page with |client_id| could potentially match
// |criteria|.
bool MeetsCriteria(const PageCriteria& criteria, const ClientId& client_id);

// Returns whether |item| matches |criteria|.
bool MeetsCriteria(const PageCriteria& criteria, const OfflinePageItem& item);

// Returns the list of offline page namespaces that could potentially match
// Criteria. Returns an empty list if any namespace could match.
std::vector<std::string> PotentiallyMatchingNamespaces(
    const PageCriteria& criteria);

}  // namespace offline_pages

#endif  // COMPONENTS_OFFLINE_PAGES_CORE_PAGE_CRITERIA_H_