// Copyright 2015 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.
//
// Next MinVersion: 20

module arc.mojom;

import "components/arc/common/bitmap.mojom";
import "components/arc/common/gfx.mojom";

// These values must be matched with the NOTIFICATION_EVENT_* constants in
// com.android.server.ArcNotificationListenerService.
[Extensible]
enum ArcNotificationEvent {
  BODY_CLICKED = 0,
  CLOSED = 1,
  // Five buttons at maximum (message_center::kNotificationMaximumItems = 5).
  BUTTON_1_CLICKED = 2,
  BUTTON_2_CLICKED = 3,
  BUTTON_3_CLICKED = 4,
  BUTTON_4_CLICKED = 5,
  BUTTON_5_CLICKED = 6,
  // expand/collapse the bundled notification
  [MinVersion=10] TOGGLE_EXPANSION = 7,
};

[Extensible]
enum ArcNotificationType {
  SIMPLE = 0,
  DEPRECATED_IMAGE = 1,
  DEPRECATED_PROGRESS = 2,
  DEPRECATED_LIST = 3,
  BUNDLED = 4,
};

// These values are corresponding to the priorities or importance of Android
// notification.
[Extensible]
enum ArcNotificationPriority {
  NONE = -3,
  MIN = -2,
  LOW = -1,
  DEFAULT = 0,
  HIGH = 1,
  MAX = 2,
};

// DEPRECATED
struct DeprecatedArcNotificationButton {
  // Title
  string label;
};

[Extensible, MinVersion=10]
enum ArcNotificationExpandState {
  FIXED_SIZE = 0,
  COLLAPSED = 1,
  EXPANDED = 2,
};

[Extensible, MinVersion=12]
enum ArcNotificationRemoteInputState {
  CLOSED = 0,
  OPENED = 1,
};

// These values represent what shows in an ARC custom notification.
[Extensible, MinVersion=11]
enum ArcNotificationShownContents {
  // The normal notification contents are shown.
  CONTENTS_SHOWN = 0,
  // The notification settings view is shown.
  SETTINGS_SHOWN = 1,
  // The notification snooze settings view is shown.
  [MinVersion=17]
  SNOOZE_SHOWN = 2,
};

// Flag for various feature of ARC notifications.
[Extensible, MinVersion=17]
struct ArcNotificationFlags {
  // Bits for features.
  const uint32 SUPPORT_SNOOZE = 1;  // 1 << 0

  // Bit-masked value.
  uint32 value;
};

struct ArcNotificationData {
  // Identifier of notification
  string key;
  // Type of notification
  ArcNotificationType type;
  // Body message of notification
  string message;
  // Title of notification
  string title;
  // DEPRECATED: Mimetype of |icon_data|
  string? deprecated_icon_mimetype;
  // DEPRECATED: Binary data of the icon
  array<uint8>? deprecated_icon_data;
  // Priority of notification
  ArcNotificationPriority priority;
  // Timestamp related to the notification
  int64 time;
  // DEPRECATED: The current value of progress, must be [0, progress_max].
  int32 deprecated_progress_current;
  // DEPRECATED: The maximum value of progress.
  int32 deprecated_progress_max;
  // DEPRECATED: Action buttons
  array<DeprecatedArcNotificationButton>? deprecated_buttons;
  // Flag if the notification has FLAG_NO_CLEAR.
  [MinVersion=1]
  bool no_clear;
  // Flag if the notification has FLAG_ONGOING_EVENT.
  [MinVersion=1]
  bool ongoing_event;
  // DEPRECATED: Subtexts for list notifications.
  [MinVersion=3]
  array<string>? deprecated_texts;
  // DEPRECATED: Image for image notifications.
  [MinVersion=3]
  ArcBitmap? deprecated_big_picture;
  // DEPRECATED: Flag if a notification is a custom notification backed by a
  // notification surface.
  [MinVersion=5]
  bool deprecated_use_custom_notification;
  [MinVersion=6]
  ArcBitmap? small_icon;
  // A snapshot image to show before the notification window is created.
  [MinVersion=7]
  ArcBitmap? snapshot_image;
  [MinVersion=7]
  float snapshot_image_scale;
  // Accessibility text
  [MinVersion=8]
  string? accessible_name;
  // Flag if the notification is expandable
  [MinVersion=10]
  ArcNotificationExpandState expand_state;
  // Flag for what shows in a notification.
  [MinVersion=11]
  ArcNotificationShownContents shown_contents;
  [MinVersion=12]
  ArcNotificationRemoteInputState remote_input_state;
  // Indicates a rect for which Android wants to handle swipe events for by
  // itself. The coordinates in this Rect are in Android pixels and represent
  // a sub-rectangle of the notification, with the origin being the top left
  // of the notification.
  [MinVersion=14]
  Rect? swipe_input_rect;
  [MinVersion=15]
  string? package_name;
  [MinVersion=17]
  ArcNotificationFlags? flags;
};

[Extensible, MinVersion=18]
struct ArcDoNotDisturbStatus {
  bool enabled;
};

// Next Method ID: 8
interface NotificationsHost {
  // Set the Do-Not-Disturb status on Chrome side from Android side.
  [MinVersion=18]
  OnDoNotDisturbStatusUpdated@7(ArcDoNotDisturbStatus status);

  // Tells the Chrome that a notification is posted (created or updated) on
  // Android. If you know that the notification exists, please consider to use
  // OnNotificationUpdate instead.
  // |notification_data| is the data of notification (id, texts, icon and ...).
  OnNotificationPosted@0(ArcNotificationData notification_data);

  // Notifies that a notification is removed on Android.
  // |key| is the identifier of the notification.
  OnNotificationRemoved@1(string key);

  [MinVersion=13]
  // Notifies that an existing notiication is updated on Android.
  OnNotificationUpdated@5(ArcNotificationData notification_data);

  [MinVersion=16]
  // Opens the Chrome OS message center.
  OpenMessageCenter@6();
};

// Next Method ID: 9
// TODO(lhchavez): Migrate all request/response messages to Mojo.
interface NotificationsInstance {
  // DEPRECATED: Please use Init@5 instead.
  InitDeprecated@0(NotificationsHost host_ptr);

  // Establishes full-duplex communication with the host.
  [MinVersion=14] Init@5(NotificationsHost host_ptr) => ();

  // Sends an event from Chrome notification UI to Android.
  // |event| is a type of occured event.
  SendNotificationEventToAndroid@1(string key, ArcNotificationEvent event);

  // Requests to Android side to create the notification window.
  // |key| is the identifier of the notification which is generated by Android
  // side.
  [MinVersion=7]
  CreateNotificationWindow@2(string key);

  // Requests to Android side to close the notification window.
  // |key| is the identifier of the notification which is generated by Android
  // side.
  [MinVersion=7]
  CloseNotificationWindow@3(string key);

  // Requests to Android side to open notification settings.
  // |key| is the identifier of the notification which is generated by Android
  // side.
  [MinVersion=9]
  OpenNotificationSettings@4(string key);

  // Requests to Android side to open snooze settings.
  // |key| is the identifier of the notification which is generated by Android
  // side.
  [MinVersion=17]
  OpenNotificationSnoozeSettings@6(string key);

  // Sets the Do-Not-Disturb status on Android side from Chrome side.
  [MinVersion=18]
  SetDoNotDisturbStatusOnAndroid@7(ArcDoNotDisturbStatus status);

  // Cancels the long-press operation even during touching the view. This should
  // be called when the on-going gesture is recognized not as a normal touch
  // event but as a scroll event, and the on-going touch should be cancelled.
  [MinVersion=19]
  CancelLongPress@8(string key);
};
