blob: 0392bb39ddc87fbff1638d1c00081b22c0adabfc [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2021 The Chromium Authors
Daniel Rubery1287e20e2021-02-23 20:11:132// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Colin Blundell014ab17b2021-09-03 09:55:405#ifndef CHROME_BROWSER_SAFE_BROWSING_CHROME_USER_POPULATION_HELPER_H_
6#define CHROME_BROWSER_SAFE_BROWSING_CHROME_USER_POPULATION_HELPER_H_
Daniel Rubery1287e20e2021-02-23 20:11:137
8#include "chrome/browser/profiles/profile.h"
Colin Blundell8bee0392021-06-29 08:34:329#include "components/safe_browsing/core/common/proto/csd.pb.h"
Daniel Rubery0c248d62021-09-14 20:37:2610#include "third_party/abseil-cpp/absl/types/optional.h"
Daniel Rubery1287e20e2021-02-23 20:11:1311
12namespace safe_browsing {
13
Colin Blundelld6627552021-09-03 07:58:0314// A convenience function that creates a ChromeUserPopulation proto for the
15// given |profile|.
Colin Blundell3c7096852021-09-02 17:28:1616ChromeUserPopulation GetUserPopulationForProfile(Profile* profile);
Daniel Rubery1287e20e2021-02-23 20:11:1317
Daniel Ruberyc94ccce2021-09-15 17:13:1418// These values are persisted to logs. Entries should not be renumbered and
19// numeric values should never be reused.
20enum class NoCachedPopulationReason {
21 kUnknown = 0,
22 kStartup = 1,
23 kChangeMbbPref = 2,
24 kChangeSbPref = 3,
25 kMaxValue = kChangeSbPref,
26};
27
Daniel Rubery0c248d62021-09-14 20:37:2628// A cache of the ChromeUserPopulation is used to validate that we are
29// consistently populating the same values into Safe Browsing pings. This should
30// be cleared whenever we expect the correct value of the ChromeUserPopulation
31// to be cleared. See crbug/1208532.
Daniel Ruberyc94ccce2021-09-15 17:13:1432void ClearCachedUserPopulation(Profile* profile,
33 NoCachedPopulationReason reason);
Daniel Rubery0c248d62021-09-14 20:37:2634
Daniel Rubery1287e20e2021-02-23 20:11:1335} // namespace safe_browsing
36
Colin Blundell014ab17b2021-09-03 09:55:4037#endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_USER_POPULATION_HELPER_H_