File: intent_handling_metrics.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 (140 lines) | stat: -rw-r--r-- 5,445 bytes parent folder | download | duplicates (6)
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
// Copyright 2020 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_APPS_LINK_CAPTURING_METRICS_INTENT_HANDLING_METRICS_H_
#define CHROME_BROWSER_APPS_LINK_CAPTURING_METRICS_INTENT_HANDLING_METRICS_H_

#include "chrome/browser/apps/link_capturing/intent_picker_info.h"

namespace content {
class BrowserContext;
}  // namespace content

namespace apps {

class IntentHandlingMetrics {
 public:
  // The type of app the link came from, used for intent handling metrics.
  // This enum is used for recording histograms, and must be treated as
  // append-only.
  enum class AppType {
    kArc = 0,  // From an Android app
    kWeb,      // From a web app
    kMaxValue = kWeb,
  };

  // An action taken by the user in the HTTP/HTTPS Intent Picker dialog.
  // These values are persisted to logs. Entries should not be renumbered and
  // numeric values should never be reused.
  enum class IntentPickerAction {
    kInvalid = 0,
    kError = 1,
    kDialogDeactivated = 2,
    kChromeSelected = 3,
    kChromeSelectedAndPreferred = 4,
    kArcAppSelected = 5,
    kArcAppSelectedAndPreferred = 6,
    kPwaSelected = 7,
    kPwaSelectedAndPreferred = 8,
    kMaxValue = kPwaSelectedAndPreferred
  };

  // These enums are used to define the buckets for an enumerated UMA histogram
  // and need to be synced with the ArcIntentHandlerAction enum in enums.xml.
  // This enum class should also be treated as append-only.
  enum class PickerAction : int {
    // Picker errors occurring after the picker is shown.
    ERROR_AFTER_PICKER = 0,
    // DIALOG_DEACTIVATED keeps track of the user dismissing the UI via clicking
    // the close button or clicking outside of the IntentPickerBubbleView
    // surface. As with CHROME_PRESSED, the user stays in Chrome, however we
    // keep both options since CHROME_PRESSED is tied to an explicit intent of
    // staying in Chrome, not only just getting rid of the
    // IntentPickerBubbleView UI.
    DIALOG_DEACTIVATED = 1,
    OBSOLETE_ALWAYS_PRESSED = 2,
    OBSOLETE_JUST_ONCE_PRESSED = 3,
    PREFERRED_ARC_ACTIVITY_FOUND = 4,
    // The prefix "CHROME"/"ARC_APP"/"PWA_APP" determines whether the user
    // pressed [Stay in Chrome] or [Use app] at IntentPickerBubbleView.
    // "PREFERRED" denotes when the user decides to save this selection, whether
    // an app or Chrome was selected.
    CHROME_PRESSED = 5,
    CHROME_PREFERRED_PRESSED = 6,
    ARC_APP_PRESSED = 7,
    ARC_APP_PREFERRED_PRESSED = 8,
    PWA_APP_PRESSED = 9,
    // Picker errors occurring before the picker is shown.
    ERROR_BEFORE_PICKER = 10,
    INVALID = 11,
    DEVICE_PRESSED = 12,
    MAC_OS_APP_PRESSED = 13,
    PWA_APP_PREFERRED_PRESSED = 14,
    PREFERRED_PWA_FOUND = 15,
    PREFERRED_CHROME_BROWSER_FOUND = 16,
    kMaxValue = PREFERRED_CHROME_BROWSER_FOUND,
  };

  // As for PickerAction, these define the buckets for an UMA histogram, so this
  // must be treated in an append-only fashion. This helps specify where a
  // navigation will continue. Must be kept in sync with the
  // ArcIntentHandlerDestinationPlatform enum in enums.xml.
  enum class Platform : int {
    ARC = 0,
    CHROME = 1,
    PWA = 2,
    DEVICE = 3,
    MAC_OS = 4,
    kMaxValue = MAC_OS,
  };

  // These are the events that occur in the link capturing flow.
  enum class LinkCapturingEvent {
    // An entry point for the link capturing flow was shown, in the form of the
    // Intent Chip or Intent Picker.
    kEntryPointShown = 0,
    // The link was captured (opened) in an available app.
    kAppOpened = 1,
    // The user accepted the option to automatically open similar links in the
    // future with this same app selection.
    kSettingsChanged = 2,
    kMaxValue = kSettingsChanged,
  };

  IntentHandlingMetrics();

  // Records metrics for the outcome of a user selection in the http/https
  // Intent Picker UI. |entry_type| is the type of the selected app,
  // |close_reason| is the reason why the bubble closed, and |should_persist| is
  // whether the persistence checkbox was checked.
  static void RecordIntentPickerMetrics(PickerEntryType entry_type,
                                        IntentPickerCloseReason close_reason,
                                        bool should_persist);

  // Records metrics for when a link is clicked which can handle a preferred
  // app, as the result of a user previously setting a preference for that app.
  static void RecordPreferredAppLinkClickMetrics(Platform platform);

  // Records metrics for when an entry point is shown for the link capturing
  // flow. An entry point can be the Intent Chip or Intent Picker.
  static void RecordLinkCapturingEntryPointShown(
      const std::vector<IntentPickerAppInfo>& app_infos);

  // Records metrics for link capturing flow events, including when an app is
  // opened and when settings are saved.
  static void RecordLinkCapturingEvent(PickerEntryType app_type,
                                       LinkCapturingEvent event);

#if BUILDFLAG(IS_CHROMEOS)
  static void RecordExternalProtocolUserInteractionMetrics(
      content::BrowserContext* context,
      PickerEntryType entry_type,
      IntentPickerCloseReason close_reason,
      bool should_persist);
#endif  // BUILDFLAG(IS_CHROMEOS)
};

}  // namespace apps

#endif  // CHROME_BROWSER_APPS_LINK_CAPTURING_METRICS_INTENT_HANDLING_METRICS_H_