File: survey_config.h

package info (click to toggle)
chromium 120.0.6099.224-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 6,112,112 kB
  • sloc: cpp: 32,907,025; ansic: 8,148,123; javascript: 3,679,536; python: 2,031,248; asm: 959,718; java: 804,675; xml: 617,256; sh: 111,417; objc: 100,835; perl: 88,443; cs: 53,032; makefile: 29,579; fortran: 24,137; php: 21,162; tcl: 21,147; sql: 20,809; ruby: 17,735; pascal: 12,864; yacc: 8,045; lisp: 3,388; lex: 1,323; ada: 727; awk: 329; jsp: 267; csh: 117; exp: 43; sed: 37
file content (132 lines) | stat: -rw-r--r-- 6,366 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_HATS_SURVEY_CONFIG_H_
#define CHROME_BROWSER_UI_HATS_SURVEY_CONFIG_H_

#include <string>
#include <vector>

#include "base/feature_list.h"

#if !BUILDFLAG(IS_ANDROID)
// Trigger identifiers currently used; duplicates not allowed.
extern const char kHatsSurveyTriggerAutofillAddress[];
extern const char kHatsSurveyTriggerAutofillCard[];
extern const char kHatsSurveyTriggerAutofillPassword[];
extern const char kHatsSurveyTriggerDevToolsIssuesCOEP[];
extern const char kHatsSurveyTriggerDevToolsIssuesMixedContent[];
extern const char kHatsSurveyTriggerDevToolsIssuesCookiesSameSite[];
extern const char kHatsSurveyTriggerDevToolsIssuesHeavyAd[];
extern const char kHatsSurveyTriggerDevToolsIssuesCSP[];
extern const char kHatsSurveyTriggerM1AdPrivacyPage[];
extern const char kHatsSurveyTriggerM1TopicsSubpage[];
extern const char kHatsSurveyTriggerM1FledgeSubpage[];
extern const char kHatsSurveyTriggerM1AdMeasurementSubpage[];
extern const char kHatsSurveyTriggerNtpModules[];
extern const char kHatsSurveyTriggerNtpPhotosModuleOptOut[];
extern const char kHatsSurveyTriggerPerformanceControlsPerformance[];
extern const char kHatsSurveyTriggerPerformanceControlsBatteryPerformance[];
extern const char kHatsSurveyTriggerPerformanceControlsHighEfficiencyOptOut[];
extern const char kHatsSurveyTriggerPerformanceControlsBatterySaverOptOut[];
extern const char kHatsSurveyTriggerPermissionsPrompt[];
extern const char kHatsSurveyTriggerPrivacyGuide[];
extern const char kHatsSurveyTriggerPrivacySandbox[];
extern const char kHatsSurveyTriggerRedWarning[];
extern const char kHatsSurveyTriggerSettings[];
extern const char kHatsSurveyTriggerSettingsPrivacy[];
extern const char kHatsSurveyTriggerTrackingProtectionControlImmediate[];
extern const char kHatsSurveyTriggerTrackingProtectionTreatmentImmediate[];
extern const char kHatsSurveyTriggerTrackingProtectionControlDelayed[];
extern const char kHatsSurveyTriggerTrackingProtectionTreatmentDelayed[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox3ConsentAccept[];
extern const char kHatsSurveyTriggerSettingsSecurity[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox3ConsentDecline[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeDismiss[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeOk[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeSettings[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeLearnMore[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox4ConsentAccept[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox4ConsentDecline[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox4NoticeOk[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox4NoticeSettings[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySettings[];
extern const char kHatsSurveyTriggerTrustSafetyTrustedSurface[];
extern const char kHatsSurveyTriggerTrustSafetyTransactions[];
extern const char kHatsSurveyTriggerTrustSafetyV2BrowsingData[];
extern const char kHatsSurveyTriggerTrustSafetyV2ControlGroup[];
extern const char kHatsSurveyTriggerTrustSafetyV2DownloadWarningUI[];
extern const char kHatsSurveyTriggerTrustSafetyV2PasswordCheck[];
extern const char kHatsSurveyTriggerTrustSafetyV2PasswordProtectionUI[];
extern const char kHatsSurveyTriggerTrustSafetyV2SafetyCheck[];
extern const char kHatsSurveyTriggerTrustSafetyV2TrustedSurface[];
extern const char kHatsSurveyTriggerTrustSafetyV2PrivacyGuide[];
extern const char kHatsSurveyTriggerTrustSafetyV2PrivacySandbox4ConsentAccept[];
extern const char
    kHatsSurveyTriggerTrustSafetyV2PrivacySandbox4ConsentDecline[];
extern const char kHatsSurveyTriggerTrustSafetyV2PrivacySandbox4NoticeOk[];
extern const char
    kHatsSurveyTriggerTrustSafetyV2PrivacySandbox4NoticeSettings[];
extern const char kHatsSurveyTriggerTrustSafetyV2SafeBrowsingInterstitial[];
extern const char kHatsSurveyTriggerWhatsNew[];
#else
extern const char kHatsSurveyTriggerAndroidStartupSurvey[];
#endif

extern const char kHatsSurveyTriggerTesting[];
// The Trigger ID for a test HaTS Next survey which is available for testing
// and demo purposes when the migration feature flag is enabled.
extern const char kHatsNextSurveyTriggerIDTesting[];

namespace hats {
struct SurveyConfig {
  // Constructs a SurveyConfig by inspecting |feature|. This includes checking
  // if the feature is enabled, as well as inspecting the feature parameters
  // for the survey probability, and if |presupplied_trigger_id| is not
  // provided, the trigger ID. To pass any product specific data for the
  // survey, configure fields here, matches are CHECK enforced.
  SurveyConfig(
      const base::Feature* feature,
      const std::string& trigger,
      const absl::optional<std::string>& presupplied_trigger_id = absl::nullopt,
      const std::vector<std::string>& product_specific_bits_data_fields = {},
      const std::vector<std::string>& product_specific_string_data_fields = {});

  SurveyConfig();
  SurveyConfig(const SurveyConfig&);
  ~SurveyConfig();

  // Whether the survey is currently enabled and can be shown.
  bool enabled = false;

  // Probability [0,1] of how likely a chosen user will see the survey.
  double probability = 0.0f;

  // The trigger for this survey within the browser.
  std::string trigger;

  // Trigger ID for the survey.
  std::string trigger_id;

  // The survey will prompt every time because the user has explicitly decided
  // to take the survey e.g. clicking a link.
  bool user_prompted = false;

  // Product Specific Bit Data fields which are sent with the survey
  // response.
  std::vector<std::string> product_specific_bits_data_fields;

  // Product Specific String Data fields which are sent with the survey
  // response.
  std::vector<std::string> product_specific_string_data_fields;
};

using SurveyConfigs = base::flat_map<std::string, SurveyConfig>;
// Get the list of active ongoing surveys and store into
// |survey_configs_by_triggers_|.
void GetActiveSurveyConfigs(SurveyConfigs& survey_configs_by_triggers_);

}  // namespace hats

#endif  // def CHROME_BROWSER_UI_HATS_SURVEY_CONFIG_H_