// 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;
};