// Copyright 2021 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.eche_app.mojom;
import "mojo/public/mojom/base/string16.mojom";
// Interface for sending signal messages from the SWA to the browser. The
// signals are used to bootstrap a full WebRTC connection between a Nearby
// endpoint and the SWA. Any further data exchange happens directly over the
// WebRTC connection.
interface SignalingMessageExchanger {
// Called when a new signaling message is ready for transmission. The
// `signal` is a serialized WebRtcSignal.
SendSignalingMessage(array<uint8> signal);
// Sets the listener for replies sent from the browser process to the SWA.
SetSignalingMessageObserver(
pending_remote<SignalingMessageObserver> observer);
// Called when we no longer need the signal channel.
TearDownSignaling();
};
// Interface for dispatching response signaling messages as they are received.
interface SignalingMessageObserver {
// Dispatch message to recipient. The `signal` is a serialized WebRtcSignal.
OnReceivedSignalingMessage(array<uint8> signal);
};
// Screen backlight state.
// Reference from ash/public/cpp/screen_backlight_type.h
enum ScreenBacklightState {
ON,
OFF,
OFF_AUTO,
};
// Interface for getting system information.
interface SystemInfoProvider {
// Get the system info such as board name and device name. The
// output parameter is JSON encoded set of data.
GetSystemInfo() => (string system_info);
// Registers a generic interface to observe events from browser-to-renderer.
SetSystemInfoObserver(pending_remote<SystemInfoObserver> observer);
};
// A generic interface to observe events of browser process, all events from
// browser-to-render should be added in this interface if there is no other
// reason.
interface SystemInfoObserver {
// Interface for monitoring screen backlight state of device. The state is
// detected from Chrome browser process and is notified to Eche App in
// renderer process. Updates with the latest screen backlight state.
OnScreenBacklightStateChanged(ScreenBacklightState state);
// Interface for monitoring tablet mode state of device. The state is detected
// from Chrome browser process and is notified to eche app in renderer
// process. TODO(b/184119538): Need to handle the resize issue and virtual
// keyboard in table mode.
OnReceivedTabletModeChanged(bool is_tablet_mode);
// Interface for monitoring the network state of the Android device.
// The state is sent by the remote device during the signaling process
// and processed by CrOS.
OnAndroidDeviceNetworkInfoChanged(bool is_different_network,
bool android_device_on_cellular);
};
// Interface for passing accessibility events between SWA and Browser process.
interface AccessibilityProvider {
// Registers a function for sending accessibility events from the SWA to
// the browser.
// Proto from: ash/webui/eche_app_ui/proto/accessibility_mojom.proto
HandleAccessibilityEventReceived(array<uint8> serialized_proto);
// Sets the observer for when accessibility actions need to be send to the
// SWA from the browser.
SetAccessibilityObserver(pending_remote<AccessibilityObserver> observer);
// Returns true if an accessibility feature that requires
// the tree stream is enabled.
IsAccessibilityEnabled() => (bool enabled);
};
// Observer for accessibility provider. Should be created using
// SetAccessibilityObserver in AccessibilityProvider.
// Used to send messages from chrome to interact
// with the android phone through the SWA.
// Proto from: ash/webui/eche_app_ui/proto/accessibility_mojom.proto
interface AccessibilityObserver {
// Enable or disable accessibility tree streaming
// based on state of assistive technologies.
EnableAccessibilityTreeStreaming(bool enable);
// Enable or disable explore by touch based on the state of chromevox.
EnableExploreByTouch(bool enable);
// Sends the accessibility action to the SWA for processing.
// The proto sent is proto::AccessibilityActionData.
PerformAction(array<uint8> serialized_proto) => (bool result);
// Refreshes the current node with extra data.
// Returns Rect specifying location, or null if textLocation is not available.
// The result rect is encoded in binary as proto::Rect from the accessibility
// mojom.
// `refresh_data_proto` is proto::AccessibilityActionData with the type of
// GET_TEXT_LOCATION.
// `text_location_proto` is proto::Rect.
RefreshWithExtraData(array<uint8> refresh_data_proto)
=> (array<uint8>? text_location_proto);
};
// Interface for generating uid. The uid is unique and persistent.
interface UidGenerator {
// Get the uid.
GetUid() => (string local_uid);
};
// Enum representing notifications from webUI. Numerical values should not
// be changed because they must stay in sync with value on google3
enum WebNotificationType {
APP_CRAHSED,
AUTHORIZATION_NEEDED,
CONNECTION_FAILED,
CONNECTION_LOST,
DEVICE_IDLE,
INITIALIZATION_ERROR,
INVALID_NOTIFICATION,
NOTIFICATION_ACTION_NOT_LAUNCHED,
LAUNCH_NOTIFICATION_FAILED,
TABLET_MODE,
WIFI_NOT_READY,
DIFFERENT_WIFI_NETWORKS,
REMOTE_DEVICE_ON_CELLULAR,
};
// Interface for showing a native notification which was generated from WebUI.
interface NotificationGenerator {
// Show a native notification, title and message are from WebUI.
ShowNotification(mojo_base.mojom.String16 title,
mojo_base.mojom.String16 message, WebNotificationType type);
// Show a native toast, text is from WebUI.
ShowToast(mojo_base.mojom.String16 text);
};
// Enum representing the video streaming status from browser. Numerical
// values should not be changed because they must stay in sync with value on
// Eche web app code.
enum StreamStatus {
kStreamStatusUnknown, // Initial state, not trigger anything yet
kStreamStatusInitializing, // Eche browser is setting up video streaming
kStreamStatusStarted, // Video streaming is set up and started
kStreamStatusStopped, // Video streaming is stopped
};
// Interface to notify the video streaming status from Eche browser to Eche
// SWA native code.
interface DisplayStreamHandler {
// Stream a display video for Eche.
StartStreaming();
// Notifies the stream status change for Eche.
OnStreamStatusChanged(StreamStatus status);
// Registers a generic interface to observe events from browser-to-renderer.
SetStreamActionObserver(pending_remote<StreamActionObserver> observer);
};
// Enum representing stream action from Eche SWA. Numerical values should not
// be changed because they must stay in sync with value on for Eche Web app.
enum StreamAction {
// Notify the stream should be close.
kStreamActionClose,
// Notify the stream should go back to the previous page.
kStreamActionGoBack,
};
// A generic interface to observe stream action from Eche SWA native code for
// Eche Web app can free resource for stream
interface StreamActionObserver {
// Interface for notifying Eche web app that stream action happens from Eche
// SWA
OnStreamAction(StreamAction action);
};
// Interface to send new orientation for the app streaming bubble from Eche SWA.
interface StreamOrientationObserver {
// Notifies what orientation the stream has changed to.
OnStreamOrientationChanged(bool isLandscape);
};
// Enum representing the bootstrap connection status to the phone.
enum ConnectionStatus {
kConnectionStatusDisconnected, // Initial state before connection is started
kConnectionStatusConnecting, // Attempting to establish connection
kConnectionStatusConnected, // Connected to phone
kConnectionStatusFailed, // Failed to bootstrap connection
};
// Interface to notify bootstrap connection status from Eche browser to Eche
// SWA native code.
interface ConnectionStatusObserver {
// Notifies the connection status change for Eche.
OnConnectionStatusChanged(ConnectionStatus status);
};
// Interface for when the Eche SWA requests for the current keyboard layout and
// sets an observer to see whenever the layout changes within ChromeOS.
interface KeyboardLayoutHandler {
// Notifies the native code that the Eche SWA has requested for the current
// keyboard layout.
RequestCurrentKeyboardLayout();
// Registers a generic interface to observe events from browser-to-renderer.
SetKeyboardLayoutObserver(pending_remote<KeyboardLayoutObserver> observer);
};
// A generic interface to let Eche SWA observe the system's keyboard layout
// changes.
interface KeyboardLayoutObserver {
// Sends the keyboard layout information to the Eche SWA.
// id - ID that identifies the IME (e.g., "t:latn-post", "pinyin").
// longName - Long name of the IME, which is used as the user-visible name.
// shortName - UI indicator for the IME (e.g., "US"). If the IME has no
// indicator, uses the first two characters in its preferred
// keyboard layout or language code (e.g., "ko", "ja", "en-US").
// layoutTag - Keyboard layout name (e.g., "us(workman)", "us(colemak)", "us",
// "fr(oss)", "gb(extd)").
OnKeyboardLayoutChanged(string id, string longName, string shortName,
string layoutTag);
};
// Enum representing what EntryPoint was used to launch the eche app stream.
// Keep in sync with AppStreamLaunchEntryPoint in
// tools/metrics/histograms/enums.xml
enum AppStreamLaunchEntryPoint {
APPS_LIST = 0, // App stream was launched from the full apps list.
NOTIFICATION = 1, // App stream was launched from a notification.
RECENT_APPS = 2, // App stream was launched from the recent apps.
// The initial value set before app streaming started. Should never be
// recorded histogram since by the time we start app streaming, a proper
// value should have been set.
UNKNOWN = 3,
};