Patricia Alfonso | 3b296e9f | 2023-09-14 15:18:14 | [diff] [blame] | 1 | // 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 Lin | 03748b4 | 2023-09-22 19:21:03 | [diff] [blame^] | 8 | #include "base/no_destructor.h" |
| 9 | |
Patricia Alfonso | 3b296e9f | 2023-09-14 15:18:14 | [diff] [blame] | 10 | namespace tpcd::experiment { |
| 11 | |
| 12 | class ExperimentManager { |
| 13 | public: |
Nan Lin | 03748b4 | 2023-09-22 19:21:03 | [diff] [blame^] | 14 | static ExperimentManager* GetInstance(); |
Patricia Alfonso | 3b296e9f | 2023-09-14 15:18:14 | [diff] [blame] | 15 | |
| 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 Lin | 03748b4 | 2023-09-22 19:21:03 | [diff] [blame^] | 21 | protected: |
| 22 | ExperimentManager(); |
| 23 | ~ExperimentManager() = default; |
| 24 | |
Patricia Alfonso | 3b296e9f | 2023-09-14 15:18:14 | [diff] [blame] | 25 | private: |
Nan Lin | 03748b4 | 2023-09-22 19:21:03 | [diff] [blame^] | 26 | friend base::NoDestructor<ExperimentManager>; |
| 27 | |
Patricia Alfonso | 3b296e9f | 2023-09-14 15:18:14 | [diff] [blame] | 28 | // 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_ |