Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame^] | 1 | // Copyright 2021 The Chromium Authors |
Daniel Rubery | 1287e20e | 2021-02-23 20:11:13 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Colin Blundell | 014ab17b | 2021-09-03 09:55:40 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_SAFE_BROWSING_CHROME_USER_POPULATION_HELPER_H_ |
| 6 | #define CHROME_BROWSER_SAFE_BROWSING_CHROME_USER_POPULATION_HELPER_H_ |
Daniel Rubery | 1287e20e | 2021-02-23 20:11:13 | [diff] [blame] | 7 | |
| 8 | #include "chrome/browser/profiles/profile.h" |
Colin Blundell | 8bee039 | 2021-06-29 08:34:32 | [diff] [blame] | 9 | #include "components/safe_browsing/core/common/proto/csd.pb.h" |
Daniel Rubery | 0c248d6 | 2021-09-14 20:37:26 | [diff] [blame] | 10 | #include "third_party/abseil-cpp/absl/types/optional.h" |
Daniel Rubery | 1287e20e | 2021-02-23 20:11:13 | [diff] [blame] | 11 | |
| 12 | namespace safe_browsing { |
| 13 | |
Colin Blundell | d662755 | 2021-09-03 07:58:03 | [diff] [blame] | 14 | // A convenience function that creates a ChromeUserPopulation proto for the |
| 15 | // given |profile|. |
Colin Blundell | 3c709685 | 2021-09-02 17:28:16 | [diff] [blame] | 16 | ChromeUserPopulation GetUserPopulationForProfile(Profile* profile); |
Daniel Rubery | 1287e20e | 2021-02-23 20:11:13 | [diff] [blame] | 17 | |
Daniel Rubery | c94ccce | 2021-09-15 17:13:14 | [diff] [blame] | 18 | // These values are persisted to logs. Entries should not be renumbered and |
| 19 | // numeric values should never be reused. |
| 20 | enum class NoCachedPopulationReason { |
| 21 | kUnknown = 0, |
| 22 | kStartup = 1, |
| 23 | kChangeMbbPref = 2, |
| 24 | kChangeSbPref = 3, |
| 25 | kMaxValue = kChangeSbPref, |
| 26 | }; |
| 27 | |
Daniel Rubery | 0c248d6 | 2021-09-14 20:37:26 | [diff] [blame] | 28 | // 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 Rubery | c94ccce | 2021-09-15 17:13:14 | [diff] [blame] | 32 | void ClearCachedUserPopulation(Profile* profile, |
| 33 | NoCachedPopulationReason reason); |
Daniel Rubery | 0c248d6 | 2021-09-14 20:37:26 | [diff] [blame] | 34 | |
Daniel Rubery | 1287e20e | 2021-02-23 20:11:13 | [diff] [blame] | 35 | } // namespace safe_browsing |
| 36 | |
Colin Blundell | 014ab17b | 2021-09-03 09:55:40 | [diff] [blame] | 37 | #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_USER_POPULATION_HELPER_H_ |