blob: 6f950f06372e9c9a9d5ee04462b0c00f440dd4b6 [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 Ruberyea66a0442023-04-13 19:54:0618// A convenience function that creates a ChromeUserPopulation proto for the
19// given |profile|. This is used by real-time URL lookups and download pings to
20// sometimes add telemetry about running experiments.
21ChromeUserPopulation GetUserPopulationForProfileWithCookieTheftExperiments(
22 Profile* profile);
23
Daniel Ruberyc94ccce2021-09-15 17:13:1424// These values are persisted to logs. Entries should not be renumbered and
25// numeric values should never be reused.
26enum class NoCachedPopulationReason {
27 kUnknown = 0,
28 kStartup = 1,
29 kChangeMbbPref = 2,
30 kChangeSbPref = 3,
31 kMaxValue = kChangeSbPref,
32};
33
Daniel Rubery0c248d62021-09-14 20:37:2634// A cache of the ChromeUserPopulation is used to validate that we are
35// consistently populating the same values into Safe Browsing pings. This should
36// be cleared whenever we expect the correct value of the ChromeUserPopulation
37// to be cleared. See crbug/1208532.
Daniel Ruberyc94ccce2021-09-15 17:13:1438void ClearCachedUserPopulation(Profile* profile,
39 NoCachedPopulationReason reason);
Daniel Rubery0c248d62021-09-14 20:37:2640
Sarah Krakowiak5fb14952023-02-10 13:36:3941// Function that gets a PageLoadToken for a given URL
42ChromeUserPopulation::PageLoadToken GetPageLoadTokenForURL(Profile* profile,
43 GURL url);
44
Daniel Rubery1287e20e2021-02-23 20:11:1345} // namespace safe_browsing
46
Colin Blundell014ab17b2021-09-03 09:55:4047#endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_USER_POPULATION_HELPER_H_