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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
ash / webui / camera_app_ui / camera_app_helper.mojom [blame]
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module ash.camera_app.mojom;
import "ash/components/arc/mojom/camera_intent.mojom";
import "ash/webui/camera_app_ui/events_sender.mojom";
import "ash/webui/camera_app_ui/ocr.mojom";
import "ash/webui/camera_app_ui/pdf_builder.mojom";
import "ash/webui/camera_app_ui/types.mojom";
import "chromeos/services/machine_learning/public/mojom/document_scanner_param_types.mojom";
import "mojo/public/mojom/base/big_buffer.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "url/mojom/url.mojom";
// Interface for monitoring tablet mode state of device. The state is detected
// from Chrome browser process and is notified to Chrome Camera App in renderer
// process.
interface TabletModeMonitor {
// Updates with the latest changed tablet mode state.
Update(bool is_tablet_mode);
};
// Screen backlight state.
// Reference from ash/public/cpp/screen_backlight_type.h
enum ScreenState {
kOn,
kOff,
kOffAuto,
};
// Lid state.
// Reference from media/capture/video/chromeos/mojom/system_event_monitor.mojom
// Dulplication has the following advantages.
// 1. 'cca.py dev' doesn't need to parse system_event_monitor.mojom.
// 2. Make CameraAppHelper independent of system_event_monitor.mojom.
// 3. No need to generate js mojo files for system_event_monitor.mojom.
//
// LINT.IfChange(LidState)
enum LidState {
kOpen, // Lid is open.
kClosed, // Lid is closed.
kNotPresent, // No lid is present
};
// LINT.ThenChange(//media/capture/video/chromeos/mojom/system_event_monitor.mojom:LidState)
// Configurations which can be provided by Wi-Fi QR Code.
struct WifiConfig {
// Required fields.
string ssid;
WifiSecurityType security;
// Optional fields.
string? password;
WifiEapMethod? eap_method;
WifiEapPhase2Method? eap_phase2_method;
string? eap_identity;
string? eap_anonymous_identity;
};
// Interface for monitoring screen state of device. The state is detected from
// Chrome browser process and is notified to Chrome Camera App in renderer
// process.
interface ScreenStateMonitor {
// Updates with the latest changed screen state.
Update(ScreenState state);
};
// Interface for monitoring lock state of screen. The state is detected from
// Chrome browser process and is notified to Chrome Camera App in renderer
// process.
interface ScreenLockedMonitor {
// Updates when the lock state of screen got changed.
Update(bool is_screen_locked);
};
// Interface for monitoring the existence of external screen. The state is
// detected from Chrome browser process and is notified to Chrome Camera App in
// renderer process.
interface ExternalScreenMonitor {
// Updates when the existence of external screen got changed.
Update(bool has_external_screen);
};
// Interface to monitor camera usage ownership changes.
interface CameraUsageOwnershipMonitor {
// Updates when the camera usage ownership is changed.
OnCameraUsageOwnershipChanged(bool has_usage) => ();
};
// Interface to monitor lid state changes.
interface LidStateMonitor {
// Updates when the lid state is changed.
Update(LidState lid_status);
};
// Interface for monitoring state of software privacy switch. The sw privacy
// switch is available on th Privacy Hub of OS settings page. It allows users
// to disable cameras at OS level for privacy concern. The state is detected
// from Chrome browser process and is notified to Chrome Camera App in renderer
// process.
interface SWPrivacySwitchMonitor {
// Updates when the state of sw privacy switch got changed.
Update(bool is_sw_privacy_switch_on);
};
// The window states that we care about.
enum WindowStateType {
kMinimized = 0,
kMaximized = 1,
kFullscreen = 2,
kRegular = 3, // None of the above.
};
// Interface for monitoring window states.
interface WindowStateMonitor {
// Updates when any of the window states are changed.
OnWindowStateChanged(array<WindowStateType> states);
// Updates when the window focus state is changed.
OnWindowFocusChanged(bool is_focus);
};
// The possible result of the file deletion monitor.
enum FileMonitorResult {
// The file is deleted.
kDeleted = 0,
// The request is canceled since there is another monitor request.
kCanceled = 1,
// Fails to monitor the file due to errors.
kError = 2,
};
enum StorageMonitorStatus {
// There are enough storage space to operate CCA functionalities.
kNormal = 0,
// Storage is getting low, display warning to users.
kLow = 1,
// Storage is almost full. Should stop ongoing recording and don't allow new
// recording.
kCriticallyLow = 2,
// Monitoring got canceled since there is another monitor request.
kCanceled = 3,
// Monitoring get errors.
kError = 4,
};
// Interface to monitor storage status changes.
interface StorageMonitor {
// Update when storage status is changed.
Update(StorageMonitorStatus status);
};
// Interface for window controlling.
interface WindowStateController {
// Adds |monitor| for window state changes.
AddMonitor(pending_remote<WindowStateMonitor> monitor)
=> (array<WindowStateType> states);
// Gets current |states| of the window.
GetWindowState() => (array<WindowStateType> states);
// Minimize the window.
Minimize() => ();
// Restore the window.
Restore() => ();
// Maximize the window.
Maximize() => ();
// Fullscreen the window.
Fullscreen() => ();
// Focus the window.
Focus() => ();
};
// The values for generating a custom aspect ratio order.
enum AspectRatio {
kOthers = 0,
k4To3 = 1,
k16To9 = 2,
};
// Interface for communication between Chrome Camera App (Remote) and Chrome
// (Receiver).
interface CameraAppHelper {
// Sends the captured result |data| for corresponding intent recognized by
// |intent_id| back to ARC. The handler should handle |data| and may notify
// the intent caller according to the intention of the |action|. |is_success|
// will be set to true if the ARC received the result and set to false for
// invalid input.
HandleCameraResult(uint32 intent_id,
arc.mojom.CameraIntentAction action,
array<uint8> data) => (bool is_success);
// Checks if device is under tablet mode currently.
IsTabletMode() => (bool is_tablet_mode);
// Triggers the begin of event tracing for given |event|.
StartPerfEventTrace(string event);
// Triggers the end of event tracing for given |event|.
StopPerfEventTrace(string event);
// Registers a TabletModeMonitor instance and returns the tablet mode
// initial state. Calling the Update() whenever the tablet mode state
// changes.
SetTabletMonitor(pending_remote<TabletModeMonitor> monitor)
=> (bool is_tablet_mode);
// Registers a ScreenStateMonitor instance and returns the initial screen
// state. Calling the Update() whenever the screen state changes.
SetScreenStateMonitor(pending_remote<ScreenStateMonitor> monitor)
=> (ScreenState initial_state);
// Checks if the logging consent option is enabled. It is only usable for SWA
// version. For platform app version, we use Chrome MetricsPrivate API.
IsMetricsAndCrashReportingEnabled() => (bool is_enabled);
// Registers a ExternalScreenMonitor instance and returns the initial state of
// the existence of external screen. Calling the Update() whenever the screen
// state changes.
SetExternalScreenMonitor(pending_remote<ExternalScreenMonitor> monitor)
=> (bool has_external_screen);
// Opens the file in Downloads folder by its |name| in gallery. It is only
// usable for SWA version.
OpenFileInGallery(string name);
// Opens the chrome feedback dialog and show |placeholder| in the description
// field. It is only usable for SWA version. For platform app version, we send
// message to Feedback extension via chrome.runtime API.
OpenFeedbackDialog(string placeholder);
// Opens the given URL in the browser.
OpenUrlInBrowser(url.mojom.Url url);
// Gets the controller to control and monitor the window state of app.
GetWindowStateController()
=> (pending_remote<WindowStateController> controller);
// Sends broadcast when a picture/video is captured. |is_video| is true if a
// video is captured and false for a picture. |name| is the file name which
// will be used to generate the URI for the broadcast.
SendNewCaptureBroadcast(bool is_video, string name);
// Monitors the deletion for given file |name| in the camera folder. The
// function will return when the deletion happens, or when another monitor
// request is raised, or when the error occurs. We can determine the cases
// by result.
MonitorFileDeletion(string name) => (FileMonitorResult result);
// Check if document scanner is supported.
IsDocumentScannerSupported() => (bool is_supported);
// Registers a callback which will be resolved once the document scanner is
// ready or when it fails to load. If the document scanner is not supported on
// the device, it returns false immediately. If the document scanner fails to
// load in the previous round, it retries upon the call.
CheckDocumentModeReadiness() => (bool is_loaded);
// Returns the detected document corners from given |jpeg_data|.
// The amount of corners will be either 0, indicating there are no corners
// detected, or 4, which are in top-left => bottom-left => bottom-right =>
// top-right order. The value of the coordinate of a corner will be in [0, 1).
// If there is non-zero orientation info in EXIF of |jpeg_data|, the output
// |corners| will be detected on image with orientation corrected.
ScanDocumentCorners(array<uint8> jpeg_data)
=> (array<gfx.mojom.PointF> corners);
// Does the post processing for document given by its |jpeg_data|, document
// |corners|, clockwise rotate in |rotation| degrees. The input |corners|
// should be the ones based on the image with corrected orientation. And it is
// guaranteed that the output |doc_data| will have none or corrected
// orientation.
ConvertToDocument(array<uint8> jpeg_data,
array<gfx.mojom.PointF, 4> corners,
chromeos.machine_learning.mojom.Rotation rotation)
=> (array<uint8> doc_data);
// Triggers HaTS survey for the camera app if all the conditions match:
// 1. The camera app session is longer than 15 seconds
// 2. The user is chosen to take the survey
// 3. The user hasn't done any survey recently
MaybeTriggerSurvey();
// Register a Storage Monitor instance and return initial status. Calling
// Update() whenever the state changes.
StartStorageMonitor(pending_remote<StorageMonitor> monitor)
=> (StorageMonitorStatus initial_status);
// Stop ongoing storage monitor, no-op if there is no current monitoring.
StopStorageMonitor();
// Open "Storage management" page directly. This page is inside Settings app,
// under "Device" section.
OpenStorageManagement();
// Opens the Wi-Fi connection dialog and fills the dialog with provided
// `config` extracted from QR code. Since the call won't invoke the network
// connection directly, no error message will be returned when the config is
// incorrect.
OpenWifiDialog(WifiConfig config);
// Registers a LidStateMonitor instance and returns the initial status.
// Calling the Update() whenever the lid state changes.
SetLidStateMonitor(pending_remote<LidStateMonitor> monitor)
=> (LidState lid_status);
// Registers a SWPrivacySwitchMonitor instance and returns the initial status.
// Calling the Update() whenever the sw privacy switch state changes.
SetSWPrivacySwitchMonitor(pending_remote<SWPrivacySwitchMonitor> monitor)
=> (bool is_sw_privacy_switch_on);
// Gets an event sender which can be used to send events to CrOS Events.
GetEventsSender() => (pending_remote<EventsSender> events_sender);
// Registers a ScreenLockedMonitor instance and returns the initial lock
// state of screen.
// Calling the Update() whenever the screen is locked/unlocked.
SetScreenLockedMonitor(pending_remote<ScreenLockedMonitor> monitor)
=> (bool is_screen_locked);
// Returns the first page of a PDF as a JPEG.
RenderPdfAsJpeg(array<uint8> pdf_data) => (array<uint8> jpeg_data);
// Performs OCR on the image and returns the OCR result.
PerformOcr(mojo_base.mojom.BigBuffer jpeg_data) => (OcrResult ocr_result);
// Same as `PerformOcr`, but using `array<uint8>`.
PerformOcrInline(array<uint8> jpeg_data) => (OcrResult ocr_result);
// Creates a PDF builder.
CreatePdfBuilder(pending_receiver<PdfBuilder> builder);
// Returns the custom aspect ratio order for the device.
GetAspectRatioOrder() => (array<AspectRatio> order);
};