chromium/chromeos/crosapi/mojom/dlp.mojom

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

import "mojo/public/mojom/base/string16.mojom";
import "url/mojom/url.mojom";
import "mojo/public/mojom/base/file_path.mojom";

// Corresponds to DlpRulesManager::Level enum.
[Stable, Extensible]
enum DlpRestrictionLevel {
  kAllow = 0,
  kReport = 1,
  kWarn = 2,
  kBlock = 3,
  [MinVersion=2] kNotSet = 4,
};

// Corresponds to RestrictionLevelAndUrl struct.
[Stable]
struct DlpRestrictionLevelAndUrl {
  DlpRestrictionLevel level@0;
  url.mojom.Url url@1;
};

// Corresponds to DlpContentRestrictionSet class.
[Stable]
struct DlpRestrictionSet {
  DlpRestrictionLevelAndUrl screenshot@0;
  DlpRestrictionLevelAndUrl privacy_screen@1;
  DlpRestrictionLevelAndUrl print@2;
  DlpRestrictionLevelAndUrl screen_share@3;
};

// Captured area.
[Stable]
struct ScreenShareArea {
  // All root windows if |window_id| is null.
  string? window_id@0;

  // Unique identifier for a window from SnapshotSource in screen_manager.mojom.
  [MinVersion=3] uint64 snapshot_source_id@1 = 0;
};

// Callback to control the state (pause/resume) of a remote screen share.
[Stable]
interface StateChangeDelegate {
  // Request to pause the screen share.
  OnPause@0();
  // Request to resume the screen share.
  OnResume@1();
  // Request to stop the screen share. Should be called only once.
  OnStop@2();
};

// Corresponds to the dlp::FileAction enum.
[Stable, Extensible]
enum FileAction {
  [Default] kUnknown = 0,
  kDownload = 1,
  kTransfer = 2,
  kUpload = 3,
  kCopy = 4,
  kMove = 5,
  kOpen = 6,
  kShare = 7,
};

// Interface to communicate from Lacros DLP layer to Ash. Used to notify Ash
// about changes in restrictions applied to web content in Lacros.
//
// TODO(b/308912502): Move this interface to Wayland IPC. Until than: The
// connection by Lacros has to be kept over its whole lifetime as the closing
// indicates that associated windows are no longer existing.
//
// Next MinVersion: 5
// Next ID: 5
[Stable, Uuid="793ee9c6-3873-4ea8-a541-894412ddfc0b"]
interface Dlp {
  // Called when |restrictions| are changed for window with |window_id|.
  DlpRestrictionsUpdated@0(string window_id, DlpRestrictionSet restrictions);

  // Called to evaluate screenshare restriction for a window or full screen.
  [MinVersion=1] CheckScreenShareRestriction@1(
      ScreenShareArea area, mojo_base.mojom.String16 application_title) =>
          (bool proceed);

  // Called when screen share in Lacros is started.
  [MinVersion=2] OnScreenShareStarted@2(string label, ScreenShareArea area,
      mojo_base.mojom.String16 application_title,
      pending_remote<StateChangeDelegate> delegate);

  // Called when screen share in Lacros is stopped.
  [MinVersion=2] OnScreenShareStopped@3(string label, ScreenShareArea area);

  // Shows a notification to inform the user that `files` where blocked during
  // `action` while performing a task with id `task_id`.
  [MinVersion=4] ShowBlockedFiles@4(uint64? task_id,
      array<mojo_base.mojom.FilePath> files, FileAction action);
};