File: user_education_metadata.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (86 lines) | stat: -rw-r--r-- 3,104 bytes parent folder | download | duplicates (5)
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
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_USER_EDUCATION_COMMON_USER_EDUCATION_METADATA_H_
#define COMPONENTS_USER_EDUCATION_COMMON_USER_EDUCATION_METADATA_H_

#include <initializer_list>
#include <string>

#include "base/containers/flat_set.h"
#include "base/feature_list.h"
#include "base/memory/raw_ptr.h"

namespace user_education {

// Provides metadata about a user education experience (IPH, Tutorial, "New"
// Badge, etc.).
//
// Metadata will be shown and used on the tester page
// (chrome://user-education-internals), and also provides information as to when
// the journey was added to Chrome and by whom.
struct Metadata {
  // The platform the experience can be shown on.
  //
  // These are a subset of variations::Study::Platform.
  //
  // TODO(dfried): figure out how to unify a single list of platforms for all
  // use cases; enums like this are scattered all over the codebase.
  enum class Platforms {
    kWindows = 0,
    kMac = 1,
    kLinux = 2,
    kChromeOS = 3,
  };

  // All desktop platforms.
  static constexpr std::initializer_list<Platforms> kAllDesktopPlatforms{
      Platforms::kWindows, Platforms::kMac, Platforms::kLinux,
      Platforms::kChromeOS};

  using FeatureSet =
      base::flat_set<raw_ptr<const base::Feature, CtnExperimental>>;
  using PlatformSet = base::flat_set<Platforms>;

  Metadata(int launch_milestone,
           std::string owners,
           std::string additional_description,
           FeatureSet required_features = {},
           PlatformSet platforms = kAllDesktopPlatforms);
  Metadata();
  Metadata(Metadata&&) noexcept;
  Metadata& operator=(Metadata&&) noexcept;
  ~Metadata();

  // The integer part of the launch milestone. For example, 118.
  int launch_milestone = 0;

  // The email, ldap, group name, team name, etc. of the owner(s) of the
  // experience. This is a display-only field on an internal page, so the format
  // is up to the implementing team, but it is also metadata to track each
  // experience's lifecycle so be sure to specify it.
  std::string owners;

  // Additional description of the user education experience. This could include
  // clarification of how and when the experience is shown to the user, the goal
  // of presenting the experience, etc.
  //
  // This is a display-only field on an internal page, so the format is up to
  // the implementing team, but a good description will help other people
  // understand how and why the experience was implemented as well as when to
  // expect it to appear.
  std::string additional_description;

  // The set of additional features that must be enabled in order for this
  // experience to be displayed. Does not include the `base::Feature` for the
  // experience itself.
  FeatureSet required_features;

  // The set of platforms the experience can be displayed on.
  PlatformSet platforms = kAllDesktopPlatforms;
};

}  // namespace user_education

#endif  // COMPONENTS_USER_EDUCATION_COMMON_USER_EDUCATION_METADATA_H_