blob: 5ea7aef08624f59928207d7e56786e20c1499e54 [file] [log] [blame]
Patricia Alfonso3b296e9f2023-09-14 15:18:141// Copyright 2023 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_TPCD_EXPERIMENT_EXPERIMENT_MANAGER_H_
6#define CHROME_BROWSER_TPCD_EXPERIMENT_EXPERIMENT_MANAGER_H_
7
Nan Lin03748b42023-09-22 19:21:038#include "base/no_destructor.h"
9
Patricia Alfonso3b296e9f2023-09-14 15:18:1410namespace tpcd::experiment {
11
12class ExperimentManager {
13 public:
Nan Lin03748b42023-09-22 19:21:0314 static ExperimentManager* GetInstance();
Patricia Alfonso3b296e9f2023-09-14 15:18:1415
16 // Called by EligibilityService to tell the manager whether a profile is
17 // eligible. Mode B also needs to know whether the profile has been onboarded
18 // to the 3PCD UX, but Mode A does not.
19 void SetClientEligibility(bool is_eligible, bool is_onboarded = false);
20
Nan Lin03748b42023-09-22 19:21:0321 protected:
22 ExperimentManager();
23 ~ExperimentManager() = default;
24
Patricia Alfonso3b296e9f2023-09-14 15:18:1425 private:
Nan Lin03748b42023-09-22 19:21:0326 friend base::NoDestructor<ExperimentManager>;
27
Patricia Alfonso3b296e9f2023-09-14 15:18:1428 // Mode B experiment will need to register the client for the synthetic trial
29 // IFF the client is eligible and onboarded (TCPDExperimentState ==
30 // kOnboardedEligible). Register the client for the correct arm of the
31 // synthetic trial based on Finch feature params.
32 void RegisterSyntheticTrial();
33
34 // If a previously registered client becomes ineligible, unregister it from
35 // the synthetic trial by registering it to a "invalidated" experiment arm.
36 void UnregisterSyntheticTrial();
37
38 // Check the client is eligible for 3PCD Experiments. Returns false when: the
39 // client is <30 days old or Android users with a PWA installed.
40 bool isClientEligible();
41};
42
43} // namespace tpcd::experiment
44
45#endif // CHROME_BROWSER_TPCD_EXPERIMENT_EXPERIMENT_MANAGER_H_