File: launch_mode_recorder.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; 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 (90 lines) | stat: -rw-r--r-- 3,967 bytes parent folder | download | duplicates (4)
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
// 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_UI_STARTUP_LAUNCH_MODE_RECORDER_H_
#define CHROME_BROWSER_UI_STARTUP_LAUNCH_MODE_RECORDER_H_

#include <optional>

#include "base/functional/callback_forward.h"

namespace base {
class CommandLine;
}

// These enums describe how Chrome was launched. They are determined from the
// command line switches and arguments, not from what Chrome does when launched.
// "Web App" is shorthand for Chrome launched with --app or --appid switches,
// "Chrome" is Chrome launched with neither of those switches.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class LaunchMode {
  kNone = 0,   // Don't record this launch.
  kOther = 1,  // Catch-all launch for Windows
  // kUserExperiment = 2,  Launched after acceptance of a user experiment.
  //                       Deprecated.
  kOtherOS = 3,          // Result bucket for OSes with no coverage here.
  kProtocolHandler = 4,  // Chrome launched as registered protocol handler.
  kFileTypeHandler = 5,  // Chrome launched as registered file handler.
  // Chrome launched with url(s) in the cmd line, but not from a shell
  // registration or a shortcut. Only 1st arg is considered.
  kWithUrl = 6,
  // Chrome launched with file(s) in the cmd line, but not from a shell
  // registration or a shortcut. Only first arg is considered.
  kWithFile = 7,
  // Launched from shortcut but no name available, Chrome, or Web App.
  kShortcutNoName = 8,
  // Following are shortcuts to Chrome, w/o a Web App.
  kShortcutUnknown = 9,     // Launched from user-defined shortcut.
  kShortcutDesktop = 10,    // Launched from a desktop shortcut.
  kShortcutTaskbar = 11,    // Launched from the Windows taskbar.
  kShortcutStartMenu = 12,  // A Windows Start Menu shortcut.

  // Launched from toast notification activation on Windows.
  kWinPlatformNotification = 13,
  // Launched as a logon stub for the Google Credential Provider for Windows.
  kCredentialProviderSignIn = 14,

  // Mac-specific launch modes.
  kMacUndockedDiskLaunch = 15,  // Undocked launch from disk.
  kMacDockedDiskLaunch = 16,    // Docked launch from disk.
  kMacUndockedDMGLaunch = 17,   // Undocked launch from a dmg.
  kMacDockedDMGLaunch = 18,     // Docked launch from a dmg.
  kMacDockStatusError = 19,     // Error determining dock status.
  kMacDMGStatusError = 20,      // Error determining dmg status.
  kMacDockDMGStatusError = 21,  // Error determining dock and dmg status.

  // Web App on command line, but not from a shortcut, or a file type/protocol
  // handler.
  kWebAppOther = 22,
  // Web App launched from various shortcut locations.
  kWebAppShortcutUnknown = 23,
  kWebAppShortcutDesktop = 24,
  kWebAppShortcutStartMenu = 25,
  kWebAppShortcutTaskbar = 26,
  // Web App launched as a registered file type handler.
  kWebAppFileTypeHandler = 27,
  // Web App launched as a registered protocol handler.
  kWebAppProtocolHandler = 28,
  kMaxValue = kWebAppProtocolHandler,
};

// Computes and records the launch mode based on `command_line` and process
// state. The launch mode may be recorded asynchronously.
void ComputeAndRecordLaunchMode(const base::CommandLine& command_line);

// Computes the launch mode based on `command_line` and process state. Runs
// `result_callback` with the result either synchronously or asynchronously on
// the caller's sequence.
// This is exposed for testing.
void ComputeLaunchMode(
    const base::CommandLine& command_line,
    base::OnceCallback<void(std::optional<LaunchMode>)> result_callback);

// Returns the callback used to record launch modes. This is used by unit tests
// to verify its behavior.
base::OnceCallback<void(std::optional<LaunchMode>)>
GetRecordLaunchModeForTesting();

#endif  // CHROME_BROWSER_UI_STARTUP_LAUNCH_MODE_RECORDER_H_