summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/services/app_service/public/mojom/types.mojom
blob: 7479619237e18d6036bd199c51f4a1f66245e25f (plain)
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
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module apps.mojom;

import "mojo/public/mojom/base/time.mojom";
import "ui/gfx/image/mojom/image.mojom";

// Information about an app. See chrome/services/app_service/README.md.
struct App {
  AppType app_type;
  string app_id;

  // The fields above are mandatory. Everything else below is optional.

  Readiness readiness;
  string? name;
  string? short_name;
  string? description;
  string? version;
  array<string> additional_search_terms;
  IconKey? icon_key;
  mojo_base.mojom.Time? last_launch_time;
  mojo_base.mojom.Time? install_time;

  // This vector must be treated atomically, if there is a permission
  // change, the publisher must send through the entire list of permissions.
  // Should contain no duplicate IDs.
  // If empty during updates, Subscriber can assume no changes.
  // There is no guarantee that this is sorted by any criteria.
  array<Permission> permissions;

  // Whether the app was installed by sync, policy or as a default app.
  InstallSource install_source;

  // Whether the app is an extensions::Extensions where is_platform_app()
  // returns true.
  OptionalBool is_platform_app;

  // TODO(nigeltao): be more principled, instead of ad hoc show_in_xxx and
  // show_in_yyy fields?
  OptionalBool recommendable;
  OptionalBool searchable;
  OptionalBool show_in_launcher;
  OptionalBool show_in_search;
  OptionalBool show_in_management;

  // This vector stores all the intent filters defined in this app. Each
  // intent filter defines a matching criteria for whether an intent can
  // be handled by this app. One app can have multiple intent filters.
  array<IntentFilter> intent_filters;

  // When adding new fields, also update the Merge method and other helpers in
  // chrome/services/app_service/public/cpp/app_update.*
};

struct Permission {
  // An AppType-specific value, opaque to the App Service.
  // Different publishers (with different AppType's) can
  // re-use the same numerical value to mean different things.
  uint32 permission_id;
  PermissionValueType value_type;
  // The semantics of value depends on the value_type.
  uint32 value;
  // If the permission is managed by an enterprise policy.
  bool is_managed;
};

// The types of apps available in the registry.
enum AppType {
  kUnknown = 0,
  kArc,        // Android app.
  kBuiltIn,    // Built-in app.
  kCrostini,   // Linux app.
  kExtension,  // Extension-backed app.
  kWeb,        // Web app.
};

// Whether an app is ready to launch, i.e. installed.
enum Readiness {
  kUnknown = 0,
  kReady,                // Installed and launchable.
  kDisabledByBlacklist,  // Disabled by SafeBrowsing.
  kDisabledByPolicy,     // Disabled by admin policy.
  kDisabledByUser,       // Disabled by explicit user action.
  kTerminated,           // Renderer process crashed.
  kUninstalledByUser,
};

// How the app was installed.
enum InstallSource {
  kUnknown = 0,
  kSystem,     // Installed with the system and is considered a part of the OS.
  kPolicy,     // Installed by policy.
  kOem,        // Installed by an OEM.
  kDefault,    // Preinstalled by default, but is not considered a system app.
  kSync,       // Installed by sync.
  kUser,       // Installed by user action.
};

// Augments a bool to include an 'unknown' value.
enum OptionalBool {
  kUnknown = 0,
  kFalse,
  kTrue,
};

struct IconKey {
  // A timeline value for icons that do not change.
  const uint64 kDoesNotChangeOverTime = 0;

  const int32 kInvalidResourceId = 0;

  // A monotonically increasing number so that, after an icon update, a new
  // IconKey, one that is different in terms of field-by-field equality, can be
  // broadcast by a Publisher.
  //
  // The exact value of the number isn't important, only that newer IconKey's
  // (those that were created more recently) have a larger timeline than older
  // IconKey's.
  //
  // This is, in some sense, *a* version number, but the field is not called
  // "version", to avoid any possible confusion that it encodes *the* app's
  // version number, e.g. the "2.3.5" in "FooBar version 2.3.5 is installed".
  //
  // For example, if an app is disabled for some reason (so that its icon is
  // grayed out), this would result in a different timeline even though the
  // app's version is unchanged.
  uint64 timeline;
  // If non-zero (or equivalently, not equal to kInvalidResourceId), the
  // compressed icon is compiled into the Chromium binary as a statically
  // available, int-keyed resource.
  int32 resource_id;
  // A bitmask of icon post-processing effects, such as desaturation to gray
  // and rounding the corners.
  uint32 icon_effects;

  // When adding new fields, also update the IconLoader::Key type in
  // chrome/services/app_service/public/cpp/icon_loader.*
};

enum IconCompression {
  kUnknown,
  kUncompressed,
  kCompressed,
};

struct IconValue {
  IconCompression icon_compression;
  gfx.mojom.ImageSkia? uncompressed;
  array<uint8>? compressed;
  bool is_placeholder_icon;
};

enum LaunchSource {
  kUnknown,
  kFromAppListGrid,              // Grid of apps, not the search box.
  kFromAppListGridContextMenu,   // Grid of apps; context menu.
  kFromAppListQuery,             // Query-dependent results (larger icons).
  kFromAppListQueryContextMenu,  // Query-dependent results; context menu.
  kFromAppListRecommendation,    // Query-less recommendations (smaller icons).
  kFromParentalControls,         // Parental Controls Settings Section.
  kFromShelf,                    // Shelf.
  kFromFileManager,              // FileManager.
  kFromLink,                     // Left-licking on links in the browser.
  kFromOmnibox,                  // Enter URL in the Omnibox in the browser.
};

enum TriState {
  kAllow,
  kBlock,
  kAsk,
};

enum PermissionValueType {
  kBool,                       // Permission.value is a Bool (either 0 or 1).
  kTriState,                   // Permission.value is a TriState.
};

// The intent filter matching condition types.
enum ConditionType {
  kScheme,    // Matches the URL scheme (e.g. https, tel).
  kHost,      // Matches the URL host (e.g. www.google.com).
  kPattern,   // Matches the URL pattern (e.g. /abc/*).
};

// The pattern match type for intent filter pattern condition.
enum PatternMatchType {
  kNone = 0,
  kLiteral,
  kPrefix,
  kGlob,
};

// For pattern type of condition, the value match will be based on the pattern
// match type. If the match_type is kNone, then an exact match with the value
// will be required.
struct ConditionValue {
  string value;
  PatternMatchType match_type; // This will be None for non pattern conditions.
};

// The condition for an intent filter. It matches if the intent contains this
// condition type and the corresponding value matches with any of the
// condition_values.
struct Condition {
  ConditionType condition_type;
  array<ConditionValue> condition_values;
};

// An intent filter is defined by an app, and contains a list of conditions that
// an intent needs to match. If all conditions match, then this intent filter
// matches against an intent.
struct IntentFilter {
  array<Condition> conditions;
};

// Action and resource handling request. This includes the scheme and URL at
// the moment, and will be extended to handle MIME type and file extensions in
// the future.
struct Intent {
  string? scheme; // URL scheme. e.g. https.
  string? host;   // URL host. e.g. www.google.com.
  string? path;   // URL path. e.g. /abc.
};