chromium/ash/public/mojom/tray_action.mojom

// Copyright 2017 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.mojom;

// An action handler state.
enum TrayActionState {
  // The action cannot be handled - due to no client being set, the client not
  // supporting the action, user session not being locked etc.
  kNotAvailable,

  // The client supports the action and is not currently handling the action.
  kAvailable,

  // The client received the request for the action and it is launching the
  // flow to handle it.
  kLaunching,

  // The client is currently handling the action.
  kActive,
};

// The user action that triggered a request for a new note.
enum LockScreenNoteOrigin {
  // The note request originated from the new note button in the system
  // tray - note that this UI element is deprecated.
  kTrayAction,

  // The user tapped the note action button shown on the lock screen.
  kLockScreenButtonTap,

  // The user swiped from the note action button shown on the lock screen.
  kLockScreenButtonSwipe,

  // The user activated the lock screen button shown on the lock screen using
  // the keyboard.
  kLockScreenButtonKeyboard,

  // The user ejected the stylus tool from the device.
  kStylusEject,
};

// Reason for closing a lock screen note, and consequentially closing any
// existing note handler app windows.
enum CloseLockScreenNoteReason {
  // The user session was unlocked.
  kSessionUnlock,

  // The user session was shut down (e.g. due to user sign-out).
  kShutdown,

  // The user display was completely dimmed (e.g. due to user inactivity).
  kScreenDimmed,

  // Device suspended.
  kSuspend,

  // The app window associated with the note was closed by the app.
  kAppWindowClosed,

  // The note taking app's support for the lock screen note taking was disabled
  // (e.g. because of a policy update).
  kAppLockScreenSupportDisabled,

  // The user pressed "Unlock" button on the lock screen UI.
  kUnlockButtonPressed,
};

// Used by a client (e.g. Chrome) to set up a handler for a tray action, and
// notify ash on the action handler's state changes. A tray action is one of
// predefined actions (currently only the "new note on lock screen" action is
// supported) that appear as an ash status area button if the client declares
// the action as available. Clicking the button invokes a client method that
// requests the action associated with the button to be handled.
interface TrayAction {
  // Sets the client to be used to handle action requests.
  // |lock_screen_note_state|: The current lock screen note action state
  //     associated with the client.
  SetClient(pending_remote<TrayActionClient> client,
            TrayActionState lock_screen_note_state);

  // Updates action state for the lock screen note action. If called with no
  // client set, the state change will not take effect until a client is set.
  // Null client is equivalent to kNotAvailable state.
  UpdateLockScreenNoteState(TrayActionState state);
};

// Used by ash to request Chrome to handle an action.
interface TrayActionClient {
  // Requests a lock screen note action to be handled.
  RequestNewLockScreenNote(LockScreenNoteOrigin origin);

  // Closes lock screen note.
  CloseLockScreenNote(CloseLockScreenNoteReason reason);
};