chromium/chromeos/crosapi/mojom/editor_panel.mojom

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

// Next MinVersion: 8

module crosapi.mojom;

[Stable, Extensible]
enum EditorPanelMode {
  // Editor panel should not be shown (due to consent rejected or other
  // restrictions). This mode is deprecated.
  [Default] kBlocked_DEPRECATED = 0,
  // Editor panel should be shown in write mode.
  kWrite = 1,
  // Editor panel should be shown in rewrite mode.
  kRewrite = 2,
  // Editor panel feature promo card should be shown (to inform the user
  // about the feature and ask if they want to learn more).
  kPromoCard = 3,
  // Editor panel is blocked because the it does not meet hard
  // requirements such as policy, age and country.
  [MinVersion=6] kHardBlocked = 4,
  // Editor panel is temporarily blocked because the it does not meet
  // transient requirements such as internet connection.
  [MinVersion=6] kSoftBlocked = 5,
};

[Stable, Extensible]
enum EditorPanelPresetQueryCategory {
  [Default] kUnknown = 0,
  [MinVersion=1] kShorten = 1,
  [MinVersion=1] kElaborate = 2,
  [MinVersion=1] kRephrase = 3,
  [MinVersion=1] kFormalize = 4,
  [MinVersion=1] kEmojify = 5,
  [MinVersion=4] kProofread = 6,
};

[Stable]
struct EditorPanelPresetTextQuery {
  string text_query_id@0;
  string name@1;
  string description@2;
  EditorPanelPresetQueryCategory category@3;
};

[Stable]
struct EditorPanelContext {
  EditorPanelMode editor_panel_mode@0;

  array<EditorPanelPresetTextQuery> preset_text_queries@1;

  // a boolean value indicating whether the editor consent status has been set
  // or not.
  [MinVersion=7] bool consent_status_settled@2;
};

// An interface to allow clients in the Lacros side to observe important state
// changes in the Ash side.
[Stable, Uuid="4622a780-9055-4e61-8e21-638a152a23ac"]
interface EditorObserver {
  // Fired whenever the EditorPanelMode state has changed.
  OnEditorPanelModeChanged@0(EditorPanelMode mode);
};

// EditorPanelManager is an interface to allow lacros to handle requests between
// the context menu editor panel and the backend of the editor feature
// Next MinVersion: 2
[Stable, Uuid="a5d776e7-98e6-489c-9b15-57f00000c847"]
interface EditorPanelManager {
  // Gets the context required to determine what should be shown on the editor
  // panel.
  GetEditorPanelContext@0() => (EditorPanelContext editor_panel_context);

  // Should be called when the promo card is implicitly dismissed (e.g. the
  // user clicked out of the promo card).
  OnPromoCardDismissed@1();

  // Should be called when the promo card is explicitly dismissed via clicking
  // the button.
  OnPromoCardDeclined@2();

  // Starts the editing flow, showing the consent form if needed.
  StartEditingFlow@3();

  // Starts the rewrite flow with a preset text query.
  StartEditingFlowWithPreset@4(string text_query_id);

  // Starts the write/rewrite flow with a freeform query.
  StartEditingFlowWithFreeform@5(string text);

  // Should be called when the editor menu is shown or hidden.
  [MinVersion=1] OnEditorMenuVisibilityChanged@6(bool visible);

  // Reports the mode of the editor panel.
  [MinVersion=2] LogEditorMode@7(EditorPanelMode mode);

  // Binds a new EditorObserver in ash
  [MinVersion=3] BindEditorObserver@8(
      pending_remote<EditorObserver> pending_observer_remote);

  // Should be called when the consent is rejected by the user.
  [MinVersion=5] OnConsentRejected@9();
};