blob: f9c2059d64eb2c24abd2b7f722dc36520bb2ae92 [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
Arthur Sonzognife132ee2024-01-15 11:01:048#include <optional>
9
Daniel Rubery1287e20e2021-02-23 20:11:1310#include "chrome/browser/profiles/profile.h"
Colin Blundell8bee0392021-06-29 08:34:3211#include "components/safe_browsing/core/common/proto/csd.pb.h"
Daniel Rubery1287e20e2021-02-23 20:11:1312
13namespace safe_browsing {
14
Colin Blundelld6627552021-09-03 07:58:0315// A convenience function that creates a ChromeUserPopulation proto for the
16// given |profile|.
Colin Blundell3c7096852021-09-02 17:28:1617ChromeUserPopulation GetUserPopulationForProfile(Profile* profile);
Daniel Rubery1287e20e2021-02-23 20:11:1318
Daniel Ruberyea66a0442023-04-13 19:54:0619// 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.
22ChromeUserPopulation GetUserPopulationForProfileWithCookieTheftExperiments(
23 Profile* profile);
24
Daniel Ruberyc94ccce2021-09-15 17:13:1425// These values are persisted to logs. Entries should not be renumbered and
26// numeric values should never be reused.
27enum class NoCachedPopulationReason {
28 kUnknown = 0,
29 kStartup = 1,
30 kChangeMbbPref = 2,
31 kChangeSbPref = 3,
32 kMaxValue = kChangeSbPref,
33};
34
Daniel Rubery0c248d62021-09-14 20:37:2635// 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 Ruberyc94ccce2021-09-15 17:13:1439void ClearCachedUserPopulation(Profile* profile,
40 NoCachedPopulationReason reason);
Daniel Rubery0c248d62021-09-14 20:37:2641
Sarah Krakowiak5fb14952023-02-10 13:36:3942// Function that gets a PageLoadToken for a given URL
43ChromeUserPopulation::PageLoadToken GetPageLoadTokenForURL(Profile* profile,
44 GURL url);
45
Daniel Rubery1287e20e2021-02-23 20:11:1346} // namespace safe_browsing
47
Colin Blundell014ab17b2021-09-03 09:55:4048#endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_USER_POPULATION_HELPER_H_