File: installable_metrics.h

package info (click to toggle)
chromium 138.0.7204.157-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,864 kB
  • sloc: cpp: 34,936,859; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,967; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (286 lines) | stat: -rw-r--r-- 8,282 bytes parent folder | download | duplicates (3)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
// Copyright 2017 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_WEBAPPS_BROWSER_INSTALLABLE_INSTALLABLE_METRICS_H_
#define COMPONENTS_WEBAPPS_BROWSER_INSTALLABLE_INSTALLABLE_METRICS_H_

#include <iosfwd>

namespace content {
class WebContents;
}  // namespace content

namespace webapps {

// A Java counterpart will be generated for this enum.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.webapps
enum class InstallTrigger {
  AMBIENT_BADGE,
  API,
  AUTOMATIC_PROMPT,
  MENU,
  CREATE_SHORTCUT,
};

// Sources for triggering webapp installation. Each install source must map to
// one web_app::Source::Type that is calculated in the method
// `web_app::ConvertExternalInstallSourceToSource`.
//
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
//
// NOTE: each enum entry which is reportable must be added to
// InstallableMetrics::IsReportableInstallSource(). This enum backs a UMA
// histogram and must be treated as append-only. A Java counterpart will be
// generated for this enum.
//
// This should be kept in sync with WebappInstallSource in
// tools/metrics/histograms/enums.xml.
//
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.webapps
enum class WebappInstallSource {
  // Menu item in a browser tab.
  MENU_BROWSER_TAB = 0,

  // Menu item in an Android Custom Tab.
  MENU_CUSTOM_TAB = 1,

  // Automatic prompt in a browser tab.
  AUTOMATIC_PROMPT_BROWSER_TAB = 2,

  // Automatic prompt in an Android Custom Tab.
  AUTOMATIC_PROMPT_CUSTOM_TAB = 3,

  // Developer-initiated API in a browser tab.
  API_BROWSER_TAB = 4,

  // Developer-initiated API in an Android Custom Tab.
  API_CUSTOM_TAB = 5,

  // Installation from a debug flow (e.g. via devtools).
  DEVTOOLS = 6,

  // Extensions management API (not reported).
  MANAGEMENT_API = 7,

  // PWA ambient badge in Android browser Tab.
  AMBIENT_BADGE_BROWSER_TAB = 8,

  // PWA ambient badge in an Android Custom Tab.
  AMBIENT_BADGE_CUSTOM_TAB = 9,

  // Installation via ARC on Chrome OS.
  ARC = 10,

  // An internal default-installed app on Chrome OS (i.e. triggered from code).
  INTERNAL_DEFAULT = 11,

  // An external default-installed app on Chrome OS (i.e. triggered from an
  // external source file).
  EXTERNAL_DEFAULT = 12,

  // A policy-installed app on Chrome OS.
  // Note: IWAs use a separate `ISOLATED_WEB_APP_EXTERNAL_POLICY` source.
  EXTERNAL_POLICY = 13,

  // A system app installed on Chrome OS.
  SYSTEM_DEFAULT = 14,

  // Install icon in the Omnibox.
  OMNIBOX_INSTALL_ICON = 15,

  // Installed from sync (not reported by |TrackInstallEvent|).
  SYNC = 16,

  // Create shortcut item in menu
  MENU_CREATE_SHORTCUT = 17,

  // Installed via the SubApps API.
  SUB_APP = 18,

  // Chrome Android service for installing WebAPKs from another app.
  CHROME_SERVICE = 19,

  // PWA rich install bottom sheet in WebLayer.
  RICH_INSTALL_UI_WEBLAYER = 20,

  // Installed by Kiosk on Chrome OS.
  KIOSK = 21,

  // Isolated app installation for development via command line.
  IWA_DEV_COMMAND_LINE = 22,

  // Lock screen app infrastructure installing to the lock screen app profile.
  EXTERNAL_LOCK_SCREEN = 23,

  // OEM apps installed by the App Preload Service on ChromeOS.
  PRELOADED_OEM = 24,

  // Installed via the Microsoft 365 setup dialog.
  MICROSOFT_365_SETUP = 25,

  // Profile picking in ProfileMenuView (for installable WebUIs).
  PROFILE_MENU = 26,

  // Installation promotion was triggered via ML model.
  ML_PROMOTION = 27,

  // Default apps installed by the App Preload Service on ChromeOS.
  PRELOADED_DEFAULT = 28,

  // Apps installed in shimless RMA.
  IWA_SHIMLESS_RMA = 29,

  // A policy-installed Isolated Web App.
  // Note: PWAs use a separate `EXTERNAL_POLICY` source.
  IWA_EXTERNAL_POLICY = 30,

  IWA_GRAPHICAL_INSTALLER = 31,

