1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176

ash / public / mojom / accelerator_info.mojom [blame]

// Copyright 2022 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;

import "mojo/public/mojom/base/string16.mojom";
import "ui/base/accelerators/mojom/accelerator.mojom";

// AcceleratorInfo is a representation of an Accelerator with more information
// regarding the accelerator. This is used only by Ash clients, hence why this
// is not in ui/*.

// Contains all sources of shortcuts, new sources must added to this enum.
enum AcceleratorSource {
  // Accelerators that are owned by ash and handled in
  // accelerator_controller_impl.cc.
  kAsh,
  // Event rewriters that are owned by ash and handled in
  // event_rewriter_ash.cc.
  kEventRewriter,
  // Accelerators that are owned by the browser and sources from
  // accelerator_table.cc.
  kBrowser,
  // Ambient accelerators such as Ctrl-C are not owned by any specific source.
  kAmbient,
  // Arc++ specific accelerators owned by Android apps.
  kAndroid,
};

// Enum of all possible types of accelerators.
// Must be kept in sync with ash/public/cpp/accelerator_configuration.h.
enum AcceleratorType {
  // System default accelerator.
  kDefault,
  // User defined accelerator, this is a custom accelerator.
  kUser,
  // Deprecated accelerator.
  kDeprecated,
  // Developer-specific accelerators.
  kDeveloper,
  // Accelerator used for debugging.
  kDebug,
};

// Represents the states of an accelerator.
// Must be kept in sync with ash/public/cpp/accelerator_configuration.h.
enum AcceleratorState {
  // Accelerator is available to be used.
  kEnabled,
  // Accelerator disabled due to a conflict with another accelerator.
  kDisabledByConflict,
  // Accelerator disabled due to user manually disabling it.
  kDisabledByUser,
  // Accelerator disabled due to certain keys are not available.
  kDisabledByUnavailableKeys,
};

// Represents the style of layout for an accelerator.
enum AcceleratorLayoutStyle {
  // Used for shortcuts containing zero or more modifiers and one key,
  // e.g. "Ctrl+T", "Ctrl+Shift+T", "<Refresh Icon>", etc.
  kDefault = 0,
  // Used to display arbitrary text with optional modifiers/keys interspersed,
  // e.g. "Hold <Ctrl> and click on a link" or "Drag link to bookmarks bar".
  kText = 1,
};

// Enum of top-level accelerator categories. Used in the UI for categorization.
// Must be kept in sync with enums.xml: `ShortcutCustomizationMainCategory`.
enum AcceleratorCategory {
  kGeneral,
  kDevice,
  kBrowser,
  kText,
  kWindowsAndDesks,
  kAccessibility,
  kDebug,
  kDeveloper,
};

// Enum of secondary-level accelerator categories. Used in the UI for
// categorization.
enum AcceleratorSubcategory {
  kGeneralControls,
  kApps,
  kMedia,
  kInputs,
  kDisplay,
  kGeneral,
  kBrowserNavigation,
  kPages,
  kTabs,
  kBookmarks,
  kDeveloperTools,
  kTextNavigation,
  kTextEditing,
  kWindows,
  kDesks,
  kChromeVox,
  kMouseKeys,
  kVisibility,
  kAccessibilityNavigation,
};

// Enum of possible options for text accelerators.
enum TextAcceleratorPartType {
  kPlainText,
  kModifier,
  kKey,
  kDelimiter,
};

// The text to display as well as its corresponding type which determines how
// it should be displayed.
struct TextAcceleratorPart {
  mojo_base.mojom.String16 text;
  TextAcceleratorPartType type;
};

// An accelerator that can display arbitrary text with optional modifiers/keys
// interspersed.
struct TextAcceleratorProperties {
  array<TextAcceleratorPart> parts;
};

// An accelerator that has at least one modifier and a set of keys.
struct StandardAcceleratorProperties {
  // Underlying accelerator struct, contains keycode and modifier.
  ui.mojom.Accelerator accelerator;
  // The user viewable string of the primary activation key for the accelerator.
  mojo_base.mojom.String16 key_display;
  // Optional field - if the accelerator is an alias of another accelerator this
  // field represents the original accelerator.
  ui.mojom.Accelerator? original_accelerator;
};

// Contains properties specific to an accelerator type.
union LayoutStyleProperties {
  StandardAcceleratorProperties standard_accelerator;
  TextAcceleratorProperties text_accelerator;
};

// Represents an accelerator in its entirety. Includes the keys, state, type,
// and whether the accelerator is locked.
struct AcceleratorInfo {
  AcceleratorType type;
  AcceleratorState state;
  // True if the accelerator action can not be customized by the user.
  // False if the accelerator action can be customized by the user.
  bool locked;
  // True if the accelerator can not be customized by the user.
  // False if the accelerator can be customized by the user.
  bool accelerator_locked;
  LayoutStyleProperties layout_properties;
};

// Represents layout styling descriptors of an accelerator. Includes the
// description of the accelerator along with its category identifiers.
struct AcceleratorLayoutInfo {
  // Top-level category used for categorization in the UI.
  AcceleratorCategory category;
  // Secondary-level category used for categorization in the UI.
  AcceleratorSubcategory sub_category;
  // Translated string for the action description.
  mojo_base.mojom.String16 description;
  // The way the AcceleratorRow should be styled.
  AcceleratorLayoutStyle style;

  // The accelerator source, which help differentiate same action id's from
  // different sources.
  AcceleratorSource source;
  // The accelerator id, used as part of the identifier to map
  // `AcceleratorLayoutInfo` to an `AcceleratorInfo`.
  uint32 action;
};