chromium/third_party/blink/public/mojom/idle/idle_manager.mojom

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module blink.mojom;

import "mojo/public/mojom/base/time.mojom";

// Interfaces for implementing the Idle Detection API.
//
// https://wicg.github.io/idle-detection/

enum IdleManagerError {
  kSuccess,
  kPermissionDisabled,
};

struct IdleState {
  // If not null, the time since it was detected that the user has been idle for
  // at least IdleManager.kUserInputThresholdMs milliseconds.
  mojo_base.mojom.TimeDelta? idle_time;

  // Whether the screen is currently locked.
  bool screen_locked;
};

// Interface implemented by a client of the IdleManager interface which allows
// the manager to update the client with the current idle state.
interface IdleMonitor {
  // Called when the idle state has changed. If |is_overridden_by_devtools| is
  // passed this update represents a DevTools override and should be applied
  // without waiting for the developer's configured threshold.
  Update(IdleState state, bool is_overridden_by_devtools);
};

// Interface implemented by the browser process to provide clients with the
// current idle state.
interface IdleManager {
  // The amount of time which must pass without input before the user is
  // considered idle.
  const uint32 kUserInputThresholdMs = 60000;

  // Register an IdleMonitor instance. When registered, it will return the
  // initial state. It will be notified by calls to Update() when the idle
  // state changes. It can be unregistered by closing the pipe.
  AddMonitor(pending_remote<IdleMonitor> monitor)
      => (IdleManagerError error, IdleState? state);
};