tree: 930da56f713b669a7b9aaedf09db8513d5ac067e [path history] [tgz]
  1. BUILD.gn
  2. DEPS
  3. DIR_METADATA
  4. history_clearable_strike_database.h
  5. history_clearable_strike_database_unittest.cc
  6. OWNERS
  7. README.md
  8. simple_autofill_strike_database.h
  9. simple_autofill_strike_database_unittest.cc
  10. strike_data.proto
  11. strike_database.cc
  12. strike_database.h
  13. strike_database_base.cc
  14. strike_database_base.h
  15. strike_database_features.cc
  16. strike_database_features.h
  17. strike_database_integrator_base.cc
  18. strike_database_integrator_base.h
  19. strike_database_integrator_test_strike_database.cc
  20. strike_database_integrator_test_strike_database.h
  21. strike_database_integrator_test_strike_database_unittest.cc
  22. strike_database_unittest.cc
  23. test_inmemory_strike_database.cc
  24. test_inmemory_strike_database.h
components/strike_database/README.md

Strike database

Strike databases are a way of counting “strikes” in a per-profile manner that is persisted across restarts and, due to caching, available synchronously. Strike information is not synced across devices and, depending on the chosen implementation, provides support for easily clearing it on browsing data removal.

An example use case for strikes is the address autofill: To ensure that a user does not see too many “Save address” prompts, autofill uses a strike database that keeps track of how often a user has declined to save a profile - it can do so either by tracking counting consecutive declines on a given domain or by counting how often a user has declined to save a specific address.

To use a strike database, you need to do the following:

  • Define Traits that specify how your strike database is supposed to behave, e.g., the expiry time of strikes or the maximum number of strikes before a features is blocked.
  • Create either an instance of SimpleAutofillStrikeDatabase<YourTraits> or HistoryClearableStrikeDatabase<YourTraits> and pass a pointer to the StrikeDatabaseBase. This is a KeyedService that you obtain in your embedder (e.g., Chrome).
  • Use your strike database!

Note that SimpleAutofillStrikeDatabase<YourTraits> and HistoryClearableStrikeDatabase<YourTraits> contain no state beyond a pointer to the StrikeDatabaseBase. Therefore instantiating lots of strike databases across multiple tabs is cheap and they all share the same underlying database.