  IWA_DEV_UI = 32,

  // Web apps installed via almanac://install-app navigation, ChromeOS only, see
  // [App Install
  // Service](../../chrome/browser/apps/app_service/app_install/README.md).
  ALMANAC_INSTALL_APP_URI = 33,

  // WebAPK Backup and restore.
  WEBAPK_RESTORE = 34,

  // Recommended apps screen in the ChromeOS Out Of Box Experience.
  OOBE_APP_RECOMMENDATIONS = 35,

  // Installed from web content via Web Install API.
  WEB_INSTALL = 36,

  // Installed via the ChromeOS help app directing the user to a page and
  // displaying the install dialog for that page.
  CHROMEOS_HELP_APP = 37,

  kMaxValue = CHROMEOS_HELP_APP,
};

std::ostream& operator<<(std::ostream& os, WebappInstallSource source);

// Uninstall surface from which an uninstall was initiated. This value cannot be
// used to infer an install source. These values are persisted to logs. Entries
// should not be renumbered and numeric values should never be reused.
enum class WebappUninstallSource {
  // Unknown surface, potentially in ChromeOS.
  kUnknown = 0,

  // Menu item from the 3-dot menu of a WebApp window.
  kAppMenu = 1,

  // Context menu for a WebApp in chrome://apps.
  kAppsPage = 2,

  // Via OS Settings or Controls.
  kOsSettings = 3,

  // Uninstalled from Sync.
  kSync = 4,

  // App management surface, currently ChromeOS-only.
  kAppManagement = 5,

  // Migration.
  kMigration = 6,

  // App List (Launcher in ChromeOS).
  kAppList = 7,

  // Shelf (in ChromeOS).
  kShelf = 8,

  // Internally managed pre-installed app management.
  kInternalPreinstalled = 9,

  // Externally managed pre-installed app management.
  kExternalPreinstalled = 10,

  // Enterprise policy app management.
  // Note: IWAs use a separate `kIwaEnterprisePolicy` source.
  kExternalPolicy = 11,

  // System app management on ChromeOS.
  kSystemPreinstalled = 12,

  // Placeholder app management for preinstalled apps.
  kPlaceholderReplacement = 13,

  // Externally managed Arc apps.
  kArc = 14,

  // SubApp API.
  kSubApp = 15,

  // On system startup, any apps that are flagged as uninstalling but have not
  // yet been fully uninstalled are re-uninstalled.
  kStartupCleanup = 16,

  // Used to track uninstalls for web_apps which are installed as sub-apps and
  // are being removed because of the removal of the parent app.
  kParentUninstall = 17,

  // Lock screen app infrastructure uninstalling from the lock screen app
  // profile.
  kExternalLockScreen = 18,

  // Tests often need a way of fully installing apps to clean up OS integration.
  kTestCleanup = 19,

  // The DedupeInstallUrlsCommand.
  kInstallUrlDeduping = 20,

  // Healthcare app cleaning up all user installed apps in between shared
  // sessions.
  kHealthcareUserInstallCleanup = 21,

  // Isolated Web App Enterprise policy.
  kIwaEnterprisePolicy = 22,

  // Via devtools PWA.uninstall or similar commands.
  kDevtools = 23,

  // Add any new values above this one.
  kMaxValue = kDevtools,
};

std::ostream& operator<<(std::ostream& os, WebappUninstallSource source);

bool IsUserUninstall(WebappUninstallSource source);

class InstallableMetrics {
 public:
  InstallableMetrics() = delete;
  InstallableMetrics(const InstallableMetrics&) = delete;
  InstallableMetrics& operator=(const InstallableMetrics&) = delete;

  // Records |source| in the Webapp.Install.InstallEvent histogram.
  // IsReportableInstallSource(|source|) must be true.
  static void TrackInstallEvent(WebappInstallSource source);

  // Returns whether |source| is a value that may be passed to
  // TrackInstallEvent.
  static bool IsReportableInstallSource(WebappInstallSource source);

  // Returns the appropriate WebappInstallSource for |web_contents| when the
  // install originates from |trigger|.
  static WebappInstallSource GetInstallSource(
      content::WebContents* web_contents,
      InstallTrigger trigger);

  // Records |source| in the Webapp.Install.UninstallEvent histogram.
  static void TrackUninstallEvent(WebappUninstallSource source);

  // Records the result for WebApp.Install.Result,
  // WebApp.Install.Source.Success and WebApp.Install.Source.Failure
  // histograms.
  static void TrackInstallResult(bool result, WebappInstallSource source);
};

}  // namespace webapps

#endif  // COMPONENTS_WEBAPPS_BROWSER_INSTALLABLE_INSTALLABLE_METRICS_H_