File: app_launch_util.h

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,122,156 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 (121 lines) | stat: -rw-r--r-- 5,279 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
// Copyright 2022 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_SERVICES_APP_SERVICE_PUBLIC_CPP_APP_LAUNCH_UTIL_H_
#define COMPONENTS_SERVICES_APP_SERVICE_PUBLIC_CPP_APP_LAUNCH_UTIL_H_

#include <iosfwd>
#include <optional>

#include "base/component_export.h"
#include "components/services/app_service/public/protos/app_types.pb.h"
#include "ui/gfx/geometry/rect.h"

namespace apps {

// Enumeration of possible app launch sources. When adding a new entry to this
// enum:
// - Update DefaultAppLaunchSource in metadata/apps/histograms.xml
// - Update LaunchSource in enums.xml
// - Update ApplicationLaunchSource in
//   //components/services/app_service/public/protos/app_types.proto.
//
// This is used for metrics, persisted to logs, and we should not
//   - change the assigned value, nor
//   - reuse the value which was used (even in past historically)
// Email chromeos-data-team@google.com to request a corresponding change to
// backend enums.
enum class LaunchSource {
  kUnknown = 0,
  kFromAppListGrid = 1,              // Grid of apps, not the search box.
  kFromAppListGridContextMenu = 2,   // Grid of apps; context menu.
  kFromAppListQuery = 3,             // Query-dependent results (larger icons).
  kFromAppListQueryContextMenu = 4,  // Query-dependent results; context menu.
  kFromAppListRecommendation = 5,    // Query-less recommendations (smaller
                                     // icons).
  kFromParentalControls = 6,         // Parental Controls Settings Section and
                                     // Per App time notification.
  kFromShelf = 7,                    // Shelf.
  kFromFileManager = 8,              // FileManager.
  kFromLink = 9,                     // Left-clicking on links in the browser.
  kFromOmnibox = 10,                 // Enter URL in the Omnibox in the
                                     // browser.
  kFromChromeInternal = 11,          // Chrome internal call.
  kFromKeyboard = 12,                // Keyboard shortcut for opening app.
  kFromOtherApp = 13,                // Clicking link in another app or webui.
  kFromMenu = 14,                    // Menu.
  kFromInstalledNotification = 15,   // Installed notification
  kFromTest = 16,                    // Test
  kFromArc = 17,                     // Arc.
  kFromSharesheet = 18,              // Sharesheet.
  kFromReleaseNotesNotification = 19,  // Release Notes Notification.
  kFromFullRestore = 20,               // Full restore.
  kFromSmartTextContextMenu = 21,      // Smart text selection context menu.
  kFromDiscoverTabNotification = 22,   // Discover Tab Notification.
  kFromManagementApi = 23,             // Management API.
  kFromKiosk = 24,                     // Kiosk.
  kFromCommandLine = 25,               // Command line.
  kFromBackgroundMode = 26,            // Background mode.
  kFromNewTabPage = 27,                // New tab page.
  kFromIntentUrl = 28,                 // Intent URL.
  kFromOsLogin = 29,                   // Run on OS login.
  kFromProtocolHandler = 30,           // Protocol handler.
  kFromUrlHandler = 31,                // Url handler.
  kFromLockScreen = 32,                // Lock screen app launcher.
  kFromAppHomePage = 33,               // App Home (chrome://apps) page.
  kFromReparenting = 34,               // Moving content into an app.
  kFromProfileMenu =
      35,  // Profile menu of installable chrome://password-manager WebUI.
  kFromSysTrayCalendar = 36,      // Launches from the system tray Calendar.
  kFromInstaller = 37,            // Installation UI
  kFromFirstRun = 38,             // First Run.
  kFromWelcomeTour = 39,          // Welcome Tour.
  kFromFocusMode = 40,            // Focus Mode panel.
  kFromSparky = 41,               // From Sparky feature.
  kFromNavigationCapturing = 42,  // Web App Navigation Capturing.
  kFromWebInstallApi = 43,        // Web Install API.

  // Add any new values above this one, and update kMaxValue to the highest
  // enumerator value.
  kMaxValue = kFromWebInstallApi,
};

// Don't remove items or change the order of this enum.  It's used in
// histograms and preferences.
enum class LaunchContainer {
  kLaunchContainerWindow = 0,
  kLaunchContainerPanelDeprecated = 1,
  kLaunchContainerTab = 2,
  // For platform apps, which don't actually have a container (they just get a
  // "onLaunched" event).
  kLaunchContainerNone = 3,

  // Add any new values above this one, and update kMaxValue to the highest
  // enumerator value.
  kMaxValue = kLaunchContainerNone,
};

// The window information to launch an app.
struct COMPONENT_EXPORT(APP_TYPES) WindowInfo {
  WindowInfo() = default;
  explicit WindowInfo(int64_t display_id);

  int32_t window_id = -1;
  int32_t state = 0;
  int64_t display_id = -1;
  std::optional<gfx::Rect> bounds;
};

using WindowInfoPtr = std::unique_ptr<WindowInfo>;

COMPONENT_EXPORT(APP_TYPES)
ApplicationLaunchSource ConvertLaunchSourceToProtoApplicationLaunchSource(
    LaunchSource launch_source);

COMPONENT_EXPORT(APP_TYPES)
std::ostream& operator<<(std::ostream& out, LaunchSource launch_source);

}  // namespace apps

#endif  // COMPONENTS_SERVICES_APP_SERVICE_PUBLIC_CPP_APP_LAUNCH_UTIL_H_