chromium/components/autofill/core/browser/strike_databases/history_clearable_strike_database.h

// Copyright 2024 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_AUTOFILL_CORE_BROWSER_STRIKE_DATABASES_HISTORY_CLEARABLE_STRIKE_DATABASE_H_
#define COMPONENTS_AUTOFILL_CORE_BROWSER_STRIKE_DATABASES_HISTORY_CLEARABLE_STRIKE_DATABASE_H_

#include <set>
#include <string>

#include "base/time/time.h"
#include "components/autofill/core/browser/strike_databases/simple_autofill_strike_database.h"
#include "components/autofill/core/browser/strike_databases/strike_database_integrator_base.h"
#include "components/history/core/browser/history_types.h"

namespace autofill {

// This class defines an interface for strike database whose keys should be
// cleared when the user clears his personal browsing history. The key of such
// strike databases doesn't necessarily need to be the origin of the website
// (Domain URL), but the origin needs to be retrievable from the key so that
// strikes could be cleared by origin.
//
// Simply define the traits of the strike database and define the strike
// database as an alias:
//
// struct MyStrikeDatabaseTraits {
//   static constexpr std::string_view kName = "MyStrikeDatabase";
//   static constexpr std::optional<size_t> kMaxStrikeEntities = 100;
//   static constexpr std::optional<size_t>
//                                kMaxStrikeEntitiesAfterCleanup = 70;
//   static constexpr size_t kMaxStrikeLimit = 3;
//   static constexpr std::optional<base::TimeDelta> kExpiryTimeDelta =
//       base::Days(180);
//   static constexpr bool kUniqueIdRequired = true;
//
//   static std::string OriginFromId(const std::string& id) {
//     // Add logic here to retrieve the origin from the ID od the strike entry.
//   }
// };
//  using MyStrikeDatabase =
//                 HistoryClearableStrikeDatabase<MyStrikeDatabaseTraits>;
//
// If additional logic or overrides are needed, derive from this class.
template <typename Traits>
class HistoryClearableStrikeDatabase
    : public SimpleAutofillStrikeDatabase<Traits> {};

}  // namespace autofill

#endif  // COMPONENTS_AUTOFILL_CORE_BROWSER_STRIKE_DATABASES_HISTORY_CLEARABLE_STRIKE_DATABASE_H_