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 | |
Arthur Sonzogni | fe132ee | 2024-01-15 11:01:04 | [diff] [blame] | 8 | #include <optional> |
| 9 | |
Daniel Rubery | 1287e20e | 2021-02-23 20:11:13 | [diff] [blame] | 10 | #include "chrome/browser/profiles/profile.h" |
Colin Blundell | 8bee039 | 2021-06-29 08:34:32 | [diff] [blame] | 11 | #include "components/safe_browsing/core/common/proto/csd.pb.h" |
Daniel Rubery | 1287e20e | 2021-02-23 20:11:13 | [diff] [blame] | 12 | |
| 13 | namespace safe_browsing { |
| 14 | |
Colin Blundell | d662755 | 2021-09-03 07:58:03 | [diff] [blame] | 15 | // A convenience function that creates a ChromeUserPopulation proto for the |
| 16 | // given |profile|. |
Colin Blundell | 3c709685 | 2021-09-02 17:28:16 | [diff] [blame] | 17 | ChromeUserPopulation GetUserPopulationForProfile(Profile* profile); |
Daniel Rubery | 1287e20e | 2021-02-23 20:11:13 | [diff] [blame] | 18 | |
Daniel Rubery | ea66a044 | 2023-04-13 19:54:06 | [diff] [blame] | 19 | // A convenience function that creates a ChromeUserPopulation proto for the |
| 20 | // given |profile|. This is used by real-time URL lookups and download pings to |
| 21 | // sometimes add telemetry about running experiments. |
| 22 | ChromeUserPopulation GetUserPopulationForProfileWithCookieTheftExperiments( |
| 23 | Profile* profile); |
| 24 | |
Daniel Rubery | c94ccce | 2021-09-15 17:13:14 | [diff] [blame] | 25 | // These values are persisted to logs. Entries should not be renumbered and |
| 26 | // numeric values should never be reused. |
| 27 | enum class NoCachedPopulationReason { |
| 28 | kUnknown = 0, |
| 29 | kStartup = 1, |
| 30 | kChangeMbbPref = 2, |
| 31 | kChangeSbPref = 3, |
| 32 | kMaxValue = kChangeSbPref, |
| 33 | }; |
| 34 | |
Daniel Rubery | 0c248d6 | 2021-09-14 20:37:26 | [diff] [blame] | 35 | // A cache of the ChromeUserPopulation is used to validate that we are |
| 36 | // consistently populating the same values into Safe Browsing pings. This should |
| 37 | // be cleared whenever we expect the correct value of the ChromeUserPopulation |
| 38 | // to be cleared. See crbug/1208532. |
Daniel Rubery | c94ccce | 2021-09-15 17:13:14 | [diff] [blame] | 39 | void ClearCachedUserPopulation(Profile* profile, |
| 40 | NoCachedPopulationReason reason); |
Daniel Rubery | 0c248d6 | 2021-09-14 20:37:26 | [diff] [blame] | 41 | |
Sarah Krakowiak | 5fb1495 | 2023-02-10 13:36:39 | [diff] [blame] | 42 | // Function that gets a PageLoadToken for a given URL |
| 43 | ChromeUserPopulation::PageLoadToken GetPageLoadTokenForURL(Profile* profile, |
| 44 | GURL url); |
| 45 | |
Daniel Rubery | 1287e20e | 2021-02-23 20:11:13 | [diff] [blame] | 46 | } // namespace safe_browsing |
| 47 | |
Colin Blundell | 014ab17b | 2021-09-03 09:55:40 | [diff] [blame] | 48 | #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_USER_POPULATION_HELPER_H_ |